申请扣款
委托代扣可应用于定期扣款或需事后扣款以期提高效率的场景。例如公交,地铁等通过用户授权给商户,进行委托扣款的场景。注:扣费请求首先按签约协议中记录的优先支付方式扣费,否则从可用扣款方式中依次选择扣款。
| 请求参数 | 类型 | 描述 |
|---|---|---|
| xml | object | 声明请求的XML数据结构 |
| appid | string | 公众账号id |
| sub_appid | string | 子商户公众账号id |
| mch_id | string | 商户号 |
| sub_mch_id | string | 子商户号 |
| sign_type | string | 签名类型HMAC-SHA256 枚举值 |
| body | string | 商品描述 |
| detail | string | 商品详情 |
| attach | string | 附加数据 |
| out_trade_no | string | 商户订单号 |
| total_fee | integer | 总金额 |
| fee_type | string | 货币类型 |
| spbill_create_ip | string | 终端IP |
| goods_tag | string | 商品标记 |
| notify_url | string | 回调通知url |
| trade_type | string | 交易类型PAP 枚举值 |
| contract_id | string | 委托代扣协议id |
| trade_scene | string | 交易场景METRO | BUS 枚举值之一 |
| scene_info | string | 场景信息JSON格式字符串 |
| scene_info | object | 场景METRO信息 |
| start_time | string | 乘车时间 |
| end_time | string | 结束时间 |
| qrcode_hash | string | 乘车码SHA256 |
| start_station | string | 起始站 |
| end_station | string | 终点站 |
| scene_info | object | 场景BUS信息 |
| start_time | string | 乘车时间 |
| line_name | string | 乘车路线 |
| qrcode_hash | string | 乘车码SHA256 |
| plate_number | string | 车牌号 |
| clientip | string | 客户端 IP |
| deviceid | string | 设备ID |
| mobile | string | 手机号 |
| string | 邮箱地址 | |
| string | QQ号 | |
| openid | string | 微信openID |
| creid | string | 身份证号 |
| outerid | string | 商户侧用户标识 |
| version | string | 版本号 此字段仅针对有垫资权限的商户有效。2.0 枚举值 |
php
$instance->v2->transit->partnerpay->payapply->postAsync([
'xml' => [
'appid' => 'wxcbda96de0b165486',
'sub_appid' => 'wxcbda96de0b165489',
'mch_id' => '10000098',
'sub_mch_id' => '1900000109',
'sign_type' => 'HMAC-SHA256',
'body' => '公交代扣',
'detail' => '公交代扣:A 公交代扣:B 公交代扣:C',
'attach' => '自定义参数',
'out_trade_no' => '1217752501201407033233368018',
'total_fee' => '888',
'fee_type' => 'CNY',
'spbill_create_ip' => '8.8.8.8',
'goods_tag' => 'WXG',
'notify_url' => 'http://yoursite.com/wxpay.html',
'trade_type' => 'PAP',
'contract_id' => 'Wx15463511252015071056489715',
'trade_scene' => 'METRO',
'scene_info' => \json_encode([
'scene_info' => [
'start_time' => '20170826104339',
'end_time' => '20170826114339',
'qrcode_hash' => 'a756836e7432437d98bbf07bdde2942c99f6a2ab88a72b60aa747fce54b093c6',
'start_station' => '西单',
'end_station' => '天安门西',
],
]),
'clientip' => '119.145.83.6',
'deviceid' => 'baf04e6bbbd06f7b1a197d18ed53b7f1',
'mobile' => '18933432355',
'email' => 'aobama@whitehouse.com',
'qq' => '100243',
'openid' => 'baf04e6bbbd06f7b1a197d18ed53b7f1',
'creid' => '110102199701011000',
'outerid' => 'user123',
'version' => '2.0',
],
])
->then(static function(\Psr\Http\Message\ResponseInterface $response) {
print_r(\WeChatPay\Transformer::toArray((string) $response->getBody()));
})
->wait();php
$instance->chain('v2/transit/partnerpay/payapply')->postAsync([
'xml' => [
'appid' => 'wxcbda96de0b165486',
'sub_appid' => 'wxcbda96de0b165489',
'mch_id' => '10000098',
'sub_mch_id' => '1900000109',
'sign_type' => 'HMAC-SHA256',
'body' => '公交代扣',
'detail' => '公交代扣:A 公交代扣:B 公交代扣:C',
'attach' => '自定义参数',
'out_trade_no' => '1217752501201407033233368018',
'total_fee' => '888',
'fee_type' => 'CNY',
'spbill_create_ip' => '8.8.8.8',
'goods_tag' => 'WXG',
'notify_url' => 'http://yoursite.com/wxpay.html',
'trade_type' => 'PAP',
'contract_id' => 'Wx15463511252015071056489715',
'trade_scene' => 'METRO',
'scene_info' => \json_encode([
'scene_info' => [
'start_time' => '20170826104339',
'end_time' => '20170826114339',
'qrcode_hash' => 'a756836e7432437d98bbf07bdde2942c99f6a2ab88a72b60aa747fce54b093c6',
'start_station' => '西单',
'end_station' => '天安门西',
],
]),
'clientip' => '119.145.83.6',
'deviceid' => 'baf04e6bbbd06f7b1a197d18ed53b7f1',
'mobile' => '18933432355',
'email' => 'aobama@whitehouse.com',
'qq' => '100243',
'openid' => 'baf04e6bbbd06f7b1a197d18ed53b7f1',
'creid' => '110102199701011000',
'outerid' => 'user123',
'version' => '2.0',
],
])
->then(static function(\Psr\Http\Message\ResponseInterface $response) {
print_r(\WeChatPay\Transformer::toArray((string) $response->getBody()));
})
->wait();php
$instance['v2/transit/partnerpay/payapply']->postAsync([
'xml' => [
'appid' => 'wxcbda96de0b165486',
'sub_appid' => 'wxcbda96de0b165489',
'mch_id' => '10000098',
'sub_mch_id' => '1900000109',
'sign_type' => 'HMAC-SHA256',
'body' => '公交代扣',
'detail' => '公交代扣:A 公交代扣:B 公交代扣:C',
'attach' => '自定义参数',
'out_trade_no' => '1217752501201407033233368018',
'total_fee' => '888',
'fee_type' => 'CNY',
'spbill_create_ip' => '8.8.8.8',
'goods_tag' => 'WXG',
'notify_url' => 'http://yoursite.com/wxpay.html',
'trade_type' => 'PAP',
'contract_id' => 'Wx15463511252015071056489715',
'trade_scene' => 'METRO',
'scene_info' => \json_encode([
'scene_info' => [
'start_time' => '20170826104339',
'end_time' => '20170826114339',
'qrcode_hash' => 'a756836e7432437d98bbf07bdde2942c99f6a2ab88a72b60aa747fce54b093c6',
'start_station' => '西单',
'end_station' => '天安门西',
],
]),
'clientip' => '119.145.83.6',
'deviceid' => 'baf04e6bbbd06f7b1a197d18ed53b7f1',
'mobile' => '18933432355',
'email' => 'aobama@whitehouse.com',
'qq' => '100243',
'openid' => 'baf04e6bbbd06f7b1a197d18ed53b7f1',
'creid' => '110102199701011000',
'outerid' => 'user123',
'version' => '2.0',
],
])
->then(static function(\Psr\Http\Message\ResponseInterface $response) {
print_r(\WeChatPay\Transformer::toArray((string) $response->getBody()));
})
->wait();php
$response = $instance->v2->transit->partnerpay->payapply->post([
'xml' => [
'appid' => 'wxcbda96de0b165486',
'sub_appid' => 'wxcbda96de0b165489',
'mch_id' => '10000098',
'sub_mch_id' => '1900000109',
'sign_type' => 'HMAC-SHA256',
'body' => '公交代扣',
'detail' => '公交代扣:A 公交代扣:B 公交代扣:C',
'attach' => '自定义参数',
'out_trade_no' => '1217752501201407033233368018',
'total_fee' => '888',
'fee_type' => 'CNY',
'spbill_create_ip' => '8.8.8.8',
'goods_tag' => 'WXG',
'notify_url' => 'http://yoursite.com/wxpay.html',
'trade_type' => 'PAP',
'contract_id' => 'Wx15463511252015071056489715',
'trade_scene' => 'METRO',
'scene_info' => \json_encode([
'scene_info' => [
'start_time' => '20170826104339',
'end_time' => '20170826114339',
'qrcode_hash' => 'a756836e7432437d98bbf07bdde2942c99f6a2ab88a72b60aa747fce54b093c6',
'start_station' => '西单',
'end_station' => '天安门西',
],
]),
'clientip' => '119.145.83.6',
'deviceid' => 'baf04e6bbbd06f7b1a197d18ed53b7f1',
'mobile' => '18933432355',
'email' => 'aobama@whitehouse.com',
'qq' => '100243',
'openid' => 'baf04e6bbbd06f7b1a197d18ed53b7f1',
'creid' => '110102199701011000',
'outerid' => 'user123',
'version' => '2.0',
],
]);
print_r(\WeChatPay\Transformer::toArray((string) $response->getBody()));php
$response = $instance->chain('v2/transit/partnerpay/payapply')->post([
'xml' => [
'appid' => 'wxcbda96de0b165486',
'sub_appid' => 'wxcbda96de0b165489',
'mch_id' => '10000098',
'sub_mch_id' => '1900000109',
'sign_type' => 'HMAC-SHA256',
'body' => '公交代扣',
'detail' => '公交代扣:A 公交代扣:B 公交代扣:C',
'attach' => '自定义参数',
'out_trade_no' => '1217752501201407033233368018',
'total_fee' => '888',
'fee_type' => 'CNY',
'spbill_create_ip' => '8.8.8.8',
'goods_tag' => 'WXG',
'notify_url' => 'http://yoursite.com/wxpay.html',
'trade_type' => 'PAP',
'contract_id' => 'Wx15463511252015071056489715',
'trade_scene' => 'METRO',
'scene_info' => \json_encode([
'scene_info' => [
'start_time' => '20170826104339',
'end_time' => '20170826114339',
'qrcode_hash' => 'a756836e7432437d98bbf07bdde2942c99f6a2ab88a72b60aa747fce54b093c6',
'start_station' => '西单',
'end_station' => '天安门西',
],
]),
'clientip' => '119.145.83.6',
'deviceid' => 'baf04e6bbbd06f7b1a197d18ed53b7f1',
'mobile' => '18933432355',
'email' => 'aobama@whitehouse.com',
'qq' => '100243',
'openid' => 'baf04e6bbbd06f7b1a197d18ed53b7f1',
'creid' => '110102199701011000',
'outerid' => 'user123',
'version' => '2.0',
],
]);
print_r(\WeChatPay\Transformer::toArray((string) $response->getBody()));php
$response = $instance['v2/transit/partnerpay/payapply']->post([
'xml' => [
'appid' => 'wxcbda96de0b165486',
'sub_appid' => 'wxcbda96de0b165489',
'mch_id' => '10000098',
'sub_mch_id' => '1900000109',
'sign_type' => 'HMAC-SHA256',
'body' => '公交代扣',
'detail' => '公交代扣:A 公交代扣:B 公交代扣:C',
'attach' => '自定义参数',
'out_trade_no' => '1217752501201407033233368018',
'total_fee' => '888',
'fee_type' => 'CNY',
'spbill_create_ip' => '8.8.8.8',
'goods_tag' => 'WXG',
'notify_url' => 'http://yoursite.com/wxpay.html',
'trade_type' => 'PAP',
'contract_id' => 'Wx15463511252015071056489715',
'trade_scene' => 'METRO',
'scene_info' => \json_encode([
'scene_info' => [
'start_time' => '20170826104339',
'end_time' => '20170826114339',
'qrcode_hash' => 'a756836e7432437d98bbf07bdde2942c99f6a2ab88a72b60aa747fce54b093c6',
'start_station' => '西单',
'end_station' => '天安门西',
],
]),
'clientip' => '119.145.83.6',
'deviceid' => 'baf04e6bbbd06f7b1a197d18ed53b7f1',
'mobile' => '18933432355',
'email' => 'aobama@whitehouse.com',
'qq' => '100243',
'openid' => 'baf04e6bbbd06f7b1a197d18ed53b7f1',
'creid' => '110102199701011000',
'outerid' => 'user123',
'version' => '2.0',
],
]);
print_r(\WeChatPay\Transformer::toArray((string) $response->getBody()));| 返回字典 | 类型 | 描述 |
|---|---|---|
| return_code | string | 返回状态码SUCCESS | FAIL 枚举值之一 |
| return_msg | string | 返回信息 |
| appid | string | 公众账号id |
| sub_appid | string | 子商户公众账号id |
| mch_id | string | 商户号 |
| sub_mch_id | string | 子商户号 |
| device_info | string | 设备号 |
| nonce_str | string | 随机字符串 |
| sign | string | 签名 |
| result_code | string | 业务结果SUCCESS | FAIL 枚举值之一 |
| err_code | string | 错误代码 |
| err_code_des | string | 错误代码描述 |
参阅 官方文档