AmeriaClient
Defined in: src/client.ts:105
Client for the Ameriabank vPOS REST API.
Example
Section titled “Example”import { AmeriaClient } from "@ameria/vpos-sdk";
const ameria = new AmeriaClient({ clientId: process.env.AMERIA_CLIENT_ID!, username: process.env.AMERIA_USERNAME!, password: process.env.AMERIA_PASSWORD!, isTest: true,});Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new AmeriaClient(
params):AmeriaClient
Defined in: src/client.ts:116
Parameters
Section titled “Parameters”params
Section titled “params”Returns
Section titled “Returns”AmeriaClient
Properties
Section titled “Properties”
readonlyhost:string
Defined in: src/client.ts:114
Base URL of the bank API this client talks to.
Accessors
Section titled “Accessors”clientId
Section titled “clientId”Get Signature
Section titled “Get Signature”get clientId():
string
Defined in: src/client.ts:131
The client ID this client was created with.
Returns
Section titled “Returns”string
Methods
Section titled “Methods”getUrl()
Section titled “getUrl()”getUrl(
paymentId,lang?):string
Defined in: src/client.ts:168
Build the bank’s payment page URL for a payment ID.
AmeriaClient.initPayment already returns it as url.
Parameters
Section titled “Parameters”paymentId
Section titled “paymentId”string
"en" | "am" | "hy" | "ru"
Returns
Section titled “Returns”string
initPayment()
Section titled “initPayment()”initPayment(
params):Promise<InitPaymentResponse&object>
Defined in: src/client.ts:186
Register a payment and get the URL of the bank’s card page.
Redirect the payer to url. After paying they come back to backUrl;
that redirect is not signed, so confirm the result with
AmeriaClient.verifyPayment before fulfilling the order.
Parameters
Section titled “Parameters”params
Section titled “params”Returns
Section titled “Returns”Promise<InitPaymentResponse & object>
The bank’s response plus url, which is null unless
ResponseCode is 1.
getPaymentId()
Section titled “getPaymentId()”getPaymentId(
orderId):Promise<GetPaymentIdResponse>
Defined in: src/client.ts:209
Look up the bank’s payment ID for one of your order IDs.
Parameters
Section titled “Parameters”orderId
Section titled “orderId”string | number
Returns
Section titled “Returns”Promise<GetPaymentIdResponse>
confirmPayment()
Section titled “confirmPayment()”confirmPayment(
paymentId,amount):Promise<ConfirmPaymentResponse>
Defined in: src/client.ts:218
Deposit a payment that was only approved (two-step payments).
Parameters
Section titled “Parameters”paymentId
Section titled “paymentId”string
amount
Section titled “amount”number
Amount to deposit; up to the approved amount.
Returns
Section titled “Returns”Promise<ConfirmPaymentResponse>
getPaymentDetails()
Section titled “getPaymentDetails()”getPaymentDetails(
paymentId):Promise<PaymentDetailsResponse>
Defined in: src/client.ts:231
Get the raw status and details of a payment. To decide whether to fulfil an order, prefer AmeriaClient.verifyPayment.
Parameters
Section titled “Parameters”paymentId
Section titled “paymentId”string
Returns
Section titled “Returns”Promise<PaymentDetailsResponse>
verifyPayment()
Section titled “verifyPayment()”verifyPayment(
paymentId,expected):Promise<PaymentVerification>
Defined in: src/client.ts:255
Ask the bank whether a payment really succeeded for the amount you
expect. Use it when the payer comes back to your backUrl: that
redirect is not signed and can be forged.
paid is true only if the bank approved the payment, the amount,
currency and order ID match what you expect, the money was deposited
(or, with twoStep, approved) and nothing was refunded.
Parameters
Section titled “Parameters”paymentId
Section titled “paymentId”string
expected
Section titled “expected”Returns
Section titled “Returns”Promise<PaymentVerification>
Example
Section titled “Example”const { paid, reason } = await ameria.verifyPayment(paymentId, { amount: order.total, currency: "AMD", orderId: order.id,});if (paid) await fulfil(order);getPendingTransactions()
Section titled “getPendingTransactions()”getPendingTransactions(
params):Promise<GetPendingTransactionsResponse>
Defined in: src/client.ts:289
List transactions that were started but not completed in a date range.
Parameters
Section titled “Parameters”params
Section titled “params”Returns
Section titled “Returns”Promise<GetPendingTransactionsResponse>
refundPayment()
Section titled “refundPayment()”refundPayment(
paymentId,amount):Promise<RefundPaymentResponse>
Defined in: src/client.ts:303
Refund a completed payment, fully or partly.
Parameters
Section titled “Parameters”paymentId
Section titled “paymentId”string
amount
Section titled “amount”number
Amount to refund; up to the deposited amount.
Returns
Section titled “Returns”Promise<RefundPaymentResponse>
cancelPayment()
Section titled “cancelPayment()”cancelPayment(
paymentId):Promise<CancelPaymentResponse>
Defined in: src/client.ts:316
Cancel (reverse) a payment. For two-step payments this releases an approved amount that was never confirmed.
Parameters
Section titled “Parameters”paymentId
Section titled “paymentId”string
Returns
Section titled “Returns”Promise<CancelPaymentResponse>
getBindings()
Section titled “getBindings()”getBindings(
paymentType):Promise<GetBindingsResponse>
Defined in: src/client.ts:322
List the saved cards (bindings) of your merchant account.
Parameters
Section titled “Parameters”paymentType
Section titled “paymentType”Returns
Section titled “Returns”Promise<GetBindingsResponse>
activateBinding()
Section titled “activateBinding()”activateBinding(
cardHolderId,paymentType):Promise<ActivateBindingResponse>
Defined in: src/client.ts:328
Re-enable a saved card that was deactivated.
Parameters
Section titled “Parameters”cardHolderId
Section titled “cardHolderId”string
paymentType
Section titled “paymentType”Returns
Section titled “Returns”Promise<ActivateBindingResponse>
deactivateBinding()
Section titled “deactivateBinding()”deactivateBinding(
cardHolderId,paymentType):Promise<DeactivateBindingResponse>
Defined in: src/client.ts:340
Disable a saved card so it can no longer be charged.
Parameters
Section titled “Parameters”cardHolderId
Section titled “cardHolderId”string
paymentType
Section titled “paymentType”Returns
Section titled “Returns”Promise<DeactivateBindingResponse>
makeBindingPayment()
Section titled “makeBindingPayment()”makeBindingPayment(
params):Promise<MakeBindingPaymentResponse>
Defined in: src/client.ts:357
Charge a saved card without the payer entering card details.
If the response has AcsUrl set, the card issuer requires 3-D Secure
and the payment is not complete until the payer passes it.
Parameters
Section titled “Parameters”params
Section titled “params”Returns
Section titled “Returns”Promise<MakeBindingPaymentResponse>
ssnCheck()
Section titled “ssnCheck()”ssnCheck(
paymentId,ssn,identifierType):Promise<SsnCheckResponse>
Defined in: src/client.ts:378
Submit the payer’s national identifier for a payment (SSNCheck). The identifier is personal data: do not log it.
Parameters
Section titled “Parameters”paymentId
Section titled “paymentId”string
string
identifierType
Section titled “identifierType”Returns
Section titled “Returns”Promise<SsnCheckResponse>