Skip to content

扣款

使用签约协议号发起扣款,本接口支持两种模式,通过参数模式(payment_mode)进行选择。 同步扣款模式会立即返回扣款结果,异步扣款模式会立即返回受理结果,最终的扣款结果会通过回调的方式通知给商户 两种模式下,若出现超时或未回调时,商户均可调用商户订单号查单接口查询订单扣款结果。

请求参数类型描述
jsonobject声明请求的JSON数据结构
appidstring商户appid
sub_mchidstring子商户号
sub_appidstring子商户appid
descriptionstring商品描述
attachstring商户数据
out_trade_nostring商户订单号
goods_tagstring订单优惠标记
notify_urlstring商户接收通知地址
contract_idstring签约协议号
user_idstring用户账号
amountobject订单金额
totalinteger总金额
currencystring货币类型
scene_infoobject场景信息
start_timestring消费时间
school_idstring学校编号
scene_typestring消费场景类型
device_infoobject设备信息
device_idstring设备号
device_ipstring商户端设备ip
settle_infoobject分账结算信息
profit_sharingboolean是否指定分账
payment_modestring扣款模式
php
$instance->v3->eduschoolpay->transactions->postAsync([
  'json' => [
    'appid'        => 'wx8888888888888888',
    'sub_mchid'    => '1900000109',
    'sub_appid'    => 'wx8888888888888888',
    'description'  => '中山大学-第二食堂-海鲜炒饭',
    'attach'       => '自定义数据',
    'out_trade_no' => '121775250124070332',
    'goods_tag'    => 'test',
    'notify_url'   => 'https://www.weixin.qq.com/wxpay/pay',
    'contract_id'  => '2045011120563805041758214605',
    'user_id'      => '20200330tony',
    'amount'       => [
      'total'    => 888,
      'currency' => 'CNY',
    ],
    'scene_info'   => [
      'start_time' => '2017-08-26T09:43:39+08:00',
      'school_id'  => '18260256813396',
      'scene_type' => 'CANTEEN',
    ],
    'device_info'  => [
      'device_id' => '12343232',
      'device_ip' => '123.12.12.123',
    ],
    'settle_info'  => [
      'profit_sharing' => true,
    ],
    'payment_mode' => 'SYNC',
  ],
])
->then(static function(\Psr\Http\Message\ResponseInterface $response) {
  print_r(json_decode((string) $response->getBody(), true));
})
->wait();
php
$instance->chain('v3/eduschoolpay/transactions')->postAsync([
  'json' => [
    'appid'        => 'wx8888888888888888',
    'sub_mchid'    => '1900000109',
    'sub_appid'    => 'wx8888888888888888',
    'description'  => '中山大学-第二食堂-海鲜炒饭',
    'attach'       => '自定义数据',
    'out_trade_no' => '121775250124070332',
    'goods_tag'    => 'test',
    'notify_url'   => 'https://www.weixin.qq.com/wxpay/pay',
    'contract_id'  => '2045011120563805041758214605',
    'user_id'      => '20200330tony',
    'amount'       => [
      'total'    => 888,
      'currency' => 'CNY',
    ],
    'scene_info'   => [
      'start_time' => '2017-08-26T09:43:39+08:00',
      'school_id'  => '18260256813396',
      'scene_type' => 'CANTEEN',
    ],
    'device_info'  => [
      'device_id' => '12343232',
      'device_ip' => '123.12.12.123',
    ],
    'settle_info'  => [
      'profit_sharing' => true,
    ],
    'payment_mode' => 'SYNC',
  ],
])
->then(static function(\Psr\Http\Message\ResponseInterface $response) {
  print_r(json_decode((string) $response->getBody(), true));
})
->wait();
php
$instance['v3/eduschoolpay/transactions']->postAsync([
  'json' => [
    'appid'        => 'wx8888888888888888',
    'sub_mchid'    => '1900000109',
    'sub_appid'    => 'wx8888888888888888',
    'description'  => '中山大学-第二食堂-海鲜炒饭',
    'attach'       => '自定义数据',
    'out_trade_no' => '121775250124070332',
    'goods_tag'    => 'test',
    'notify_url'   => 'https://www.weixin.qq.com/wxpay/pay',
    'contract_id'  => '2045011120563805041758214605',
    'user_id'      => '20200330tony',
    'amount'       => [
      'total'    => 888,
      'currency' => 'CNY',
    ],
    'scene_info'   => [
      'start_time' => '2017-08-26T09:43:39+08:00',
      'school_id'  => '18260256813396',
      'scene_type' => 'CANTEEN',
    ],
    'device_info'  => [
      'device_id' => '12343232',
      'device_ip' => '123.12.12.123',
    ],
    'settle_info'  => [
      'profit_sharing' => true,
    ],
    'payment_mode' => 'SYNC',
  ],
])
->then(static function(\Psr\Http\Message\ResponseInterface $response) {
  print_r(json_decode((string) $response->getBody(), true));
})
->wait();
php
$response = $instance->v3->eduschoolpay->transactions->post([
  'json' => [
    'appid'        => 'wx8888888888888888',
    'sub_mchid'    => '1900000109',
    'sub_appid'    => 'wx8888888888888888',
    'description'  => '中山大学-第二食堂-海鲜炒饭',
    'attach'       => '自定义数据',
    'out_trade_no' => '121775250124070332',
    'goods_tag'    => 'test',
    'notify_url'   => 'https://www.weixin.qq.com/wxpay/pay',
    'contract_id'  => '2045011120563805041758214605',
    'user_id'      => '20200330tony',
    'amount'       => [
      'total'    => 888,
      'currency' => 'CNY',
    ],
    'scene_info'   => [
      'start_time' => '2017-08-26T09:43:39+08:00',
      'school_id'  => '18260256813396',
      'scene_type' => 'CANTEEN',
    ],
    'device_info'  => [
      'device_id' => '12343232',
      'device_ip' => '123.12.12.123',
    ],
    'settle_info'  => [
      'profit_sharing' => true,
    ],
    'payment_mode' => 'SYNC',
  ],
]);
print_r(json_decode((string) $response->getBody(), true));
php
$response = $instance->chain('v3/eduschoolpay/transactions')->post([
  'json' => [
    'appid'        => 'wx8888888888888888',
    'sub_mchid'    => '1900000109',
    'sub_appid'    => 'wx8888888888888888',
    'description'  => '中山大学-第二食堂-海鲜炒饭',
    'attach'       => '自定义数据',
    'out_trade_no' => '121775250124070332',
    'goods_tag'    => 'test',
    'notify_url'   => 'https://www.weixin.qq.com/wxpay/pay',
    'contract_id'  => '2045011120563805041758214605',
    'user_id'      => '20200330tony',
    'amount'       => [
      'total'    => 888,
      'currency' => 'CNY',
    ],
    'scene_info'   => [
      'start_time' => '2017-08-26T09:43:39+08:00',
      'school_id'  => '18260256813396',
      'scene_type' => 'CANTEEN',
    ],
    'device_info'  => [
      'device_id' => '12343232',
      'device_ip' => '123.12.12.123',
    ],
    'settle_info'  => [
      'profit_sharing' => true,
    ],
    'payment_mode' => 'SYNC',
  ],
]);
print_r(json_decode((string) $response->getBody(), true));
php
$response = $instance['v3/eduschoolpay/transactions']->post([
  'json' => [
    'appid'        => 'wx8888888888888888',
    'sub_mchid'    => '1900000109',
    'sub_appid'    => 'wx8888888888888888',
    'description'  => '中山大学-第二食堂-海鲜炒饭',
    'attach'       => '自定义数据',
    'out_trade_no' => '121775250124070332',
    'goods_tag'    => 'test',
    'notify_url'   => 'https://www.weixin.qq.com/wxpay/pay',
    'contract_id'  => '2045011120563805041758214605',
    'user_id'      => '20200330tony',
    'amount'       => [
      'total'    => 888,
      'currency' => 'CNY',
    ],
    'scene_info'   => [
      'start_time' => '2017-08-26T09:43:39+08:00',
      'school_id'  => '18260256813396',
      'scene_type' => 'CANTEEN',
    ],
    'device_info'  => [
      'device_id' => '12343232',
      'device_ip' => '123.12.12.123',
    ],
    'settle_info'  => [
      'profit_sharing' => true,
    ],
    'payment_mode' => 'SYNC',
  ],
]);
print_r(json_decode((string) $response->getBody(), true));
返回字典类型描述
mchidstring商户号
appidstring商户AppID
sub_mchidstring子商户号
sub_appidstring子商户AppID
out_trade_nostring商户订单号
transaction_idstring微信支付订单号
trade_typestring交易类型
trade_statestring交易状态
trade_state_descstring交易状态描述
bank_typestring付款银行
attachstring商户数据
success_timestring支付完成时间
payerobject支付者
openidstring商户AppID下的用户标识
sub_openidstring子商户AppID下的用户标识
amountobject订单金额
totalnumber订单金额
payer_totalnumber用户支付金额
discount_totalnumber折扣
currencystring货币类型
device_infoobject设备信息
device_idstring设备号
device_ipstring商户端设备IP
promotion_detailobject[]优惠详情
coupon_idstring券ID
namestring优惠名称
scopestring优惠范围
typestring优惠类型
amountnumber优惠券面额
stock_idstring活动ID
wechatpay_contributenumber微信出资
merchant_contributenumber商户出资
other_contributenumber其他出资

参阅 官方文档

Published on the GitHub by TheNorthMemory