Skip to main content

Withdrawals

Introduction

The Withdrawal service exposes features for managing withdrawals:

  • Get Withdrawal Options
  • Preview, Create and Confirm a Withdrawal
  • Get Withdrawals List
  • Get Single Withdrawal

Use the following code to obtain an instance of WithdrawalService:

val withdrawals = Wallet.getInstance().getWithdrawalService()

Get Withdrawal Options

Use getOptions method to retrieve a list of all available withdrawal options for the customer.

Withdraw options refer to the methods of transferring funds (e.g., bank cards or bank accounts), while instrument types pertain to the specific financial tools or mechanisms used in these transactions (e.g., a concrete bank card or account).

try {
val withdrawalOptions: List<PaymentOptionDetails> = withdrawals.getOptions()
Log.d(TAG, withdrawalOptions.toString())
} catch (exception: Exception) {
Log.d(TAG, exception.toString())
}

Get Withdrawals List

Use getAll method to retrieve a list of withdrawals by passing the GetWithdrawalsParameters. If no parameters are passed, it will return the last 10 withdrawals by default.

val getWithdrawalsParameters = GetWithdrawalsParameters(
limit = 10,
merchantRefNum = "19481996",
offset = 10,
slipId = "123"
)

try {
val result = withdrawals.getAll(getWithdrawalsParameters)
Log.d(TAG, result.toString())
} catch (exception: Exception) {
Log.d(TAG, exception.toString())
}

Get Single Withdrawal

Use get method to retrieve a withdrawal by passing its id.

val withdrawalId = "123"

try {
val withdrawal = withdrawals.get(withdrawalId)
Log.d(TAG, withdrawal.toString())
} catch (exception: Exception) {
Log.d(TAG, exception.toString())
}

Preview Withdrawal

Use preview method to create a withdrawal for the current customer. Withdrawals are created in PREVIEW state. Withdrawals in PREVIEW state do not create actual transaction in Paysafe Wallet system. It allows to check withdrawal parameters and display the fees.

To initiate withdrawal you should use WithdrawalRequest object.

val withdrawalRequest = WithdrawalRequest(
amount = 100,
currencyCode = "USD",
paymentOption = PaymentOptionType.BANK_TRANSFER,
paymentInstrumentReference = PaymentInstrumentReference(
id = "123",
instrumentType = InstrumentType.US_BANK_ACCOUNT
),
merchantRefNum = "19481996",
paymentProperties = null
)

try {
val withdrawalPreview = withdrawals.preview(withdrawalRequest)
Log.d(TAG, withdrawalPreview.toString())
} catch (exception: Exception) {
Log.d(TAG, exception.toString())
}

Create Withdrawal

Use create method to perform the required validations and move the withdrawal in PENDING state.

Use WithdrawalCreate object to create the withdrawal. Pass the id from the Withdrawal object returned by the preview method.

val withdrawalCreate = WithdrawalCreate(id = "123")

try {
val withdrawal = withdrawals.create(withdrawalCreate)
Log.d(TAG, withdrawal.toString())
} catch (exception: Exception) {
Log.d(TAG, exception.toString())
}

Confirm Withdrawal

Use confirm method to confirm the withdrawal.

info

This operation might require Strong Customer Authentication (SCA). Please read Strong Customer Authentication for more information on the process.

note

If the Withdrawal object returned by confirm has action: PaymentCompletionAction.SCA, the scaDetails will contain the SCA authentication properties needed to complete the process. Follow the steps outlined in Submit the SCA Authentication to confirm the event. After the SCA event is accepted, invoke confirm method again, providing scaDetails in the WithdrawalConfirm parameter.

Use WithdrawalConfirm object to create the withdrawal. Pass the id from the Withdrawal object returned by the create method.

val withdrawalConfirm = WithdrawalConfirm(id = "123")

try {
val withdrawal = withdrawals.confirm(withdrawalConfirm)
Log.d(TAG, withdrawal.toString())
} catch (exception: Exception) {
Log.d(TAG, exception.toString())
}