发放代金券
商户平台/API完成制券后,可使用发放代金券接口发券。通过调用此接口可发放指定批次给指定用户,发券场景可以是小程序、H5、APP等。
请求参数 | 类型 | 描述 |
---|---|---|
openid | string | 用户openid |
json | object | 声明请求的JSON 数据结构 |
stock_id | string | 批次号 |
out_request_no | string | 商户单据号 |
appid | string | 公众账号ID |
stock_creator_mchid | string | 创建批次的商户号 |
coupon_value | integer | 指定面额发券,面额 |
coupon_minimum | integer | 指定面额发券,券门槛 |
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_id | string | 代金券id |
根据商户号查用户的券
可通过该接口查询用户在某商户号可用的全部券,可用于商户的小程序/H5中,用户"我的代金券"或"提交订单页"展示优惠信息。无法查询到微信支付立减金。本接口查不到用户的微信支付立减金(又称“全平台通用券”),即在所有商户都可以使用的券,例如:摇摇乐红包
请求参数 | 类型 | 描述 |
---|---|---|
openid | string | 用户openid |
query | object | 声明请求的查询参数 |
appid | string | 公众账号ID |
stock_id | string | 批次号 |
status | string | 代金券状态SENDED | USED | EXPIRED 枚举值之一 |
creator_mchid | string | 创建批次的商户号 |
sender_mchid | string | 批次发放商户号 |
available_mchid | string | 可用商户号 |
offset | integer | 分页页码 |
limit | integer | 分页大小 |
business_type | string | 业务类型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_count | integer | 总数量 |
offset | integer | 分页页码 |
limit | integer | 分页大小 |
参阅 官方文档