Accept payments with Mini Program
This topic provides a step-by-step guide for Acquiring Service Providers (ACQPs) on how to accept a payment with a merchant mini program that is deployed in the mobile apps of Mobile Payment Providers (MPPs).
Before you begin
Before you begin, you need to familiarize yourself with the procedure of implementing Cashier Payment on merchant platforms such as App, Web, or WAP. For more information, see Integration overview.
About the task
This task is applicable to the scenario where a consumer places an order on a merchant mini program that runs in an MPP app.
User experience
The following figure illustrates the user experience for this scenario:
Figure 1. Pay via merchant mini program
The following steps describe the user experience for this scenario:
- The consumer places an order on a merchant mini program that runs in a wallet app. The wallet that hosts the merchant mini program is automatically selected as the payment method.
- The consumer is redirected to the payment confirmation page of the wallet app to confirm the payment.
- The consumer completes the payment and is then redirected to the payment result page in the wallet app.
- The consumer returns to the merchant mini program.
Workflow
The following figure illustrates the workflow of accepting a payment with a merchant mini program:
Figure 2. Workflow of accepting a payment with merchant mini program
The payment process consists of the following steps:
- The user opens a merchant mini program and places an order (Step 1).
- The merchant mini program calls the merchant's server side and sends a request to create an order (Steps 2-3).
- The merchant's server side sends the order creation request to the ACQP and then the ACQP calls the pay API to place an order with Alipay+ (Steps 4-5).
- After placing the order, Alipay+ returns the normalUrl parameter to the ACQP, who syncs the URL to the merchant's server side. The merchant's server side returns the URL to the merchant mini program (Steps 6-8).
- With the URL, the merchant mini program invokes the my.tradePay API to initiate a payment at the MPP side. The MPP app then calls Alipay+ with the order code to obtain the order information. With the order information returned by Alipay+, the MPP app renders the cashier page where the user confirms the payment (Steps 9-12).
- After the user confirms the payment at the MPP side, the MPP completes the payment and returns my.tradePay response to the merchant mini program, and calls the notifyPayment API to notify Alipay+ of the payment result (Steps 13-16).
Procedure
- Step 1. Instruct your merchants to get onboarded to Mini Program Platform
- Step 2. Instruct your merchants to implement Cashier Payment capability
- Step 3. Accept a payment
Step 1. Instruct your merchants to get onboarded to Mini Program Platform
You need to instruct your merchants to get onboarded to Alipay+ Mini Program Platform and then build their mini programs on the platform. For more information about the onboarding process, see Merchant onboarding.
Step 2. Instruct your merchants to implement Cashier Payment capability
After your merchants have created mini programs, you need to provide instructions to help your merchants implement Cashier Payment capability. For more information about the procedure that the merchants need to follow when implementing Cashier Payment capability in their mini programs, see Cashier Payment.
Step 3. Accept a payment
This step focuses on the differences that the ACQP needs to pay attention to when accepting payments with mini-programs in comparison with other merchant platforms (App, Web, or WAP). For the complete procedure of implementing Cashier Payment on merchant platforms such as App, Web, or WAP, see Integration overview.
The differences lie in the following steps:
Consult payment method information
In the mini program scenario, you do not need to consult the payment method because the wallet that hosts the merchant mini program is used as the payment method.
Integrate the pay API
When calling the pay API in the mini program scenario, pay attention to the following differences when specifying the request parameters:
Request parameter | Merchant platform | |
App, Web, and WAP | Mini Program | |
order.env.terminalType | Specify | Specify |
paymentMethod.paymentMethodType | Specify | Specify the wallet that hosts the mini program. Valid values are:
|
After processing your request, Alipay+ returns the MPP's cashier page URL in the normalUrl parameter. You need to pass the normalUrl parameter to your merchant side for subsequent steps.