Skip to main content

Virtual Instruments

Introduction

The Virtual Instruments module exposes features for managing virtual instruments.

Virtual Instruments Service

The VirtualPaymentInstrumentService class for managing virtual instrument related operations.

Get Supported Virtual Instrument Types

Use getAccountVirtualInstrumentTypes function to retrieve the supported virtual instrument types VirtualInstrumentTypeList for the specific account.

import { Wallet } from '@paysafe/paysafe-wallet-saas-web/wallet';

const accountId = '123234';

Wallet.getInstance().getVirtualPaymentInstrumentService().getAccountVirtualInstrumentTypes(accountId)
.then(response => console.log('Virtual instrument types', response))
.catch(error => console.error('Error fetching virtual instrument types', error));

Request Virtual Instrument

Use requestVirtualInstrument function to request assignment of a new virtual instrument to existing balance account. It returns VirtualInstrumentRequestStatus object. Use VirtualInstrumentRequest to provide parameters.

import { Wallet } from '@paysafe/paysafe-wallet-saas-web/wallet';
import { VirtualInstrumentRequest } from '@paysafe/paysafe-wallet-saas-web/virtual-payment-instruments';
import { VirtualInstrumentType } from '@paysafe/paysafe-wallet-saas-web/common';

const requestBody: VirtualInstrumentRequest = {
instrumentType: VirtualInstrumentType.US_BANK_ACCOUNT,
accountId: '123234'
};

Wallet.getInstance().getVirtualPaymentInstrumentService().requestVirtualInstrument(requestBody)
.then(response => console.log('Request virtual instrument', response))
.catch(error => console.error('Error requesting virtual instrument', error));

Get Virtual Instrument Request Status

Use getVirtualInstrumentRequestStatus function to retrieve the virtual instrument request status VirtualInstrumentRequestStatus.

import { Wallet } from '@paysafe/paysafe-wallet-saas-web/wallet';

const virtualInstrumentRequestId = '5029090724';

Wallet.getInstance().getVirtualPaymentInstrumentService().getVirtualInstrumentRequestStatus(virtualInstrumentRequestId)
.then(response => console.log('Virtual instrument request status', response))
.catch(error => console.error('Error fetching virtual instrument request status', error));

Get Virtual Instrument Requests

Use getVirtualInstrumentRequests function to retrieve the virtual instrument requests list VirtualInstrumentRequestStatusList of a customer. Use VirtualInstrumentRequestsParameters to provide parameters.

import { Wallet } from '@paysafe/paysafe-wallet-saas-web/wallet';
import { VirtualInstrumentRequestsParameters } from '@paysafe/paysafe-wallet-saas-web/virtual-payment-instruments';
import { VirtualInstrumentType } from '@paysafe/paysafe-wallet-saas-web/common';

const virtualInstrumentRequestsParameters: VirtualInstrumentRequestsParameters = {
limit: 10,
offset: 0,
accountId: '123234',
instrumentType: VirtualInstrumentType.US_BANK_ACCOUNT
};

Wallet.getInstance().getVirtualPaymentInstrumentService().getVirtualInstrumentRequests(virtualInstrumentRequestsParameters)
.then(response => console.log('Virtual Instrument Requests', response))
.catch(error => console.error('Error fetching virtual instrument requests', error));

Pagination

tip

You can achieve pagination by combining the limit and offset filters. For instance, implementing pagination with a page size of 10 results per page would involve configuring:

  • Page 1: limit=10, offset=0
    const virtualInstrumentRequestsParameters: VirtualInstrumentRequestsParameters = {
    limit: 10,
    offset: 0,
    accountId: '123234',
    instrumentType: VirtualInstrumentType.US_BANK_ACCOUNT
    };
  • Page 2: limit=10, offset=10
  • Page 3: limit=10, offset=20