Skip to content

合单下单

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

🔐

本接口服务已于 2021.09.01 (北京时间)停止开放,新接口见这里 这里 这里 这里,此文档仅做留存参考。

请求参数类型描述
xmlobject声明请求的XML数据结构
combine_appidstring合单appid
combine_mch_idstring合单商户号
device_infostring设备号
sign_typestring签名类型
HMAC-SHA256 枚举值
combine_out_trade_nostring合单商户订单号
spbill_create_ipstring终端IP
time_startstring交易起始时间
time_expirestring交易结束时间
notify_urlstring通知地址
trade_typestring交易类型
product_idstring商品ID
combine_openidstring合单用户标识
scene_infostring场景信息JSON格式字符串
device_idstring商户端设备号
payer_client_ipstring用户终端IP
h5_infoobjectH5场景信息
typestring场景类型
iOS | Android | Wap 枚举值之一
app_namestring应用名称
app_urlstring网站URL
bundle_idstringiOS平台BundleID
package_namestringAndroid平台PackageName
sub_order_liststring子单信息JSON格式字符串
order_numnumber子订单数
order_listobject[]子订单信息
appidstring子单商户appid
mch_idstring子单商户号
bodystring商品描述
detailstring商品详情
attachstring附加数据
out_trade_nostring子单商户订单号
fee_typestring标价币种
total_feeinteger子单金额,单位为分
sub_appidstring服务商模式下,特约商户的appid
sub_mch_idstring特约商户商户号,服务商模式必传
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'           => \json_encode([
      'device_id'       => 'POS1:1',
      'payer_client_ip' => '14.17.22.32',
      'h5_info'         => [
        'type'         => 'iOS',
        'app_name'     => '王者荣耀',
        'app_url'      => '',
        'bundle_id'    => 'com.tencent.wzryIOS',
        'package_name' => '',
      ],
    ]),
    'sub_order_list'       => \json_encode([
      'order_num'  => 2,
      'order_list' => [[
        'appid'        => 'wxdace645e0bc2c424',
        'mch_id'       => '1900009001',
        'body'         => '子订单1',
        'detail'       => '商品详细描述',
        'attach'       => '深圳分店',
        'out_trade_no' => 'OD201708030001',
        'fee_type'     => 'CNY',
        'total_fee'    => 88,
        'sub_appid'    => 'wxd678efh567hg6787',
        'sub_mch_id'   => '1256324589',
      ],],
    ]),
  ],
])
->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'           => \json_encode([
      'device_id'       => 'POS1:1',
      'payer_client_ip' => '14.17.22.32',
      'h5_info'         => [
        'type'         => 'iOS',
        'app_name'     => '王者荣耀',
        'app_url'      => '',
        'bundle_id'    => 'com.tencent.wzryIOS',
        'package_name' => '',
      ],
    ]),
    'sub_order_list'       => \json_encode([
      'order_num'  => 2,
      'order_list' => [[
        'appid'        => 'wxdace645e0bc2c424',
        'mch_id'       => '1900009001',
        'body'         => '子订单1',
        'detail'       => '商品详细描述',
        'attach'       => '深圳分店',
        'out_trade_no' => 'OD201708030001',
        'fee_type'     => 'CNY',
        'total_fee'    => 88,
        'sub_appid'    => 'wxd678efh567hg6787',
        'sub_mch_id'   => '1256324589',
      ],],
    ]),
  ],
])
->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'           => \json_encode([
      'device_id'       => 'POS1:1',
      'payer_client_ip' => '14.17.22.32',
      'h5_info'         => [
        'type'         => 'iOS',
        'app_name'     => '王者荣耀',
        'app_url'      => '',
        'bundle_id'    => 'com.tencent.wzryIOS',
        'package_name' => '',
      ],
    ]),
    'sub_order_list'       => \json_encode([
      'order_num'  => 2,
      'order_list' => [[
        'appid'        => 'wxdace645e0bc2c424',
        'mch_id'       => '1900009001',
        'body'         => '子订单1',
        'detail'       => '商品详细描述',
        'attach'       => '深圳分店',
        'out_trade_no' => 'OD201708030001',
        'fee_type'     => 'CNY',
        'total_fee'    => 88,
        'sub_appid'    => 'wxd678efh567hg6787',
        'sub_mch_id'   => '1256324589',
      ],],
    ]),
  ],
])
->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'           => \json_encode([
      'device_id'       => 'POS1:1',
      'payer_client_ip' => '14.17.22.32',
      'h5_info'         => [
        'type'         => 'iOS',
        'app_name'     => '王者荣耀',
        'app_url'      => '',
        'bundle_id'    => 'com.tencent.wzryIOS',
        'package_name' => '',
      ],
    ]),
    'sub_order_list'       => \json_encode([
      'order_num'  => 2,
      'order_list' => [[
        'appid'        => 'wxdace645e0bc2c424',
        'mch_id'       => '1900009001',
        'body'         => '子订单1',
        'detail'       => '商品详细描述',
        'attach'       => '深圳分店',
        'out_trade_no' => 'OD201708030001',
        'fee_type'     => 'CNY',
        'total_fee'    => 88,
        'sub_appid'    => 'wxd678efh567hg6787',
        'sub_mch_id'   => '1256324589',
      ],],
    ]),
  ],
]);
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'           => \json_encode([
      'device_id'       => 'POS1:1',
      'payer_client_ip' => '14.17.22.32',
      'h5_info'         => [
        'type'         => 'iOS',
        'app_name'     => '王者荣耀',
        'app_url'      => '',
        'bundle_id'    => 'com.tencent.wzryIOS',
        'package_name' => '',
      ],
    ]),
    'sub_order_list'       => \json_encode([
      'order_num'  => 2,
      'order_list' => [[
        'appid'        => 'wxdace645e0bc2c424',
        'mch_id'       => '1900009001',
        'body'         => '子订单1',
        'detail'       => '商品详细描述',
        'attach'       => '深圳分店',
        'out_trade_no' => 'OD201708030001',
        'fee_type'     => 'CNY',
        'total_fee'    => 88,
        'sub_appid'    => 'wxd678efh567hg6787',
        'sub_mch_id'   => '1256324589',
      ],],
    ]),
  ],
]);
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'           => \json_encode([
      'device_id'       => 'POS1:1',
      'payer_client_ip' => '14.17.22.32',
      'h5_info'         => [
        'type'         => 'iOS',
        'app_name'     => '王者荣耀',
        'app_url'      => '',
        'bundle_id'    => 'com.tencent.wzryIOS',
        'package_name' => '',
      ],
    ]),
    'sub_order_list'       => \json_encode([
      'order_num'  => 2,
      'order_list' => [[
        'appid'        => 'wxdace645e0bc2c424',
        'mch_id'       => '1900009001',
        'body'         => '子订单1',
        'detail'       => '商品详细描述',
        'attach'       => '深圳分店',
        'out_trade_no' => 'OD201708030001',
        'fee_type'     => 'CNY',
        'total_fee'    => 88,
        'sub_appid'    => 'wxd678efh567hg6787',
        'sub_mch_id'   => '1256324589',
      ],],
    ]),
  ],
]);
print_r(\WeChatPay\Transformer::toArray((string) $response->getBody()));
返回字典类型描述
return_codestring返回状态码
SUCCESS | FAIL 枚举值之一
return_msgstring返回信息
combine_appidstring合单appid
combine_mch_idstring合单商户号
device_infostring设备号
nonce_strstring随机字符串
signstring签名
result_codestring业务结果
SUCCESS | FAIL 枚举值之一
err_codestring错误代码
err_code_desstring错误代码描述
trade_typestring交易类型
code_urlstring二维码链接
prepay_idstring预支付交易会话标识
mweb_urlstringH5支付跳转链接

参阅 官方合单支付文档

Published on the GitHub by TheNorthMemory