糖果


创建订单

<p><strong>简要描述:</strong><br /> 使用指定支付方式, 购买指定支付项.<br /> 不同支付方式的返回数据结构不尽相同, 客户端请参考本页最下方的开发建议.</p> <p><strong>请求URL:</strong><br /> <code>/api/v1/order</code></p> <p><strong>请求方式:</strong><br /> <code>POST</code></p> <p><strong>参数:</strong> </p> <table> <thead> <tr> <th style="text-align: left;">参数名</th> <th style="text-align: left;">是否必选</th> <th style="text-align: left;">类型</th> <th>说明</th> </tr> </thead> <tbody> <tr> <td style="text-align: left;">source</td> <td style="text-align: left;">必选</td> <td style="text-align: left;">string</td> <td>渠道号</td> </tr> <tr> <td style="text-align: left;">package_id</td> <td style="text-align: left;">必选</td> <td style="text-align: left;">string</td> <td>套餐ID</td> </tr> <tr> <td style="text-align: left;">channel</td> <td style="text-align: left;">必选</td> <td style="text-align: left;">string</td> <td>支付通道</td> </tr> <tr> <td style="text-align: left;">gateway</td> <td style="text-align: left;">可选</td> <td style="text-align: left;">string</td> <td>支付网关, 参考各支付通道对应网关, 没有可不填</td> </tr> <tr> <td style="text-align: left;">coupon_prop_id</td> <td style="text-align: left;">可选</td> <td style="text-align: left;">string</td> <td>优惠券道具ID</td> </tr> <tr> <td style="text-align: left;">cost_order_id</td> <td style="text-align: left;">可选</td> <td style="text-align: left;">string</td> <td>消耗订单ID(当补差价时此参数必填, 由服务端提供)</td> </tr> </tbody> </table> <p><strong>channel支付通道说明:</strong></p> <table> <thead> <tr> <th style="text-align: left;">类型</th> <th>说明</th> </tr> </thead> <tbody> <tr> <td style="text-align: left;">alipay</td> <td>支付宝</td> </tr> <tr> <td style="text-align: left;">wechat</td> <td>微信</td> </tr> <tr> <td style="text-align: left;">helloNow</td> <td>你好现在</td> </tr> <tr> <td style="text-align: left;">apple</td> <td>苹果</td> </tr> <tr> <td style="text-align: left;">yijie</td> <td>易接</td> </tr> <tr> <td style="text-align: left;">quickSdk</td> <td>quickSdk</td> </tr> <tr> <td style="text-align: left;">adapay</td> <td>adapay</td> </tr> </tbody> </table> <p><strong>gateway支付网关 (channel=alipay)</strong></p> <table> <thead> <tr> <th style="text-align: left;">类型</th> <th>说明</th> </tr> </thead> <tbody> <tr> <td style="text-align: left;">app</td> <td>APP支付</td> </tr> <tr> <td style="text-align: left;">web</td> <td>电脑网站支付</td> </tr> <tr> <td style="text-align: left;">wap</td> <td>手机网站支付</td> </tr> </tbody> </table> <p><strong>gateway支付网关 (channel=wechat)</strong></p> <table> <thead> <tr> <th style="text-align: left;">类型</th> <th>说明</th> </tr> </thead> <tbody> <tr> <td style="text-align: left;">app</td> <td>APP支付</td> </tr> <tr> <td style="text-align: left;">scan</td> <td>PC端扫码支付</td> </tr> <tr> <td style="text-align: left;"><del>web</del></td> <td><del>电脑网站支付</del></td> </tr> <tr> <td style="text-align: left;">wap</td> <td>手机网站支付</td> </tr> </tbody> </table> <p><strong>gateway支付网关 (channel=helloNow)</strong></p> <table> <thead> <tr> <th style="text-align: left;">类型</th> <th>说明</th> </tr> </thead> <tbody> <tr> <td style="text-align: left;">alipay</td> <td>支付宝</td> </tr> <tr> <td style="text-align: left;">wechat</td> <td>微信</td> </tr> </tbody> </table> <p><strong>支付网关(adapay渠道)</strong></p> <table> <thead> <tr> <th style="text-align: left;">类型</th> <th>说明</th> </tr> </thead> <tbody> <tr> <td style="text-align: left;">alipay</td> <td>支付宝</td> </tr> </tbody> </table> <p><strong>身份验证: </strong></p> <p><code>是</code></p> <p><strong>返回示例</strong></p> <pre><code class="language-bash">// 支付宝APP { &amp;quot;code&amp;quot;: 0, &amp;quot;message&amp;quot;: &amp;quot;&amp;quot;, &amp;quot;data&amp;quot;: &amp;quot;app_id=2016102602338302&amp;amp;format=JSON&amp;amp;charset=utf-8&amp;amp;sign_type=RSA2&amp;amp;version=1.0&amp;amp;return_url=http%3A%2F%2F192.168.10.10%3A8080%2Fapi%2Fv1%2Forder%2Freturn%2Falipay&amp;amp;notify_url=http%3A%2F%2F192.168.10.10%3A8080%2Fapi%2Fv1%2Forder%2Fnotify%2Falipay&amp;amp;timestamp=2020-05-09+10%3A13%3A55&amp;amp;biz_content=%7B%22out_trade_no%22%3A%22ALI202005091013554620%22%2C%22total_amount%22%3A1.23%2C%22subject%22%3A%221%22%2C%22body%22%3A%221%22%2C%22product_code%22%3A%22QUICK_MSECURITY_PAY%22%7D&amp;amp;method=alipay.trade.app.pay&amp;amp;sign=eyHap1fJgrIlxclpOmx425Bfxd44gBIge0JvF7ePfrvqhgSVAJDwqcSzLnPyHM5usBhFqzhK63wzGMpvu600p3q4aMuVKK8e1ZNNan4eyA%2F%2F0DhFbPtzGFSBt47l5APxjwtt0riu4ySVbRNF0Uzw23eHJP3MH%2FaOZF72T08A1ElgHaVszzHf8JvaRiBRWjTQOlEiuUgXGbku0S%2BUOPN8XQwAqwXHR%2Fsk1%2Boaw7TTL9pnZu5PxFYarm%2F3qDuFaRfgSgA6HiR4feeTB4KhZpyQ4C3002iFoetqWtVpilZb%2By%2FQwhacKZn3h5Bwwt%2BXFJhH%2FjhIyXyC%2BoKzVOOro9JTUg%3D%3D&amp;quot; } // 支付宝 WEB { &amp;quot;code&amp;quot;: 0, &amp;quot;message&amp;quot;: &amp;quot;&amp;quot;, &amp;quot;data&amp;quot;: &amp;quot;https://openapi.alipay.com/gateway.do?charset=utf-8&amp;amp;app_id=2016080401702147&amp;amp;format=JSON&amp;amp;charset=utf-8&amp;amp;sign_type=RSA2&amp;amp;version=1.0&amp;amp;return_url=http%3A%2F%2F192.168.10.10%3A8080%2Fapi%2Fv1%2Forder%2Freturn%2Falipay&amp;amp;notify_url=http%3A%2F%2F192.168.10.10%3A8080%2Fapi%2Fv1%2Forder%2Fnotify%2Falipay&amp;amp;timestamp=2020-06-02+19%3A13%3A12&amp;amp;biz_content=%7B%22out_trade_no%22%3A%22ALI202006021913128396%22%2C%22total_amount%22%3A0.01%2C%22subject%22%3A%22%5Cu81f3%5Cu5c0a20%5Cu5929%5Cu793c%5Cu5305%22%2C%22body%22%3A%22%5Cu81f3%5Cu5c0a20%5Cu5929%5Cu793c%5Cu5305%22%2C%22product_code%22%3A%22FAST_INSTANT_TRADE_PAY%22%7D&amp;amp;method=alipay.trade.page.pay&amp;amp;sign=FOvXpcGNa0K8usKu%2BxStSKCBdRDu0DqYl7U0nOiF3FlQC5BLmhBukALYMUA%2F8oF9WqgOuLx0DNNFnn2%2Bo0fkT4%2FTKOuPExMI6YLBK1VV6wK8w7cLCbY2gNXbsm7s1lSu8QlRMD8A8Iwx%2BWJizHM6KHFJ4ELXjD8bUGPRHVYbNEC1wofh%2BTo5V1Zrf6y3nJpPBs8aDQKF5YERzliEoLoJ3pGAfcXDYEySDDiXU23PLjgs2C2cNyhQAspcV1H2b2d0Hg%2BKPscA%2BWSVl7GHvZQp19xGkrozbt%2BO4ty50ZD7xChW3D21ndvMiqaD98m3q42THtTSti0pK%2BgaZBSr%2Bci6Ig%3D%3D&amp;quot; } // 苹果内购 { &amp;quot;code&amp;quot;: 0, &amp;quot;message&amp;quot;: &amp;quot;&amp;quot;, &amp;quot;data&amp;quot;: { &amp;quot;orderid&amp;quot;: &amp;quot;PG202007301609314744&amp;quot;, &amp;quot;price&amp;quot;: 1, &amp;quot;appleProductId&amp;quot;: &amp;quot;0&amp;quot;, &amp;quot;sign&amp;quot;: &amp;quot;taXbm9MwfDF8NDQ3NDEzOTA2MTAzNzAwMjAyR1A=&amp;quot; } } // 易接 { &amp;quot;code&amp;quot;: 0, &amp;quot;message&amp;quot;: &amp;quot;&amp;quot;, &amp;quot;data&amp;quot;: { &amp;quot;orderid&amp;quot;: &amp;quot;NO202008061711392723&amp;quot;, &amp;quot;price&amp;quot;: 1, &amp;quot;title&amp;quot;: &amp;quot;至尊20天礼包&amp;quot;, &amp;quot;notify_url&amp;quot;: &amp;quot;http://192.168.10.10/api/v1/order/notify/nopay&amp;quot; } } // 微信支付 APP支付(app) { &amp;quot;code&amp;quot;: 0, &amp;quot;message&amp;quot;: &amp;quot;&amp;quot;, &amp;quot;data&amp;quot;: { &amp;quot;appid&amp;quot;: &amp;quot;wxade597438d0d2fa3&amp;quot;, &amp;quot;partnerid&amp;quot;: &amp;quot;1602969828&amp;quot;, &amp;quot;prepayid&amp;quot;: &amp;quot;wx2714310732185443cbbfb8623c9ed60000&amp;quot;, &amp;quot;timestamp&amp;quot;: &amp;quot;1601188267&amp;quot;, &amp;quot;noncestr&amp;quot;: &amp;quot;AmnAP7JtoPXTfX3g&amp;quot;, &amp;quot;package&amp;quot;: &amp;quot;Sign=WXPay&amp;quot;, &amp;quot;sign&amp;quot;: &amp;quot;18275991C86FD7899BC4860A21D8E223&amp;quot; } } // 微信支付 PC扫码(scan) { &amp;quot;code&amp;quot;: 0, &amp;quot;message&amp;quot;: &amp;quot;&amp;quot;, &amp;quot;data&amp;quot;: { &amp;quot;return_code&amp;quot;: &amp;quot;SUCCESS&amp;quot;, &amp;quot;return_msg&amp;quot;: &amp;quot;OK&amp;quot;, &amp;quot;appid&amp;quot;: &amp;quot;wx17471a05c15d2d70&amp;quot;, &amp;quot;mch_id&amp;quot;: &amp;quot;1602969828&amp;quot;, &amp;quot;nonce_str&amp;quot;: &amp;quot;BHtPQkM8xVZ8hrco&amp;quot;, &amp;quot;sign&amp;quot;: &amp;quot;92F2531441C52962B8BC0CF8F3777DB8&amp;quot;, &amp;quot;result_code&amp;quot;: &amp;quot;SUCCESS&amp;quot;, &amp;quot;prepay_id&amp;quot;: &amp;quot;wx271431075556675898d4ab51b336580000&amp;quot;, &amp;quot;trade_type&amp;quot;: &amp;quot;NATIVE&amp;quot;, &amp;quot;code_url&amp;quot;: &amp;quot;weixin://wxpay/bizpayurl?pr=5Glkec400&amp;quot; } } // 微信支付 H5支付(wap) { &amp;quot;code&amp;quot;: 0, &amp;quot;message&amp;quot;: &amp;quot;&amp;quot;, &amp;quot;data&amp;quot;: &amp;quot;weixin://wxpay/bizpayurl?pr=5Glkec400&amp;quot; } // quickSdk { &amp;quot;code&amp;quot;: 0, &amp;quot;message&amp;quot;: &amp;quot;&amp;quot;, &amp;quot;data&amp;quot;: { &amp;quot;orderid&amp;quot;: &amp;quot;NO202011021821484222&amp;quot;, &amp;quot;price&amp;quot;: 1, &amp;quot;title&amp;quot;: &amp;quot;199元单人套餐男宾一位&amp;quot;, &amp;quot;gold&amp;quot;: 11000000, &amp;quot;diamond&amp;quot;: 0, &amp;quot;notify_url&amp;quot;: &amp;quot;http://192.168.10.10:8080/api/v1/order/notify/quickSdk&amp;quot; } } // helloNow 两种支付方式, 一种是APP支付, 一种是H5支付, 由服务端控制, 客户端需要根据 is_h5 字段判断. // APP支付 直接使用返回返参, 调起你好SDK. // H5支付 则需要客户端使用webview、浏览器打开HTTP链接或直接打开scheme链接 // helloNow 你好现在(APP支付) // alipay与wechat返参大致相同 { &amp;quot;code&amp;quot;: 0, &amp;quot;message&amp;quot;: &amp;quot;&amp;quot;, &amp;quot;data&amp;quot;: { &amp;quot;funcode&amp;quot;: &amp;quot;WP001&amp;quot;, &amp;quot;version&amp;quot;: &amp;quot;1.0.3&amp;quot;, &amp;quot;appId&amp;quot;: &amp;quot;1234567890&amp;quot;, &amp;quot;mhtOrderNo&amp;quot;: &amp;quot;HNOW202111251534516355&amp;quot;, &amp;quot;mhtOrderName&amp;quot;: &amp;quot;Yolanda Cartwright&amp;quot;, &amp;quot;mhtOrderType&amp;quot;: &amp;quot;05&amp;quot;, &amp;quot;mhtCurrencyType&amp;quot;: &amp;quot;156&amp;quot;, &amp;quot;mhtOrderAmt&amp;quot;: 100, &amp;quot;mhtOrderDetail&amp;quot;: &amp;quot;Yolanda Cartwright&amp;quot;, &amp;quot;mhtOrderStartTime&amp;quot;: &amp;quot;20211125153451&amp;quot;, &amp;quot;notifyUrl&amp;quot;: &amp;quot;http:\/\/localhost\/api\/v1\/order\/notify\/helloNow\/0&amp;quot;, &amp;quot;mhtCharset&amp;quot;: &amp;quot;UTF-8&amp;quot;, &amp;quot;deviceType&amp;quot;: &amp;quot;01&amp;quot;, &amp;quot;payChannelType&amp;quot;: &amp;quot;12&amp;quot;, &amp;quot;consumerCreateIp&amp;quot;: &amp;quot;192.168.10.10&amp;quot;, &amp;quot;mhtSignType&amp;quot;: &amp;quot;MD5&amp;quot;, &amp;quot;mhtSignature&amp;quot;: &amp;quot;ac31c2e05d9d542301c11e087c3406ad&amp;quot; } } // helloNow 你好现在(H5支付) { &amp;quot;code&amp;quot;: 0, &amp;quot;message&amp;quot;: &amp;quot;&amp;quot;, &amp;quot;data&amp;quot;: { &amp;quot;is_h5&amp;quot;: true, &amp;quot;url&amp;quot;: &amp;quot;alipays:\/\/platformapi\/startapp?appId=10000007&amp;amp;qrcode=https%3A%2F%2Fqr.alipay.com%2Fbax03957tcjaspafm4ok3058#Intent&amp;quot; } } { &amp;quot;code&amp;quot;: 0, &amp;quot;message&amp;quot;: &amp;quot;&amp;quot;, &amp;quot;data&amp;quot;: { &amp;quot;is_h5&amp;quot;: true, &amp;quot;url&amp;quot;: &amp;quot;https://openapi.alipay.com/gateway.do?alipay_sdk=alipay-sdk-java-dynamicVersionNo&amp;amp;app_auth_token=201612BBe7933914c71745ae99360f4c29fedB06&amp;amp;app_id=2016090701862812&amp;amp;biz_content=%7B%22total_amount%22%3A%220.01%22%2C%22timeout_express%22%3A%2260m%22%2C%22product_code%22%3A%22QUICK_WAP_PAY%22%2C%22subject%22%3A%22mhtOrderName%E8%AE%A2%E5%8D%95%E5%90%8D%E7%A7%B0%22%2C%22out_trade_no%22%3A%22200601201710231457537743001%22%2C%22extend_params%22%3A%22%7B%5C%22sys_service_provider_id%5C%22%3A%5C%222088421452327167%5C%22%7D%22%7D&amp;amp;charset=UTF-8&amp;amp;format=json&amp;amp;method=alipay.trade.wap.pay&amp;amp;notify_url=https%3A%2F%2Fpay.ipaynow.cn%2FaliPayNotify%2F2006%2F0df24039a41c139eB1123_116_22478846Be9cf69e5774937B260_22_0091777671&amp;amp;return_url=https%3A%2F%2Fpay.ipaynow.cn%2FalipayFrontNotify%2F2006%2F0df24039a41c139eB1123_116_22478846Be9cf69e5774937B260_22_0091777671&amp;amp;sign=R%2BpsmG%2BCon1OL5SkuhsApxcUS4U2BwD5ZrL%2Ben1SgmOAv3%2B2JV5x6CEoJbFgOdh9UhkR%2Bn5PR6RNDAhKP2XSP6uWptS20aydIB4PZ8%2BYwX%2FlW0WH6uE5WI65K%2Bd5uOzb%2B6CZEcwqhC8Et%2Fm2KIw7wGvp94wFZn7P14Y3wcx%2Berk%3D&amp;amp;sign_type=RSA&amp;amp;timestamp=2017-10-23+14%3A57%3A53&amp;amp;version=1.0&amp;amp;sign=R%2BpsmG%2BCon1OL5SkuhsApxcUS4U2BwD5ZrL%2Ben1SgmOAv3%2B2JV5x6CEoJbFgOdh9UhkR%2Bn5PR6RNDAhKP2XSP6uWptS20aydIB4PZ8%2BYwX%2FlW0WH6uE5WI65K%2Bd5uOzb%2B6CZEcwqhC8Et%2Fm2KIw7wGvp94wFZn7P14Y3wcx%2Berk%3D&amp;quot; } } # adapay alipay { &amp;quot;code&amp;quot;: 0, &amp;quot;message&amp;quot;: &amp;quot;&amp;quot;, &amp;quot;data&amp;quot;: &amp;quot;alipays://platformapi/startapp?saId=10000007&amp;amp;qrcode=https://qr.alipay.com/bax02911brluc2xieoph6001&amp;quot; }</code></pre> <p><strong>返回参数说明</strong> </p> <p><strong>备注</strong> </p> <p>当 <code>data.code</code> 为<code>0</code>, 且<code>data.message</code> 不为空时, 客户端应使用确认框显示文本内容, 其余流程不变.</p> <p><strong>开发建议</strong></p> <p>考虑到后面会接入很多支付宝/微信的第三方支付, 为减小工作量, 建议首先判断 <code>data</code> 为<code>string</code>时, 进行<strong>scheme前缀匹配</strong>, 匹配成功直接打开.</p> <pre><code># 直接打开支付宝, 前缀 alipays:// { &amp;quot;code&amp;quot;: 0, &amp;quot;message&amp;quot;: &amp;quot;&amp;quot;, &amp;quot;data&amp;quot;: &amp;quot;alipays://platformapi/startapp?saId=10000007&amp;amp;qrcode=https://qr.alipay.com/bax02911brluc2xieoph6001&amp;quot; } # 直接打开微信, 前缀 weixin:// { &amp;quot;code&amp;quot;: 0, &amp;quot;message&amp;quot;: &amp;quot;&amp;quot;, &amp;quot;data&amp;quot;: &amp;quot;weixin://wxpay/bizpayurl?pr=5Glkec400&amp;quot; } # 直接打开自带浏览器, 前缀 http:// 或 https:// { &amp;quot;code&amp;quot;: 0, &amp;quot;message&amp;quot;: &amp;quot;&amp;quot;, &amp;quot;data&amp;quot;: &amp;quot;https://openapi.alipay.com/gateway.do?charset=utf-8&amp;amp;app_id=2016080401702147&amp;amp;format=JSON&amp;amp;charset=utf-8&amp;amp;sign_type=RSA2&amp;amp;version=1.0&amp;amp;return_url=http%3A%2F%2F192.168.10.10%3A8080%2Fapi%2Fv1%2Forder%2Freturn%2Falipay&amp;amp;notify_url=http%3A%2F%2F192.168.10.10%3A8080%2Fapi%2Fv1%2Forder%2Fnotify%2Falipay&amp;amp;timestamp=2020-06-02+19%3A13%3A12&amp;amp;biz_content=%7B%22out_trade_no%22%3A%22ALI202006021913128396%22%2C%22total_amount%22%3A0.01%2C%22subject%22%3A%22%5Cu81f3%5Cu5c0a20%5Cu5929%5Cu793c%5Cu5305%22%2C%22body%22%3A%22%5Cu81f3%5Cu5c0a20%5Cu5929%5Cu793c%5Cu5305%22%2C%22product_code%22%3A%22FAST_INSTANT_TRADE_PAY%22%7D&amp;amp;method=alipay.trade.page.pay&amp;amp;sign=FOvXpcGNa0K8usKu%2BxStSKCBdRDu0DqYl7U0nOiF3FlQC5BLmhBukALYMUA%2F8oF9WqgOuLx0DNNFnn2%2Bo0fkT4%2FTKOuPExMI6YLBK1VV6wK8w7cLCbY2gNXbsm7s1lSu8QlRMD8A8Iwx%2BWJizHM6KHFJ4ELXjD8bUGPRHVYbNEC1wofh%2BTo5V1Zrf6y3nJpPBs8aDQKF5YERzliEoLoJ3pGAfcXDYEySDDiXU23PLjgs2C2cNyhQAspcV1H2b2d0Hg%2BKPscA%2BWSVl7GHvZQp19xGkrozbt%2BO4ty50ZD7xChW3D21ndvMiqaD98m3q42THtTSti0pK%2BgaZBSr%2Bci6Ig%3D%3D&amp;quot; }</code></pre>

页面列表

ITEM_HTML