Skip to content

发放代金券

用于商户主动调用接口给用户发放代金券的场景,已做防小号处理,给小号发放代金券将返回错误码。**注意:通过接口发放的代金券不会进入微信卡包**

🎃

本接口服务已于 2020年 (北京时间)处于流放状态,新接口见这里,此文档仅做留存参考。

请求参数类型描述
securitytrue声明加载商户API证书
xmlobject声明请求的XML数据结构
coupon_stock_idstring代金券批次id
openid_countintegeropenid记录数
partner_trade_nostring商户单据号
openidstring用户openid
appidstring公众账号ID
mch_idstring商户号
op_user_idstring操作员
device_infostring设备号
versionstring协议版本
1.0 枚举值
typestring协议类型
XML 枚举值
php
$instance->v2->mmpaymkttransfers->send_coupon->postAsync([
  'security' => true,
  'xml' => [
    'coupon_stock_id'  => '1757',
    'openid_count'     => '1',
    'partner_trade_no' => '1000009820141203515766',
    'openid'           => 'onqOjjrXT-776SpHnfexGm1_P7iE',
    'appid'            => 'wx5edab3bdfba3dc1c',
    'mch_id'           => '10000098',
    'op_user_id'       => '10000098',
    'device_info'      => '',
    'version'          => '1.0',
    'type'             => 'XML',
  ],
])
->then(static function(\Psr\Http\Message\ResponseInterface $response) {
  print_r(\WeChatPay\Transformer::toArray((string) $response->getBody()));
})
->wait();
php
$instance->chain('v2/mmpaymkttransfers/send_coupon')->postAsync([
  'security' => true,
  'xml' => [
    'coupon_stock_id'  => '1757',
    'openid_count'     => '1',
    'partner_trade_no' => '1000009820141203515766',
    'openid'           => 'onqOjjrXT-776SpHnfexGm1_P7iE',
    'appid'            => 'wx5edab3bdfba3dc1c',
    'mch_id'           => '10000098',
    'op_user_id'       => '10000098',
    'device_info'      => '',
    'version'          => '1.0',
    'type'             => 'XML',
  ],
])
->then(static function(\Psr\Http\Message\ResponseInterface $response) {
  print_r(\WeChatPay\Transformer::toArray((string) $response->getBody()));
})
->wait();
php
$instance['v2/mmpaymkttransfers/send_coupon']->postAsync([
  'security' => true,
  'xml' => [
    'coupon_stock_id'  => '1757',
    'openid_count'     => '1',
    'partner_trade_no' => '1000009820141203515766',
    'openid'           => 'onqOjjrXT-776SpHnfexGm1_P7iE',
    'appid'            => 'wx5edab3bdfba3dc1c',
    'mch_id'           => '10000098',
    'op_user_id'       => '10000098',
    'device_info'      => '',
    'version'          => '1.0',
    'type'             => 'XML',
  ],
])
->then(static function(\Psr\Http\Message\ResponseInterface $response) {
  print_r(\WeChatPay\Transformer::toArray((string) $response->getBody()));
})
->wait();
php
$response = $instance->v2->mmpaymkttransfers->send_coupon->post([
  'security' => true,
  'xml' => [
    'coupon_stock_id'  => '1757',
    'openid_count'     => '1',
    'partner_trade_no' => '1000009820141203515766',
    'openid'           => 'onqOjjrXT-776SpHnfexGm1_P7iE',
    'appid'            => 'wx5edab3bdfba3dc1c',
    'mch_id'           => '10000098',
    'op_user_id'       => '10000098',
    'device_info'      => '',
    'version'          => '1.0',
    'type'             => 'XML',
  ],
]);
print_r(\WeChatPay\Transformer::toArray((string) $response->getBody()));
php
$response = $instance->chain('v2/mmpaymkttransfers/send_coupon')->post([
  'security' => true,
  'xml' => [
    'coupon_stock_id'  => '1757',
    'openid_count'     => '1',
    'partner_trade_no' => '1000009820141203515766',
    'openid'           => 'onqOjjrXT-776SpHnfexGm1_P7iE',
    'appid'            => 'wx5edab3bdfba3dc1c',
    'mch_id'           => '10000098',
    'op_user_id'       => '10000098',
    'device_info'      => '',
    'version'          => '1.0',
    'type'             => 'XML',
  ],
]);
print_r(\WeChatPay\Transformer::toArray((string) $response->getBody()));
php
$response = $instance['v2/mmpaymkttransfers/send_coupon']->post([
  'security' => true,
  'xml' => [
    'coupon_stock_id'  => '1757',
    'openid_count'     => '1',
    'partner_trade_no' => '1000009820141203515766',
    'openid'           => 'onqOjjrXT-776SpHnfexGm1_P7iE',
    'appid'            => 'wx5edab3bdfba3dc1c',
    'mch_id'           => '10000098',
    'op_user_id'       => '10000098',
    'device_info'      => '',
    'version'          => '1.0',
    'type'             => 'XML',
  ],
]);
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错误代码描述
coupon_stock_idstring代金券批次id
resp_countinteger返回记录数
success_countinteger成功记录数
failed_countinteger失败记录数
openidstring用户标识
ret_codestring返回码
coupon_idstring代金券id
ret_msgstring返回信息

参阅 官方文档

Published on the GitHub by TheNorthMemory