Skip to content

Expiry

Every Exchange Pay order has an expiresAt timestamp (ms since epoch). When it elapses, the SDK emits exchangePay:orderExpired and clears the active order.

When to use

Show a countdown on the checkout screen and handle expired UI (create a new order or go back).

Methods

APIPurpose
client.exchangePay.getActiveOrderExpiresAt()Active order’s expiresAt, or null
client.exchangePay.getActiveOrderTimeLeft(){ hours, minutes, seconds }, or null when there is no order
client.exchangePay.isActiveOrderExpired()Whether time is up (false when there is no order)

Example

ts
const timeLeft = client.exchangePay.getActiveOrderTimeLeft();

if (timeLeft) {
  const { hours, minutes, seconds } = timeLeft;
  console.log(`Time left: ${hours}:${minutes}:${seconds}`);
  console.log('expired?', client.exchangePay.isActiveOrderExpired());
}

client.exchangePay.onOrderExpired(({ order }) => {
  // Show “order expired”; offer create again
  console.log('expired', order.id);
});

getActiveOrderTimeLeft() returns null when there is no active order — skip the countdown instead of formatting 0. isActiveOrderExpired() is also false in that case, so it is not a substitute for that null check.

For a live ticking UI in vanilla JS, poll getActiveOrderTimeLeft() on an interval, or subscribe to onOrderExpired for the end state. In React, prefer useExchangePayOrderCountdown.

Notes

  • Expiry is per order, not a Coinbase-style submission cooldown.
  • Provider APIs return expiry in different formats; the SDK normalizes to epoch ms (with a safe fallback if missing).
  • After expiry, create a new order — do not reuse the old checkout links.

Errors

Expiry methods do not throw. Order creation / status errors are covered in Orders and Errors.