In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article will explain in detail the example analysis of sandbox keys in WeChat Pay's development. The editor thinks it is very practical, so I share it with you for reference. I hope you can get something after reading this article.
1. Simulation test system
In order to reduce the threshold of merchant testing, WeChat Pay team developed a set of independent simulation test system. The system returns different response messages according to the amount of acceptance use cases to meet the needs of normal function testing, security / exception testing and performance testing.
Fig. 1 WeChat Pay simulation test system
Figure 1 shows the simplified schematic diagram of WeChat Pay's simulation test system (later referred to as the simulation system). The API protocol of the simulation system is exactly the same as the formal API. Merchant developers only need to add one layer of sandboxnew path to the calling URL of the official API to connect to the simulation system.
For example, pay URL:api.mch.weixin.qq.com/pay/micropay by credit card
Change to: api.mch.weixin.qq.com/sandboxnew/pay/micropay.
The simulation system is completely independent of the production environment, including the storage layer. All transactions made by merchants in the simulation system (such as placing orders, payments, inquiries) are false data without capital flow, that is, users do not need real deductions, and merchants will not have funds in the account. Vouchers are the same, and there is no need for merchants to make and issue coupons in a sandbox environment, and there will be no real coupons. The API verification key of the acceptance simulation test system should be obtained from API:
Get the verification key API:
Request Urlapi.mch.weixin.qq.com/sandboxnew/pay/getsignkey whether a certificate is required No request method POST
Request parameters:
Field name field required sample value type description merchant number mch_id is 1305638280String (32) Wechat merchant number random string assigned by WeChat Pay nonce_str is 5K8264ILTKCH16CQ2502SI8ZNMTM67VSString (32) random string, no longer than 32-bit signature sign is 5K8264ILTKCH16CQ2502SI8ZNMTM67VSString (32) signature value
Return parameters:
Field name field required sample value type description return status code return_code is SUCCESSString (16) SUCCESS/FAIL this field is the communication ID, non-transaction ID returns information return_msg No signature failed String (128) returns information, if not empty, for error reasons, signature failure, parameter format verification error
The following fields are returned when return_code is SUCCESS.
Field name field required example value type description merchant number mch_id is 1305638280String (32) Wechat merchant number sandbox key assigned by WeChat Pay sandbox_ signkey whether 013467007045764String (32) returned sandbox key merchant access simulation system example:
1. The merchant initiates the payment request by card and calls api.mch.weixin.qq.com/sandboxnew/pay/micropay by POST.
two。 Https requests with sandboxnew are routed to the simulation system by nginx. The simulation system returns the expected message to the merchant according to the payment amount (total_fee field). At the same time, the request data is landed.
3. Merchant initiates order search and calls api.mch.weixin.qq.com/sandboxnew/pay/orderquery with Wechat order number (transaction_id) or merchant internal order number (out_trade_no)
4. After receiving the order search request, the simulation system returns the expected order search result to the merchant according to the order number and amount.
5. The merchant downloads the statement, calls api.mch.weixin.qq.com/sandboxnew/pay/downloadbill, and the simulation system returns the fixed bill format to the merchant. Note: the content of the bill is not necessarily the same as the transaction generated by the merchant in the simulation system.
2. Sandbox key
Using Fang Bei Studio WeChat Pay omnipotent interface class, it can be realized in a few lines of code.
/ / 1.5 Sandbox key $obj = array (); $obj ['mch_id'] = MCHID;$url =' https://api.mch.weixin.qq.com/sandboxnew/pay/getsignkey';$wxHongBaoHelper = new WxPay (); $data = $wxHongBaoHelper- > wxpay ($url, $obj, false); $res = $wxHongBaoHelper- > xmlToArray ($data)
The returned result is as follows
Array (3) {["return_code"] = > string (7) "SUCCESS" ["return_msg"] = > string (2) "ok" ["sandbox_signkey"] = > string (32) "4d827419cb511d8f6ccc35d574ff1f7b"} Simulation Test system in order to lower the threshold of merchant testing, WeChat Pay team developed an independent simulation test system. The system returns different response messages according to the amount of acceptance use cases to meet the needs of normal function testing, security / exception testing and performance testing.
This is the end of the article on "sample analysis of sandbox keys in WeChat Pay's development". I hope the above content can be of some help to you, so that you can learn more knowledge. If you think the article is good, please share it for more people to see.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.