Aller au contenu

trackPurchaseStatus

Ce contenu n’est pas encore disponible dans votre langue.

trackPurchaseStatus(args): Promise<void>

Defined in: actions/trackPurchaseStatus.ts:34

Function used to track the status of a purchase when a purchase is tracked, the purchaseCompleted interactions will be automatically send for the user when we receive the purchase confirmation via webhook.

string | number

The customer id that made the purchase (on your side)

string

Optional explicit merchant id to use for the tracking request

string | number

The order id of the purchase (on your side)

string

The token of the purchase

Promise<void>

This function will send a request to the backend to listen for the purchase status.

async function trackPurchase(checkout) {
const payload = {
customerId: checkout.order.customer.id,
orderId: checkout.order.id,
token: checkout.token,
merchantId: "your-merchant-id",
};
await trackPurchaseStatus(payload);
}
  • Merchant id is resolved in this order: explicit args.merchantId, then sdkConfigStore.resolveMerchantId() (config store → sessionStorage → backend fetch).
  • This function supports anonymous users and will use the x-frak-client-id header when available.
  • At least one identity source must exist (frak-wallet-interaction-token or x-frak-client-id), otherwise the tracking request is skipped.
  • This function will print a warning if used in a non-browser environment or if no identity / merchant id can be resolved.