Payment Methods
The SDK supports card, Apple Pay and Google Pay payments. The flow is the same for each — only the function that starts the payment differs.
Available payment methods
- Card
- Apple Pay
- Google Pay
Initiating and completing a payment
These steps are the same for every available payment method — the only difference is the function that starts the payment.
1. Create the PaymentConfig
See Payment Setup.
2. Initiate the PaymentProcessor
3. Let the user input their card details
4. Start the payment process
Launch the relevant function of the PaymentProcessor to begin the payment:
Card
paymentProcessor.processCardPayment(billingAddress: customerBillingAddress)paymentProcessor?.processCardPayment(billingAddress: customerBillingAddress)Apple Pay
paymentProcessor?.processApplePayPayment(appleMerchantId: applePayMerchantId, billingAddress: customerBillingAddress)Google Pay
paymentProcessor.processGooglePayPayment(billingAddress: customerBillingAddress)Good to know
While we do not impose any guideline for creating the normal payment button (pay by card), we strongly recommend handling its state properly. For example, when the user presses the button to pay with the card, make sure the UI updates after the click to inform them that something is happening — a loading indicator, the button becoming disabled, and so on. Design your payment flow with good UX: make sure the user knows at all times what stage they are at.
5. Wait for the payment result
6. Interpret the payment result
The callback returns a Status object of one of the following types:
| Status | Description |
|---|---|
Success | The payment was successful. |
Canceled | The user cancelled the payment process. This usually happens when the user cancels the Google Pay or Apple Pay dialog before completing. |
SessionExpired | The authentication token has expired. This happens if the payment session is left open for longer than the expiration time of the token (3 hours). |
Error | The payment failed. The object has two extra values that can be accessed to identify the issue: status.message and status.traceId. The traceId can be used as a debugging aid by us if the payment finished with an unexpected error. |
Status.Canceled can be used to inform the user that they cancelled the process for that payment method (only for Google Pay and Apple Pay) and ask whether they still want to continue with the same or a different payment method in the same session.Verify a new card
A verify card session is a special payment session where no amount is deducted from the cardholder. It can be used to pre-verify a card’s validity before a transaction, or to save a card to a customer without making a payment.
To save a card using a verify session:
- The customer details are necessary
- A
clientTokenwith the MOBILE_CUSTOMER_PAYMENT scope enabled - The Save Card toggle UI must be added and enabled — or create your own by calling the following from your UI element
paymentProcessor.processVerifyCard(billingAddress)You create a new verify card session by providing the PaymentConfig with a TransactionDetails object whose amount is set to null.
val paymentConfig = PaymentConfig(
installationId = installationId,
countryCode = countryCode,
currencyCode = currency,
transactionType = TransactionType.PAYMENT, // <-- keep transaction type as payment
clientToken = authToken,
transaction = TransactionDetails(
amount = null, // <-- amount set to null
currency = currency,
merchantRef = merchantRef,
),
customer = customerDetails,
financialServices = financialServices,
environment = environment
)