Stored Card Operations

The SDK supports card tokenization during standard purchase flows, direct charging against a stored token, and authorization with a separate capture step.

Card Tokenization

Request a card token alongside a standard purchase by passing storeCard: true in the checkout fields. The token is returned in the webhook notification.

const checkoutFields = await client.generateCheckoutFields({
  orderId: 'order-20240601-002',
  amount: 49.00,
  currency: 'EUR',
  urlOk: 'https://mystore.example/checkout/success',
  urlCancel: 'https://mystore.example/checkout/cancel',
  urlNotify: 'https://mystore.example/api/payment/notify',
  cartItems: [{ name: 'Annual subscription', quantity: 1, price: 49.00 }],
  storeCard: true,
})
const checkoutFields = await client.generateCheckoutFields({
  orderId: 'order-20240601-002',
  amount: 49.00,
  currency: 'EUR',
  urlOk: 'https://mystore.example/checkout/success',
  urlCancel: 'https://mystore.example/checkout/cancel',
  urlNotify: 'https://mystore.example/api/payment/notify',
  cartItems: [{ name: 'Annual subscription', quantity: 1, price: 49.00 }],
  storeCard: true,
})

In the webhook handler, extract the token from result.data.cardToken and store it in your database for future charges.

Direct Card Charging

Charge a stored card token directly without a hosted-page redirect using iaPurchase().

Requires myPOS enablement: Direct card charging (iaPurchase) must be explicitly enabled for your merchant account by myPOS before you can use it.

const result = await client.iaPurchase({
  orderId: 'order-20240601-003',
  amount: 49.00,
  currency: 'EUR',
  cardToken: 'tok_live_abc123',
  urlNotify: 'https://mystore.example/api/payment/notify',
  cartItems: [{ name: 'Renewal', quantity: 1, price: 49.00 }],
})

if (result.success) {
  console.log('Charge successful:', result.data.transactionRef)
} else {
  console.error('Charge failed:', result.error)
}
const result = await client.iaPurchase({
  orderId: 'order-20240601-003',
  amount: 49.00,
  currency: 'EUR',
  cardToken: 'tok_live_abc123',
  urlNotify: 'https://mystore.example/api/payment/notify',
  cartItems: [{ name: 'Renewal', quantity: 1, price: 49.00 }],
})

if (result.success) {
  console.log('Charge successful:', result.data.transactionRef)
} else {
  console.error('Charge failed:', result.error)
}

Authorization & Capture

Reserve funds against a stored token without immediately capturing them, then capture (complete) the charge in a separate step.

Step 1 — Authorize

const authResult = await client.iaPreAuthorization({
  orderId: 'order-20240601-004',
  amount: 150.00,
  currency: 'EUR',
  cardToken: 'tok_live_abc123',
  urlNotify: 'https://mystore.example/api/payment/notify',
})

if (authResult.success) {
  const { transactionRef } = authResult.data
  // Store transactionRef — needed for capture or cancellation
  console.log('Authorized:', transactionRef)
}
const authResult = await client.iaPreAuthorization({
  orderId: 'order-20240601-004',
  amount: 150.00,
  currency: 'EUR',
  cardToken: 'tok_live_abc123',
  urlNotify: 'https://mystore.example/api/payment/notify',
})

if (authResult.success) {
  const { transactionRef } = authResult.data
  // Store transactionRef — needed for capture or cancellation
  console.log('Authorized:', transactionRef)
}

Step 2 — Capture

const captureResult = await client.preAuthorizationCompletion({
  transactionRef: 'TXN_REF_FROM_AUTH',
  amount: 150.00,
  currency: 'EUR',
  urlNotify: 'https://mystore.example/api/payment/notify',
})

if (captureResult.success) {
  console.log('Capture successful')
}
const captureResult = await client.preAuthorizationCompletion({
  transactionRef: 'TXN_REF_FROM_AUTH',
  amount: 150.00,
  currency: 'EUR',
  urlNotify: 'https://mystore.example/api/payment/notify',
})

if (captureResult.success) {
  console.log('Capture successful')
}