Skip to content

Saved cards

Saved cards — “binding transactions” in the bank’s terms — let you charge a card again without the payer entering it: subscriptions, recurring payments, one-click checkout.

An authorised person at your company, usually the director, applies through Ameriabank’s mobile or internet banking. The feature works once the bank approves it.

saved-cards.ts
import { ameria } from "./client.js";
// 1. First payment: pass cardHolderId so the bank saves the card.
await ameria.initPayment({
orderId: 2350302,
amount: 10,
description: "Subscription, first month",
backUrl: "https://shop.example/payment/back",
opaque: "",
cardHolderId: "customer-77",
});
// 2. Later payments: charge the saved card, no payer interaction.
const charge = await ameria.makeBindingPayment({
cardHolderId: "customer-77",
orderId: 2350303,
amount: 10,
description: "Subscription, second month",
backUrl: "https://shop.example/payment/back",
opaque: "",
});
if (charge.AcsUrl) {
// The issuer wants 3-D Secure: the payer has to confirm this payment.
console.log("Send the payer to", charge.AcsUrl);
} else if (charge.ResponseCode === "00") {
console.log("Charged", charge.Amount);
}
// List, disable and re-enable saved cards.
const { CardBindingFileds: cards } =
await ameria.getBindings("BindingMainRest");
console.log(cards.map((c) => c.CardPan));
await ameria.deactivateBinding("customer-77", "BindingMainRest");
await ameria.activateBinding("customer-77", "BindingMainRest");
  1. Pass your own customer ID as cardHolderId to initPayment. When that payment succeeds, the bank saves the card under that ID.
  2. Charge it later with makeBindingPayment and the same ID. paymentType defaults to "BindingMainRest".

The card issuer can still ask the payer to confirm a charge. Then the response has AcsUrl (with PaReq and TermUrl) set and the payment is not complete until the payer passes the check. Handle this case, or the charge silently never happens.

getBindings, deactivateBinding and activateBinding list, disable and re-enable saved cards. The bank only accepts "MainRest" and "BindingMainRest" as payment types for these calls.