Skip to content

发放代金券

商户平台/API完成制券后,可使用发放代金券接口发券。通过调用此接口可发放指定批次给指定用户,发券场景可以是小程序、H5、APP等。

请求参数类型描述
openidstring用户openid
jsonobject声明请求的JSON数据结构
stock_idstring批次号
out_request_nostring商户单据号
appidstring公众账号ID
stock_creator_mchidstring创建批次的商户号
coupon_valueinteger指定面额发券,面额
coupon_minimuminteger指定面额发券,券门槛
php
$instance->v3->marketing->favor->users->_openid_->coupons->postAsync([
  'openid' => '',
  'json' => [
    'stock_id' => '9856000',
    'out_request_no' => '89560002019101000121',
    'appid' => 'wx233544546545989',
    'stock_creator_mchid' => '8956000',
    'coupon_value' => 100,
    'coupon_minimum' => 100,
  ],
])
->then(static function(\Psr\Http\Message\ResponseInterface $response) {
  print_r(json_decode((string) $response->getBody(), true));
})
->wait();
php
$instance->chain('v3/marketing/favor/users/{openid}/coupons')->postAsync([
  'openid' => '',
  'json' => [
    'stock_id' => '9856000',
    'out_request_no' => '89560002019101000121',
    'appid' => 'wx233544546545989',
    'stock_creator_mchid' => '8956000',
    'coupon_value' => 100,
    'coupon_minimum' => 100,
  ],
])
->then(static function(\Psr\Http\Message\ResponseInterface $response) {
  print_r(json_decode((string) $response->getBody(), true));
})
->wait();
php
$instance['v3/marketing/favor/users/{openid}/coupons']->postAsync([
  'openid' => '',
  'json' => [
    'stock_id' => '9856000',
    'out_request_no' => '89560002019101000121',
    'appid' => 'wx233544546545989',
    'stock_creator_mchid' => '8956000',
    'coupon_value' => 100,
    'coupon_minimum' => 100,
  ],
])
->then(static function(\Psr\Http\Message\ResponseInterface $response) {
  print_r(json_decode((string) $response->getBody(), true));
})
->wait();
php
$response = $instance->v3->marketing->favor->users->_openid_->coupons->post([
  'openid' => '',
  'json' => [
    'stock_id' => '9856000',
    'out_request_no' => '89560002019101000121',
    'appid' => 'wx233544546545989',
    'stock_creator_mchid' => '8956000',
    'coupon_value' => 100,
    'coupon_minimum' => 100,
  ],
]);
print_r(json_decode((string) $response->getBody(), true));
php
$response = $instance->chain('v3/marketing/favor/users/{openid}/coupons')->post([
  'openid' => '',
  'json' => [
    'stock_id' => '9856000',
    'out_request_no' => '89560002019101000121',
    'appid' => 'wx233544546545989',
    'stock_creator_mchid' => '8956000',
    'coupon_value' => 100,
    'coupon_minimum' => 100,
  ],
]);
print_r(json_decode((string) $response->getBody(), true));
php
$response = $instance['v3/marketing/favor/users/{openid}/coupons']->post([
  'openid' => '',
  'json' => [
    'stock_id' => '9856000',
    'out_request_no' => '89560002019101000121',
    'appid' => 'wx233544546545989',
    'stock_creator_mchid' => '8956000',
    'coupon_value' => 100,
    'coupon_minimum' => 100,
  ],
]);
print_r(json_decode((string) $response->getBody(), true));
返回字典类型描述
coupon_idstring代金券id

参阅 官方文档 官方文档 官方文档

根据商户号查用户的券

可通过该接口查询用户在某商户号可用的全部券,可用于商户的小程序/H5中,用户"我的代金券"或"提交订单页"展示优惠信息。无法查询到微信支付立减金。本接口查不到用户的微信支付立减金(又称“全平台通用券”),即在所有商户都可以使用的券,例如:摇摇乐红包

请求参数类型描述
openidstring用户openid
queryobject声明请求的查询参数
appidstring公众账号ID
stock_idstring批次号
statusstring代金券状态
SENDED | USED | EXPIRED 枚举值之一
creator_mchidstring创建批次的商户号
sender_mchidstring批次发放商户号
available_mchidstring可用商户号
offsetinteger分页页码
limitinteger分页大小
business_typestring业务类型
MULTIUSE 枚举值
php
$instance->v3->marketing->favor->users->_openid_->coupons->getAsync([
  'openid' => '',
  'query' => [
    'appid' => '',
    'stock_id' => '',
    'status' => 'SENDED',
    'creator_mchid' => '',
    'sender_mchid' => '',
    'available_mchid' => '',
    'offset' => 0,
    'limit' => 20,
    'business_type' => 'MULTIUSE',
  ],
])
->then(static function(\Psr\Http\Message\ResponseInterface $response) {
  print_r(json_decode((string) $response->getBody(), true));
})
->wait();
php
$instance->chain('v3/marketing/favor/users/{openid}/coupons')->getAsync([
  'openid' => '',
  'query' => [
    'appid' => '',
    'stock_id' => '',
    'status' => 'SENDED',
    'creator_mchid' => '',
    'sender_mchid' => '',
    'available_mchid' => '',
    'offset' => 0,
    'limit' => 20,
    'business_type' => 'MULTIUSE',
  ],
])
->then(static function(\Psr\Http\Message\ResponseInterface $response) {
  print_r(json_decode((string) $response->getBody(), true));
})
->wait();
php
$instance['v3/marketing/favor/users/{openid}/coupons']->getAsync([
  'openid' => '',
  'query' => [
    'appid' => '',
    'stock_id' => '',
    'status' => 'SENDED',
    'creator_mchid' => '',
    'sender_mchid' => '',
    'available_mchid' => '',
    'offset' => 0,
    'limit' => 20,
    'business_type' => 'MULTIUSE',
  ],
])
->then(static function(\Psr\Http\Message\ResponseInterface $response) {
  print_r(json_decode((string) $response->getBody(), true));
})
->wait();
php
$response = $instance->v3->marketing->favor->users->_openid_->coupons->get([
  'openid' => '',
  'query' => [
    'appid' => '',
    'stock_id' => '',
    'status' => 'SENDED',
    'creator_mchid' => '',
    'sender_mchid' => '',
    'available_mchid' => '',
    'offset' => 0,
    'limit' => 20,
    'business_type' => 'MULTIUSE',
  ],
]);
print_r(json_decode((string) $response->getBody(), true));
php
$response = $instance->chain('v3/marketing/favor/users/{openid}/coupons')->get([
  'openid' => '',
  'query' => [
    'appid' => '',
    'stock_id' => '',
    'status' => 'SENDED',
    'creator_mchid' => '',
    'sender_mchid' => '',
    'available_mchid' => '',
    'offset' => 0,
    'limit' => 20,
    'business_type' => 'MULTIUSE',
  ],
]);
print_r(json_decode((string) $response->getBody(), true));
php
$response = $instance['v3/marketing/favor/users/{openid}/coupons']->get([
  'openid' => '',
  'query' => [
    'appid' => '',
    'stock_id' => '',
    'status' => 'SENDED',
    'creator_mchid' => '',
    'sender_mchid' => '',
    'available_mchid' => '',
    'offset' => 0,
    'limit' => 20,
    'business_type' => 'MULTIUSE',
  ],
]);
print_r(json_decode((string) $response->getBody(), true));
返回字典类型描述
total_countinteger总数量
offsetinteger分页页码
limitinteger分页大小

参阅 官方文档

Published on the GitHub by TheNorthMemory