Skip to main content

IAP.completeProductGrant

Notifies the Toss app that product fulfillment for a completed order has finished successfully. Call this after your server-side fulfillment logic succeeds, typically inside the processProductGrant callback of createOneTimePurchaseOrder.

Signature

completeProductGrant is a member of the IAP namespace object.

import { IAP } from '@apps-in-toss/web-framework';

declare const IAP: {
completeProductGrant(args: {
params: { orderId: string };
}): Promise<boolean>;
// ...see overview
};

Parameters

NameTypeRequiredDescription
args.params.orderIdstringThe unique ID of the order to mark as fulfilled. Pass the orderId received from the processProductGrant callback.

Returns

  • Promise<boolean> — whether fulfillment was acknowledged. May return undefined on app versions below the minimum (Android 5.233.0 / iOS 5.233.0).

Permission

No permission required — the IAP namespace is not bound to a PermissionName.

Examples

Minimal

import { IAP } from '@apps-in-toss/web-framework';

async function handleGrantProduct(orderId: string) {
try {
await IAP.completeProductGrant({ params: { orderId } });
} catch (error) {
console.error(error);
}
}

Realistic — server fulfillment then complete grant

import { IAP } from '@apps-in-toss/web-framework';

async function grantOnServer(orderId: string): Promise<void> {
const res = await fetch('/api/grant', {
method: 'POST',
body: JSON.stringify({ orderId }),
headers: { 'Content-Type': 'application/json' },
});
if (!res.ok) throw new Error('Server fulfillment failed');
}

IAP.createOneTimePurchaseOrder({
options: {
sku: 'item_coin_100',
processProductGrant: async ({ orderId }) => {
try {
await grantOnServer(orderId);
await IAP.completeProductGrant({ params: { orderId } });
return true;
} catch {
return false;
}
},
},
onEvent: (event) => console.log('Purchase complete', event.data),
onError: (error) => console.error('Purchase error', error),
});

Try it live

The IAP workflow in sdk-example shows the fulfillment step after a successful purchase.

Open in sdk-example
  • Guides — IAP payment flowprocessProductGrant/completeProductGrant sequencing, server fulfillment, and recovery patterns in one place.

External references