Transfers
Introduction
The Transfers module exposes features for managing transfers.
A transfer is the movement of funds between two wallet accounts. It allows for peer-to-peer transfers as well as the exchange of funds between customer accounts if multi-currency is supported.
The transfer resource goes through several stages before the transaction is complete. Please refer to the statuses
enumeration for further details.
Transfer Service
The TransferService
can be used for managing transfers.
A transfer goes through several stages before its completion.
Preview transfer
Preview is always the first step in creating a transfer and as such the transfer is created in a PREVIEW
state. At this point there is no transaction and the operation's primary function is to check transfer parameters and display the fees.
Use the preview
method to create a transfer for the current customer:
import { Wallet } from '@paysafe/paysafe-wallet-saas-web/wallet';
import { TransferReason } from '@paysafe/paysafe-wallet-saas-web/common';
import { CustomerTransferRequest } from '@paysafe/paysafe-wallet-saas-web/transfers';
const transferPreviewRequest: CustomerTransferRequest = {
amount: 1000,
currencyCode: 'USD',
recipient: {
email: 'jon.doe@paysafe.com'
},
transferDetails: {
reason: TransferReason.PEER_TRANSFER,
description: 'This is transfer request!'
}
};
Wallet.getInstance().getTransferService().preview(transferPreviewRequest)
.then(response => console.log('Create transfer preview', response))
.catch(error => console.error('Error create transfer preview', error));
Create Transfer
Use create
method to perform the required validations and move the transfer to PENDING
state.
Pass the id
from the CustomerTransfer
object returned by the preview
method.
import { Wallet } from '@paysafe/paysafe-wallet-saas-web/wallet';
import { TransferCreate } from '@paysafe/paysafe-wallet-saas-web/transfers';
const requestBody: TransferCreate = {
id: '1234567890'
}
Wallet.getInstance().getTransferService().create(requestBody)
.then(response => console.log('Create transfer', response))
.catch(error => console.error('Error create transfer', error));
Confirm Transfer
Use confirm
method to confirm the transfer. Pass the id
from the CustomerTransfer
object returned by the create
method.
import { Wallet } from '@paysafe/paysafe-wallet-saas-web/wallet';
import { TransferConfirm } from '@paysafe/paysafe-wallet-saas-web/transfers';
const requestBody: TransferConfirm = {
id: '1234567890'
}
Wallet.getInstance().getTransferService().confirm(requestBody)
.then(response => console.log('Confirm transfer', response))
.catch(error => console.error('Error confirm transfer', error));
Get Transfers
Use getAll
method to retrieve a list of transfers by passing the GetTransferParameters
.
If no parameters are passed, it will return the last 10 transfers by default.
import { Wallet } from '@paysafe/paysafe-wallet-saas-web/wallet';
import { GetTransferParameters } from '@paysafe/paysafe-wallet-saas-web/transfers';
const getTransferParameters: GetTransferParameters = {
offset: 10,
limit: 10,
merchantRefNum: '1234567890',
slipId: '1234567890',
}
Wallet.getInstance().getTransferService().getAll(getTransferParameters)
.then(response => console.log('Get all transfers', response))
.catch(error => console.error('Error get all transfers', error));
Get Transfer
To retrieve transfer by id use get
method.
import { Wallet } from '@paysafe/paysafe-wallet-saas-web/wallet';
const transferId = '1234567890';
Wallet.getInstance().getTransferService().get(transferId)
.then(response => console.log('Get get transfer', response))
.catch(error => console.error('Error get transfer', error));
Request Parameter Clarification
CustomerTransferRecipient
Contains transfer recipient information. If used in CustomerTransferRequest
context, the system tries to resolve email
or mobile
to customerId
in the system. At least one of the three identifiers is required.
DeviceInfo
The DeviceInfo
contains device profiling information.
TransferDetails
The RequestTransferDetails
model describes transfer metadata.