Skip to content

合单下单

使用合单支付接口,用户只输入一次密码,即可完成多个订单的支付。目前最多一次可支持10笔订单进行合单支付。用合单下单api在微信支付服务后台生成预支付交易单,返回正确的预支付交易会话标识后再按扫码、JSAPI、APP、H5等不同场景生成交易串调起支付。

请求参数类型描述
xmlobject声明请求的XML数据结构
combine_appidstring合单appid
combine_mch_idstring合单商户号
device_infostring设备号
sign_typestring签名类型
combine_out_trade_nostring合单商户订单号
spbill_create_ipstring终端IP
time_startstring交易起始时间
time_expirestring交易结束时间
notify_urlstring通知地址
trade_typestring交易类型
product_idstring商品ID
combine_openidstring合单用户标识
scene_infostring场景信息
sub_order_liststring+子单信息
php
$instance->v2->pay->combinedorder->postAsync([
  'xml' => [
    'combine_appid' => 'wx8888888888888888',
    'combine_mch_id' => '1900000109',
    'device_info' => '013467007045764',
    'sign_type' => 'HMAC-SHA256',
    'combine_out_trade_no' => '1217752501201407033233368018',
    'spbill_create_ip' => '8.8.8.8',
    'time_start' => '20171225091010',
    'time_expire' => '20171225091510',
    'notify_url' => 'http://www.weixin.qq.com/wxpay/pay.php',
    'trade_type' => 'JSAPI',
    'product_id' => '1234567890',
    'combine_openid' => '120061098828009406',
    'scene_info' => '{"h5_info": {"type":"IOS","app_name": "王者荣耀","bundle_id": "com.tencent.wzryIOS"}}',
    'sub_order_list' => '{"order_list": [{"appid": "wxdace645e0bc2c424","attach": "深圳分店","body": "子订单1","fee_type": "CNY","mch_id": "1900009001","out_trade_no": "OD201708030001","total_fee": 1234}],"order_num": 3}',
  ],
])
->then(static function(\Psr\Http\Message\ResponseInterface $response) {
  print_r(\WeChatPay\Transformer::toArray((string) $response->getBody()));
})
->wait();
php
$instance->chain('v2/pay/combinedorder')->postAsync([
  'xml' => [
    'combine_appid' => 'wx8888888888888888',
    'combine_mch_id' => '1900000109',
    'device_info' => '013467007045764',
    'sign_type' => 'HMAC-SHA256',
    'combine_out_trade_no' => '1217752501201407033233368018',
    'spbill_create_ip' => '8.8.8.8',
    'time_start' => '20171225091010',
    'time_expire' => '20171225091510',
    'notify_url' => 'http://www.weixin.qq.com/wxpay/pay.php',
    'trade_type' => 'JSAPI',
    'product_id' => '1234567890',
    'combine_openid' => '120061098828009406',
    'scene_info' => '{"h5_info": {"type":"IOS","app_name": "王者荣耀","bundle_id": "com.tencent.wzryIOS"}}',
    'sub_order_list' => '{"order_list": [{"appid": "wxdace645e0bc2c424","attach": "深圳分店","body": "子订单1","fee_type": "CNY","mch_id": "1900009001","out_trade_no": "OD201708030001","total_fee": 1234}],"order_num": 3}',
  ],
])
->then(static function(\Psr\Http\Message\ResponseInterface $response) {
  print_r(\WeChatPay\Transformer::toArray((string) $response->getBody()));
})
->wait();
php
$instance['v2/pay/combinedorder']->postAsync([
  'xml' => [
    'combine_appid' => 'wx8888888888888888',
    'combine_mch_id' => '1900000109',
    'device_info' => '013467007045764',
    'sign_type' => 'HMAC-SHA256',
    'combine_out_trade_no' => '1217752501201407033233368018',
    'spbill_create_ip' => '8.8.8.8',
    'time_start' => '20171225091010',
    'time_expire' => '20171225091510',
    'notify_url' => 'http://www.weixin.qq.com/wxpay/pay.php',
    'trade_type' => 'JSAPI',
    'product_id' => '1234567890',
    'combine_openid' => '120061098828009406',
    'scene_info' => '{"h5_info": {"type":"IOS","app_name": "王者荣耀","bundle_id": "com.tencent.wzryIOS"}}',
    'sub_order_list' => '{"order_list": [{"appid": "wxdace645e0bc2c424","attach": "深圳分店","body": "子订单1","fee_type": "CNY","mch_id": "1900009001","out_trade_no": "OD201708030001","total_fee": 1234}],"order_num": 3}',
  ],
])
->then(static function(\Psr\Http\Message\ResponseInterface $response) {
  print_r(\WeChatPay\Transformer::toArray((string) $response->getBody()));
})
->wait();
php
$response = $instance->v2->pay->combinedorder->post([
  'xml' => [
    'combine_appid' => 'wx8888888888888888',
    'combine_mch_id' => '1900000109',
    'device_info' => '013467007045764',
    'sign_type' => 'HMAC-SHA256',
    'combine_out_trade_no' => '1217752501201407033233368018',
    'spbill_create_ip' => '8.8.8.8',
    'time_start' => '20171225091010',
    'time_expire' => '20171225091510',
    'notify_url' => 'http://www.weixin.qq.com/wxpay/pay.php',
    'trade_type' => 'JSAPI',
    'product_id' => '1234567890',
    'combine_openid' => '120061098828009406',
    'scene_info' => '{"h5_info": {"type":"IOS","app_name": "王者荣耀","bundle_id": "com.tencent.wzryIOS"}}',
    'sub_order_list' => '{"order_list": [{"appid": "wxdace645e0bc2c424","attach": "深圳分店","body": "子订单1","fee_type": "CNY","mch_id": "1900009001","out_trade_no": "OD201708030001","total_fee": 1234}],"order_num": 3}',
  ],
]);
print_r(\WeChatPay\Transformer::toArray((string) $response->getBody()));
php
$response = $instance->chain('v2/pay/combinedorder')->post([
  'xml' => [
    'combine_appid' => 'wx8888888888888888',
    'combine_mch_id' => '1900000109',
    'device_info' => '013467007045764',
    'sign_type' => 'HMAC-SHA256',
    'combine_out_trade_no' => '1217752501201407033233368018',
    'spbill_create_ip' => '8.8.8.8',
    'time_start' => '20171225091010',
    'time_expire' => '20171225091510',
    'notify_url' => 'http://www.weixin.qq.com/wxpay/pay.php',
    'trade_type' => 'JSAPI',
    'product_id' => '1234567890',
    'combine_openid' => '120061098828009406',
    'scene_info' => '{"h5_info": {"type":"IOS","app_name": "王者荣耀","bundle_id": "com.tencent.wzryIOS"}}',
    'sub_order_list' => '{"order_list": [{"appid": "wxdace645e0bc2c424","attach": "深圳分店","body": "子订单1","fee_type": "CNY","mch_id": "1900009001","out_trade_no": "OD201708030001","total_fee": 1234}],"order_num": 3}',
  ],
]);
print_r(\WeChatPay\Transformer::toArray((string) $response->getBody()));
php
$response = $instance['v2/pay/combinedorder']->post([
  'xml' => [
    'combine_appid' => 'wx8888888888888888',
    'combine_mch_id' => '1900000109',
    'device_info' => '013467007045764',
    'sign_type' => 'HMAC-SHA256',
    'combine_out_trade_no' => '1217752501201407033233368018',
    'spbill_create_ip' => '8.8.8.8',
    'time_start' => '20171225091010',
    'time_expire' => '20171225091510',
    'notify_url' => 'http://www.weixin.qq.com/wxpay/pay.php',
    'trade_type' => 'JSAPI',
    'product_id' => '1234567890',
    'combine_openid' => '120061098828009406',
    'scene_info' => '{"h5_info": {"type":"IOS","app_name": "王者荣耀","bundle_id": "com.tencent.wzryIOS"}}',
    'sub_order_list' => '{"order_list": [{"appid": "wxdace645e0bc2c424","attach": "深圳分店","body": "子订单1","fee_type": "CNY","mch_id": "1900009001","out_trade_no": "OD201708030001","total_fee": 1234}],"order_num": 3}',
  ],
]);
print_r(\WeChatPay\Transformer::toArray((string) $response->getBody()));
返回字典类型描述
return_codestring返回状态码
return_msgstring返回信息
combine_appidstring合单appid
combine_mch_idstring合单商户号
device_infostring设备号
nonce_strstring随机字符串
signstring签名
result_codestring业务结果
err_codestring错误代码
err_code_desstring错误代码描述
trade_typestring交易类型
code_urlstring二维码链接
prepay_idstring预支付交易会话标识
mweb_urlstringH5支付跳转链接

参阅 官方合单支付文档

Published on the GitHub by TheNorthMemory