Skip to content

发放普通红包

现金红包发放后会以公众号消息的形式触达用户,不同情况下触达消息的形式会有差别,相关规则如下:1.已关注公众号的用户,使用“防伪消息”触达;2.未关注公众号的用户,使用“模板消息”触达。

请求参数类型描述
xmlobject声明请求的XML数据结构
mch_billnostring商户订单号
mch_idstring商户号
wxappidstring公众账号appid
send_namestring商户名称
re_openidstring用户openid
total_amountinteger付款金额
total_numinteger红包发放总人数
wishingstring红包祝福语
client_ipstringIp地址
act_namestring活动名称
remarkstring备注
scene_idstring场景id
risk_infostring活动信息
securityboolean声明加载商户API证书
固定值true
php
$instance->v2->mmpaymkttransfers->sendredpack->postAsync([
  'xml' => [
    'mch_billno' => '10000098201411111234567890',
    'mch_id' => '10000098',
    'wxappid' => 'wx8888888888888888',
    'send_name' => '天虹百货',
    're_openid' => 'oxTWIuGaIt6gTKsQRLau2M0yL16E',
    'total_amount' => '1000',
    'total_num' => '1',
    'wishing' => '感谢您参加猜灯谜活动,祝您元宵节快乐!',
    'client_ip' => '192.168.0.1',
    'act_name' => '猜灯谜抢红包活动',
    'remark' => '猜越多得越多,快来抢!',
    'scene_id' => 'PRODUCT_8',
    'risk_info' => 'posttime%3d123123412%26clientversion%3d234134%26mobile%3d122344545%26deviceid%3dIOS',
  ],
  'security' => true,
])
->then(static function(\Psr\Http\Message\ResponseInterface $response) {
  print_r(\WeChatPay\Transformer::toArray((string) $response->getBody()));
})
->wait();
php
$instance->chain('v2/mmpaymkttransfers/sendredpack')->postAsync([
  'xml' => [
    'mch_billno' => '10000098201411111234567890',
    'mch_id' => '10000098',
    'wxappid' => 'wx8888888888888888',
    'send_name' => '天虹百货',
    're_openid' => 'oxTWIuGaIt6gTKsQRLau2M0yL16E',
    'total_amount' => '1000',
    'total_num' => '1',
    'wishing' => '感谢您参加猜灯谜活动,祝您元宵节快乐!',
    'client_ip' => '192.168.0.1',
    'act_name' => '猜灯谜抢红包活动',
    'remark' => '猜越多得越多,快来抢!',
    'scene_id' => 'PRODUCT_8',
    'risk_info' => 'posttime%3d123123412%26clientversion%3d234134%26mobile%3d122344545%26deviceid%3dIOS',
  ],
  'security' => true,
])
->then(static function(\Psr\Http\Message\ResponseInterface $response) {
  print_r(\WeChatPay\Transformer::toArray((string) $response->getBody()));
})
->wait();
php
$instance['v2/mmpaymkttransfers/sendredpack']->postAsync([
  'xml' => [
    'mch_billno' => '10000098201411111234567890',
    'mch_id' => '10000098',
    'wxappid' => 'wx8888888888888888',
    'send_name' => '天虹百货',
    're_openid' => 'oxTWIuGaIt6gTKsQRLau2M0yL16E',
    'total_amount' => '1000',
    'total_num' => '1',
    'wishing' => '感谢您参加猜灯谜活动,祝您元宵节快乐!',
    'client_ip' => '192.168.0.1',
    'act_name' => '猜灯谜抢红包活动',
    'remark' => '猜越多得越多,快来抢!',
    'scene_id' => 'PRODUCT_8',
    'risk_info' => 'posttime%3d123123412%26clientversion%3d234134%26mobile%3d122344545%26deviceid%3dIOS',
  ],
  'security' => true,
])
->then(static function(\Psr\Http\Message\ResponseInterface $response) {
  print_r(\WeChatPay\Transformer::toArray((string) $response->getBody()));
})
->wait();
php
$response = $instance->v2->mmpaymkttransfers->sendredpack->post([
  'xml' => [
    'mch_billno' => '10000098201411111234567890',
    'mch_id' => '10000098',
    'wxappid' => 'wx8888888888888888',
    'send_name' => '天虹百货',
    're_openid' => 'oxTWIuGaIt6gTKsQRLau2M0yL16E',
    'total_amount' => '1000',
    'total_num' => '1',
    'wishing' => '感谢您参加猜灯谜活动,祝您元宵节快乐!',
    'client_ip' => '192.168.0.1',
    'act_name' => '猜灯谜抢红包活动',
    'remark' => '猜越多得越多,快来抢!',
    'scene_id' => 'PRODUCT_8',
    'risk_info' => 'posttime%3d123123412%26clientversion%3d234134%26mobile%3d122344545%26deviceid%3dIOS',
  ],
  'security' => true,
]);
print_r(\WeChatPay\Transformer::toArray((string) $response->getBody()));
php
$response = $instance->chain('v2/mmpaymkttransfers/sendredpack')->post([
  'xml' => [
    'mch_billno' => '10000098201411111234567890',
    'mch_id' => '10000098',
    'wxappid' => 'wx8888888888888888',
    'send_name' => '天虹百货',
    're_openid' => 'oxTWIuGaIt6gTKsQRLau2M0yL16E',
    'total_amount' => '1000',
    'total_num' => '1',
    'wishing' => '感谢您参加猜灯谜活动,祝您元宵节快乐!',
    'client_ip' => '192.168.0.1',
    'act_name' => '猜灯谜抢红包活动',
    'remark' => '猜越多得越多,快来抢!',
    'scene_id' => 'PRODUCT_8',
    'risk_info' => 'posttime%3d123123412%26clientversion%3d234134%26mobile%3d122344545%26deviceid%3dIOS',
  ],
  'security' => true,
]);
print_r(\WeChatPay\Transformer::toArray((string) $response->getBody()));
php
$response = $instance['v2/mmpaymkttransfers/sendredpack']->post([
  'xml' => [
    'mch_billno' => '10000098201411111234567890',
    'mch_id' => '10000098',
    'wxappid' => 'wx8888888888888888',
    'send_name' => '天虹百货',
    're_openid' => 'oxTWIuGaIt6gTKsQRLau2M0yL16E',
    'total_amount' => '1000',
    'total_num' => '1',
    'wishing' => '感谢您参加猜灯谜活动,祝您元宵节快乐!',
    'client_ip' => '192.168.0.1',
    'act_name' => '猜灯谜抢红包活动',
    'remark' => '猜越多得越多,快来抢!',
    'scene_id' => 'PRODUCT_8',
    'risk_info' => 'posttime%3d123123412%26clientversion%3d234134%26mobile%3d122344545%26deviceid%3dIOS',
  ],
  'security' => true,
]);
print_r(\WeChatPay\Transformer::toArray((string) $response->getBody()));
返回字典类型描述
return_codestring返回状态码
return_msgstring返回信息
result_codestring业务结果
err_codestring错误代码
err_code_desstring错误代码描述
mch_billnostring商户订单号
mch_idstring商户号
wxappidstring公众账号appid
re_openidstring用户openid
total_amountinteger付款金额
send_listidstring微信单号

参阅 官方文档

Published on the GitHub by TheNorthMemory