본문으로 건너뛰기

grantPromotionRewardForGame

Deprecated

grantPromotionRewardForGame은 더 이상 사용되지 않습니다. 대신 grantPromotionReward를 사용하세요. 모든 카테고리에서 동작하며 에러 코드가 동일합니다.

게임 카테고리 미니앱에서 프로모션 코드를 사용해 사용자에게 포인트 리워드를 지급합니다. 게임 카테고리가 아닌 미니앱에서 호출하면 에러 코드 "40000"이 반환됩니다.

시그니처

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

type GrantPromotionRewardForGameResult =
| { key: string }
| { code: string; [key: string]: unknown }
| { errorCode: string; message: string }
| 'ERROR'
| undefined;

declare function grantPromotionRewardForGame(params: {
params: {
promotionCode: string;
amount: number;
};
}): Promise<GrantPromotionRewardForGameResult>;

파라미터

이름타입필수설명
paramsobject리워드 지급 정보를 담은 래퍼 객체.
params.promotionCodestring사전에 등록된 프로모션 코드.
params.amountnumber지급할 포인트 금액.

반환값

  • { key: string } — 지급 성공. key는 리워드 키입니다.
  • { errorCode: string; message: string } — 지급 실패. 에러 코드는 다음과 같습니다.
    • "40000" — 게임 카테고리가 아닌 미니앱에서 호출했습니다.
    • "4100" — 프로모션 정보를 찾을 수 없습니다.
    • "4104" — 프로모션이 중지되었습니다.
    • "4105" — 프로모션이 종료되었습니다.
    • "4108" — 프로모션이 승인되지 않았습니다.
    • "4109" — 프로모션이 실행 중이 아닙니다.
    • "4110" — 리워드를 지급·회수할 수 없습니다.
    • "4112" — 프로모션 머니가 부족합니다.
    • "4113" — 이미 지급·회수된 내역입니다.
    • "4114" — 프로모션에 설정된 1회 지급 금액을 초과했습니다.
  • 'ERROR' — 알 수 없는 오류가 발생했습니다.
  • undefined — 앱 버전이 최소 지원 버전보다 낮습니다.

권한

권한이 필요하지 않습니다. 토스 세션(계정 연결)이 처리합니다. 단, 게임 카테고리 미니앱에서만 성공적으로 리워드를 지급할 수 있습니다.

마이그레이션

// 이전 코드 (게임 카테고리 전용)
import { grantPromotionRewardForGame } from '@apps-in-toss/web-framework';
const result = await grantPromotionRewardForGame({
params: { promotionCode: 'GAME_EVENT', amount: 1000 },
});

// 권장 코드 (모든 카테고리)
import { grantPromotionReward } from '@apps-in-toss/web-framework';
const result = await grantPromotionReward({
params: { promotionCode: 'GAME_EVENT', amount: 1000 },
});

예제

최소 예제

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

const result = await grantPromotionRewardForGame({
params: { promotionCode: 'GAME_EVENT_2024', amount: 1000 },
});

if (!result) {
console.warn('앱 버전이 최소 지원 버전보다 낮습니다.');
} else if (result === 'ERROR') {
console.error('리워드 지급 중 알 수 없는 오류가 발생했습니다.');
} else if ('key' in result) {
console.log('리워드 지급 성공! 키:', result.key);
} else if ('errorCode' in result) {
console.error('리워드 지급 실패:', result.errorCode, result.message);
}

직접 실행해 보기

sdk-example의 Game 페이지에서 grantPromotionRewardForGame 카드를 실행해 결과를 확인할 수 있습니다.

sdk-example에서 실행해 보기

관련 API

관련 가이드

외부 참조