The Alipay sandbox is an environment that helps developers develop APIs and enables integration tests of main functions. The sandbox environment simulates the main functions and logic of Alipay products. During the integration process, developers can develop and debug various open APIs in the sandbox environment according to the needs of each application. This enables integration tests to be completed quickly and successfully and helps the application to pass all acceptance tests before going live.
Before starting your integration in the sandbox, learn about the entire integration process to make the necessary preparations. Then, register on the Alipay portal and get your Alipay account to log in to the Alipay Developer Center. Complete the following tasks in Alipay Developer Center:
- Specify your role to set the integration mode.
- Create an application, and select the product and scenarios to integrate with and specify the test currency. Afterward, the sandbox resources are automatically allocated to you.
- Check the sandbox resources and make configurations. For example, you can check your sandbox client ID, configure sandbox keys, and set the gateway URL.
- Start using the sandbox functionalities.
For more information about Alipay Developer Center, see Alipay Developer Center.
The Alipay sandbox provides the following functionalities to facilitate your integration tests:
- API call simulation
- Development tools
- Test wallets
- Reconciliation reports generation
API call simulation
In the sandbox, multiple ways are provided to make an API call simulation, and you can call each API multiple times. API calls are correlated with each other if you provide the corresponding information. For example, you first call the pay API to initiate a payment. Then you can call the refund API to initiate a refund against the payment by specifying the paymentId. The related transaction information still exists in the sandbox environment.
In addition, when you call the pay or consult API in the sandbox, the sandbox also simulates the redirection process between the merchant and the wallet in each terminal type of WEB, WAP, and APP.
API call methods
You can simulate the API call process in the sandbox by using the following tools:
- Common development tools such as Postman: In addition to all the below-mentioned tools provided by Alipay, you can also use other tools that you are familiar with to call the API. For example, you can use Postman to call the specific API by specifying the sandbox request URL and request body.
- Alipay provided tools:
- iTest: Alipay Developer Center provides the iTest tool to allow you to test an API integration. You can select a specific API, wallet, and device that need to be tested and send the request to Alipay in iTest to get the corresponding response.
- SDKs: Alipay-provided open SDKs encapsulate the process of performing the integration, including adding and validating signatures for calling Alipay APIs. You can download the corresponding SDK according to your needs. To use an SDK for sandbox development work, follow the instructions in the SDK readme to download and install the SDK. Then you can use the structure it provides to edit the sample code and specify the values in the request body, and send the request in the sandbox environment to get the response.
- Doc Center API Explorer: You can use the API Explorer function in Alipay Doc Center to send the request to Alipay in the sandbox environment. By editing the sample code and specifying values in the request body in API Explorer, you can send the request in the sandbox environment and then get a real-time response from the Alipay sandbox in the response section. Each API has its own API explorer interface, for example, the following graphic shows the interface for the pay API in Alipay Doc Center:
Figure 1. API Explorer
Redirection process simulation
After initiating a payment or an authorization process in the production environment, a redirection process will occur. To provide you with an experience close to the production environment, the redirection process simulation is also provided when you call the pay or consult API in the sandbox.
Take AlipayCN as an example: The user is redirected from the merchant terminal to the wallet terminal when making the payment. The following table shows the wallet page that the user is redirected to from each possible merchant terminal type: WEB, WAP, and APP.
Table 1. Redirection to the wallet terminal
Take AlipayCN as an example: The user is redirected from the merchant terminal to the wallet terminal when making the authorization. The following table shows the wallet page that the user is redirected to from each possible merchant terminal type: WEB, WAP, and APP.
Table 2. Redirection to the authorization page
Alipay Developer Center provides various development test tools for you to develop and test applications in the sandbox environment. As a developer, you can simplify your integration by using tools such as iTest, iDiagnose, iMock, and iNotify:
- iTest: helps to test an API integration in the sandbox environment. You can debug APIs during testing.
- iDiagnose: helps to locate problems quickly during integration testing, and makes corresponding changes according to the suggestions provided by the system during troubleshooting.
- iMock: provides simulations of different API results and returns the specified response for integration testing. iMock can simulate all the result codes, including rare production environment scenarios.
- iNotify: helps to simulate the process of receiving and handling asynchronous notifications.
The sandbox also provides test wallets. Alipay provides a test wallet app to help you with end-to-end testing during your integration process. In the test wallet app, you can simulate the process of making a payment or authorization by using a wallet of choice. In addition, you can check the transaction history in the test wallet. For more information, see Test wallet.
Reconciliation reports generation
For transactions that occur in the sandbox, reconciliation reports are also generated. You can view details of the transactions in the reconciliation reports, which include settlement summary, settlement items, and transaction items. Alipay uploads these reports to a specific directory on the SFTP. Contact Alipay Technical Support for an SFTP account and password in the sandbox. Then you can log in to the SFTP server to download these reports for reconciliation in the sandbox.
The settlement cycle and settlement strategy for Alipay+ Mobile Payment Partners (Alipay+ MPPs) are also simulated in the sandbox. The reports' generation dates for AlipayCN and other Alipay+ MPPs are different according to the settlement cycle. For more information, see Settlement cycle.