Skip to content

申请扣款

委托代扣可应用于定期扣款或需事后扣款以期提高效率的场景。例如公交,地铁等通过用户授权给商户,进行委托扣款的场景。注:扣费请求首先按签约协议中记录的优先支付方式扣费,否则从可用扣款方式中依次选择扣款。

请求参数类型描述
xmlobject声明请求的XML数据结构
appidstring公众账号id
mch_idstring商户号
sign_typestring签名类型
HMAC-SHA256 枚举值
bodystring商品描述
detailstring商品详情
attachstring附加数据
out_trade_nostring商户订单号
total_feeinteger总金额
fee_typestring货币类型
spbill_create_ipstring终端IP
goods_tagstring商品标记
notify_urlstring回调通知url
trade_typestring交易类型
PAP 枚举值
contract_idstring委托代扣协议id
trade_scenestring交易场景
METRO | BUS 枚举值之一
scene_infostring场景信息JSON格式字符串
scene_infoobject场景METRO信息
start_timestring乘车时间
end_timestring结束时间
qrcode_hashstring乘车码SHA256
start_stationstring起始站
end_stationstring终点站
scene_infoobject场景BUS信息
start_timestring乘车时间
line_namestring乘车路线
qrcode_hashstring乘车码SHA256
plate_numberstring车牌号
clientipstring客户端 IP
deviceidstring设备ID
mobilestring手机号
emailstring邮箱地址
qqstringQQ号
openidstring微信openID
creidstring身份证号
outeridstring商户侧用户标识
versionstring版本号 此字段仅针对有垫资权限的商户有效。
2.0 枚举值
php
$instance->v2->transit->pay->payapply->postAsync([
  'xml' => [
    'appid'            => 'wxcbda96de0b165486',
    'mch_id'           => '10000098',
    '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/pay/payapply')->postAsync([
  'xml' => [
    'appid'            => 'wxcbda96de0b165486',
    'mch_id'           => '10000098',
    '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/pay/payapply']->postAsync([
  'xml' => [
    'appid'            => 'wxcbda96de0b165486',
    'mch_id'           => '10000098',
    '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->pay->payapply->post([
  'xml' => [
    'appid'            => 'wxcbda96de0b165486',
    'mch_id'           => '10000098',
    '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/pay/payapply')->post([
  'xml' => [
    'appid'            => 'wxcbda96de0b165486',
    'mch_id'           => '10000098',
    '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/pay/payapply']->post([
  'xml' => [
    'appid'            => 'wxcbda96de0b165486',
    'mch_id'           => '10000098',
    '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_codestring返回状态码
SUCCESS | FAIL 枚举值之一
return_msgstring返回信息
appidstring公众账号id
mch_idstring商户号
device_infostring设备号
nonce_strstring随机字符串
signstring签名
result_codestring业务结果
SUCCESS | FAIL 枚举值之一
err_codestring错误代码
err_code_desstring错误代码描述

参阅 官方文档

Published on the GitHub by TheNorthMemory