Starts the payment flow for the vaulted payment method. You can get the id from any instance of PrimerVaultedPaymentMethod returned by fetchVaultedPaymentMethods.

Upon a successful invocation of this function, the SDK will automatically trigger the standard payment callbacks.

Without additional data

1
suspend fun startPaymentFlow(vaultedPaymentMethodId: String): Result<Unit>
kotlin
copy

Parameters

The id of a PrimerVaultedPaymentMethod previously retrieved with fetchVaultedPaymentMethods.

With additional data

In certain cases, you can pass additional data when starting a payment flow. For example, you might need to pass CVV which can be recommended to increase auth rates.

Make sure that additionalData is validated before being passed to this method.

1234
suspend fun startPaymentFlow(    vaultedPaymentMethodId: String,    additionalData: PrimerVaultedPaymentMethodAdditionalData): Result<Unit>
kotlin
copy

Parameters

The id of a PrimerVaultedPaymentMethod previously retrieved with fetchVaultedPaymentMethods.

additionalData
PrimerVaultedPaymentMethodAdditionalDataRequired
direct subclasses
Properties
cvv
StringRequired
CVV value associated with the vaulted card.

Returns

The startPaymentFlow method initiates the payment process using the provided vaultedPaymentMethodId. This method is responsible for beginning the payment flow associated with a specific payment method stored in the vault. Returns a result object of type Result.

The Result class represents the outcome of the operation, indicating success or failure.

By inspecting the returned Result object, you can determine the success or failure of the starting payment process for the vaulted payment method. This allows you to handle different scenarios based on the result.

In case of successful operation result, SDK will return Unit.

In case of unsuccessful operation result, as part of Result object SDK will return:

In case the id passed does not match any payment method previously retrieved by fetchVaultedPaymentMethods.

Example

Refer to the following example for fetching vaulted payment methods.

Without additional data

123456789101112
private fun startPaymentFlow(  vaultedPaymentMethodId: String,) {  // 👇 start payment flow calling suspend function within the scope  scope.launch {    vaultManager.startPaymentFlow(vaultedPaymentMethodId).onSuccess {      // listen to SDK callbacks    }.onFailure { throwable ->      // handle error    }  }}
kotlin
copy

With additional data

Refer to the following example for validation of the vaulted payment method additional data.

12345678910111213
private fun startPaymentFlow(  vaultedPaymentMethodId: String,  additionalData: PrimerVaultedPaymentMethodAdditionalData) {  // 👇 start payment flow calling suspend function within the scope  scope.launch {    vaultManager.startPaymentFlow(vaultedPaymentMethodId, additionalData).onSuccess {      // listen to SDK callbacks    }.onFailure { throwable ->      // handle error    }  }}
kotlin
copy