@apps-in-toss/native-modules 2.6.1 → 2.6.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +22 -0
- package/dist/index.d.cts +19 -3
- package/dist/index.d.ts +19 -3
- package/dist/index.js +21 -0
- package/package.json +2 -2
- package/src/MiniAppModule/native-modules/iap.ts +39 -2
package/dist/index.cjs
CHANGED
|
@@ -67,6 +67,7 @@ __export(index_exports, {
|
|
|
67
67
|
requestNotificationAgreement: () => requestNotificationAgreement,
|
|
68
68
|
requestOneTimePurchase: () => requestOneTimePurchase,
|
|
69
69
|
requestReview: () => requestReview,
|
|
70
|
+
requestSubscriptionPurchase: () => requestSubscriptionPurchase,
|
|
70
71
|
requestTossPayPaysBilling: () => requestTossPayPaysBilling,
|
|
71
72
|
safePostMessage: () => safePostMessage,
|
|
72
73
|
safeSyncPostMessage: () => safeSyncPostMessage,
|
|
@@ -716,6 +717,26 @@ function requestOneTimePurchase(params) {
|
|
|
716
717
|
);
|
|
717
718
|
return unregisterCallbacks;
|
|
718
719
|
}
|
|
720
|
+
function requestSubscriptionPurchase(params) {
|
|
721
|
+
const { options, onEvent, onError } = params;
|
|
722
|
+
const { sku, offerId } = options;
|
|
723
|
+
const unregisterCallbacks = INTERNAL__appBridgeHandler.invokeAppBridgeMethod(
|
|
724
|
+
"requestSubscriptionPurchase",
|
|
725
|
+
{ sku, offerId: offerId ?? null },
|
|
726
|
+
{
|
|
727
|
+
onPurchased: (params2) => {
|
|
728
|
+
onEvent({ type: "purchased", data: params2 });
|
|
729
|
+
},
|
|
730
|
+
onSuccess: (result) => {
|
|
731
|
+
onEvent({ type: "success", data: result });
|
|
732
|
+
},
|
|
733
|
+
onError: (error) => {
|
|
734
|
+
onError(error);
|
|
735
|
+
}
|
|
736
|
+
}
|
|
737
|
+
);
|
|
738
|
+
return unregisterCallbacks;
|
|
739
|
+
}
|
|
719
740
|
function createOneTimePurchaseOrder(params) {
|
|
720
741
|
const isIAPSupported = isMinVersionSupported({
|
|
721
742
|
android: "5.219.0",
|
|
@@ -1304,6 +1325,7 @@ var INTERNAL__module = {
|
|
|
1304
1325
|
requestNotificationAgreement,
|
|
1305
1326
|
requestOneTimePurchase,
|
|
1306
1327
|
requestReview,
|
|
1328
|
+
requestSubscriptionPurchase,
|
|
1307
1329
|
requestTossPayPaysBilling,
|
|
1308
1330
|
safePostMessage,
|
|
1309
1331
|
safeSyncPostMessage,
|
package/dist/index.d.cts
CHANGED
|
@@ -470,7 +470,7 @@ interface OneTimePurchaseSuccessEvent {
|
|
|
470
470
|
type: 'success';
|
|
471
471
|
data: IapCreateOneTimePurchaseOrderResult;
|
|
472
472
|
}
|
|
473
|
-
interface
|
|
473
|
+
interface OneTimePurchasedEvent {
|
|
474
474
|
type: 'purchased';
|
|
475
475
|
data: {
|
|
476
476
|
orderId: string;
|
|
@@ -497,7 +497,7 @@ interface IapCreateOneTimePurchaseOrderOptions {
|
|
|
497
497
|
}
|
|
498
498
|
interface IapRequestOneTimePurchaseOptions {
|
|
499
499
|
options: Sku;
|
|
500
|
-
onEvent: (event:
|
|
500
|
+
onEvent: (event: OneTimePurchasedEvent | OneTimePurchaseSuccessEvent) => void | Promise<void>;
|
|
501
501
|
onError: (error: unknown) => void | Promise<void>;
|
|
502
502
|
}
|
|
503
503
|
declare function iapCreateOneTimePurchaseOrder(params: Sku): Promise<IapCreateOneTimePurchaseOrderResult>;
|
|
@@ -506,6 +506,22 @@ declare function processProductGrant(params: {
|
|
|
506
506
|
isProductGranted: boolean;
|
|
507
507
|
}): Promise<void>;
|
|
508
508
|
declare function requestOneTimePurchase(params: IapRequestOneTimePurchaseOptions): () => void;
|
|
509
|
+
interface SubscriptionPurchasedEvent {
|
|
510
|
+
type: 'purchased';
|
|
511
|
+
data: {
|
|
512
|
+
orderId: string;
|
|
513
|
+
subscriptionId?: string;
|
|
514
|
+
};
|
|
515
|
+
}
|
|
516
|
+
interface IapRequestSubscriptionPurchaseOrderOptions {
|
|
517
|
+
options: {
|
|
518
|
+
sku: string;
|
|
519
|
+
offerId?: string | null;
|
|
520
|
+
};
|
|
521
|
+
onEvent: (event: SubscriptionPurchasedEvent | SubscriptionSuccessEvent) => void | Promise<void>;
|
|
522
|
+
onError: (error: unknown) => void | Promise<void>;
|
|
523
|
+
}
|
|
524
|
+
declare function requestSubscriptionPurchase(params: IapRequestSubscriptionPurchaseOrderOptions): () => void;
|
|
509
525
|
/**
|
|
510
526
|
* @public
|
|
511
527
|
* @category 인앱결제
|
|
@@ -3588,4 +3604,4 @@ declare const INTERNAL__module: {
|
|
|
3588
3604
|
tossCoreEventLog: typeof tossCoreEventLog;
|
|
3589
3605
|
};
|
|
3590
3606
|
|
|
3591
|
-
export { type AlbumItemResponse, type AlbumItemType, type AppsInTossSignTossCertParams, type CheckoutPaymentOptions, type CheckoutPaymentResult, type CompletedOrRefundedOrdersResult, type ConsumableProductListItem, type ContactsViralParams, type CreateSubscriptionPurchaseOrderOptions, type EventLogParams, type FetchAlbumItemsOptions, type GameCenterGameProfileResponse, type GetAnonymousKeyResponse, type GetAnonymousKeySuccessResponse, type GetUserKeyForGameErrorResponse, type GetUserKeyForGameResponse, type GetUserKeyForGameSuccessResponse, GoogleAdMob, type GrantPromotionRewardErrorResponse, type GrantPromotionRewardErrorResult, type GrantPromotionRewardForGameErrorResponse, type GrantPromotionRewardForGameErrorResult, type GrantPromotionRewardForGameResponse, type GrantPromotionRewardForGameSuccessResponse, type GrantPromotionRewardResponse, type GrantPromotionRewardSuccessResponse, type HapticFeedbackType, IAP, INTERNAL__appBridgeHandler, INTERNAL__module, type IapCreateOneTimePurchaseOrderOptions, type IapCreateOneTimePurchaseOrderResult, type IapCreateSubscriptionPurchaseOrderResult, type IapProductListItem, type IapSubscriptionInfoResult, type NetworkStatus, type NonConsumableProductListItem, type NotificationAgreementResult, type OpenPDFViewerParams, type OpenPDFViewerResult, type Primitive, type RequestNotificationAgreementOptions, type RequestTossPayPaysBillingOptions, type RequestTossPayPaysBillingResult, type SaveBase64DataParams, Storage, type SubmitGameCenterLeaderBoardScoreResponse, type SubscriptionProductListItem, TossPay, type UpdateLocationEventEmitter, appLogin, appsInTossEvent, appsInTossSignTossCert, checkoutPayment, closeView, contactsViral, eventLog, fetchAlbumItems, fetchAlbumPhotos, fetchContacts, generateHapticFeedback, getAnonymousKey, getClipboardText, getCurrentLocation, getDeviceId, getGameCenterGameProfile, getGroupId, getIsTossLoginIntegratedService, getLocale, getNetworkStatus, getOperationalEnvironment, getPlatformOS, getSchemeUri, getServerTime, getTossAppVersion, getTossShareLink, getUserKeyForGame, grantPromotionReward, grantPromotionRewardForGame, iapCreateOneTimePurchaseOrder, isMinVersionSupported, onVisibilityChangedByTransparentServiceWeb, openCamera, openGameCenterLeaderboard, openPDFViewer, openURL, processProductGrant, requestNotificationAgreement, requestOneTimePurchase, requestReview, requestTossPayPaysBilling, safePostMessage, safeSyncPostMessage, saveBase64Data, setClipboardText, setDeviceOrientation, setIosSwipeGestureEnabled, setScreenAwakeMode, setSecureScreen, share, shareWithScheme, startUpdateLocation, submitGameCenterLeaderBoardScore };
|
|
3607
|
+
export { type AlbumItemResponse, type AlbumItemType, type AppsInTossSignTossCertParams, type CheckoutPaymentOptions, type CheckoutPaymentResult, type CompletedOrRefundedOrdersResult, type ConsumableProductListItem, type ContactsViralParams, type CreateSubscriptionPurchaseOrderOptions, type EventLogParams, type FetchAlbumItemsOptions, type GameCenterGameProfileResponse, type GetAnonymousKeyResponse, type GetAnonymousKeySuccessResponse, type GetUserKeyForGameErrorResponse, type GetUserKeyForGameResponse, type GetUserKeyForGameSuccessResponse, GoogleAdMob, type GrantPromotionRewardErrorResponse, type GrantPromotionRewardErrorResult, type GrantPromotionRewardForGameErrorResponse, type GrantPromotionRewardForGameErrorResult, type GrantPromotionRewardForGameResponse, type GrantPromotionRewardForGameSuccessResponse, type GrantPromotionRewardResponse, type GrantPromotionRewardSuccessResponse, type HapticFeedbackType, IAP, INTERNAL__appBridgeHandler, INTERNAL__module, type IapCreateOneTimePurchaseOrderOptions, type IapCreateOneTimePurchaseOrderResult, type IapCreateSubscriptionPurchaseOrderResult, type IapProductListItem, type IapSubscriptionInfoResult, type NetworkStatus, type NonConsumableProductListItem, type NotificationAgreementResult, type OpenPDFViewerParams, type OpenPDFViewerResult, type Primitive, type RequestNotificationAgreementOptions, type RequestTossPayPaysBillingOptions, type RequestTossPayPaysBillingResult, type SaveBase64DataParams, Storage, type SubmitGameCenterLeaderBoardScoreResponse, type SubscriptionProductListItem, TossPay, type UpdateLocationEventEmitter, appLogin, appsInTossEvent, appsInTossSignTossCert, checkoutPayment, closeView, contactsViral, eventLog, fetchAlbumItems, fetchAlbumPhotos, fetchContacts, generateHapticFeedback, getAnonymousKey, getClipboardText, getCurrentLocation, getDeviceId, getGameCenterGameProfile, getGroupId, getIsTossLoginIntegratedService, getLocale, getNetworkStatus, getOperationalEnvironment, getPlatformOS, getSchemeUri, getServerTime, getTossAppVersion, getTossShareLink, getUserKeyForGame, grantPromotionReward, grantPromotionRewardForGame, iapCreateOneTimePurchaseOrder, isMinVersionSupported, onVisibilityChangedByTransparentServiceWeb, openCamera, openGameCenterLeaderboard, openPDFViewer, openURL, processProductGrant, requestNotificationAgreement, requestOneTimePurchase, requestReview, requestSubscriptionPurchase, requestTossPayPaysBilling, safePostMessage, safeSyncPostMessage, saveBase64Data, setClipboardText, setDeviceOrientation, setIosSwipeGestureEnabled, setScreenAwakeMode, setSecureScreen, share, shareWithScheme, startUpdateLocation, submitGameCenterLeaderBoardScore };
|
package/dist/index.d.ts
CHANGED
|
@@ -470,7 +470,7 @@ interface OneTimePurchaseSuccessEvent {
|
|
|
470
470
|
type: 'success';
|
|
471
471
|
data: IapCreateOneTimePurchaseOrderResult;
|
|
472
472
|
}
|
|
473
|
-
interface
|
|
473
|
+
interface OneTimePurchasedEvent {
|
|
474
474
|
type: 'purchased';
|
|
475
475
|
data: {
|
|
476
476
|
orderId: string;
|
|
@@ -497,7 +497,7 @@ interface IapCreateOneTimePurchaseOrderOptions {
|
|
|
497
497
|
}
|
|
498
498
|
interface IapRequestOneTimePurchaseOptions {
|
|
499
499
|
options: Sku;
|
|
500
|
-
onEvent: (event:
|
|
500
|
+
onEvent: (event: OneTimePurchasedEvent | OneTimePurchaseSuccessEvent) => void | Promise<void>;
|
|
501
501
|
onError: (error: unknown) => void | Promise<void>;
|
|
502
502
|
}
|
|
503
503
|
declare function iapCreateOneTimePurchaseOrder(params: Sku): Promise<IapCreateOneTimePurchaseOrderResult>;
|
|
@@ -506,6 +506,22 @@ declare function processProductGrant(params: {
|
|
|
506
506
|
isProductGranted: boolean;
|
|
507
507
|
}): Promise<void>;
|
|
508
508
|
declare function requestOneTimePurchase(params: IapRequestOneTimePurchaseOptions): () => void;
|
|
509
|
+
interface SubscriptionPurchasedEvent {
|
|
510
|
+
type: 'purchased';
|
|
511
|
+
data: {
|
|
512
|
+
orderId: string;
|
|
513
|
+
subscriptionId?: string;
|
|
514
|
+
};
|
|
515
|
+
}
|
|
516
|
+
interface IapRequestSubscriptionPurchaseOrderOptions {
|
|
517
|
+
options: {
|
|
518
|
+
sku: string;
|
|
519
|
+
offerId?: string | null;
|
|
520
|
+
};
|
|
521
|
+
onEvent: (event: SubscriptionPurchasedEvent | SubscriptionSuccessEvent) => void | Promise<void>;
|
|
522
|
+
onError: (error: unknown) => void | Promise<void>;
|
|
523
|
+
}
|
|
524
|
+
declare function requestSubscriptionPurchase(params: IapRequestSubscriptionPurchaseOrderOptions): () => void;
|
|
509
525
|
/**
|
|
510
526
|
* @public
|
|
511
527
|
* @category 인앱결제
|
|
@@ -3588,4 +3604,4 @@ declare const INTERNAL__module: {
|
|
|
3588
3604
|
tossCoreEventLog: typeof tossCoreEventLog;
|
|
3589
3605
|
};
|
|
3590
3606
|
|
|
3591
|
-
export { type AlbumItemResponse, type AlbumItemType, type AppsInTossSignTossCertParams, type CheckoutPaymentOptions, type CheckoutPaymentResult, type CompletedOrRefundedOrdersResult, type ConsumableProductListItem, type ContactsViralParams, type CreateSubscriptionPurchaseOrderOptions, type EventLogParams, type FetchAlbumItemsOptions, type GameCenterGameProfileResponse, type GetAnonymousKeyResponse, type GetAnonymousKeySuccessResponse, type GetUserKeyForGameErrorResponse, type GetUserKeyForGameResponse, type GetUserKeyForGameSuccessResponse, GoogleAdMob, type GrantPromotionRewardErrorResponse, type GrantPromotionRewardErrorResult, type GrantPromotionRewardForGameErrorResponse, type GrantPromotionRewardForGameErrorResult, type GrantPromotionRewardForGameResponse, type GrantPromotionRewardForGameSuccessResponse, type GrantPromotionRewardResponse, type GrantPromotionRewardSuccessResponse, type HapticFeedbackType, IAP, INTERNAL__appBridgeHandler, INTERNAL__module, type IapCreateOneTimePurchaseOrderOptions, type IapCreateOneTimePurchaseOrderResult, type IapCreateSubscriptionPurchaseOrderResult, type IapProductListItem, type IapSubscriptionInfoResult, type NetworkStatus, type NonConsumableProductListItem, type NotificationAgreementResult, type OpenPDFViewerParams, type OpenPDFViewerResult, type Primitive, type RequestNotificationAgreementOptions, type RequestTossPayPaysBillingOptions, type RequestTossPayPaysBillingResult, type SaveBase64DataParams, Storage, type SubmitGameCenterLeaderBoardScoreResponse, type SubscriptionProductListItem, TossPay, type UpdateLocationEventEmitter, appLogin, appsInTossEvent, appsInTossSignTossCert, checkoutPayment, closeView, contactsViral, eventLog, fetchAlbumItems, fetchAlbumPhotos, fetchContacts, generateHapticFeedback, getAnonymousKey, getClipboardText, getCurrentLocation, getDeviceId, getGameCenterGameProfile, getGroupId, getIsTossLoginIntegratedService, getLocale, getNetworkStatus, getOperationalEnvironment, getPlatformOS, getSchemeUri, getServerTime, getTossAppVersion, getTossShareLink, getUserKeyForGame, grantPromotionReward, grantPromotionRewardForGame, iapCreateOneTimePurchaseOrder, isMinVersionSupported, onVisibilityChangedByTransparentServiceWeb, openCamera, openGameCenterLeaderboard, openPDFViewer, openURL, processProductGrant, requestNotificationAgreement, requestOneTimePurchase, requestReview, requestTossPayPaysBilling, safePostMessage, safeSyncPostMessage, saveBase64Data, setClipboardText, setDeviceOrientation, setIosSwipeGestureEnabled, setScreenAwakeMode, setSecureScreen, share, shareWithScheme, startUpdateLocation, submitGameCenterLeaderBoardScore };
|
|
3607
|
+
export { type AlbumItemResponse, type AlbumItemType, type AppsInTossSignTossCertParams, type CheckoutPaymentOptions, type CheckoutPaymentResult, type CompletedOrRefundedOrdersResult, type ConsumableProductListItem, type ContactsViralParams, type CreateSubscriptionPurchaseOrderOptions, type EventLogParams, type FetchAlbumItemsOptions, type GameCenterGameProfileResponse, type GetAnonymousKeyResponse, type GetAnonymousKeySuccessResponse, type GetUserKeyForGameErrorResponse, type GetUserKeyForGameResponse, type GetUserKeyForGameSuccessResponse, GoogleAdMob, type GrantPromotionRewardErrorResponse, type GrantPromotionRewardErrorResult, type GrantPromotionRewardForGameErrorResponse, type GrantPromotionRewardForGameErrorResult, type GrantPromotionRewardForGameResponse, type GrantPromotionRewardForGameSuccessResponse, type GrantPromotionRewardResponse, type GrantPromotionRewardSuccessResponse, type HapticFeedbackType, IAP, INTERNAL__appBridgeHandler, INTERNAL__module, type IapCreateOneTimePurchaseOrderOptions, type IapCreateOneTimePurchaseOrderResult, type IapCreateSubscriptionPurchaseOrderResult, type IapProductListItem, type IapSubscriptionInfoResult, type NetworkStatus, type NonConsumableProductListItem, type NotificationAgreementResult, type OpenPDFViewerParams, type OpenPDFViewerResult, type Primitive, type RequestNotificationAgreementOptions, type RequestTossPayPaysBillingOptions, type RequestTossPayPaysBillingResult, type SaveBase64DataParams, Storage, type SubmitGameCenterLeaderBoardScoreResponse, type SubscriptionProductListItem, TossPay, type UpdateLocationEventEmitter, appLogin, appsInTossEvent, appsInTossSignTossCert, checkoutPayment, closeView, contactsViral, eventLog, fetchAlbumItems, fetchAlbumPhotos, fetchContacts, generateHapticFeedback, getAnonymousKey, getClipboardText, getCurrentLocation, getDeviceId, getGameCenterGameProfile, getGroupId, getIsTossLoginIntegratedService, getLocale, getNetworkStatus, getOperationalEnvironment, getPlatformOS, getSchemeUri, getServerTime, getTossAppVersion, getTossShareLink, getUserKeyForGame, grantPromotionReward, grantPromotionRewardForGame, iapCreateOneTimePurchaseOrder, isMinVersionSupported, onVisibilityChangedByTransparentServiceWeb, openCamera, openGameCenterLeaderboard, openPDFViewer, openURL, processProductGrant, requestNotificationAgreement, requestOneTimePurchase, requestReview, requestSubscriptionPurchase, requestTossPayPaysBilling, safePostMessage, safeSyncPostMessage, saveBase64Data, setClipboardText, setDeviceOrientation, setIosSwipeGestureEnabled, setScreenAwakeMode, setSecureScreen, share, shareWithScheme, startUpdateLocation, submitGameCenterLeaderBoardScore };
|
package/dist/index.js
CHANGED
|
@@ -631,6 +631,26 @@ function requestOneTimePurchase(params) {
|
|
|
631
631
|
);
|
|
632
632
|
return unregisterCallbacks;
|
|
633
633
|
}
|
|
634
|
+
function requestSubscriptionPurchase(params) {
|
|
635
|
+
const { options, onEvent, onError } = params;
|
|
636
|
+
const { sku, offerId } = options;
|
|
637
|
+
const unregisterCallbacks = INTERNAL__appBridgeHandler.invokeAppBridgeMethod(
|
|
638
|
+
"requestSubscriptionPurchase",
|
|
639
|
+
{ sku, offerId: offerId ?? null },
|
|
640
|
+
{
|
|
641
|
+
onPurchased: (params2) => {
|
|
642
|
+
onEvent({ type: "purchased", data: params2 });
|
|
643
|
+
},
|
|
644
|
+
onSuccess: (result) => {
|
|
645
|
+
onEvent({ type: "success", data: result });
|
|
646
|
+
},
|
|
647
|
+
onError: (error) => {
|
|
648
|
+
onError(error);
|
|
649
|
+
}
|
|
650
|
+
}
|
|
651
|
+
);
|
|
652
|
+
return unregisterCallbacks;
|
|
653
|
+
}
|
|
634
654
|
function createOneTimePurchaseOrder(params) {
|
|
635
655
|
const isIAPSupported = isMinVersionSupported({
|
|
636
656
|
android: "5.219.0",
|
|
@@ -1218,6 +1238,7 @@ export {
|
|
|
1218
1238
|
requestNotificationAgreement,
|
|
1219
1239
|
requestOneTimePurchase,
|
|
1220
1240
|
requestReview,
|
|
1241
|
+
requestSubscriptionPurchase,
|
|
1221
1242
|
requestTossPayPaysBilling,
|
|
1222
1243
|
safePostMessage,
|
|
1223
1244
|
safeSyncPostMessage,
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@apps-in-toss/native-modules",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "2.6.
|
|
4
|
+
"version": "2.6.2",
|
|
5
5
|
"description": "Native Modules for Apps In Toss",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"typecheck": "tsc --noEmit",
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
"vitest": "^3.2.4"
|
|
43
43
|
},
|
|
44
44
|
"dependencies": {
|
|
45
|
-
"@apps-in-toss/types": "2.6.
|
|
45
|
+
"@apps-in-toss/types": "2.6.2",
|
|
46
46
|
"brick-module": "0.5.2",
|
|
47
47
|
"es-toolkit": "^1.39.3"
|
|
48
48
|
},
|
|
@@ -43,7 +43,7 @@ interface OneTimePurchaseSuccessEvent {
|
|
|
43
43
|
data: IapCreateOneTimePurchaseOrderResult;
|
|
44
44
|
}
|
|
45
45
|
|
|
46
|
-
interface
|
|
46
|
+
interface OneTimePurchasedEvent {
|
|
47
47
|
type: 'purchased';
|
|
48
48
|
data: { orderId: string };
|
|
49
49
|
}
|
|
@@ -66,7 +66,7 @@ export interface IapCreateOneTimePurchaseOrderOptions {
|
|
|
66
66
|
|
|
67
67
|
interface IapRequestOneTimePurchaseOptions {
|
|
68
68
|
options: Sku;
|
|
69
|
-
onEvent: (event:
|
|
69
|
+
onEvent: (event: OneTimePurchasedEvent | OneTimePurchaseSuccessEvent) => void | Promise<void>;
|
|
70
70
|
onError: (error: unknown) => void | Promise<void>;
|
|
71
71
|
}
|
|
72
72
|
|
|
@@ -102,6 +102,43 @@ export function requestOneTimePurchase(params: IapRequestOneTimePurchaseOptions)
|
|
|
102
102
|
return unregisterCallbacks;
|
|
103
103
|
}
|
|
104
104
|
|
|
105
|
+
interface SubscriptionPurchasedEvent {
|
|
106
|
+
type: 'purchased';
|
|
107
|
+
data: { orderId: string; subscriptionId?: string };
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
interface IapRequestSubscriptionPurchaseOrderOptions {
|
|
111
|
+
options: {
|
|
112
|
+
sku: string;
|
|
113
|
+
offerId?: string | null;
|
|
114
|
+
};
|
|
115
|
+
onEvent: (event: SubscriptionPurchasedEvent | SubscriptionSuccessEvent) => void | Promise<void>;
|
|
116
|
+
onError: (error: unknown) => void | Promise<void>;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
export function requestSubscriptionPurchase(params: IapRequestSubscriptionPurchaseOrderOptions) {
|
|
120
|
+
const { options, onEvent, onError } = params;
|
|
121
|
+
const { sku, offerId } = options;
|
|
122
|
+
|
|
123
|
+
const unregisterCallbacks = INTERNAL__appBridgeHandler.invokeAppBridgeMethod(
|
|
124
|
+
'requestSubscriptionPurchase',
|
|
125
|
+
{ sku, offerId: offerId ?? null },
|
|
126
|
+
{
|
|
127
|
+
onPurchased: (params: { orderId: string; subscriptionId?: string }) => {
|
|
128
|
+
onEvent({ type: 'purchased', data: params });
|
|
129
|
+
},
|
|
130
|
+
onSuccess: (result: IapCreateSubscriptionPurchaseOrderResult) => {
|
|
131
|
+
onEvent({ type: 'success', data: result });
|
|
132
|
+
},
|
|
133
|
+
onError: (error: any) => {
|
|
134
|
+
onError(error);
|
|
135
|
+
},
|
|
136
|
+
}
|
|
137
|
+
);
|
|
138
|
+
|
|
139
|
+
return unregisterCallbacks;
|
|
140
|
+
}
|
|
141
|
+
|
|
105
142
|
/**
|
|
106
143
|
* @public
|
|
107
144
|
* @category 인앱결제
|