The SDK is available to App developers, allowing merchants to call Alipay to pay in their own apps. The integration of the SDK is including server-side and client-side.
The client mainly implements functions such as responding to user operations, calling the payment SDK, and displaying results.
The server side should implement 3 interfaces:
- To construct the request string and calculate the signature.
- To check the signature in the payment result, and query an order if it's done.
- To receive the notifications from ScanForPay to tell the payment result.
participant User User->Merchant App: 1. Click checkout button Merchant App->Merchant server: 2. Pay request Merchant server->Merchant App: 3. Retrun payment request string Merchant App->SDK: 4. pass the request string to sdk Payment Platform->User: 5. Open Wallet App to pay User->Payment Platform: 6. Finish payment SDK->Merchant App: 7.Payment callback Merchant App->Merchant server: 8.Verify result Merchant server->ScanForPay: 9.Query order ScanForPay->Merchant server: 10.Return order status Merchant server->Merchant App: 11.Return verify result Merchant App->User: 12.Display result ScanForPay-->Merchant server: 13. Notify
Step2-4: After the user places an order, the merchant needs to pass a payment request string to SDK which can be generated either on the server or the client. But the signature must be calculated on the server side, and also the signature key cannot be kept in the client.
And see the APIs description for the body data in the request string.
Step9: After receiving the callback, merchant should do the signature validationon the server side to confirm the reality of the data. And then merchant server can raise a Pay Query request to check the real status of an order.
Step13: Merchant should implement an interface to receive payment result notifications pushed by ScanForPay. More details in Notifications