


Detailed explanation of sandbox key steps for WeChat payment development
1. Simulation test system
In order to lower the test threshold for merchants, the WeChat payment team developed an independent simulation test system. The system returns different response messages based on the amount of the acceptance use case to meet the merchant's needs for normal function testing, security/abnormality testing, and performance testing.
Figure 1 WeChat payment simulation test system
Figure 1 is a simplified schematic diagram of the WeChat payment simulation test system (hereinafter referred to as the simulation system). The API protocol of the simulation system is exactly the same as the official API. Merchant developers only need to add a sandboxnew path to the official API call URL to connect to the simulation system.
For example, the credit card payment URL: api.mch.weixin.qq.com/pay/micropay
is changed to: api.mch.weixin.qq.com/sandboxnew/pay/micropay.
The simulation system is completely independent from the production environment, including the storage layer. All transactions made by merchants in the simulation system (such as orders, payments, and query) are fake data without fund flow, that is, users do not need to actually deduct money, and merchants will not have funds credited to their account. The same applies to vouchers. In the sandbox environment, merchants do not need to actually create and issue vouchers, and there will be no real deductions. The API verification key for the acceptance simulation test system needs to be obtained from the API:
Get the verification key API:
Request Url | api.mch.weixin.qq.com/sandboxnew/pay/getsignkey |
---|---|
Do you need a certificate | No |
Request method | POST |
Field | Required | Example value | Type | Description | |
---|---|---|---|---|---|
mch_id | is | 1305638280 | String(32) | WeChat merchant number assigned by WeChat payment | |
characters String | nonce_stris | 5K8264ILTKCH16CQ2502SI8ZNMTM67VS | String(32) | Random string, no longer than 32 bits | |
sign | is | 5K8264ILTKCH16CQ2502SI8ZNMTM67VS | String(32) | signature value |
Field name | Field | Required | Example value | Type | Description |
---|---|---|---|---|---|
Status code | return_codeis | SUCCESS | String(16) | SUCCESS/FAIL This field is a communication identifier, not a transaction identifier | |
return_msg | No | Signature failed | String(128) | Return information, if not empty, it is an error Reason, signature failed, parameter format verification error |
Field name | Field | Required | Example value | Type | Description |
---|---|---|---|---|---|
The merchant number | mch_id | is | 1305638280 | String(32) | WeChat merchant number assigned by WeChat payment |
Sandbox key | sandbox_signkey | No | 013467007045764 | String(32) | Returned sandbox key |
Example of interaction process for merchants to access the simulation system:
1. The merchant initiates a card payment request and uses POST method to call api.mch.weixin.qq.com/sandboxnew/pay/micropay
2. https requests with sandboxnew will be routed by nginx to the simulation system. The simulation system returns the expected message to the merchant based on the payment amount (total_fee field). At the same time, the request data is landed;
3. The merchant initiates an order query, calls api.mch.weixin.qq.com/sandboxnew/pay/orderquery, and brings the WeChat order number (transaction_id) or Merchant’s internal order number (out_trade_no);
4. After receiving the order inquiry request, the simulation system returns the expected order inquiry result to the merchant based on the order number and amount;
5. The merchant downloads the statement and calls api.mch .weixin.qq.com/sandboxnew/pay/downloadbill, the simulation system returns a fixed bill format to the merchant. Note: The content of the bill is not necessarily exactly the same as the transaction generated by the merchant in the simulation system.
2. Sandbox Key
Use Fangbei Studio WeChat Payment AlmightyInterface class to achieve it with a few lines of code
//1.5 沙箱密钥$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);
Return results 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 merchant test threshold, the WeChat payment team developed an independent simulation test system. The system returns different response messages based on the amount of the acceptance use case to meet the merchant's needs for normal function testing, security/abnormality testing, and performance testing.
[Related recommendations]
1.WeChat public account platform source code download
The above is the detailed content of Detailed explanation of sandbox key steps for WeChat payment development. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

In WeChat, users can enter their payment password to make purchases, but how do they retrieve their payment password if they forget it? Users need to go to My-Services-Wallet-Payment Settings-to recover their payment password if they forget it. This introduction to how to retrieve your payment password if you forget it will tell you the specific operation method. The following is a detailed introduction, so take a look! WeChat usage tutorial. How to find the WeChat payment password if you forget it? Answer: My-Service-Wallet-Payment Settings-Forgot payment password. Specific method: 1. First, click My. 2. Click on the service inside. 3. Click on the wallet inside. 4. Find the payment settings. 5. Click Forgot payment password. 6. Enter your own information for verification. 7. Then enter the new payment password to change it.

Solution for forgetting WeChat payment password: 1. Open WeChat APP, click "I" in the lower right corner to enter the personal center page; 2. In the personal center page, click "Pay" to enter the payment page; 3. On the payment page , click "..." in the upper right corner to enter the payment management page; 4. In the payment management page, find and click "Forgot payment password"; 5. Follow the page prompts and enter personal information for identity verification. After successful verification, you can Choose the method of "retrieve by swiping your face" or "retrieve by verifying bank card information" to retrieve your password, etc.

There are many food and snack shops provided in the Meituan takeout app, and all mobile phone users log in through their accounts. Add your personal delivery address and contact number to enjoy the most convenient takeout service. Open the homepage of the software, enter product keywords, and search online to find the corresponding product results. Just swipe up or down to purchase and place an order. The platform will also recommend dozens of nearby restaurants with high reviews based on the delivery address provided by the user. The store can also set up different payment methods. You can place an order with one click to complete the order. The rider can arrange the delivery immediately and the delivery speed is very fast. There are also takeout red envelopes of different amounts for use. Now the editor is online in detail for Meituan takeout users. We show you how to set up WeChat payment. 1. After selecting the product, submit the order and click Now

Steps to set the order of deductions for WeChat payment: 1. Open the WeChat APP, click on the "Me" interface, click on "Services", and then click on "Collect and Payment"; 2. Click on "Prioritize Use This Payment Method" under the payment code on the collection and payment interface; 3. Select the preferred payment method you need.

WeChat payment cannot be canceled immediately after successful payment. Refunds usually need to meet the following conditions: 1. The merchant's refund policy. The merchant will formulate its own refund policy, including the refund time window, refund amount and refund method; 2. Payment time, refunds usually require Apply within a certain time frame, and refunds may not be possible beyond this time frame; 3. Goods or service status. If the user has received the goods or enjoyed the service, the merchant may require the user to return the goods or provide corresponding proof; 4. Refund process, etc.

When everyone has nothing to do, they will choose to browse the Xianyu platform. Everyone can find that there are a large number of products on this platform, which can allow everyone to see various second-hand products. Although these products are second-hand products, there is absolutely no problem with the quality of these products, so everyone can buy them with confidence. The prices are very affordable, and they still allow everyone to face-to-face with these products. It is entirely possible for sellers to communicate and conduct some price bargaining operations. As long as everyone negotiates properly, then you can choose to conduct transactions, and when everyone pays here, they want to make WeChat payment, but it seems that the platform It's not allowed. Please follow the editor to find out what the specific situation is. Xianyu

1. First, we need to open the WeChat APP on the mobile phone, and then click to log in to the WeChat account, so that we enter the WeChat homepage. 2. Click the [Me] button in the lower right corner of the WeChat homepage, then select the [Payment] option. We click to enter the payment page. 3. After entering the [Payment] page, click the [Wallet] option to enter, and click [Bill] in the upper right corner of the [Wallet] page.

Alibaba 1688 is a purchasing and wholesale website, and the items there are much cheaper than Taobao. So how does Alibaba use WeChat payment? The editor has compiled some relevant content to share with you. Friends in need can come and take a look. How does Alibaba use WeChat payment? Answer: WeChat payment cannot be used for the time being; 1. On the page where we purchase goods, we click [Change payment method] 2. Then in the pop-up page, we can only go to [Alipay, staged payment] , cashier] can be selected;
