본문으로 건너뛰기

IAP.completeProductGrant

결제가 완료된 주문에 대해 상품 지급이 정상적으로 끝났음을 토스 앱에 알립니다. createOneTimePurchaseOrderprocessProductGrant 콜백 안에서 서버 지급을 완료한 뒤 호출합니다.

시그니처

completeProductGrantIAP 네임스페이스 객체의 멤버로 노출됩니다.

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

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

파라미터

이름타입필수설명
args.params.orderIdstring상품 지급을 완료할 주문의 고유 ID. processProductGrant 콜백에서 받은 orderId를 그대로 전달합니다.

반환값

  • Promise<boolean> — 지급 완료 확인 여부. 앱 버전이 최소 지원 버전(Android 5.233.0 / iOS 5.233.0)보다 낮으면 undefined를 반환할 수 있습니다.

권한

권한이 필요하지 않습니다 — IAP 네임스페이스는 별도의 PermissionName에 바인딩되지 않습니다.

예제

최소 예제

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

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

실전 예제 — 결제 성공 후 서버 지급 완료 처리

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('서버 지급 실패');
}

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('결제 완료', event.data),
onError: (error) => console.error('결제 오류', error),
});

직접 실행해 보기

sdk-example의 IAP 페이지 워크플로에서 결제 완료 후 상품 지급 흐름을 확인할 수 있습니다.

sdk-example에서 실행해 보기

관련 API

관련 가이드

  • Guides — IAP 결제 흐름processProductGrant/completeProductGrant 시퀀스·서버 fulfillment·복구 패턴을 한 곳에 정리한 가이드.

외부 참조