Apple Pay/Google Pay
BBMSL Online Payment Service supports Apple Pay in iOS apps and Google Pay in Android apps. You can process wallet payments in a native way without calling the Hosted Checkout Page. Before starting the integration, you need to register your app in Apple Developer Portal and Google Play Console.
- You need to subscribe to the Apple Developer Programme before you start integrating Apple Pay with the direct model.
- Follow here to create a merchant identifier.
- Pass the
Merchant Identifierto your relationship manager, BBMSL will return a
.csrfile for uploading to the Apple Pay Payment Processing Certificate section.
By integrating with Apple PayKit, Apple Pay gathers the tokenized payment card data for you by requesting the customer's authorization. Merchants will then pass the data to the PayAPI for processing the payment. The diagram below gives an idea of how the system works on Apple Pay.
Before implementation, you have to first enable the Apple Pay Capability in your Xcode project. The available merchant identifiers will be shown by clicking the refresh button, and you should check the one you passed to BBMSL.
A sample app is provided by Apple here for referencing the implementation of Apple Pay. In this section, we will focus on the details for integrating to BBMSL Online Payment Service.
Before requesting for payment, the app should check if the customers' iOS device supported Apple Pay or have Apple Pay set up. If yes, you may show the button to start the payment, or ask the customers to set up Apple Pay otherwise. Note that you need to handle the button layout constraint by yourselves.
After that, you can follow the demo above to construct a payment request containing all the information about your payment, and use the following code to present the payment view controller once the button is pressed,
You must register the delegate by
paymentController?.delegate = self to receive the payment result callback later.
When the user authorizes the payment, the system calls the following handler to return the payment card data, and you need to pass the payment data to BBMSL through the PayAPI Auth.
If the PayAPI response with
responseCode == "0000", meaning your payment is succeeded and completed until this step.
A sample code for parsing the Apple Pay payment data and requesting PayAPI is attached below for reference.
For Apple Pay, you must request the PayAPI before you call the completion block, as the result will be reflected on the UI to customers to indicate the payment result.
Once the completion block is called in the previous step, the system calls another handler to let the app know that the view controller can be dismissed,
The merchant should also handle the result by navigating to another view in the app, otherwise, the app will stay on the same page and customers can proceed with the same payment again.
Please contact your relationship manager for a
Similarly to Apple Pay, the Google Pay API collects customers' payment data securely for you, by submitting the payment data to BBMSL, the payment can proceed immediately. Below is a flow diagram of using Google Pay in an Android app.
Google has provided a demo app here to guide you through the whole implementation. Before you start, you have to configure your app by following instruction here.
To request the payment, a payment token for encrypting the customer's card data needs to be defined by using the provided
gatewayMerchantId with the following code,
BBMSL Online Payment Service uses Worldpay as the payment service provider for Google Pay. You must fill in
worldpay for the value of
Also, you have to define the supported card network and auth methods,
To request payment, a request object containing all the information is needed to present the payment activity. The payment process is an Async process, the
LOAD_PAYMENT_DATA_REQUEST_CODE can be used to get the result in the callback later.
Below is some reference code quoted from the sample app for requesting payment,
The payment data and result can be found in the
If the payment attempt is succeeded with
resultCode == RESULT_OK, the payment data can be collected and then send to BBMSL through the PayAPI Auth.
If the PayAPI response with
responseCode == "0000", meaning your payment is completed.
A sample code of parsing the Google Pay
paymentData and requesting PayAPI is attached below for reference.
The sample code used Retrofit library for HTTP request, but any other libraries will do the same.
Parsing Google Pay Payment Data
paymentData.paymentMethodData.tokenizationData.token is returned as JSON string from Google Pay API, you have to parse it to JSON object to retrieve the JSON value before posting to the PayAPI.
Different from Apple Pay, Google Pay dismisses the payment view when the payment data is successfully obtained, merchants need to handle the payment failed scenarios by the app UI.