# New One-time Subscription Message Development Guide Beta
# 1 Access Guidelines
# 1.1 Preparation before access
Developers first need to clarify their own service format, select the corresponding format card access.
The developer synchronizes to the platform according to the template rules of different cards. Each card has a number of status templates (such as "calling vehicle," "driver rushing to pick-up point," etc.), Each template has different required fields and optional fields (such as "driver license plate number," "estimated arrival time at the boarding point," etc.), and the platform issues a notice to the user based on the status flow information.
# 1.2 Application template
Developers need to log inMini Program management background , InFeatures - Subscription Messages - Common Template Library - One-time SubscriptionCan be applied for the template query, after the audit can be used.
The template has the corresponding category requirements, and the Mini programs that meet the category requirements can see the new template in the public template library first.
It should be noted that after adding such templates, the template id does not support subscription and distribution by the original way.wx.requestSubscribeMessageRequest a user to subscribe to the template.
In addition, the developer and agent development service provider can communicate via the server side interface addMessageTemplate Add a template, tid
See below, kidList
Please pass in an empty array.
Support templates are currently supported as follows:
notify_type | Card format | category | How to get the code | Template definition | Addmessagetemplate Interface tid |
---|---|---|---|---|---|
2001 | Shopping (physical logistics) service dynamics | Business self, e-commerce platform/E-commerce platform | Use Weixin Pay order number as Code | link | 10000001 |
2002 | Shopping (pickup) service dynamics | Business self, e-commerce platform/E-commerce platform | Use Weixin Pay order number as Code | link | 10000002 |
2003 | Shopping (Virtual Shipping) Service Dynamics | IT Technology/Basic telecommunications business, IT technology/Telecom business agent, IT technology/Resale mobile communication, business operation, e-commerce platform/E-commerce platform | Use Weixin Pay order number as Code | link | 10000003 |
2004 | Express delivery service | Logistics services/Postal and logistics services/To receive/Dispatch, Logistics Services/Express Cabinet, Logistics Service/freight or cargo transportation | Use Weixin Pay order number as Code | link | 10000004 |
2005 | Purchase of public service | financial sector/Insurance, financial industry/bank | Use Weixin Pay order number as Code | link | 10000005 |
2006 | Shopping & Catering (City Delivery) Service Dynamics | Business self, e-commerce platform/E-commerce platform, catering services/Takeaway Platform, Catering Service/Catering Service Locations/Food Service Management Businesses | Use Weixin Pay order number as Code | link | 10000006 |
2007 | Shopping & Dining & Local Living (Waiting to Collect) Service Dynamics | Food and Beverages/Catering Service Locations/Food Service Management Businesses | Use Weixin Pay order number as Code | link | 10000007 |
2008 | Hotel Reservation Service | Travel services/Accommodation services | Use Weixin Pay order number as Code | link | 10000021 |
2009 | Airline ticket service | Transportation services/aviation | Use Weixin Pay order number as Code | link | 10000024 |
2010 | Train tickets, car tickets, ferry ticket service dynamics | Transportation services/train/high speed rail/Motor vehicles, transportation services/Long-distance bus | Use Weixin Pay order number as Code | link | 10000022 |
2011 | Scenic spot ticket service | Travel services/Scenic Area Services | Use Weixin Pay order number as Code | link | 10000029 |
1001 | Taxi service dynamics | Transportation services/Taxis, Transportation Services/Online Car Booking, Transportation Services/coattails/to carpool | Get through the front end Code | link | 10000017 |
1003 | City Distribution Service | Business owner/Health Products, Business Self-Employment/Jewelry jade, business self-management/Food and beverage, business self-management/Adult Supplies (Medical Devices), Business Self-Employment/Alcohol, business self-management/Refined oil, business self-management/Commemorative coins, business self-management/Fresh/Primary edible agricultural products, self-employed businesses/Telephone card sales, business self/Prepaid card, business self/Adult sex toys, business self/Department Store/Shopping centers, business owners/Mother and baby food, e-commerce platform/E-commerce platform, catering services/Takeaway Platform, Catering Service/Catering Service Locations/Food Service Management Businesses | Get through the front end Code | link | 10000019 |
1004 | Dynamic waiting service | Food and Beverages/Catering Service Locations/Food Service Management Businesses | Get through the front end Code | link | 10000020 |
1005 | Restaurant Queue Service Dynamics | Food and Beverages/Catering Service Locations/Food Service Management Businesses | Get through the front end Code | link | 10000018 |
# 1.3 Use Weixin Pay order number as Code Template Development Guide for
# 1.3.1 Obtain Code
When the user makes a payment in the Mini Program, he obtains the corresponding information according to the different ordering channels.Code
:
(1) The current order isOrdinary Weixin Pay order
Developers can get Weixin Pay order number, which can be directly used as Code
。
(2) The current order isWeixin Pay Sub-order
Developers can get the order number of Weixin Pay service, which can be directly used as Code
。
this Code
Unique in the current service process, subsequent developers update the user's service status through this Code
Proceed.
Notes:
- It should be noted that there is a certain delay between the generation of Weixin Pay order number and the verification of the order number. If you receive the wrong order number, it will be notified._Code Does not exist. It is recommended to try again in 1 minute.
- For the combined order payment scenario, you need to use the order number of the suborder as the
Code
, multiple suborders can be used to activate multiple cards without interfering with each other. - Weixin Pay order number for current mini program only/Weixin Pay service order number, please do not use other Mini programs, Official Account message template, APP payment order number.
- Different ordering channels invoke the server-side interface
setUserNotify
You need to make the corresponding declaration in the fields passed in.
# 1.3.2 Activation card
The developer must call the server interface within 24 hours of payment completion. setUserNotify
Pass in the initialized card state and status-related fields (see template definition links in 1.1) to activate the first Code
, the follow-up can continue through setUserNotify
Update the dynamics of the service.
# 1.3.3 Update Card Status
Code
And activated, the developer can invoke the server-side interface within 30 days of activation setUserNotify
, updates card status and status-related fields (see template definition links in 1.1). After 30 days, or when the status is unchanged for the next status (such as the status update to "order completed"), developer updates are no longer allowed.
# 1.4 Get through the front end Code Template Development Guide for
# 1.4.1 Obtain Code
From the base library 2.26.2 Start support
Developers need to be on the front end that will trigger the service's button
Component open-type
The value of the liveActivity
, Setting activity - type
The parameter is notify_type。When the user clicks button
Later, you can pass the bindcreateliveactivity
The event callback gets the Code
。
this Code
Unique in the current service process, subsequent developers update the user's service status through this Code
Proceed.
Notes:
- The platform is relevant.
button
Component for detection, including whether to induce a user to click, access through a button unrelated to the cardCode
Etc.
Code example:
<button open-type="liveActivity" activity-type="1001" bindcreateliveactivity="onLiveActivityCreate">Call Now</button>
Page({
onLiveActivityCreate (possibly ) {
console.log(evt.detail.code)
}
})
# 1.4.2 Activation card
The developer needs to call the server-side interface within 5 minutes of getting setUserNotify
Pass in the initialized card state and status-related fields (see template definition links in 1.1) to activate the first Code
, the follow-up can continue through setUserNotify
Update the dynamics of the service.
# 1.4.3 Update Card Status
Code
After activation, the server-side interface can be invoked within 24 hours of activation setUserNotify
, updates card status and status-related fields (see template definition links in 1.1). For more than 24 hours, or for the next status when the status is unchanged (such as a status update to "Order Completed"), developer updates are no longer allowed.
# 1.5 Monitoring Event Development Guide
The developer invokes the server-side interface setUserNotify
After that, the platform will be triggered to issue a subscription message, and the developer can access theWeChat Mini Program Messaging ServiceReceive a subscription message to issue a failed event.
The subscription message issue failed event parameters are as follows:
parameter | describe |
---|---|
ToUser | Mini Program account ID |
FromUserName | User openid |
CreateTime | timestamp |
MsgType | Message type, fixed to "event" |
Event | Event type, fixed as "notify_service_msg_send_result" |
Openid | User openid |
notify_Code | Dynamic update token |
notify_type | Card id |
card_status | Status id |
fail_ret | Error code: -10001 System error-10002 Content security check does not pass-1003 No subscription message template added-1004 The user rejects this. Template-1005 Messages are intercepted too frequently |
fail_msg | Error message |
An example of the JSON format is as follows:
{
"ToUserName":"gh_e5e82d93a62a",
"FromUserName":"o7esq5PHRGBQYmeNyfG064wEFVpQ",
"CreateTime":1699428279,
"MsgType":"event",
"Event":"notify_service_msg_send_result",
"openid":"o7esq5PHRGBQYmeNyfG064wEFVpQ"
"notify_code":"p1.4200002043202311087295582095",
"notify_type":2006,
"card_status:4,
"fail_direct:-1004,
"fail_msg":"user reject message "
}
# 1.6 Additional Feature Development Guide
# 1.6.1 Query Card Status
Because the update of the card state has a set of strict verification mechanism, in the process of the developer synchronizing the information to the platform, there are scenarios such as information loss and update not in time, so the developer can use the server interface getUserNotify
query Code
Corresponds to state and service related information stored on the platform side.
# 1.6.2 Incoming extension information
Developers through this function in addition to the user to issue notices, but also through the server-side interface getUserNotifyExt
Bringing in more service-related information and enabling more functionality, currently supported capabilities include:
- Transaction evaluation upgrade: https://docs.qq.com/doc/DV2J4U1ltSExScnBB
# 2 Related Interface Documentation
Activate and update cards:setUserNotify
Check Card Status:getUserNotify
Configure more service related information:[setUserNotifyExt ](https://developers.weixin.qq.com/miniprogram/dev/OpenApiDoc/mp-message-management/subscribe-message/setUserNotifyExt .html)
# 3 Q&A
The following Q & A answers some of the developers' concerns, and more questions can be asked atWeChat Open CommunityQuestion.
# Activation and update mechanism
Q: Can the activation time and update time be extended? A: There are currently no plans to extend the activation time and update time of real-time cards. For trading cards, considering the existence of pre-sale, service appointment and other scenarios, the follow-up plan supports developers to set up aStart Update Time, fromStart Update TimeCalculate the 30-day renewal time.
# Notification mechanism
Q: Why do some status changes get notified and some don't? Do I not have to follow a template to pass in a no-notification status? A: WeChat will dynamically adjust the content according to the user's needs, so the developer can change all the state according to the template, without adjusting the re-access according to the WeChat side.
Q: Why do some fields show up in the card when passed in and some don't? Do I not have to pass in by template for fields that are not displayed? A: WeChat will dynamically adjust the content according to user needs, so the developer can change all the fields according to the template, without re-accessing according to WeChat side adjustment.
Q: Some of the notifications sent through this scheme will conflict with previous subscription messages, and will they repeatedly disturb the user? A: For messages sent through this way, it is recommended that developers manually not send similar subscription message templates, and no longer pop up similar subscription message application pop-up windows. The follow-up WeChat side will be on the line certain strategies to help developers intercept.
# Template
Q: My current business form is not satisfied, will I open more templates in the future? A: The platform will continue to design new templates based on user and developer feedback, and developers are welcome.Submit Template Design。