Documentation / @frak-labs/core-sdk / actions / trackPurchaseStatus
Function: trackPurchaseStatus()
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.
Parameters
args
customerId
string | number
The customer id that made the purchase (on your side)
merchantId?
string
Optional explicit merchant id to use for the tracking request
orderId
string | number
The order id of the purchase (on your side)
token
string
The token of the purchase
Returns
Promise<void>
Example
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);
}Remarks
- Merchant id is resolved in this order: explicit
args.merchantId, thensdkConfigStore.resolveMerchantId()(config store → sessionStorage → backend fetch). - This function supports anonymous users and will use the
x-frak-client-idheader when available. - At least one identity source must exist (
frak-wallet-interaction-tokenorx-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.