Skip to content

扫码支付下单

合作伙伴系统先调用该接口在微信支付服务后台生成预支付交易单,返回正确的预支付交易会话标识后再按Native、JSAPI、APP等不同场景生成交易串调起支付。

请求参数类型描述
jsonobject声明请求的JSON数据结构
sp_appidstring合作伙伴应用AppID
sp_mchidstring合作伙伴商户号
sub_appidstring特约商户应用AppID
sub_mchidstring特约商户号
descriptionstring商品描述
out_trade_nostring商户订单号
time_expirestring交易结束时间
attachstring附加数据
notify_urlstring通知地址
goods_tagstring订单优惠标记
support_fapiaoboolean电子发票入口开放标识
amountobject订单金额
totalnumber总金额
currencystring货币类型
payerobject支付者
sp_openidstring用户标识
sub_openidstring用户子标识
detailobject优惠功能
cost_pricenumber订单原价
invoice_idstring商品小票 ID
goods_detailobject[]单品列表
merchant_goods_idstring商品编码
wechatpay_goods_idstring微信侧商品编码
goods_namestring商品名称
quantitynumber商品数量
unit_pricenumber商品单价
scene_infoobject场景信息
payer_client_ipstring用户终端IP
device_idstring商户端设备号
store_infoobject商户门店信息
idstring门店ID
out_idstring商家自定义编码
settle_infoobject结算信息
profit_sharingboolean是否指定分账
php
$instance->v3->pay->partner->transactions->scannedpos->postAsync([
  'json' => [
    'sp_appid' => 'wx8888888888888888',
    'sp_mchid' => '1230000109',
    'sub_appid' => 'wxd678efh567hg6999',
    'sub_mchid' => '1900000109',
    'description' => 'Image形象店-深圳腾大-QQ公仔',
    'out_trade_no' => '1217752501201407033233368018',
    'time_expire' => '2018-06-08T10:34:56+08:00',
    'attach' => '自定义数据',
    'notify_url' => 'https://www.weixin.qq.com/wxpay/pay.php',
    'goods_tag' => 'WXG',
    'support_fapiao' => true,
    'amount' => [
      'total' => 888,
      'currency' => 'CNY',
    ],
    'payer' => [
      'sp_openid' => 'oUpF8uMuAJO_M2pxb1Q9zNjWeS6o',
      'sub_openid' => 'oUpF8uMuAJO_M2pxb1Q9zNjWeS6o',
    ],
    'detail' => [
      'cost_price' => 1,
      'invoice_id' => 'wx123',
      'goods_detail' => [[
        'merchant_goods_id' => '由半角的大小写字母、数字、中划线、下划线中的一种或几种组成',
        'wechatpay_goods_id' => '微信支付定义的统一商品编号(没有可不传)',
        'goods_name' => 'iPhone6s 16G',
        'quantity' => 1,
        'unit_price' => 528800,
      ],],
    ],
    'scene_info' => [
      'payer_client_ip' => '14.23.150.211',
      'device_id' => '013467007045764',
      'store_info' => [
        'id' => '0001',
        'out_id' => 'example_out_id',
      ],
    ],
    'settle_info' => [
      'profit_sharing' => true,
    ],
  ],
])
->then(static function(\Psr\Http\Message\ResponseInterface $response) {
  print_r(json_decode((string) $response->getBody(), true));
})
->wait();
php
$instance->chain('v3/pay/partner/transactions/scannedpos')->postAsync([
  'json' => [
    'sp_appid' => 'wx8888888888888888',
    'sp_mchid' => '1230000109',
    'sub_appid' => 'wxd678efh567hg6999',
    'sub_mchid' => '1900000109',
    'description' => 'Image形象店-深圳腾大-QQ公仔',
    'out_trade_no' => '1217752501201407033233368018',
    'time_expire' => '2018-06-08T10:34:56+08:00',
    'attach' => '自定义数据',
    'notify_url' => 'https://www.weixin.qq.com/wxpay/pay.php',
    'goods_tag' => 'WXG',
    'support_fapiao' => true,
    'amount' => [
      'total' => 888,
      'currency' => 'CNY',
    ],
    'payer' => [
      'sp_openid' => 'oUpF8uMuAJO_M2pxb1Q9zNjWeS6o',
      'sub_openid' => 'oUpF8uMuAJO_M2pxb1Q9zNjWeS6o',
    ],
    'detail' => [
      'cost_price' => 1,
      'invoice_id' => 'wx123',
      'goods_detail' => [[
        'merchant_goods_id' => '由半角的大小写字母、数字、中划线、下划线中的一种或几种组成',
        'wechatpay_goods_id' => '微信支付定义的统一商品编号(没有可不传)',
        'goods_name' => 'iPhone6s 16G',
        'quantity' => 1,
        'unit_price' => 528800,
      ],],
    ],
    'scene_info' => [
      'payer_client_ip' => '14.23.150.211',
      'device_id' => '013467007045764',
      'store_info' => [
        'id' => '0001',
        'out_id' => 'example_out_id',
      ],
    ],
    'settle_info' => [
      'profit_sharing' => true,
    ],
  ],
])
->then(static function(\Psr\Http\Message\ResponseInterface $response) {
  print_r(json_decode((string) $response->getBody(), true));
})
->wait();
php
$instance['v3/pay/partner/transactions/scannedpos']->postAsync([
  'json' => [
    'sp_appid' => 'wx8888888888888888',
    'sp_mchid' => '1230000109',
    'sub_appid' => 'wxd678efh567hg6999',
    'sub_mchid' => '1900000109',
    'description' => 'Image形象店-深圳腾大-QQ公仔',
    'out_trade_no' => '1217752501201407033233368018',
    'time_expire' => '2018-06-08T10:34:56+08:00',
    'attach' => '自定义数据',
    'notify_url' => 'https://www.weixin.qq.com/wxpay/pay.php',
    'goods_tag' => 'WXG',
    'support_fapiao' => true,
    'amount' => [
      'total' => 888,
      'currency' => 'CNY',
    ],
    'payer' => [
      'sp_openid' => 'oUpF8uMuAJO_M2pxb1Q9zNjWeS6o',
      'sub_openid' => 'oUpF8uMuAJO_M2pxb1Q9zNjWeS6o',
    ],
    'detail' => [
      'cost_price' => 1,
      'invoice_id' => 'wx123',
      'goods_detail' => [[
        'merchant_goods_id' => '由半角的大小写字母、数字、中划线、下划线中的一种或几种组成',
        'wechatpay_goods_id' => '微信支付定义的统一商品编号(没有可不传)',
        'goods_name' => 'iPhone6s 16G',
        'quantity' => 1,
        'unit_price' => 528800,
      ],],
    ],
    'scene_info' => [
      'payer_client_ip' => '14.23.150.211',
      'device_id' => '013467007045764',
      'store_info' => [
        'id' => '0001',
        'out_id' => 'example_out_id',
      ],
    ],
    'settle_info' => [
      'profit_sharing' => true,
    ],
  ],
])
->then(static function(\Psr\Http\Message\ResponseInterface $response) {
  print_r(json_decode((string) $response->getBody(), true));
})
->wait();
php
$response = $instance->v3->pay->partner->transactions->scannedpos->post([
  'json' => [
    'sp_appid' => 'wx8888888888888888',
    'sp_mchid' => '1230000109',
    'sub_appid' => 'wxd678efh567hg6999',
    'sub_mchid' => '1900000109',
    'description' => 'Image形象店-深圳腾大-QQ公仔',
    'out_trade_no' => '1217752501201407033233368018',
    'time_expire' => '2018-06-08T10:34:56+08:00',
    'attach' => '自定义数据',
    'notify_url' => 'https://www.weixin.qq.com/wxpay/pay.php',
    'goods_tag' => 'WXG',
    'support_fapiao' => true,
    'amount' => [
      'total' => 888,
      'currency' => 'CNY',
    ],
    'payer' => [
      'sp_openid' => 'oUpF8uMuAJO_M2pxb1Q9zNjWeS6o',
      'sub_openid' => 'oUpF8uMuAJO_M2pxb1Q9zNjWeS6o',
    ],
    'detail' => [
      'cost_price' => 1,
      'invoice_id' => 'wx123',
      'goods_detail' => [[
        'merchant_goods_id' => '由半角的大小写字母、数字、中划线、下划线中的一种或几种组成',
        'wechatpay_goods_id' => '微信支付定义的统一商品编号(没有可不传)',
        'goods_name' => 'iPhone6s 16G',
        'quantity' => 1,
        'unit_price' => 528800,
      ],],
    ],
    'scene_info' => [
      'payer_client_ip' => '14.23.150.211',
      'device_id' => '013467007045764',
      'store_info' => [
        'id' => '0001',
        'out_id' => 'example_out_id',
      ],
    ],
    'settle_info' => [
      'profit_sharing' => true,
    ],
  ],
]);
print_r(json_decode((string) $response->getBody(), true));
php
$response = $instance->chain('v3/pay/partner/transactions/scannedpos')->post([
  'json' => [
    'sp_appid' => 'wx8888888888888888',
    'sp_mchid' => '1230000109',
    'sub_appid' => 'wxd678efh567hg6999',
    'sub_mchid' => '1900000109',
    'description' => 'Image形象店-深圳腾大-QQ公仔',
    'out_trade_no' => '1217752501201407033233368018',
    'time_expire' => '2018-06-08T10:34:56+08:00',
    'attach' => '自定义数据',
    'notify_url' => 'https://www.weixin.qq.com/wxpay/pay.php',
    'goods_tag' => 'WXG',
    'support_fapiao' => true,
    'amount' => [
      'total' => 888,
      'currency' => 'CNY',
    ],
    'payer' => [
      'sp_openid' => 'oUpF8uMuAJO_M2pxb1Q9zNjWeS6o',
      'sub_openid' => 'oUpF8uMuAJO_M2pxb1Q9zNjWeS6o',
    ],
    'detail' => [
      'cost_price' => 1,
      'invoice_id' => 'wx123',
      'goods_detail' => [[
        'merchant_goods_id' => '由半角的大小写字母、数字、中划线、下划线中的一种或几种组成',
        'wechatpay_goods_id' => '微信支付定义的统一商品编号(没有可不传)',
        'goods_name' => 'iPhone6s 16G',
        'quantity' => 1,
        'unit_price' => 528800,
      ],],
    ],
    'scene_info' => [
      'payer_client_ip' => '14.23.150.211',
      'device_id' => '013467007045764',
      'store_info' => [
        'id' => '0001',
        'out_id' => 'example_out_id',
      ],
    ],
    'settle_info' => [
      'profit_sharing' => true,
    ],
  ],
]);
print_r(json_decode((string) $response->getBody(), true));
php
$response = $instance['v3/pay/partner/transactions/scannedpos']->post([
  'json' => [
    'sp_appid' => 'wx8888888888888888',
    'sp_mchid' => '1230000109',
    'sub_appid' => 'wxd678efh567hg6999',
    'sub_mchid' => '1900000109',
    'description' => 'Image形象店-深圳腾大-QQ公仔',
    'out_trade_no' => '1217752501201407033233368018',
    'time_expire' => '2018-06-08T10:34:56+08:00',
    'attach' => '自定义数据',
    'notify_url' => 'https://www.weixin.qq.com/wxpay/pay.php',
    'goods_tag' => 'WXG',
    'support_fapiao' => true,
    'amount' => [
      'total' => 888,
      'currency' => 'CNY',
    ],
    'payer' => [
      'sp_openid' => 'oUpF8uMuAJO_M2pxb1Q9zNjWeS6o',
      'sub_openid' => 'oUpF8uMuAJO_M2pxb1Q9zNjWeS6o',
    ],
    'detail' => [
      'cost_price' => 1,
      'invoice_id' => 'wx123',
      'goods_detail' => [[
        'merchant_goods_id' => '由半角的大小写字母、数字、中划线、下划线中的一种或几种组成',
        'wechatpay_goods_id' => '微信支付定义的统一商品编号(没有可不传)',
        'goods_name' => 'iPhone6s 16G',
        'quantity' => 1,
        'unit_price' => 528800,
      ],],
    ],
    'scene_info' => [
      'payer_client_ip' => '14.23.150.211',
      'device_id' => '013467007045764',
      'store_info' => [
        'id' => '0001',
        'out_id' => 'example_out_id',
      ],
    ],
    'settle_info' => [
      'profit_sharing' => true,
    ],
  ],
]);
print_r(json_decode((string) $response->getBody(), true));
返回字典类型描述
prepay_idstring预支付交易会话标识

参阅 官方文档

Published on the GitHub by TheNorthMemory