Tools Tags
Backend Development
PHP
WeChat public platform developer documentation
Card and coupon event push
directory
Tools Tags
Card and coupon event push
Card and coupon event push

1.Update log
| Version number | Update content | Update Time |
|---|---|---|
| V1.0 | Write-off event adds a new write-off store, if it is a mobile assistant write-off The underwriter openid can be pushed. | 2015-8-31 |
| ##V1.1 | New fields related to purchase orders, merchant order number and WeChat payment transaction order number are added to the write-off event. | 2015-9-8 |
| ##V1.2 | Added a new inventory alarm event. When the user receives the best card and coupon, the inventory alarm event will be pushed | 2015-9-8 |
| V1.3 | Add a new library membership card content update event to inform developers of changes in points and balances through events | 2015-10-28 |
| V1.4 | New interface for transferring membership cards | 2016-9-19 |
| Parameters | Description |
|---|---|
| ##ToUserName | Developer WeChat ID |
| FromUserName | Sender account (one OpenID) |
| CreateTime | Message creation time (integer) |
| MsgType | Message type, event |
| Event type, card_pass_check (card and coupon passed review), card_not_pass_check (card and coupon failed to pass review) | |
| CardId | Card ID |
RefuseReason | Reasons for failed review |
Use web debugging tools to debug this interface
2.2 Receive event push
When users receive cards and coupons, WeChat will Push this event to the URL filled in by the developer. Push XML data package example:
<xml> <ToUserName> <![CDATA[gh_fc0a06a20993]]> </ToUserName> <FromUserName> <![CDATA[oZI8Fj040-be6rlDohc6gkoPOQTQ]]> </FromUserName> <CreateTime>1472551036</CreateTime> <MsgType> <![CDATA[event]]> </MsgType> <Event> <![CDATA[user_get_card]]> </Event> <CardId> <![CDATA[pZI8Fjwsy5fVPRBeD78J4RmqVvBc]]> </CardId> <IsGiveByFriend>0</IsGiveByFriend> <UserCardCode> <![CDATA[226009850808]]> </UserCardCode> <FriendUserName> <![CDATA[]]> </FriendUserName> <OuterId>0</OuterId> <OldUserCardCode> <![CDATA[]]> </OldUserCardCode> <OuterStr> <![CDATA[12b]]> </OuterStr> <IsRestoreMemberCard>0</IsRestoreMemberCard> <IsRecommendByFriend>0</IsRecommendByFriend> </xml>
Parameter description:
| Parameters | Description |
|---|---|
| ToUserName | Developer WeChat ID. |
| FromUserName | The coupon account number (an OpenID). |
| CreateTime | Message creation time (integer). |
| MsgType | Message type, event |
| Event | #Event type, user_get_card (user receives card and coupon). |
| CardId | Card ID. |
| IsGiveByFriend | Whether it is a transfer to receive, 1 means yes, 0 means no. |
| FriendUserName | The field filled in when IsGiveByFriend is 1, indicating the openid of the user who initiated the transfer |
| UserCardCode | code serial number. |
| OldUserCardCode | To ensure safety, WeChat will change the code number of the card after the transfer occurs. The field indicates the code before transfer. |
| OuterStr | Receive scene value, which is used to receive channel data statistics. The string value of this field can be customized in the QR code generation interface and Addcard interface. |
| IsRestoreMemberCard | After the user deletes the membership card, it can be retrieved again. When the user's current operation is to retrieve it , the value is 1, otherwise it is 0 |
Use web debugging tools to debug this interface
##2.3 Transfer event push
#When a user transfers a gift card or coupon, WeChat will push this event to the URL filled in by the developer. Push XML packet example:
<xml> <ToUserName><![CDATA[gh_3fcea188bf78]]></ToUserName> <FromUserName><![CDATA[obLatjjwDolFjRRd3doGIdwNqRXw]]></FromUserName> <CreateTime>1474181868</CreateTime> <MsgType><![CDATA[event]]></MsgType> <Event><![CDATA[user_gifting_card]]></Event> <CardId><![CDATA[pbLatjhU-3pik3d4PsbVzvBxZvJc]]></CardId> <UserCardCode><![CDATA[297466945104]]></UserCardCode> <IsReturnBack>0</IsReturnBack> <FriendUserName><![CDATA[obLatjlNerkb62HtSdQUx66C4NTU]]></FriendUserName> <IsChatRoom>0</IsChatRoom> </xml>
Parameter description:
| Parameters | Description |
|---|---|
| ToUserName | Developer WeChat ID. |
| FromUserName | The coupon account number (an OpenID). |
| CreateTime | Message creation time (integer). |
| MsgType | Message type, event |
| Event | Event type, user_gifting_card (user transfers gift card coupon). |
| CardId | Card ID. |
| FriendUserName | The openid of the user who receives the coupon |
| UserCardCode | code serial number. |
IsReturnBack | ##Whether to return as a gift, 0 means no , 1 represents yes. |
IsChatRoom | Is it a group transfer |
| Parameters | Description |
|---|---|
| ToUserName | Developer WeChat ID. |
| FromUserName | Sender account (an OpenID) |
| CreateTime | Message creation time (integer). |
| MsgType | Message type, event |
| Event | Event type, user_del_card (user deletes card) |
| CardId | Card coupon ID. |
| UserCardCode | code serial number. Event push is supported after cards and coupons with custom codes and non-custom codes are collected. |
Use web debugging tools to debug this interface
2.5 Write-off event push
When the card and coupon are written off, WeChat This event will be pushed to the URL filled in by the developer. Push XML packet example:
<xml> <ToUserName> <![CDATA[gh_fc0a06a20993]]> </ToUserName> <FromUserName> <![CDATA[oZI8Fj040-be6rlDohc6gkoPOQTQ]]> </FromUserName> <CreateTime>1472549042</CreateTime> <MsgType> <![CDATA[event]]> </MsgType> <Event> <![CDATA[user_consume_card]]> </Event> <CardId> <![CDATA[pZI8Fj8y-E8hpvho2d1ZvpGwQBvA]]> </CardId> <UserCardCode> <![CDATA[452998530302]]> </UserCardCode> <ConsumeSource> <![CDATA[FROM_API]]> </ConsumeSource> <LocationName> <![CDATA[]]> </LocationName> <StaffOpenId> <![CDATA[oZ********nJ3bPJu_Rtjkw4c]]> </StaffOpenId> <VerifyCode> <![CDATA[]]> </VerifyCode> <RemarkAmount> <![CDATA[]]> </RemarkAmount> <OuterStr> <![CDATA[xxxxx]]> </OuterStr> </xml>
| Parameter | Description |
|---|---|
| ToUserName | Developer WeChat ID. |
| FromUserName | Sender account (an OpenID). |
| CreateTime | Message creation time (integer). |
| MsgType | Message type, event. |
| Event | Event type, user_consume_card (write-off event) |
| CardId | Card ID. |
| UserCardCode | Card code. |
| ConsumeSource | Confirmation source. Supports developer statistics API write-off (FROM_API), public platform write-off (FROM_MP), card and coupon merchant assistant write-off (FROM_MOBILE_HELPER) (verifier WeChat ID) |
| LocationName | Store name, the name of the store where the current card and coupon are being verified (this field will only appear through self-service verification and purchase order verification) |
| StaffOpenId | The openid of the person who verifies the card and coupon (will only appear when verification is done through the card and coupon merchant assistant) |
VerifyCode | The verification code entered by the user during self-service verification |
| ##RemarkAmount | The remark amount entered by the user during self-service write-off |
| OuterStr | Initiated by the developer Custom parameters passed in during write-off, used for write-off channel statistics |
| Parameter | Description |
|---|---|
| ToUserName | Developer WeChat ID. |
| FromUserName | Sender account (an OpenID). |
| CreateTime | Message creation time (integer). |
| MsgType | Message type, event. |
| ##Event | Event type, User_pay_from_pay_cell (WeChat pay event) |
| CardId | Card ID. |
| UserCardCode | Card code. |
| TransId | WeChat payment transaction order number (only cards and coupons that are verified using the purchase function will appear) |
| LocationId | Store ID, the store ID of the current card and coupon verification (only through the card and coupon merchant assistant and It will only appear when the purchase order is written off) |
| Fee | Amount actually paid, in cents |
| OriginalFee | Amount payable in cents |
| Parameters | Description |
|---|---|
| ToUserName | Developer WeChat ID. |
| FromUserName | Sender account (an OpenID). |
| CreateTime | Message creation time (integer). |
| MsgType | Message type, event. |
| Event | Event type, user_view_card (user clicks on membership card) |
| CardId | Card ID. |
| UserCardCode | Merchant customized code value. The non-customized code is pushed as an empty string. |
| OuterStr | Merchant-defined QR code channel parameters are used to identify this scan code to open the membership card The source comes from the QR code of a certain channel value |
Use web debugging tools to debug this interface
##2.8 Enter the official account session event push from the card coupon
The user clicks on the card coupon to view the official account to enter the session (the user needs to have followed the official account), WeChat will push this event to the URL filled in by the developer. Developers can identify users who enter the official account from cards and coupons. Push XML data package example:
<xml> <ToUserName><![CDATA[toUser]]></ToUserName> <FromUserName><![CDATA[FromUser]]></FromUserName> <CreateTime>123456789</CreateTime> <MsgType><![CDATA[event]]></MsgType> <Event><![CDATA[user_enter_session_from_card]]></Event> <CardId><![CDATA[cardid]]></CardId> <UserCardCode><![CDATA[12312312]]></UserCardCode> </xml>
Parameter description:
| Parameters | Description |
|---|---|
| ToUserName | Developer WeChat ID. |
| FromUserName | Sender account (an OpenID) |
| CreateTime | Message creation time (integer). |
| MsgType | Message type, event |
| Event | Event type, user_enter_session_from_card (the user enters the official account session from the card coupon) |
| CardId | Card ID. |
| UserCardCode | Code code. |
Use web debugging tools to debug this interface
##2.9 Membership card content update event
When the user’s membership card points balance changes, WeChat will push the event Notify developers. Push XML packet example:
<xml> <ToUserName><![CDATA[gh_9e1765b5568e]]></ToUserName> <FromUserName><![CDATA[ojZ8YtyVyr30HheH3CM73y7h4jJE]]></FromUserName> <CreateTime>1445507140</CreateTime> <MsgType><![CDATA[event]]></MsgType> <Event><![CDATA[update_member_card]]></Event> <CardId><![CDATA[pjZ8Ytx-nwvpCRyQneH3Ncmh6N94]]></CardId> <UserCardCode><![CDATA[485027611252]]></UserCardCode> <ModifyBonus>3</ModifyBonus> <ModifyBalance>0</ModifyBalance> </xml>
Parameter description:
| Parameters | Description |
|---|---|
| ToUserName | Developer WeChat ID. |
| FromUserName | Sender account (an OpenID) |
| CreateTime | Message creation time (integer). |
| MsgType | Message type, event |
| Event | Event type, update_member_card (membership card content update) |
| CardId | Card coupon ID. |
| UserCardCode | Code code. |
| ModifyBonus | Changed points value. |
| ModifyBalance | The changed balance value. |
Use web debugging tools to debug this interface
##2.10 Inventory Alarm Event
#When the initial inventory of a card_id is greater than 200 and the current inventory is less than or equal to 100, the user attempts to receive the coupon will trigger a sending event To merchants, events are sent every 12 hours.
<xml> <ToUserName><![CDATA[gh_2d62d*****0]]></ToUserName> <FromUserName><![CDATA[oa3LFuBvWb7*********]]></FromUserName> <CreateTime>1443838506</CreateTime> <MsgType><![CDATA[event]]></MsgType> <Event><![CDATA[card_sku_remind]]></Event> <CardId><![CDATA[pa3LFuAh2P65**********]]></CardId> <Detail><![CDATA[the card's quantity is equal to 0]]></Detail> </xml>
Parameter description:
| Parameters | Description |
|---|---|
| ToUserName | Developer WeChat ID |
| ##FromUserName | Sender, WeChat |
| CreateTime | Message creation time (integer) |
| MsgType | Message type, event |
| Event | Event type, card_sku_remind inventory alarm |
| CardId | Card Coupon ID |
| Detail | Alarm details |
Use web debugging tools to debug this interface
##2.11 Coupon point transaction details event
#When a merchant’s friend’s coupon points change, the WeChat server will push a message to the merchant server.
<xml> <ToUserName><![CDATA[gh_7223c83d4be5]]></ToUserName> <FromUserName><![CDATA[ob5E7s-HoN9tslQY3-0I4qmgluHk]]></FromUserName> <CreateTime>1453295737</CreateTime> <MsgType><![CDATA[event]]></MsgType> <Event><![CDATA[card_pay_order]]></Event> <OrderId><![CDATA[404091456]]></OrderId> <Status><![CDATA[ORDER_STATUS_FINANCE_SUCC]]></Status> <CreateOrderTime>1453295737</CreateOrderTime> <PayFinishTime>0</PayFinishTime> <Desc><![CDATA[]]></Desc> <FreeCoinCount><![CDATA[200]]></FreeCoinCount> <PayCoinCount><![CDATA[0]]></PayCoinCount> <RefundFreeCoinCount><![CDATA[0]]></RefundFreeCoinCount> <RefundPayCoinCount><![CDATA[0]]></RefundPayCoinCount> <OrderType><![CDATA[ORDER_TYPE_SYS_ADD]]></OrderType> <Memo><![CDATA[开通账户奖励]]></Memo> <ReceiptInfo><![CDATA[]]></ReceiptInfo> </xml>
Parameter description:
| Parameters | Description |
|---|---|
| ##ToUserName | Developer WeChat ID |
| Sender, WeChat | |
| Message creation time (integer) | |
| Message type, event | |
| Event type, card_pay_order coupon point transaction details event | |
| The order number corresponding to this push | |
| Status | This order The status of the number, ORDER_STATUS_WAITING Waiting for payment ORDER_STATUS_SUCC Payment successful ORDER_STATUS_FINANCE_SUCC Adding tokens successfully ORDER_STATUS_QUANTITY_SUCC Adding inventory successfully ORDER_STATUS_HAS_REFUND Refunded coins ORDER_STATUS_REFUND_WAITING Waiting for coin refund confirmation ORDER_STATUS_ROLLBACK Refunded, system failure ORDER_STATUS_HAS_RECEIPT Invoice issued |
| CreateOrderTime | When purchasing coupon points, the payment QR code generation time |
| ##PayFinishTime | When purchasing coupon points, the actual time when payment is successful |
| Desc | Payment method, usually WeChat Pay recharge |
| FreeCoinCount | Number of remaining free coupon points |
| PayCoinCount | Number of remaining paid coupon points |
| RefundFreeCoinCount | The number of free coupon points for this change |
| RefundPayCoinCount | This time Changed number of paid coupon points |
| ##OrderType | Order type to be pulled ORDER_TYPE_SYS_ADD Platform gift coupon points ORDER_TYPE_WXPAY Recharge coupon points ORDER_TYPE_REFUND Inventory unused refund coupon points ORDER_TYPE_REDUCE Coupon points exchange for inventory ORDER_TYPE_SYS_REDUCE Platform deduction |
| Memo | System notes explain the reasons for this change, such as account opening rewards, store rewards, write-off rewards, and recharges and deductions. |
| ReceiptInfo | Details of the invoice issued |
| ## parameter | |
|---|---|
| ##Developer WeChat ID since OpenID) | |
| Message creation time (integer) | |
| Message type, event | |
| ##CardId | Card Coupon Code |
| Use the web debugging tool to debug the interface |
Hot AI Tools
Undress images for free
Online AI tool for removing clothes from photos.
AI-powered app for creating realistic nude photos
AI image generator for creative art from text prompts.
AI powered investment research for smarter decisions
Hot Article
Hot Topics
20516
7
13629
4
Popular tool
Easy-to-use and free code editor
Chinese version, very easy to use
Powerful PHP integrated development environment
Visual web development tools
God-level code editing software (SublimeText3)












![Getting Started with PHP Practical Development: PHP Quick Creation [Small Business Forum]](https://img.php.cn/upload/course/000/000/035/5d27fb58823dc974.jpg)