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

KOTLIN
suspend fun startPaymentFlow(vaultedPaymentMethodId: String): Result<Unit>

Parameters

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.

KOTLIN
suspend fun startPaymentFlow(
    vaultedPaymentMethodId: String,
    additionalData: PrimerVaultedPaymentMethodAdditionalData
): Result<Unit>

Parameters

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.

Example

Refer to the following example for fetching vaulted payment methods.

Without additional data

KOTLIN
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
    }
  }
}

With additional data

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

KOTLIN
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
    }
  }
}