Withdrawals
Introduction
Withdrawal module exposes features for managing withdrawals.
WithdrawalService
Use WithdrawalService
to manage withdrawals.
Get Withdrawal Options
Retrieves a list of withdrawal options. The withdrawal options are all the available withdrawal options for the user.
Payment options refer to the methods of transferring funds(e.g., CARD
, BANK_TRANSFER
),
while instrument types pertain to the specific financial tools or mechanisms used in these transactions (
e.g., SEPA_BANK_ACCOUNT
, CARD
).
import { Wallet } from '@paysafe/paysafe-wallet-saas-web/wallet';
Wallet.getInstance().getWithdrawalService().getOptions()
.then(response => console.log('Withdrawal options', response))
.catch(error => console.error('Error getting withdrawal options', error));
Preview withdrawal
Use preview
method to create a withdrawal for the current customer. Withdrawals are created in PREVIEW
state.
Withdrawals are created in a PREVIEW
state.
The operation allows to check withdrawal parameters and display the fees.
WithdrawalRequest
Parameter | Data type | Description | Example |
---|---|---|---|
amount | number | 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. | PaymentOption.US_BANK_ACCOUNT |
paymentInstrumentReference | PaymentInstrumentReference | Required parameter, reference to existing verified payment instrument | { instrumentType: InstrumentType.US_BANK_ACCOUNT, id: '1234567890' } |
merchantRefNum | string | Optional parameter for merchant reference number. | '19481996' |
paymentProperties | PaymentProperty[] | Optional parameter for additional payment option specific properties. | [{ key: 'key',value: 'value' }] |
PaymentOptionType
Enumeration that represents different types of payment options.
TypeScript possible values | JavaScript possible values | Description |
---|---|---|
PaymentOptionType.RAPID_TRANSFER |
'RAPID_TRANSFER' |
Rapid transfer. |
PaymentOptionType.BANK_TRANSFER |
'BANK_TRANSFER' |
Bank transfer. |
PaymentOptionType.CARD |
'CARD' |
Card. |
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. | CARD |
InstrumentType
Enumeration that represents different types of payment options.
TypeScript possible values | JavaScript possible values | Description |
---|---|---|
InstrumentType.SEPA_BANK_ACCOUNT |
'SEPA_BANK_ACCOUNT' |
SEPA bank account. |
InstrumentType.UK_BANK_ACCOUNT |
'UK_BANK_ACCOUNT' |
UK bank account. |
InstrumentType.US_BANK_ACCOUNT |
'US_BANK_ACCOUNT' |
US bank account. |
InstrumentType.CARD |
'CARD' |
Payment card. |
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' |
import { Wallet } from '@paysafe/paysafe-wallet-saas-web/wallet';
import { WithdrawalRequest } from '@paysafe/paysafe-wallet-saas-web/withdrawals';
import { PaymentInstrumentReference } from '@paysafe/paysafe-wallet-saas-web/payment-instruments';
import { InstrumentType } from '@paysafe/paysafe-wallet-saas-web/common';
const withdrawalRequest: WithdrawalRequest = {
amount: 1000,
currencyCode: 'USD',
paymentOption: PaymentOption.BANK_TRANSFER,
paymentInstrumentReference: {
instrumentType: InstrumentType.US_BANK_ACCOUNT,
id: '1234567890'
}
}
Wallet.getInstance().getWithdrawalService().preview(withdrawalRequest)
.then(response => console.log('Create withdrawal preview', response))
.catch(error => console.error('Error create withdrawal preview', 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' |
import { Wallet } from '@paysafe/paysafe-wallet-saas-web/wallet';
import { WithdrawalCreate } from '@paysafe/paysafe-wallet-saas-web/withdrawals';
const requestBody: WithdrawalCreate = {
id: '1234567890'
}
Wallet.getInstance().getWithdrawalService().create(requestBody)
.then(response => console.log('Create withdrawal', response))
.catch(error => console.error('Error create withdrawal', 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' |
import { Wallet } from '@paysafe/paysafe-wallet-saas-web/wallet';
import { WithdrawalConfirm } from '@paysafe/paysafe-wallet-saas-web/withdrawals';
const requestBody: WithdrawalConfirm = {
id: '1234567890'
}
Wallet.getInstance().getWithdrawalService().create(requestBody)
.then(response => console.log('Confirm withdrawal', response))
.catch(error => console.error('Error confirm withdrawal', error));
Get Withdrawals
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.
WithdrawalParameters
Parameter | Data type | Description | Example |
---|---|---|---|
limit | number | Optional parameter for the maximum number of withdraws to return. | 10 |
merchantRefNum | string | Optional parameter for the merchant reference number of the withdraw. | '19481996' |
offset | number | Optional parameter used to get withdraws from a specific starting point. | 10 |
slipId | string | Optional parameter for payment slip id. | '123' |
import { Wallet } from '@paysafe/paysafe-wallet-saas-web/wallet';
import { WithdrawalParameters } from '@paysafe/paysafe-wallet-saas-web/withdrawals';
const getWithdrawalsParameters: GetWithdrawalsParameters = {
offset: 10,
limit: 10,
merchantRefNum: '1234567890',
slipId: '1234567890',
}
Wallet.getInstance().getWithdrawalService().getAll(getWithdrawalsParameters)
.then(response => console.log('Get all withdrawal', response))
.catch(error => console.error('Error get all withdrawal', error));
Get Withdrawal
Retrieves the withdrawal by passing the id of the withdrawal.
import { Wallet } from '@paysafe/paysafe-wallet-saas-web/wallet';
const withdrawalId = '1234567890';
Wallet.getInstance().getWithdrawalService().get(withdrawalId)
.then(response => console.log('Get withdrawal', response))
.catch(error => console.error('Error get withdrawal', error));