Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,12 @@ export function useInAppPurchase(): UseInAppPurchaseReturn {
}, []);

const grantProduct = useCallback((orderId: string) => {
// TODO: 여기에 상품 지급 로직을 작성해 주세요.
// TODO: 상품 지급 로직을 작성해 주세요. 지금은 데모라서 아무것도 지급하지 않아요.
// 그대로 출시하면 결제한 사용자가 상품을 받지 못해요.
// - 상품을 지급하고, 지급 결과를 서버나 앱 저장소에 기록해 주세요.
// - 같은 orderId로 두 번 지급하지 않도록 처리해 주세요.
// 참고문서: https://developers-apps-in-toss.toss.im/guide/monetization/in-app-payment
// 주문 상태 조회 API(선택): https://developers-apps-in-toss.toss.im/api/iap

console.info(`상품 지급 처리: ${orderId}`);
}, []);
Expand All @@ -67,6 +72,8 @@ export function useInAppPurchase(): UseInAppPurchaseReturn {
grantProduct(orderId);

console.info(`상품 지급 처리: ${orderId}`);
// 지급이 실제로 성공했을 때만 true를 반환해 주세요.
// 실패하면 false를 반환해 주세요. 미결 주문으로 남아 restorePendingOrders에서 다시 처리돼요.
return true;
},
},
Expand Down Expand Up @@ -105,6 +112,8 @@ export function useInAppPurchase(): UseInAppPurchaseReturn {
for (const order of orders) {
grantProduct(order.orderId);

// 지급에 성공한 주문만 완료 처리해 주세요.
// 지급에 실패한 주문은 완료 처리하지 말고, 다음 복구 때 다시 처리되도록 남겨 두세요.
await IAP.completeProductGrant({ params: { orderId: order.orderId } });
console.info("미결 주문 복원 완료:", order.orderId);
}
Expand Down
11 changes: 10 additions & 1 deletion templates/samples/react-ts/iap/src/hooks/useInAppPurchase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,12 @@ export function useInAppPurchase(): UseInAppPurchaseReturn {
}, []);

const grantProduct = useCallback((orderId: string) => {
// TODO: 여기에 상품 지급 로직을 작성해 주세요.
// TODO: 상품 지급 로직을 작성해 주세요. 지금은 데모라서 아무것도 지급하지 않아요.
// 그대로 출시하면 결제한 사용자가 상품을 받지 못해요.
// - 상품을 지급하고, 지급 결과를 서버나 앱 저장소에 기록해 주세요.
// - 같은 orderId로 두 번 지급하지 않도록 처리해 주세요.
// 참고문서: https://developers-apps-in-toss.toss.im/guide/monetization/in-app-payment
// 주문 상태 조회 API(선택): https://developers-apps-in-toss.toss.im/api/iap

console.info(`상품 지급 처리: ${orderId}`);
}, []);
Expand All @@ -61,6 +66,8 @@ export function useInAppPurchase(): UseInAppPurchaseReturn {
grantProduct(orderId);

console.info(`상품 지급 처리: ${orderId}`);
// 지급이 실제로 성공했을 때만 true를 반환해 주세요.
// 실패하면 false를 반환해 주세요. 미결 주문으로 남아 restorePendingOrders에서 다시 처리돼요.
return true;
},
},
Expand Down Expand Up @@ -99,6 +106,8 @@ export function useInAppPurchase(): UseInAppPurchaseReturn {
for (const order of orders) {
grantProduct(order.orderId);

// 지급에 성공한 주문만 완료 처리해 주세요.
// 지급에 실패한 주문은 완료 처리하지 말고, 다음 복구 때 다시 처리되도록 남겨 두세요.
await IAP.completeProductGrant({ params: { orderId: order.orderId } });
console.info("미결 주문 복원 완료:", order.orderId);
}
Expand Down
11 changes: 10 additions & 1 deletion templates/samples/react/iap/src/hooks/useInAppPurchase.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,12 @@ export function useInAppPurchase() {
}, []);

const grantProduct = useCallback((orderId) => {
// TODO: 여기에 상품 지급 로직을 작성해 주세요.
// TODO: 상품 지급 로직을 작성해 주세요. 지금은 데모라서 아무것도 지급하지 않아요.
// 그대로 출시하면 결제한 사용자가 상품을 받지 못해요.
// - 상품을 지급하고, 지급 결과를 서버나 앱 저장소에 기록해 주세요.
// - 같은 orderId로 두 번 지급하지 않도록 처리해 주세요.
// 참고문서: https://developers-apps-in-toss.toss.im/guide/monetization/in-app-payment
// 주문 상태 조회 API(선택): https://developers-apps-in-toss.toss.im/api/iap
console.info(`상품 지급 처리: ${orderId}`);
}, []);

Expand All @@ -45,6 +50,8 @@ export function useInAppPurchase() {
processProductGrant: ({ orderId }) => {
grantProduct(orderId);
console.info(`상품 지급 처리: ${orderId}`);
// 지급이 실제로 성공했을 때만 true를 반환해 주세요.
// 실패하면 false를 반환해 주세요. 미결 주문으로 남아 restorePendingOrders에서 다시 처리돼요.
return true;
},
},
Expand Down Expand Up @@ -77,6 +84,8 @@ export function useInAppPurchase() {

for (const order of orders) {
grantProduct(order.orderId);
// 지급에 성공한 주문만 완료 처리해 주세요.
// 지급에 실패한 주문은 완료 처리하지 말고, 다음 복구 때 다시 처리되도록 남겨 두세요.
await IAP.completeProductGrant({ params: { orderId: order.orderId } });
console.info("미결 주문 복원 완료:", order.orderId);
}
Expand Down
11 changes: 10 additions & 1 deletion templates/samples/vanilla-ts/iap/src/lib/inAppPurchase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,12 @@ export function createInAppPurchase() {
}

function grantProduct(orderId: string) {
// TODO: 여기에 상품 지급 로직을 작성해 주세요.
// TODO: 상품 지급 로직을 작성해 주세요. 지금은 데모라서 아무것도 지급하지 않아요.
// 그대로 출시하면 결제한 사용자가 상품을 받지 못해요.
// - 상품을 지급하고, 지급 결과를 서버나 앱 저장소에 기록해 주세요.
// - 같은 orderId로 두 번 지급하지 않도록 처리해 주세요.
// 참고문서: https://developers-apps-in-toss.toss.im/guide/monetization/in-app-payment
// 주문 상태 조회 API(선택): https://developers-apps-in-toss.toss.im/api/iap
console.info(`상품 지급 처리: ${orderId}`);
}

Expand Down Expand Up @@ -57,6 +62,8 @@ export function createInAppPurchase() {
processProductGrant: ({ orderId }) => {
grantProduct(orderId);
console.info(`상품 지급 처리: ${orderId}`);
// 지급이 실제로 성공했을 때만 true를 반환해 주세요.
// 실패하면 false를 반환해 주세요. 미결 주문으로 남아 restorePendingOrders에서 다시 처리돼요.
return true;
},
},
Expand Down Expand Up @@ -90,6 +97,8 @@ export function createInAppPurchase() {

for (const order of orders) {
grantProduct(order.orderId);
// 지급에 성공한 주문만 완료 처리해 주세요.
// 지급에 실패한 주문은 완료 처리하지 말고, 다음 복구 때 다시 처리되도록 남겨 두세요.
await IAP.completeProductGrant({ params: { orderId: order.orderId } });
console.info("미결 주문 복원 완료:", order.orderId);
}
Expand Down
11 changes: 10 additions & 1 deletion templates/samples/vanilla/iap/src/lib/inAppPurchase.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,12 @@ export function createInAppPurchase() {
}

function grantProduct(orderId) {
// TODO: 여기에 상품 지급 로직을 작성해 주세요.
// TODO: 상품 지급 로직을 작성해 주세요. 지금은 데모라서 아무것도 지급하지 않아요.
// 그대로 출시하면 결제한 사용자가 상품을 받지 못해요.
// - 상품을 지급하고, 지급 결과를 서버나 앱 저장소에 기록해 주세요.
// - 같은 orderId로 두 번 지급하지 않도록 처리해 주세요.
// 참고문서: https://developers-apps-in-toss.toss.im/guide/monetization/in-app-payment
// 주문 상태 조회 API(선택): https://developers-apps-in-toss.toss.im/api/iap
console.info(`상품 지급 처리: ${orderId}`);
}

Expand Down Expand Up @@ -48,6 +53,8 @@ export function createInAppPurchase() {
processProductGrant: ({ orderId }) => {
grantProduct(orderId);
console.info(`상품 지급 처리: ${orderId}`);
// 지급이 실제로 성공했을 때만 true를 반환해 주세요.
// 실패하면 false를 반환해 주세요. 미결 주문으로 남아 restorePendingOrders에서 다시 처리돼요.
return true;
},
},
Expand Down Expand Up @@ -81,6 +88,8 @@ export function createInAppPurchase() {

for (const order of orders) {
grantProduct(order.orderId);
// 지급에 성공한 주문만 완료 처리해 주세요.
// 지급에 실패한 주문은 완료 처리하지 말고, 다음 복구 때 다시 처리되도록 남겨 두세요.
await IAP.completeProductGrant({ params: { orderId: order.orderId } });
console.info("미결 주문 복원 완료:", order.orderId);
}
Expand Down
Loading