Skip to main content

Transfers

Introduction

The Transfers module exposes features for managing transfers.

A transfer is the movement of funds between two wallet accounts. It allows peer-to-peer transfer to another wallet user.

TransferService

Use TransferService to manage transfers.

Preview transfer

Use preview method to create a transfer for the current customer. Transfers are created in a PREVIEW state. The operation allows checking transfer parameters and displaying the fees.

For a successful transfer, the following conditions must be met:

  • Customer should have enough balance in the requested currency
  • Recipient customer must exist in the system and must not be restricted
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));

CustomerTransferRecipient

Contains transfer recipient information. If used in CustomerTransferRequest context, the system tries to resolve email to customerId in the system. Аt least one of the two fields is required (email or customerId).

DeviceInfo

DeviceInfo contains device profiling information

TransferDetails

TransferDetails model describes transfer metadata.

TransferReason

Enumeration that represents different types of transfer reason. In the case of the customer-to-customer transfer the value is TransferReason.PEER_TRANSFER. For other possible values check TransferReason.

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