1.11 微信公众号(小程序)、支付宝服务窗(小程序)统一下单
<p><strong>接口地址</strong>:<code>/pay/api/1.0/unifiedOrder</code></p>
<p><strong>请求方式</strong>:<code>POST</code></p>
<p><strong>请求数据类型</strong>:<code>application/json</code></p>
<p><strong>响应数据类型</strong>:<code>application/json</code></p>
<p><em>银联云闪付js调起支付方法</em>
<img src="https://www.showdoc.com.cn/server/api/attachment/visitFile?sign=a70745afd5c6e7aa36bad95120fa2d80&amp;file=file.png" alt="" /></p>
<p>前置条件:域名加白,台卡域名需要通过招联到银联总行进行加白。
>1、如果是来自云闪付APP
(即 UnionPay/1.0,目前只支持云闪付。需要合作方重定向:<a href="https://qr.95516.com/qrcGtwWeb-web/api/userAuth?version=1.0.0&redirectUrl=合作方银联二维码授权码接收地址">https://qr.95516.com/qrcGtwWeb-web/api/userAuth?version=1.0.0&redirectUrl=合作方银联二维码授权码接收地址</a> 【注:该地址需要进行urlencode】)
2、通过步骤 2中的redirectUrl重定向获取到【授权码】
3、通过上述的【授权码】 调用【1.9 微信授权码查询openid / 银联授权码获取user_id】接口获取user_id
4、使用上述的【user_id】 调用本下单接口进行下单
(即wayCode=UNIONPAY时,subAppid,openid填空,subOpenid = user_id)
5、通过接口返回的qrCode,直接重定向调起支付</p>
<p><strong>接口描述:</strong>
>该接口常应用于<strong><code>聚合二维码(静态二维码、统一收款码、台卡等不同叫法,需合作方自己使用H5页面地址生成二维码)</code></strong>,用户扫二维码进入微信公众号/支付宝服务窗/QQJS 页面,页面调此接口生成订单,接受订单参数后调起官方支付接口支付。详见公众号/服务窗对接流程</p>
<ul>
<li>
<p><code>步骤1:</code>用户通过支付宝(服务窗)、微信(公众号)进入到商户H5/SDK页面,或者是通过扫描台卡进入。</p>
<p>合作方H5页面中可以通过user-agent获取用户使用的是哪种支付方式</p>
<ul>
<li>
<p>如果来自微信APP</p>
<ul>
<li>
<p>获取用户openid,传入交易接口sub_openid字段</p>
<p>>使用合作方或者商户自有公众号的情况,公众号appid传入sub_appid字段中,openid需要调用微信官方接口获取 <a href="https://pay.weixin.qq.com/wiki/doc/api/jsapi.php?chapter=4_4"><a href="https://pay.weixin.qq.com/wiki/doc/api/jsapi.php?chapter=4\_4">https://pay.weixin.qq.com/wiki/doc/api/jsapi.php?chapter=4\_4</a></a></p>
</li>
</ul>
</li>
<li>
<p>如果来自支付宝APP</p>
<ul>
<li>获取用户user_id(即buyer_id),传入交易接口sub_openid字段,user_id需要调用支付宝官方接口获取<a href="https://opendocs.alipay.com/open/02xtl8"><a href="https://opendocs.alipay.com/open/02xtl8">https://opendocs.alipay.com/open/02xtl8</a></a></li>
</ul>
</li>
</ul>
</li>
<li>
<p><code>步骤2:</code>用户选择商品、输入支付金额等进行下单支付</p>
</li>
<li>
<p><code>步骤3:</code>商户将单信息发送给富友,返回支付信息(用于调起支付宝、微信的参数)。</p>
</li>
<li>
<p><code>步骤4:</code>商户拿到支付信息后调起微信或者支付宝进行支付</p>
<ul>
<li>微信调起支付,使用sdk开头的参数 <a href="https://pay.weixin.qq.com/wiki/doc/api/jsapi.php?chapter=7_7&amp;index=6"><a href="https://pay.weixin.qq.com/wiki/doc/api/jsapi.php?chapter=7\_7&index=6">https://pay.weixin.qq.com/wiki/doc/api/jsapi.php?chapter=7\_7&index=6</a></a></li>
<li>支付宝调起支付,使用transactionId字段参数 <a href="https://opendocs.alipay.com/open/common/105591"><a href="https://opendocs.alipay.com/open/common/105591">https://opendocs.alipay.com/open/common/105591</a></a></li>
</ul>
</li>
<li><code>步骤5:</code>支付结果以回调的方式通知到商户</li>
</ul>
<p><strong>请求示例:</strong></p>
<pre><code class="language-json">{
&quot;appId&quot;: &quot;MCH_A698612520&quot;,
&quot;amount&quot;: 1,
&quot;body&quot;: &quot;1&quot;,
&quot;clientIp&quot;: &quot;127.0.0.1&quot;,
&quot;expireMinute&quot;: 120,
&quot;mchNo&quot;: &quot;MCH_I293975931&quot;,
&quot;mchOrderNo&quot;: &quot;2023042415040000004&quot;,
&quot;notifyUrl&quot;: &quot;http://localhost:8081/pay/api/test&quot;,
&quot;sign&quot;: &quot;df6b566e85f8f13309d71e68e40e1236&quot;,
&quot;subOpenid&quot;: &quot;2088802572771595&quot;,
&quot;subject&quot;: &quot;支付测试&quot;,
&quot;termId&quot;: &quot;12345678&quot;,
&quot;terminalInfo&quot;: {
&quot;app_version&quot;: &quot;1.0&quot;,
&quot;terminal_id&quot;: &quot;A0000257&quot;,
&quot;terminal_type&quot;: &quot;11&quot;
},
&quot;wayCode&quot;: &quot;FWC&quot;,
&quot;businessSource&quot;: &quot;A007&quot;
}</code></pre>
<p><strong>请求参数</strong>:</p>
<table>
<thead>
<tr>
<th>参数名称</th>
<th>参数说明</th>
<th>请求类型</th>
<th>是否必须</th>
<th>数据类型</th>
<th>schema</th>
</tr>
</thead>
<tbody>
<tr>
<td>req</td>
<td>req</td>
<td>body</td>
<td>true</td>
<td>聚合支付统一下单请求实体-收银台</td>
<td>聚合支付统一下单请求实体-收银台</td>
</tr>
<tr>
<td>&emsp;&emsp;version</td>
<td>版本号</td>
<td>false</td>
<td>string</td>
<td>默认1.0</td>
</tr>
<tr>
<td>&emsp;&emsp;sign</td>
<td>签名值</td>
<td>true</td>
<td>string</td>
<td>详见签名生成算法</td>
</tr>
<tr>
<td>&emsp;&emsp;termId</td>
<td>终端id</td>
<td>true</td>
<td>string</td>
<td>没有真实终端号统一填88888888</td>
</tr>
<tr>
<td>&emsp;&emsp;mchNo</td>
<td>商户号</td>
<td>true</td>
<td>string</td>
<td>招联分配给二级商户的商户号</td>
</tr>
<tr>
<td>&emsp;&emsp;appId</td>
<td>应用id</td>
<td>true</td>
<td>string</td>
<td>商户配置的应用id</td>
</tr>
<tr>
<td>&emsp;&emsp;mchOrderNo</td>
<td>商户订单号</td>
<td>true</td>
<td>string</td>
<td>商户订单号, 商户系统内部的订单号(5到30个字符、 只能包含字母数字下划线,区分大小写)</td>
</tr>
<tr>
<td>&emsp;&emsp;wayCode</td>
<td>支付方式</td>
<td>true</td>
<td>string</td>
<td>JSAPI--公众号支付<br> FWC--支付宝服务窗、支付宝小程序<br> LETPAY-微信小程序<br> UNIONPAY--云闪付扫码</td>
</tr>
<tr>
<td>&emsp;&emsp;amount</td>
<td>支付金额</td>
<td>true</td>
<td>number</td>
<td>单位:分</td>
</tr>
<tr>
<td>&emsp;&emsp;currency</td>
<td>货币代码</td>
<td>false</td>
<td>string</td>
<td>默认人民币:CNY</td>
</tr>
<tr>
<td>&emsp;&emsp;clientIp</td>
<td>实时交易终端IP地址</td>
<td>true</td>
<td>string</td>
<td>真实ip地址(ipv4)</td>
</tr>
<tr>
<td>&emsp;&emsp;subject</td>
<td>商品标题</td>
<td>true</td>
<td>string</td>
<td>显示在用户账单的商品、商品说明等地方</td>
</tr>
<tr>
<td>&emsp;&emsp;body</td>
<td>商品描述信息</td>
<td>false</td>
<td>string</td>
<td>商品描述信息</td>
</tr>
<tr>
<td>&emsp;&emsp;goodsDetail</td>
<td>单品优惠功能字段</td>
<td>false</td>
<td>JSONObject</td>
<td>见文档中[goodsDetail说明字段](<a href="https://www.showdoc.com.cn/jucaishangfu/9965976008190664?id=body%E8%AF%B4%E6%98%8E%E5%AD%97%E6%AE%B5">https://www.showdoc.com.cn/jucaishangfu/9965976008190664?id=body%E8%AF%B4%E6%98%8E%E5%AD%97%E6%AE%B5</a> "goodsDetail说明字段")</td>
</tr>
<tr>
<td>&emsp;&emsp;tag</td>
<td>商品标记</td>
<td>false</td>
<td>string</td>
</tr>
<tr>
<td>&emsp;&emsp;productId</td>
<td>商品标识</td>
<td>false</td>
<td>string</td>
</tr>
<tr>
<td>&emsp;&emsp;notifyUrl</td>
<td>通知地址</td>
<td>true</td>
<td>string</td>
<td>回调通知地址</td>
</tr>
<tr>
<td>&emsp;&emsp;subOpenid</td>
<td>子商户用户标识</td>
<td>true</td>
<td>string</td>
<td>支付宝服务窗为用户buyer_id<br>微信公众号为用户的openid<br>UNIONPAY 云闪付扫码为用户user_id</td>
</tr>
<tr>
<td>&emsp;&emsp;subAppid</td>
<td>子商户公众号id</td>
<td>false</td>
<td>string</td>
<td>微信交易为商户的appid(小程序,公众号必填)</td>
</tr>
<tr>
<td>&emsp;&emsp;limitPay</td>
<td>限制支付</td>
<td>false</td>
<td>string</td>
<td>no_credit:不能使用信用卡<br>credit_group:不能使用花呗以及信用卡</td>
</tr>
<tr>
<td>&emsp;&emsp;fyTermId</td>
<td>富友终端号</td>
<td>false</td>
<td>string</td>
<td>富友采购或自带机入网填此字段</td>
</tr>
<tr>
<td>&emsp;&emsp;termType</td>
<td>终端类型</td>
<td>false</td>
<td>string</td>
<td>0:其他<br> 1:富友终端<br> 2:POS机<br> 3:台卡<br> 4:PC软件</td>
</tr>
<tr>
<td>&emsp;&emsp;txnBonus</td>
<td>积分抵扣金额</td>
<td>false</td>
<td>string</td>
<td>单位:分</td>
</tr>
<tr>
<td>&emsp;&emsp;termSn</td>
<td>终端序列号</td>
<td>false</td>
<td>string</td>
</tr>
<tr>
<td>&emsp;&emsp;deviceInfo</td>
<td>设备信息,托传给微信。</td>
<td>false</td>
<td>string</td>
<td>用于单品券核销</td>
</tr>
<tr>
<td>&emsp;&emsp;extendParams</td>
<td>分期扩展参数</td>
<td>false</td>
<td>JSONObject</td>
<td>见文档中[extendParams分期扩展参数说明字段](<a href="https://www.showdoc.com.cn/jucaishangfu/9965976008190664">https://www.showdoc.com.cn/jucaishangfu/9965976008190664</a> "extendParams分期扩展参数说明字段")</td>
</tr>
<tr>
<td>&emsp;&emsp;storeCode</td>
<td>门店id</td>
<td>false</td>
<td>string</td>
<td>目前仅支持支付宝</td>
</tr>
<tr>
<td>&emsp;&emsp;alipayStoreId</td>
<td>支付宝店铺编号</td>
<td>false</td>
<td>string</td>
</tr>
<tr>
<td>&emsp;&emsp;terminalInfo</td>
<td>终端信息说明字段</td>
<td>false</td>
<td>JSONObject</td>
<td>终端信息说明字段,见文档中[terminalInfo终端信息说明字段](<a href="https://www.showdoc.com.cn/jucaishangfu/9965976008190664">https://www.showdoc.com.cn/jucaishangfu/9965976008190664</a> "terminalInfo终端信息说明字段")(259号文,终端信息) 以下示例仅测试环境可用:{"serial_num":"12345678901SN012"}</td>
</tr>
<tr>
<td>&emsp;&emsp;userName</td>
<td>姓名</td>
<td>false</td>
<td>String</td>
</tr>
<tr>
<td>&emsp;&emsp;userIdCard</td>
<td>身份证</td>
<td>false</td>
<td>String</td>
</tr>
<tr>
<td>&emsp;&emsp;businessParams</td>
<td>商户传入业务信息</td>
<td>false</td>
<td>JSONObject</td>
<td>应用于安全,营销等参数直传场景,格式为 json 格式:{"data":"123"}</td>
</tr>
<tr>
<td>&emsp;&emsp;sceneInfo</td>
<td>场景信息说明字段</td>
<td>false</td>
<td>JSONObject</td>
<td>见文档中[sceneInfo场景信息说明字段示例](<a href="https://www.showdoc.com.cn/jucaishangfu/9965976008190664">https://www.showdoc.com.cn/jucaishangfu/9965976008190664</a> "sceneInfo场景信息说明字段示例")</td>
</tr>
<tr>
<td>&emsp;&emsp;businessSource</td>
<td>渠道号</td>
<td><code>true</code></td>
<td>string</td>
<td>联系对接人员获取</td>
</tr>
</tbody>
</table>
<p><strong>响应状态</strong>:</p>
<table>
<thead>
<tr>
<th>状态码</th>
<th>说明</th>
<th>schema</th>
</tr>
</thead>
<tbody>
<tr>
<td>200</td>
<td>OK</td>
<td>R«订单退款返回实体类»</td>
</tr>
</tbody>
</table>
<p>>见[应答码表](<a href="https://www.showdoc.com.cn/jucaishangfu/9966099368299628">https://www.showdoc.com.cn/jucaishangfu/9966099368299628</a> "应答码表")</p>
<p>见应答码表</p>
<p><strong>响应参数</strong>:</p>
<table>
<thead>
<tr>
<th>参数名称</th>
<th>参数说明</th>
<th>类型</th>
<th>schema</th>
</tr>
</thead>
<tbody>
<tr>
<td>code</td>
<td>integer(int32)</td>
<td>integer(int32)</td>
</tr>
<tr>
<td>data</td>
<td>微信公众号(小程序)、支付宝服务窗(小程序)统一下单返回实体</td>
<td>微信公众号(小程序)、支付宝服务窗(小程序)统一下单返回实体</td>
</tr>
<tr>
<td>&emsp;&emsp;channelOrderId</td>
<td>条码流水号</td>
<td>string</td>
</tr>
<tr>
<td>&emsp;&emsp;dealDate</td>
<td>交易日期</td>
<td>string</td>
</tr>
<tr>
<td>&emsp;&emsp;extParam</td>
<td>附加数据</td>
<td>string</td>
</tr>
<tr>
<td>&emsp;&emsp;mchNo</td>
<td>商户号</td>
<td>string</td>
</tr>
<tr>
<td>&emsp;&emsp;mchOrderNo</td>
<td>商户订单号</td>
<td>string</td>
</tr>
<tr>
<td>&emsp;&emsp;orgId</td>
<td>机构号</td>
<td>string</td>
</tr>
<tr>
<td>&emsp;&emsp;payInfo</td>
<td>支付参数</td>
<td>string</td>
</tr>
<tr>
<td>&emsp;&emsp;qrCode</td>
<td>二维码链接</td>
<td>string</td>
</tr>
<tr>
<td>&emsp;&emsp;randomStr</td>
<td>随机字符串</td>
<td>string</td>
</tr>
<tr>
<td>&emsp;&emsp;sdkAppid</td>
<td>公众号id</td>
<td>string</td>
</tr>
<tr>
<td>&emsp;&emsp;sdkNonceStr</td>
<td>随机字符串</td>
<td>string</td>
</tr>
<tr>
<td>&emsp;&emsp;sdkPackage</td>
<td>订单扩展字符串</td>
<td>string</td>
</tr>
<tr>
<td>&emsp;&emsp;sdkPartnerId</td>
<td>合作方id</td>
<td>string</td>
</tr>
<tr>
<td>&emsp;&emsp;sdkPaySign</td>
<td>签名</td>
<td>string</td>
</tr>
<tr>
<td>&emsp;&emsp;sdkSignType</td>
<td>签名方式</td>
<td>string</td>
</tr>
<tr>
<td>&emsp;&emsp;sdkTimestamp</td>
<td>时间戳</td>
<td>string</td>
</tr>
<tr>
<td>&emsp;&emsp;sessionId</td>
<td>预支付交易会话标识</td>
<td>string</td>
</tr>
<tr>
<td>&emsp;&emsp;subAppid</td>
<td>子商户公众号id</td>
<td>string</td>
</tr>
<tr>
<td>&emsp;&emsp;subMerId</td>
<td>支付通道对应的子商户识别码</td>
<td>string</td>
</tr>
<tr>
<td>&emsp;&emsp;subOpenid</td>
<td>子商户用户标识</td>
<td>string</td>
</tr>
<tr>
<td>&emsp;&emsp;termId</td>
<td>终端号</td>
<td>string</td>
</tr>
<tr>
<td>&emsp;&emsp;traceNo</td>
<td>系统内部追踪号</td>
<td>string</td>
</tr>
<tr>
<td>&emsp;&emsp;transactionId</td>
<td>渠道交易流水号</td>
<td>string</td>
</tr>
<tr>
<td>&emsp;&emsp;type</td>
<td>类型</td>
<td>string</td>
<td>为空或者为"cashier"</td>
</tr>
<tr>
<td>&emsp;&emsp;response</td>
<td>form表单</td>
<td>string</td>
<td>type=cashier时返回</td>
</tr>
<tr>
<td>msg</td>
<td>string</td>
</tr>
<tr>
<td>sign</td>
<td>string</td>
</tr>
</tbody>
</table>
<p><strong>响应示例:</strong></p>
<pre><code class="language-json">{
&quot;code&quot;: 200,
&quot;msg&quot;: &quot;SUCCESS&quot;,
&quot;data&quot;: {
&quot;returnCode&quot;: &quot;000000&quot;,
&quot;returnMsg&quot;: &quot;SUCCESS&quot;,
&quot;termId&quot;: &quot;263575187&quot;,
&quot;randomStr&quot;: &quot;R52FDBN2DVI8KI2FCROZDGUNTYZ5LFUO&quot;,
&quot;agentId&quot;: &quot;AGT_0001&quot;,
&quot;mchNo&quot;: &quot;MCH_I293975931&quot;,
&quot;subMerId&quot;: &quot;406875231&quot;,
&quot;sessionId&quot;: &quot;wx271521515916655db308e891d9d6e30000&quot;,
&quot;qrCode&quot;: &quot;&quot;,
&quot;subAppid&quot;: &quot;wxfa089da95020ba1a&quot;,
&quot;subOpenid&quot;: &quot;oUpF8uAaF7ZBRRpcIlquMHmQ892Q&quot;,
&quot;sdkAppid&quot;: &quot;wx2421b1c4370ec43b&quot;,
&quot;sdkTimestamp&quot;: &quot;1679901711&quot;,
&quot;sdkNonceStr&quot;: &quot;67a8752a638d4c518fd6c1f34a2d8827&quot;,
&quot;sdkPackage&quot;: &quot;prepay_id=wx271521515916655db308e891d9d6e30000&quot;,
&quot;sdkSignType&quot;: &quot;RSA&quot;,
&quot;sdkPaySign&quot;: &quot;FBpO1VsZqF7SFZQ8ca1U9u/hbEdAW5l0nIj4Lf16qVvQUnTw8l1AylRSyind8FoZXMgo7ZPd6aADLwo4A/3ojh734XK3M8VSmPgukqzAqxE3aHdJ61YtLEGu8JirrvlYVxzpkhmMFr/Yr2cM747C7u0E9zShIPt6kTA3Pjmm48lb070FsZyW1XtKgIN96fGn8IKTQix+naHvkO9UzRw+85fXWUoiBxeLwO10EZIANLt0TlqOmu/9tkRo0TV5MvWn0i9rIOh6861b6qOGk4lwh+xHeDlf+9tIVJNulfgLB3cNGw0rp21slh5mUIXT9SusAxqD80c3cksmAWdBTIc12g==&quot;,
&quot;sdkPartnerId&quot;: &quot;&quot;,
&quot;orderNo&quot;: &quot;&quot;,
&quot;dealDate&quot;: &quot;&quot;,
&quot;transactionId&quot;: &quot;&quot;,
&quot;traceNo&quot;: &quot;030062149723&quot;,
&quot;payInfo&quot;: &quot;{\&quot;timeStamp\&quot;:\&quot;1679901711\&quot;,\&quot;package\&quot;:\&quot;prepay_id=wx271521515916655db308e891d9d6e30000\&quot;,\&quot;paySign\&quot;:\&quot;FBpO1VsZqF7SFZQ8ca1U9u/hbEdAW5l0nIj4Lf16qVvQUnTw8l1AylRSyind8FoZXMgo7ZPd6aADLwo4A/3ojh734XK3M8VSmPgukqzAqxE3aHdJ61YtLEGu8JirrvlYVxzpkhmMFr/Yr2cM747C7u0E9zShIPt6kTA3Pjmm48lb070FsZyW1XtKgIN96fGn8IKTQix+naHvkO9UzRw+85fXWUoiBxeLwO10EZIANLt0TlqOmu/9tkRo0TV5MvWn0i9rIOh6861b6qOGk4lwh+xHeDlf+9tIVJNulfgLB3cNGw0rp21slh5mUIXT9SusAxqD80c3cksmAWdBTIc12g==\&quot;,\&quot;appId\&quot;:\&quot;wx2421b1c4370ec43b\&quot;,\&quot;signType\&quot;:\&quot;RSA\&quot;,\&quot;nonceStr\&quot;:\&quot;67a8752a638d4c518fd6c1f34a2d8827\&quot;}&quot;,
&quot;channelOrderId&quot;: &quot;&quot;,
&quot;extParam&quot;: &quot;&quot;,
&quot;type&quot;:&quot;&quot;,
&quot;response&quot;:&quot;&quot;
},
&quot;sign&quot;: &quot;3e825b9c9239cc07fe806c222ed39e16&quot;
}</code></pre>