Skip to main content
Registers a listener invoked after a native purchase completes. This fires when the native SDK handles the purchase directly (i.e., no onPurchaseRequest handler is set on the native side).

Signature

onPurchaseComplete(handler: (event: PurchaseCompleteEvent) => void): () => void

Parameters

NameTypeDescription
handler(event: PurchaseCompleteEvent) => voidCallback receiving the purchase complete event

PurchaseCompleteEvent

FieldTypeDescription
productIdstringThe product ID that was purchased
transactionIdstring?iOS: StoreKit transaction ID
purchaseTokenstring?Android: Google Play purchase token
orderIdstring?Android: Google Play order ID

Returns

An unsubscribe function. Call it to remove the listener.

When It Fires

onPurchaseComplete fires only when:
  1. No onPurchaseRequest handler is registered on the native side
  2. The native SDK successfully completes a purchase
  3. The transaction is verified and finished
It does not fire when:
  • An onPurchaseRequest handler is set (the handler takes full responsibility)
  • The user cancels the purchase
  • The purchase fails or is pending

Usage

const unsubscribe = Encore.onPurchaseComplete(({ productId, transactionId }) => {
  // Sync purchase state with your subscription manager
  console.log(`Purchase complete: ${productId}`);
});
Clean up the listener when your component unmounts by calling the returned unsubscribe function.