Skip to content

申请扣款

委托代扣可应用于定期扣款或需事后扣款以期提高效率的场景。例如但不限于,会员制缴费、水电煤缴费、黄钻绿钻增值服务、打车类软件、停车场或高速公路无人缴费、理财通基金定投、信用卡还款等通过用户授权给商户,进行委托扣款的场景。

请求参数类型描述
xmlobject声明请求的XML数据结构
sub_appidstring子商户公众账号ID
sub_mch_idstring子商户号
appidstring请求appid
mch_idstring商户号
bodystring商品描述
detailstring商品详情
attachstring附加数据
out_trade_nostring商户订单号
total_feeinteger总金额
fee_typestring货币类型
spbill_create_ipstring终端IP
goods_tagstring商品标记
notify_urlstring回调通知url
trade_typestring交易类型
contract_idstring委托代扣协议id
receiptstring电子发票入口开放标识
php
$instance->v2->pay->partner->pappayapply->postAsync([
  'xml' => [
    'sub_appid'        => '',
    'sub_mch_id'       => '',
    '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/partner/pappayapply')->postAsync([
  'xml' => [
    'sub_appid'        => '',
    'sub_mch_id'       => '',
    '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/partner/pappayapply']->postAsync([
  'xml' => [
    'sub_appid'        => '',
    'sub_mch_id'       => '',
    '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->partner->pappayapply->post([
  'xml' => [
    'sub_appid'        => '',
    'sub_mch_id'       => '',
    '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/partner/pappayapply')->post([
  'xml' => [
    'sub_appid'        => '',
    'sub_mch_id'       => '',
    '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/partner/pappayapply']->post([
  'xml' => [
    'sub_appid'        => '',
    'sub_mch_id'       => '',
    '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()));
返回字典类型描述
sub_appidstring子商户公众账号ID
sub_mch_idstring子商户号
return_codestring返回状态码
SUCCESS | FAIL 枚举值之一
return_msgstring返回信息
appidstring公众账号id
mch_idstring商户号
nonce_strstring随机字符串
signstring签名
result_codestring业务结果
SUCCESS | FAIL 枚举值之一
err_codestring错误代码
err_code_desstring错误代码描述

参阅 官方文档

Published on the GitHub by TheNorthMemory