Search Overlay

Saved Cards Integration

The Paysafe Android SDK's Saved Cards functionality allows customers to complete payments faster using a saved card from their customer profile.

Saving a card to the Customer profile

After successfully generating a single-use payment handle for a card payment method using Paysafe.js, you have the option to add it to a customer profile based on the customer's intentions.

Tokenize with optional fields

If the consumer wishes to pay with a new card, you can render the card number and expiry date fields. They will become required if the singleUseCustomerToken and paymentTokenFrom are not passed on tokenize function call. 

Based on your intentions the CVV field can be the only field set, if needed. 

If the consumer already has a profile created in the Payments API, and there are cards associated with this profile, you can use Paysafe.js to tokenize a selected saved card by passing a single-use customer token and single-use payment handle to the tokenize function. A single-Use Customer Token is a temporary token representing the customer's profile. It is used to prevent exposing the customer id and multi-use payment token at the front end. A single-use payment handle is a temporary token representing the card details of the customer, located in the paymentHandles object from the response of the single-use customer token creation. If the consumer's profile contains multiple cards, you must pass the correct single-use payment handle based on the customer's intentions. 

Before you perform tokenization, complete these steps:

  1. Create a single-use customer token on your back-end server. 
  2. Retrieve the singleUseCustomerToken and the selected card paymentHandleToken from the response.
  3. Send both tokens to their front-end. 
  4. Pass them to the tokenize function using the singleUseCustomerToken and paymentTokenFrom parameters in the options object.

Usage example

/// Payment amount in minor units
let amount = totalPrice * 100
let options = PSCardTokenizeOptions(
amount = amount,
currencyCode = "USD",
transactionType = TransactionType.PAYMENT,
merchantRefNum = PaysafeSDK.getMerchantReferenceNumber(),
billingDetails = BillingDetails(
nickName = "Jax Billing Address",
street = "5335 Gate Pkwy",
city = "Jacksonville",
state = "FL",
country = "US",
zip = "32256"
),
profile = Profile(
firstName = "firstName",
lastName = "lastName",
locale = ProfileLocale.EN_GB,
dateOfBirth = DateOfBirth(
day = 1,
month = 1,
year = 1990
),
email = "john.doe@paysafe.com",
phone = "18003270093"
),
accountId = Consts.CARDS_ACCOUNT_ID,
merchantDescriptor = MerchantDescriptor(
dynamicDescriptor = "dynamicDescriptor",
phone = "18003270093"
),
shippingDetails = ShippingDetails(
shipMethod = ShippingMethod.NEXT_DAY_OR_OVERNIGHT,
street = "5335 Gate Pkwy",
street2 = "5335 Gate Pkwy",
city = "Jacksonville",
state = "FL",
countryCode = "US",
zip = "32256",
),
singleUseCustomerToken = "<singleUseCustomerToken>",
paymentHandleTokenFrom = "<paymentHandleTokenFrom>",
renderType = RenderType.BOTH,
threeDS = ThreeDS(
merchantUrl = "<merchantUrl>",
"deviceChannel": "BROWSER",
"messageCategory": "PAYMENT",
"authenticationPurpose": "PAYMENT_TRANSACTION"
)
)

cardController?.tokenize(this, cardTokenizeOptions, object : PSResultCallback<PaymentHandle> {
override fun onSuccess(value: PaymentHandle?) {
// do something with result
}

override fun onFailure(exception: Exception) {
// do something with exception
}
})