Search Overlay

Withdrawals

asdf

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()
import PaysafeWallet

let withdrawals = Wallet.instance.withdrawalService

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())
}
withdrawals.getOptions(completion: { result in
    switch result {
    case .success(let withdrawalOptions):
        // Handle withdrawalOptions
    case .failure(let error):
        // Handle error
    }
})

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.

WithdrawalRequest

Parameter Data type Description Example
amount Int Required parameter for amount of withdrawal in minor units. 100
currencyCode String Required parameter for currency of the withdrawal. Format ISO 4217. "USD"
paymentOption PaymentOptionType Required parameter for payment option of the withdrawal. PaymentOptionType.BANK_TRANSFER/.bankTransfer
paymentInstrumentReference PaymentInstrumentReference Required parameter, reference to existing verified payment instrument PaymentInstrumentReference(...)
merchantRefNum String Optional parameter for merchant reference number. "19481996"
paymentProperties List Optional parameter for additional payment option specific properties. listOf(PaymentProperty("key", "value")) / [PaymentProperty(key: "key", value: "value")]

PaymentOptionType

Enum class representing different types of payment options.

Android iOS Description
RAPID_TRANSFER .rapidTransfer Rapid transfer payment.
BANK_TRANSFER .bankTransfer Bank transfer payment.
CARD .card Payment using a card.
UNKNOWN .unknown Returned when no valid value was found.

PaymentInstrumentReference

Parameter Data type Description Example
id String Required parameter for payment instrument reference of the withdrawal. "123"
instrumentType InstrumentType Required parameter for payment instrument type of the withdrawal. InstrumentType.US_BANK_ACCOUNT/.usBankAccount

InstrumentType

Enum class representing different types of payment instruments.

Android iOS Description
CARD .card Payment card.
SEPA_BANK_ACCOUNT .sepaBankAccount SEPA bank account.
UK_BANK_ACCOUNT .ukBankAccount UK bank account.
US_BANK_ACCOUNT .usBankAccount US bank account.
UNKNOWN .unknown Returned when no valid value was found.

PaymentProperty

Parameter Data type Description Example
key String Optional parameter for key of the payment property. "key"
value String Optional parameter for value of the payment property. "value"
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())
}
let withdrawalRequest = Wallet.WithdrawalRequest(amount: 100,
                                                 currencyCode: "USD",
                                                 paymentOption: .bankTransfer,
                                                 paymentInstrumentReference: .init(id: "123",
                                                                                   instrumentType: .usBankAccount),
                                                 merchantRefNum: "19481995",
                                                 paymentProperties: nil)

withdrawals.preview(withdrawalRequest: withdrawalRequest, completion: { result in
    switch result {
    case .success(let withdrawalPreview):
        // Handle withdrawalPreview
    case .failure(let error):
        // Handle error
    }
})

Create Withdrawal

Use create method to perform the required validations and move the withdrawal in PENDING state. Pass the id from the Withdrawal object returned by the preview method.

WithdrawalCreate

Parameter Data type Description Example
id String Required parameter for id of the withdrawal. "123"
val withdrawalCreate = WithdrawalCreate(id = "123")

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

withdrawals.create(withdrawalCreate: withdrawalCreate, completion: { result in
    switch result {
    case .success(let withdrawal):
        // Handle withdrawal
    case .failure(let error):
        // Handle error
    }
})

Confirm Withdrawal

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

WithdrawalConfirm

Parameter Data type Description Example
id String Required parameter for id of the withdrawal. "123"
val withdrawalConfirm = WithdrawalConfirm(id = "123")

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

withdrawals.confirm(withdrawalConfirm: withdrawalConfirm, completion: { result in
    switch result {
    case .success(let withdrawal):
        // Handle withdrawal
    case .failure(let error):
        // Handle error
    }
})

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.

GetWithdrawalsParameters

Parameter Data type Description Example
limit Int Optional parameter for the maximum number of withdrawals to return. 10
merchantRefNum String Optional parameter for the merchant reference number of the withdraw. "19481996"
offset Int Optional parameter used to get withdraws from a specific starting point. 10
slipId String Optional parameter for payment slip id. "123"
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())
}
let getWithdrawalsParameters = Wallet.GetWithdrawalsParameters(limit: nil, 
                                                               merchantRefNum: "19481996",
                                                               offset: nil,
                                                               slipID: nil)

withdrawals.getAll(getWithdrawalsParameters: getWithdrawalsParameters, completion: { result in
    switch result {
    case .success(let withdrawals):
        // Handle withdrawals
    case .failure(let error):
        // Handle error
    }
})

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())
}
let withdrawalId = "123"

withdrawals.get(id: withdrawalId, completion: { result in
    switch result {
    case .success(let withdrawal):
        // Handle withdrawal
    case .failure(let error):
        // Handle error
    }
})
On this Page