Skip to content

Events

Subscribe to Exchange Pay order lifecycle signals.

When to use

Refresh checkout, navigate to success, or show expired UI. For current order state you can also read getActiveOrder() / getOrder().

Methods

MethodEventWhen
onOrderUpdatedexchangePay:orderUpdatedOffchain / status update ({ order, transaction })
onOrderCompletedexchangePay:orderCompletedPayment succeeded ({ order, transaction })
onOrderExpiredexchangePay:orderExpiredLocal timer hit expiresAt ({ order })

Each returns an unsubscribe function. You can also use client.on('exchangePay:…') — see Events (Core).

Example

ts
const offs = [
  client.exchangePay.onOrderUpdated(({ order, transaction }) => {
    console.log('updated', order.id, transaction.status);
  }),
  client.exchangePay.onOrderCompleted(({ order }) => {
    // success screen — then getCompletedTransactionSummary()
    console.log('paid', order.id);
  }),
  client.exchangePay.onOrderExpired(({ order }) => {
    // expired UI — create a new order or go back
    console.log('expired', order.id);
  }),
];

// later
offs.forEach(off => off());