WeChat Pay/Alipay
To integrate wallet payment with Direct Model, there are 3 different modes supported for different application scenarios. The corresponding response is returned by requesting with the correct paymentTerminal
value.
paymentTerminal | Usage | Description |
---|---|---|
SDK | Mobile App | Switch to the wallet app |
WAP | Mobile browser | Switch to the wallet app or present the payment webpage |
PCWEB | PC browser | Present QRCode for wallet app to scan |
Payment Result
Only paymentTerminal=SDK
will reply the payment result instantaneously back to merchant's application. Using WAP
and PCWEB
requires extra implementation for result handling.
SDK
For mobile app integration, the wallet app can be directly called out by integrating with its SDK. BBMSL will provide you with the necessary parameters through PayAPI Sale: direct/sale
. Below is the standard flow diagram and integration guideline.
Alipay
Please follow Alipay Doc to finish the SDK integration.
After getting the response from PayAPI, please call the below method to invoke the Alipay app to finish the payment.
- Swift
- Java
AlipaySDK.defaultService().payOrder(orderStr: bbmslPayApiResponse.alipayData,
fromScheme: appScheme) {(result) in
}
PayTask alipay = new PayTask(YourActivity.this);
final String result = alipay.pay(bbmslPayApiResponse.getAlipayData(), true);
WeChat Pay
Prerequisite
- Create a developer account on the WeChat Open Platform.
- Register your mobile app on the WeChat Open Platform. Please send the appId given by WeChat to BBMSL technical support.
You can integrate the SDK by following the guideline in here.
Here is the example code for calling the method to invoke WeChat Pay to finish the payment.
- Swift
- Java
let wechatOrder = bbmslPayApiResponse.wechatOrder
let request = PayReq()
request.partnerId = wechatOrder.partnerID
request.prepayId = wechatOrder.prepayID
request.package = wechatOrder.packageValue
request.nonceStr = wechatOrder.nonceStr
request.sign = wechatOrder.sign
request.timeStamp = wechatOrder.timeStamp
WXApi.send(request)
WechatOrderRes wechatOrder = bbmslPayApiResponse.getWechatOrder();
PayReq request = new PayReq();
request.appId = wechatOrder.getAppId();
request.partnerId = wechatOrder.getPartnerId();
request.prepayId = wechatOrder.getPrepayId();
request.packageValue = wechatOrder.getPackageValue();
request.nonceStr = wechatOrder.getNonceStr();
request.timeStamp = wechatOrder.getTimeStamp();
request.sign = wechatOrder.getSign();
boolean result = api.sendReq(request);
WAP
For web integration in a mobile web browser, a designated webpage from Alipay/WeChat Pay should be redirected. The wallet app will be called out directly if installed, otherwise, a webpage for sign-in and proceeding payment will be shown.
This redirection decision is already handled by the service provider so the merchant does not need to do extra workflow implementation. The flow is summarized in the following diagram,
info
The redirection behavior depends on the wallet account configuration.
Result Handling
BBSML will notify the payment success result to the merchant's notifyUrl
. Merchant needs to handle different state of result on their own by implementing mechanism like websocket, pull task, etc.
PCWEB
For web integration in a PC browser, merchant needs to display a QR code using the checkoutUrl
returned from the PayAPI.
The customer can use the wallet app to scan the QR code to proceed the payment process. As the payment process is conducted on the customer side, the merchant needs to query/wait for the payment success notification to obtain the payment result. The payment flow is shown as follows,
Result Handling
BBSML will notify the payment success result to the merchant's notifyUrl
. Merchant needs to handle different state of result on their own by implementing mechanism like websocket, pull task, etc.