申请扣款
委托代扣可应用于定期扣款或需事后扣款以期提高效率的场景。例如但不限于,会员制缴费、水电煤缴费、黄钻绿钻增值服务、打车类软件、停车场或高速公路无人缴费、理财通基金定投、信用卡还款等通过用户授权给商户,进行委托扣款的场景。
| 请求参数 | 类型 | 描述 |
|---|---|---|
| xml | object | 声明请求的XML数据结构 |
| appid | string | 请求appid |
| mch_id | string | 商户号 |
| 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 | 交易类型 |
| contract_id | string | 委托代扣协议id |
| receipt | string | 电子发票入口开放标识 |
php
$instance->v2->pay->pappayapply->postAsync([
'xml' => [
'appid' => 'wxcbda96de0b165486',
'mch_id' => '10000098',
'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',
'receipt' => 'Y',
],
])
->then(static function(\Psr\Http\Message\ResponseInterface $response) {
print_r(\WeChatPay\Transformer::toArray((string) $response->getBody()));
})
->wait();php
$instance->chain('v2/pay/pappayapply')->postAsync([
'xml' => [
'appid' => 'wxcbda96de0b165486',
'mch_id' => '10000098',
'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',
'receipt' => 'Y',
],
])
->then(static function(\Psr\Http\Message\ResponseInterface $response) {
print_r(\WeChatPay\Transformer::toArray((string) $response->getBody()));
})
->wait();php
$instance['v2/pay/pappayapply']->postAsync([
'xml' => [
'appid' => 'wxcbda96de0b165486',
'mch_id' => '10000098',
'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',
'receipt' => 'Y',
],
])
->then(static function(\Psr\Http\Message\ResponseInterface $response) {
print_r(\WeChatPay\Transformer::toArray((string) $response->getBody()));
})
->wait();php
$response = $instance->v2->pay->pappayapply->post([
'xml' => [
'appid' => 'wxcbda96de0b165486',
'mch_id' => '10000098',
'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',
'receipt' => 'Y',
],
]);
print_r(\WeChatPay\Transformer::toArray((string) $response->getBody()));php
$response = $instance->chain('v2/pay/pappayapply')->post([
'xml' => [
'appid' => 'wxcbda96de0b165486',
'mch_id' => '10000098',
'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',
'receipt' => 'Y',
],
]);
print_r(\WeChatPay\Transformer::toArray((string) $response->getBody()));php
$response = $instance['v2/pay/pappayapply']->post([
'xml' => [
'appid' => 'wxcbda96de0b165486',
'mch_id' => '10000098',
'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',
'receipt' => 'Y',
],
]);
print_r(\WeChatPay\Transformer::toArray((string) $response->getBody()));| 返回字典 | 类型 | 描述 |
|---|---|---|
| return_code | string | 返回状态码SUCCESS | FAIL 枚举值之一 |
| return_msg | string | 返回信息 |
| appid | string | 公众账号id |
| mch_id | string | 商户号 |
| nonce_str | string | 随机字符串 |
| sign | string | 签名 |
| result_code | string | 业务结果SUCCESS | FAIL 枚举值之一 |
| err_code | string | 错误代码 |
| err_code_des | string | 错误代码描述 |
参阅 官方文档