Skip to main content

Payment Adapter Methods

Available methods for Payment Adapter.

Method

Argument(s)

Return Type

Description

Constructor()

config: PaymentDeviceConfig

N/A

Constructor

setAdapter()

ConnectionAdapter

void

Setter for adapter field

getAdapter()

N/A

ConnectionAdapter

Getter for adapter field

getAvailableFeatures()

N/A

DeviceFeatures

Returns a list of available features for the payment device

getTimouts()

N/A

Promise<Timeouts>

Returns operation timeouts

open()

N/A

Promise<void>

Opens connection to the Device. Mostly invokes this.adapter.open(). Returns Promise that resolves when operation completes.

initSession()

data: number (nullable)

Promise<void>

Initializes the device. Data argument is a code for pairing if required. Is invoked before each operation. Returns Promise resolves when operation completes.

batchReport()

param: { timeout: number }

Promise<BatchReportObject>

Triggers batch report. Returns Promise that resolves when operation completes.

closeConnection()

N/A

Promise<void>

Closes connection to the device. Is a wrapper for the close method. Returns Promise that is resolved when operation is completed. Returned Promise resolves true when connection is closed with no error, otherwise resolves as false.

safReport()

param: { safRecordIds?: string[]; timeout: number }

Promise<Transaction[]>

Returns SaF Report (Store and Forward). Error is thrown if timeout was exceeded. new Error(`Timeout happened during operation ${name}`). Argument is an object for two fields: -  safRecordIds: string Array, optional, transaction IDs for which SaF Report is needed. -  timeout: number, timeout in seconds for this operation.

historyReport()

param: {dateStart: string; dateEnd: string; timeout: number}

Promise<BatchReportObject>

Specific to Verifone. Only only invoked if DeviceFeatures.BATCH_SCHEDULE returns true.

close()

dropConnection: boolean

noNeedToClose: boolean

Promise<void>

Closes connection to device. Argument dropConnection: close connection is true; do not close otherwise. Argument noNeedToClose: do not close socket from POS-APP side, external socket close expected.

isConnected()

N/A

Promise<boolean>

Returns boolean if the device is in an open state.

getTransactionInfo

param: { posTransactionId: string; timeout: number }

Promise<Transaction>

Returns Transaction for requested Transaction ID.

isSAFUploadOK(safResult: SAFUploadObject | SAFReportObject)

safResult: SAFUploadObject

boolean

Returns true if safResult.transactionStatus is true.

endOfDay()

N/A

Promise<BatchSettleObject>

Performs BATCH_CLOSE command on device.

cancelTransaction()

N/A

Promise<boolean>

Sends cancel transaction request, if available. Otherwise resolves as true.

orderStart()

orderNumber: string

Promise<void>

For devices that work with "order start", "open lane" or similar flow. Is invoked before each operation that requires the last four digits of the POS-APP Order number for the orderNumber argument.

orderFinish()

N/A

Promise<void>

For devices that work with "order start", "open lane" or similar flow. Is invoked after each operation that requires orderStart.

checkConfiguration(): any;

N/A

Promise<boolean>

Specific to Verifone. Checks if POS-APP is paired with Verifone. For other devices performs device.ping.

makeDeviceTransactionType()

paymentType: string

string

Defines required transaction type for payment type, transaction type and base transaction type.

Example: payment type 'GIFT', transaction type 'VOID_TRANS' and base transaction type 'ACTIVATE' methods may return 'DEACTIVATE' instead of 'VOID_TRANS', or 'ADD_VALUE' instead of 'REFUND' for 'GIFT'.

batch()

param: {timeout: number}

Promise<BatchSettleObject>

Triggers batch close on device.

safUpload()

param: {safRecordIds: string[]}

Promise<SAFUploadObject>

Triggers uploading stored (SaF) transactions. If SaF is not supported returns stub object: return Promise.resolve({ transactionStatus: true, resultCode: '0', resultText: 'OK', uploadedCount: 0, uploadedAmount: 0, pendingCount: 0, pendingAmount: 0, failedCount: 0, failedAmount: 0, transactions: [], });

on()

event: string

listener: Function

void

Is the same as node.js EventEmitter.on(). There are the following subscriptions in POS-APP: 'data', 'status', 'error', 'log' (and 'updateEntryCode' for Verifone).