# New version of one-time subscription messaging development guide
# 1 Access guidelines
# 1.1 Prepare before access
Developers first need to clarify their service format and select the corresponding format card to access.
The developers synchronize the different cards to the platform according to the template rules. Each card has several status templates (e.g. "Calling in the vehicle," "Driver driving to the point of entry," etc.), Each template has different required and selected fields (such as "driver's license plate number," "estimated arrival time," etc.), and the platform sends notifications to users based on the status flow information.
# 1.2 Request a template
Developers need to log in to [Weixin Mini Program-END]] to manage the back-end, query the templates that can be requested in Features - Subscription Messages - Public Templates Library - One-time Subscriptions, and use them once they have been approved.
Template has the corresponding category requirements, in line with the category requirements of Weixin Mini Program can be seen in the public template library priority new template.
It should be noted that after adding such templates, the template id does not support subscription and distribution by the original way, do not use wx.requestSubscribeMessage Request a user to subscribe to the template.

In addition, developers and contractors can use the server interface. addMessageTemplate Add a template,tidSee below,kidListPlease enter an empty array.
The current total support for the templates is as follows:
| notify_type | Card business form | category | How to get the code | Definition of a template | AddMessageTemplate interface tid |
|---|---|---|---|---|---|
| 2001 | Shopping (Physical Logistics) Service Dynamics | Merchants themselves, e-commerce platforms / e-business platforms | Use WeChat payment order number as code | link | 10000001 |
| 2002 | Shopping (Self-Taking) Service Dynamics | Merchants themselves, e-commerce platforms / e-business platforms | Use WeChat payment order number as code | link | 10000002 |
| 2003 | Shopping (Virtual Shipping) Service Dynamics | IT technology / basic e-business, IT technology / telecommunications business agents, IT technology / resale transfer communication, business self-employed, e-commerce platform / e-commerce platform | Use WeChat payment order number as code | link | 10000003 |
| 2004 | Courier delivery service developments | Logistics Services / Post, Logistics services / Invoices / Delivery, Logistic services / Express containers, Logistical services / Goods Transportation | Use WeChat payment order number as code | link | 10000004 |
| 2005 | Purchase of public service | Financial Industry / Insurance, Finance Industry / Banking | Use WeChat payment order number as code | link | 10000005 |
| 2006 | Shopping & Dining (Local Delivery) Service Dynamics | Merchants themselves, e-commerce platforms / e-marketplaces, food service / takeaway platforms, food services / food service establishments / foodservice management enterprises | Use WeChat payment order number as code | link | 10000006 |
| 2007 | Shopping & Dining & Local Life (Waiting & Receiving) Service Dynamics | Catering Services / Catering Services Venues / catering services management enterprises | Use WeChat payment order number as code | link | 10000007 |
| 2008 | Hotel booking service developments | Travel Services / Accommodation Services | Use WeChat payment order number as code | link | 10000021 |
| 2009 | Flight service developments | Transportation Services / Aviation | Use WeChat payment order number as code | link | 10000024 |
| 2010 | Train, bus and ferry service developments | Transportation services / trains / high-speed trains - express trains, transportation services / coaches | Use WeChat payment order number as code | link | 10000022 |
| 2011 | Developments in scenic attractions ticketing services | Tourism Services / Scenic Area Services | Use WeChat payment order number as code | link | 10000029 |
| 1001 | Taxi service developments | Transportation Services / Taxis, Transportation Services - Ride-hailing, Transportation Services, Ride-hail / Ride-sharing | Getting code through the front end | link | 10000017 |
| 1003 | Developments in co-town distribution services | Merchants / Health Care Products, Merchants ® / Jewelry & Gems, Merchants' ® ® Food & Drink,Vendor / Adult Products (Medical Devices), Vendor ® / Liquor, Vendor TM / Oil Products, Vendor S / Coins, Vendor T / Fresh / Primary Food Products, vendor T / Phone Card Sales,Shop / prepaid cards, Shop / adult sex products, Shop ® / department store / shopping center, Shop TM / mother and baby food, E-commerce platform / e-commerce platform, catering service / takeaway platform, dining service / restaurant service establishment / restaurant services management enterprise | Getting code through the front end | link | 10000019 |
| 1004 | Menu Waiting Service Dynamics | Catering Services / Catering Services Venues / catering services management enterprises | Getting code through the front end | link | 10000020 |
| 1005 | Restaurant queuing service dynamics | Catering Services / Catering Services Venues / catering services management enterprises | Getting code through the front end | link | 10000018 |
# 1.3 Template development guide using WeChat payment order number as code
# 1.3.1 Getting the code
When the user makes a payment in Weixin Mini Program, the correspondingcodeis obtained according to the different channels of the order:
(1) The current order is ordinary WeChat payment order
Developers can obtain WeChat payment order number, which can be directly used ascode.
(2) The current order is WeChat
Developers can obtain WeChat payment service subscription number, can be directly ascode.
Thiscodeis unique during the service process, and subsequent developers update the user's service status through thiscode]].
NOTE:
- It should be noted that WeChat payment order number from generation to can be verified there is a certain delay may be, if received an error notify_code does not exist, it is recommended to retry after 1 minute.
- For a single 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. - Only the WeChat payment order number / Weixin Pay service order number of the current Weixin Mini Program. Do not use other Mini programs, Official Account payment, APP payment order number.
- Different ordering channels call the service interface
setUserNotifywith the corresponding declaration in the incoming field.
# 1.3.2 Activating the card
Developers need to call the server interface within 24 hours of payment completionsetUserNotifyenter the initial card status and status-related field (see the various template definitions in 1.1) to activate`` code, and then you can continue to update the service bysetUserNotify`.
# 1.3.3 Update card status
Codeand activate it, the developer can invoke the server interfacesetUserNotifywithin 30 days of activation,Update the card status and status-related fields (see the links to the various template definitions in 1.1). Developers are no longer allowed to update beyond 30 days, or when the next state is unchanged (such as when the state is updated to "Order Completed").
# 1.4 A template development guide for getting code through the front end
# 1.4.1 Getting the code
Developers need to set the value of thebuttoncomponent of theopen-typeon the front end to [[]]liveActivity, setactivity-typeparameter to notify_type.When the user clicks thebutton, thebindcreateliveactivityevent callback gets thecode。
Thiscodeis unique during the service process, and subsequent developers update the user's service status through thiscode]].
NOTE:
- The platform detects relevant
buttoncomponents, including whether the user is induced to click, obtainingcodefrom a button unrelated to the card, and so on.
Code example:
<button open-type="liveActivity" activity-type="1001" bindcreateliveactivity="onLiveActivityCreate">立即呼叫</button>
Page({
onLiveActivityCreate (evt) {
console.log(evt.detail.code)
}
})
# 1.4.2 Activating the card
Developers need to call the server interface within 5 minutes of acquisition tosetUserNotifyto enter the initial card status and status-related field (see the various template definitions in 1.1) to activate`` code, and then you can continue to update the service bysetUserNotify`.
# 1.4.3 Update card status
When codeis activated, the server interfacesetUserNotifycan be invoked within 24 hours of activation,Update the card status and status-related fields (see the links to the various template definitions in 1.1). Developers are no longer allowed to update beyond 24 hours, or when the status is unchanged next (e.g. when the condition is updated to "Order Completed").
# 1.5 Development Guide for Listening to Events
setUserNotifyAfterthe platform triggers the downing of a subscription message, and developers can receive a failed subscription message downing event by accessing the Weixin Mini Program message push service .
The event parameter for a failed subscription message delivery is as follows:
| parameter | describe |
|---|---|
| ToUserName | Weixin Mini Program Account ID |
| FromUserName | User openid |
| CreateTime | timestamp |
| MsgType | Message type, fixed to "event" |
| Event | Event type, fixed to "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 verification does not pass; -1003 No subscription message template was added; -1004 The user rejected this template; -1005 The message sent too often was intercepted |
| 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_ret":-1004,
"fail_msg":"user reject message "
}
# 1.6 A guide to the development of other features
# 1.6.1 Query card status
Because card status updates have a strict verification mechanism, there is information loss during the process of developers synchronizing information to the platform.In cases where updates are not timely, developers can query thegetUserNotifyvia the server interface tocodecorresponding to the status and service-related information stored on the platform side.
# 1.6.2 Incoming extension information
Developers can use this feature to not only send notifications to users, but also to incorporate more service-related information through the service-side interfacegetUserNotifyExtto implement additional 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
# 3 Q&A
The following Q & A answers some of the developers' concerns, and more questions can be asked at WeChat Open Community .
# Activation and update mechanisms
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 transaction-type cards, given the existence of pre-sales, service appointments, and other scenarios, the follow-up plan allows developers to set a "start update time" and compute a 30-day update time from the "start update period."
# Notification mechanism
Q: Why do some status changes get notified and some don't? Is it not necessary for me to follow the template for a non-notification status? A: WeChat will dynamically adjust the content according to user needs, so developers can change all the state according to the template, without re-accessing according to WeChat side adjustment.
Q: Why do some fields show up in the card when passed in and some don't? Is it not necessary for me to enter fields that are not displayed according to the template? A: WeChat will dynamically adjust the content according to user needs, so developers can change all 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 of certain strategies to help developers intercept.
# Templates
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 also welcome to submit template designs](https://docs.qq.com/form/page/DTVNPbmllSEVGYVdz) .