Skip to main content

Withdrawals

Introduction

Withdrawal module exposes features for managing withdrawals.

Withdrawal Service

The WithdrawalService can be used for managing withdrawals related operations.

Get Withdrawal Options

Use getOptions to retrieve WithdrawalOption[]. 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 a PREVIEW state. The operation allows to check withdrawal parameters and display the fees.

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.

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.

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.

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

Use get to retrieve withdrawal by id.

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));