Skip to content

支付押金(JSAPI/APP支付)

微信支付提供了四种付款方式供用户支付押金:付款码支付、人脸支付、JSAPI支付、APP支付。商户可根据场景需要选择支持哪种付款方式,也可以四种都支持,即四种方式都对接。

请求参数类型描述
xmlobject声明请求的XML数据结构
appidstring服务商应用ID
mch_idstring商户号
sub_appidstring子商户应用ID
sub_mch_idstring子商户号
device_infostring设备号
sign_typestring签名类型
MD5 | HMAC-SHA256 枚举值之一
bodystring商品描述
detailstring单品优惠活动该字段必传,JSON格式字符串
cost_pricenumber订单原价
receipt_idstring商品小票ID
goods_detailobject[]单品列表
goods_idstring商品编码
wxpay_goods_idstring微信支付商品编码
goods_namestring商品名称
quantitynumber商品数量
pricenumber商品单价
attachstring附加数据
out_trade_nostring商户订单号
fee_typestring货币类型
total_feeinteger总金额
spbill_create_ipstring终端IP
time_startstring交易起始时间
time_expirestring交易结束时间
notify_urlstring通知地址
trade_typestring交易类型
JSAPI | APP 枚举值之一
product_idstring商品ID
limit_paystring指定支付方式
openidstring用户标识
sub_openidstring用户子标识
receiptstring电子发票入口开放标识
Y | N 枚举值之一
scene_infostring场景信息JSON格式字符串
store_infoobject实际门店信息
idstring门店id
namestring门店名称
area_codestring门店行政区划码
addressstring门店详细地址
php
$instance->v2->deposit->unifiedorder->postAsync([
  'xml' => [
    'appid'            => 'wx8888888888888888',
    'mch_id'           => '1900000109',
    'sub_appid'        => 'wx8888888888888888',
    'sub_mch_id'       => '1900000109',
    'device_info'      => '013467007045764',
    'sign_type'        => 'HMAC-SHA256',
    'body'             => '腾讯充值中心-QQ会员充值',
    'detail'           => '{"goods_detail":[]}',
    'attach'           => '说明',
    'out_trade_no'     => '1217752501201407033233368018',
    'fee_type'         => 'CNY',
    'total_fee'        => '888',
    'spbill_create_ip' => '123.12.12.123',
    'time_start'       => '20091225091010',
    'time_expire'      => '20091227091010',
    'notify_url'       => 'http://www.weixin.qq.com/wxpay/pay.php',
    'trade_type'       => 'JSAPI',
    'product_id'       => '12235413214070356458058',
    'limit_pay'        => 'no_credit',
    'openid'           => 'oUpF8uMuAJO_M2pxb1Q9zNjWeS6o',
    'sub_openid'       => 'oUpF8uMuAJO_M2pxb1Q9zNjWeS6o',
    'receipt'          => 'Y',
    'scene_info'       => '{"store_info":{"id":"SZTX001","name":"腾大餐厅","area_code":"440305","address":"科技园中一路腾讯大厦"}}',
  ],
])
->then(static function(\Psr\Http\Message\ResponseInterface $response) {
  print_r(\WeChatPay\Transformer::toArray((string) $response->getBody()));
})
->wait();
php
$instance->chain('v2/deposit/unifiedorder')->postAsync([
  'xml' => [
    'appid'            => 'wx8888888888888888',
    'mch_id'           => '1900000109',
    'sub_appid'        => 'wx8888888888888888',
    'sub_mch_id'       => '1900000109',
    'device_info'      => '013467007045764',
    'sign_type'        => 'HMAC-SHA256',
    'body'             => '腾讯充值中心-QQ会员充值',
    'detail'           => '{"goods_detail":[]}',
    'attach'           => '说明',
    'out_trade_no'     => '1217752501201407033233368018',
    'fee_type'         => 'CNY',
    'total_fee'        => '888',
    'spbill_create_ip' => '123.12.12.123',
    'time_start'       => '20091225091010',
    'time_expire'      => '20091227091010',
    'notify_url'       => 'http://www.weixin.qq.com/wxpay/pay.php',
    'trade_type'       => 'JSAPI',
    'product_id'       => '12235413214070356458058',
    'limit_pay'        => 'no_credit',
    'openid'           => 'oUpF8uMuAJO_M2pxb1Q9zNjWeS6o',
    'sub_openid'       => 'oUpF8uMuAJO_M2pxb1Q9zNjWeS6o',
    'receipt'          => 'Y',
    'scene_info'       => '{"store_info":{"id":"SZTX001","name":"腾大餐厅","area_code":"440305","address":"科技园中一路腾讯大厦"}}',
  ],
])
->then(static function(\Psr\Http\Message\ResponseInterface $response) {
  print_r(\WeChatPay\Transformer::toArray((string) $response->getBody()));
})
->wait();
php
$instance['v2/deposit/unifiedorder']->postAsync([
  'xml' => [
    'appid'            => 'wx8888888888888888',
    'mch_id'           => '1900000109',
    'sub_appid'        => 'wx8888888888888888',
    'sub_mch_id'       => '1900000109',
    'device_info'      => '013467007045764',
    'sign_type'        => 'HMAC-SHA256',
    'body'             => '腾讯充值中心-QQ会员充值',
    'detail'           => '{"goods_detail":[]}',
    'attach'           => '说明',
    'out_trade_no'     => '1217752501201407033233368018',
    'fee_type'         => 'CNY',
    'total_fee'        => '888',
    'spbill_create_ip' => '123.12.12.123',
    'time_start'       => '20091225091010',
    'time_expire'      => '20091227091010',
    'notify_url'       => 'http://www.weixin.qq.com/wxpay/pay.php',
    'trade_type'       => 'JSAPI',
    'product_id'       => '12235413214070356458058',
    'limit_pay'        => 'no_credit',
    'openid'           => 'oUpF8uMuAJO_M2pxb1Q9zNjWeS6o',
    'sub_openid'       => 'oUpF8uMuAJO_M2pxb1Q9zNjWeS6o',
    'receipt'          => 'Y',
    'scene_info'       => '{"store_info":{"id":"SZTX001","name":"腾大餐厅","area_code":"440305","address":"科技园中一路腾讯大厦"}}',
  ],
])
->then(static function(\Psr\Http\Message\ResponseInterface $response) {
  print_r(\WeChatPay\Transformer::toArray((string) $response->getBody()));
})
->wait();
php
$response = $instance->v2->deposit->unifiedorder->post([
  'xml' => [
    'appid'            => 'wx8888888888888888',
    'mch_id'           => '1900000109',
    'sub_appid'        => 'wx8888888888888888',
    'sub_mch_id'       => '1900000109',
    'device_info'      => '013467007045764',
    'sign_type'        => 'HMAC-SHA256',
    'body'             => '腾讯充值中心-QQ会员充值',
    'detail'           => '{"goods_detail":[]}',
    'attach'           => '说明',
    'out_trade_no'     => '1217752501201407033233368018',
    'fee_type'         => 'CNY',
    'total_fee'        => '888',
    'spbill_create_ip' => '123.12.12.123',
    'time_start'       => '20091225091010',
    'time_expire'      => '20091227091010',
    'notify_url'       => 'http://www.weixin.qq.com/wxpay/pay.php',
    'trade_type'       => 'JSAPI',
    'product_id'       => '12235413214070356458058',
    'limit_pay'        => 'no_credit',
    'openid'           => 'oUpF8uMuAJO_M2pxb1Q9zNjWeS6o',
    'sub_openid'       => 'oUpF8uMuAJO_M2pxb1Q9zNjWeS6o',
    'receipt'          => 'Y',
    'scene_info'       => '{"store_info":{"id":"SZTX001","name":"腾大餐厅","area_code":"440305","address":"科技园中一路腾讯大厦"}}',
  ],
]);
print_r(\WeChatPay\Transformer::toArray((string) $response->getBody()));
php
$response = $instance->chain('v2/deposit/unifiedorder')->post([
  'xml' => [
    'appid'            => 'wx8888888888888888',
    'mch_id'           => '1900000109',
    'sub_appid'        => 'wx8888888888888888',
    'sub_mch_id'       => '1900000109',
    'device_info'      => '013467007045764',
    'sign_type'        => 'HMAC-SHA256',
    'body'             => '腾讯充值中心-QQ会员充值',
    'detail'           => '{"goods_detail":[]}',
    'attach'           => '说明',
    'out_trade_no'     => '1217752501201407033233368018',
    'fee_type'         => 'CNY',
    'total_fee'        => '888',
    'spbill_create_ip' => '123.12.12.123',
    'time_start'       => '20091225091010',
    'time_expire'      => '20091227091010',
    'notify_url'       => 'http://www.weixin.qq.com/wxpay/pay.php',
    'trade_type'       => 'JSAPI',
    'product_id'       => '12235413214070356458058',
    'limit_pay'        => 'no_credit',
    'openid'           => 'oUpF8uMuAJO_M2pxb1Q9zNjWeS6o',
    'sub_openid'       => 'oUpF8uMuAJO_M2pxb1Q9zNjWeS6o',
    'receipt'          => 'Y',
    'scene_info'       => '{"store_info":{"id":"SZTX001","name":"腾大餐厅","area_code":"440305","address":"科技园中一路腾讯大厦"}}',
  ],
]);
print_r(\WeChatPay\Transformer::toArray((string) $response->getBody()));
php
$response = $instance['v2/deposit/unifiedorder']->post([
  'xml' => [
    'appid'            => 'wx8888888888888888',
    'mch_id'           => '1900000109',
    'sub_appid'        => 'wx8888888888888888',
    'sub_mch_id'       => '1900000109',
    'device_info'      => '013467007045764',
    'sign_type'        => 'HMAC-SHA256',
    'body'             => '腾讯充值中心-QQ会员充值',
    'detail'           => '{"goods_detail":[]}',
    'attach'           => '说明',
    'out_trade_no'     => '1217752501201407033233368018',
    'fee_type'         => 'CNY',
    'total_fee'        => '888',
    'spbill_create_ip' => '123.12.12.123',
    'time_start'       => '20091225091010',
    'time_expire'      => '20091227091010',
    'notify_url'       => 'http://www.weixin.qq.com/wxpay/pay.php',
    'trade_type'       => 'JSAPI',
    'product_id'       => '12235413214070356458058',
    'limit_pay'        => 'no_credit',
    'openid'           => 'oUpF8uMuAJO_M2pxb1Q9zNjWeS6o',
    'sub_openid'       => 'oUpF8uMuAJO_M2pxb1Q9zNjWeS6o',
    'receipt'          => 'Y',
    'scene_info'       => '{"store_info":{"id":"SZTX001","name":"腾大餐厅","area_code":"440305","address":"科技园中一路腾讯大厦"}}',
  ],
]);
print_r(\WeChatPay\Transformer::toArray((string) $response->getBody()));
返回字典类型描述
return_codestring返回状态码
SUCCESS | FAIL 枚举值之一
return_msgstring返回信息
appidstring服务商应用ID
mch_idstring商户号
sub_appidstring子商户应用ID
sub_mch_idstring子商户号
device_infostring设备号
nonce_strstring随机字符串
signstring签名
result_codestring业务结果
SUCCESS | FAIL 枚举值之一
err_codestring错误代码
err_code_desstring错误代码描述
trade_typestring交易类型
JSAPI | APP 枚举值之一
prepay_idstring预支付交易会话标识
code_urlstring二维码链接

参阅 官方文档 官方文档

Published on the GitHub by TheNorthMemory