Skip to main content

WeChat Pay/Alipay

To integrate wallet payment with the Direct Model, three terminal modes are supported for different application scenarios. Pass the correct paymentTerminal value to receive the appropriate response.

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 returns the payment result synchronously to your application. For WAP and PCWEB, you must implement an asynchronous result-handling mechanism.

SDK​

What you do: Call PayAPI Sale: direct/sale to receive the wallet-specific parameters from BBMSL, then invoke the wallet SDK to complete the payment.

Expected result: The wallet SDK processes the payment and returns the result directly to your application.

Next step: Handle the result in your application workflow.

For mobile app integration, the wallet app is called directly using its SDK. The standard flow is shown in the diagram below.

Docusaurus

Alipay​

Please follow Alipay Doc to finish the SDK integration.

After receiving the response from PayAPI, call the method below to invoke the Alipay app and 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 and send the appId provided by WeChat to BBMSL technical support.

Integrate the SDK by following the guidelines here.

Call the method below to invoke WeChat Pay and complete 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​

What you do: Use the checkoutUrl returned by PayAPI Sale to redirect the customer in a mobile web browser. The wallet app is launched if installed; otherwise, a sign-in and payment webpage is shown.

Expected result: The wallet service provider handles the redirection decision. BBMSL sends the payment result to your notifyUrl.

Next step: Implement an asynchronous result-handling mechanism (for example, a websocket or polling task) to receive and process the payment result. See Result Notification for details.

The flow is summarized in the diagram below.

Docusaurus

info

The redirection behavior depends on the wallet account configuration.

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.