Skip to main content

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.

paymentTerminalUsageDescription
SDKMobile AppSwitch to the wallet app
WAPMobile browserSwitch to the wallet app or present the payment webpage
PCWEBPC browserPresent 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.

Docusaurus

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.

AlipaySDK.defaultService().payOrder(orderStr: bbmslPayApiResponse.alipayData,
  fromScheme: appScheme) {(result) in

}

WeChat Pay

Prerequisite
  1. Create a developer account on the WeChat Open Platform.
  2. 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.

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)

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,

Docusaurus

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,

Docusaurus

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.