react-native-iap 11.0.3 → 11.0.4
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/ios/RNIapIos.m +1 -1
- package/lib/commonjs/internal/platform.js +4 -2
- package/lib/commonjs/internal/platform.js.map +1 -1
- package/lib/commonjs/purchaseError.js +1 -0
- package/lib/commonjs/purchaseError.js.map +1 -1
- package/lib/module/internal/platform.js +3 -2
- package/lib/module/internal/platform.js.map +1 -1
- package/lib/module/purchaseError.js +1 -0
- package/lib/module/purchaseError.js.map +1 -1
- package/lib/typescript/purchaseError.d.ts +2 -1
- package/package.json +1 -1
- package/src/internal/platform.ts +4 -2
- package/src/purchaseError.ts +1 -0
package/ios/RNIapIos.m
CHANGED
|
@@ -22,7 +22,7 @@ RCT_EXTERN_METHOD(getItems:
|
|
|
22
22
|
|
|
23
23
|
RCT_EXTERN_METHOD(getAvailableItems:
|
|
24
24
|
(BOOL)automaticallyFinishRestoredTransactions
|
|
25
|
-
(RCTPromiseResolveBlock)resolve
|
|
25
|
+
resolve:(RCTPromiseResolveBlock)resolve
|
|
26
26
|
reject:(RCTPromiseRejectBlock)reject)
|
|
27
27
|
|
|
28
28
|
RCT_EXTERN_METHOD(buyProduct:
|
|
@@ -7,6 +7,8 @@ exports.storekitHybridMode = exports.storekit2Mode = exports.storekit1Mode = exp
|
|
|
7
7
|
|
|
8
8
|
var _reactNative = require("react-native");
|
|
9
9
|
|
|
10
|
+
var _purchaseError = require("../purchaseError");
|
|
11
|
+
|
|
10
12
|
const {
|
|
11
13
|
RNIapIos,
|
|
12
14
|
RNIapIosSk2,
|
|
@@ -30,7 +32,7 @@ exports.setAndroidNativeModule = setAndroidNativeModule;
|
|
|
30
32
|
|
|
31
33
|
const checkNativeAndroidAvailable = () => {
|
|
32
34
|
if (!RNIapModule && !RNIapAmazonModule) {
|
|
33
|
-
throw new Error(
|
|
35
|
+
throw new Error(_purchaseError.ErrorCode.E_IAP_NOT_AVAILABLE);
|
|
34
36
|
}
|
|
35
37
|
};
|
|
36
38
|
|
|
@@ -112,7 +114,7 @@ exports.storekitHybridMode = storekitHybridMode;
|
|
|
112
114
|
|
|
113
115
|
const checkNativeIOSAvailable = () => {
|
|
114
116
|
if (!RNIapIos && !isStorekit2Avaiable()) {
|
|
115
|
-
throw new Error(
|
|
117
|
+
throw new Error(_purchaseError.ErrorCode.E_IAP_NOT_AVAILABLE);
|
|
116
118
|
}
|
|
117
119
|
};
|
|
118
120
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["RNIapIos","RNIapIosSk2","RNIapModule","RNIapAmazonModule","NativeModules","isIos","Platform","OS","isAndroid","isAmazon","androidNativeModule","setAndroidNativeModule","nativeModule","checkNativeAndroidAvailable","Error","getAndroidModule","getNativeModule","getIosModule","iosNativeModule","isStorekit2Avaiable","isAvailable","isIosStorekit2","setIosNativeModule","storekit2Mode","disable","console","warn","storekit1Mode","storekitHybridMode","info","checkNativeIOSAvailable"],"sources":["platform.ts"],"sourcesContent":["import {NativeModules, Platform} from 'react-native';\n\nconst {RNIapIos, RNIapIosSk2, RNIapModule, RNIapAmazonModule} = NativeModules;\n\nexport const isIos = Platform.OS === 'ios';\nexport const isAndroid = Platform.OS === 'android';\nexport const isAmazon = isAndroid && !!RNIapAmazonModule;\n\n// Android\n\nlet androidNativeModule = RNIapModule;\n\nexport const setAndroidNativeModule = (\n nativeModule: typeof RNIapModule,\n): void => {\n androidNativeModule = nativeModule;\n};\n\nexport const checkNativeAndroidAvailable = (): void => {\n if (!RNIapModule && !RNIapAmazonModule) {\n throw new Error(
|
|
1
|
+
{"version":3,"names":["RNIapIos","RNIapIosSk2","RNIapModule","RNIapAmazonModule","NativeModules","isIos","Platform","OS","isAndroid","isAmazon","androidNativeModule","setAndroidNativeModule","nativeModule","checkNativeAndroidAvailable","Error","ErrorCode","E_IAP_NOT_AVAILABLE","getAndroidModule","getNativeModule","getIosModule","iosNativeModule","isStorekit2Avaiable","isAvailable","isIosStorekit2","setIosNativeModule","storekit2Mode","disable","console","warn","storekit1Mode","storekitHybridMode","info","checkNativeIOSAvailable"],"sources":["platform.ts"],"sourcesContent":["import {NativeModules, Platform} from 'react-native';\n\nimport {ErrorCode} from '../purchaseError';\n\nconst {RNIapIos, RNIapIosSk2, RNIapModule, RNIapAmazonModule} = NativeModules;\n\nexport const isIos = Platform.OS === 'ios';\nexport const isAndroid = Platform.OS === 'android';\nexport const isAmazon = isAndroid && !!RNIapAmazonModule;\n\n// Android\n\nlet androidNativeModule = RNIapModule;\n\nexport const setAndroidNativeModule = (\n nativeModule: typeof RNIapModule,\n): void => {\n androidNativeModule = nativeModule;\n};\n\nexport const checkNativeAndroidAvailable = (): void => {\n if (!RNIapModule && !RNIapAmazonModule) {\n throw new Error(ErrorCode.E_IAP_NOT_AVAILABLE);\n }\n};\n\nexport const getAndroidModule = ():\n | typeof RNIapModule\n | typeof RNIapAmazonModule => {\n checkNativeAndroidAvailable();\n\n return androidNativeModule\n ? androidNativeModule\n : RNIapModule\n ? RNIapModule\n : RNIapAmazonModule;\n};\n\nexport const getNativeModule = ():\n | typeof RNIapModule\n | typeof RNIapAmazonModule\n | typeof RNIapIos\n | typeof RNIapIosSk2 => {\n return isAndroid ? getAndroidModule() : getIosModule();\n};\n\n// iOS\n\nlet iosNativeModule: typeof RNIapIos | typeof RNIapIosSk2 = RNIapIos;\n\nexport const isStorekit2Avaiable = (): boolean =>\n isIos && RNIapIosSk2?.isAvailable() === 1;\n\nexport const isIosStorekit2 = () =>\n isIos &&\n !!iosNativeModule &&\n iosNativeModule === RNIapIosSk2 &&\n isStorekit2Avaiable();\n\nexport const setIosNativeModule = (\n nativeModule: typeof RNIapIos | typeof RNIapIosSk2,\n): void => {\n iosNativeModule = nativeModule;\n};\n\nexport const storekit2Mode = () => {\n iosNativeModule = RNIapIosSk2;\n if (isStorekit2Avaiable()) {\n RNIapIos.disable();\n return true;\n }\n if (isIos) {\n console.warn('Storekit 2 is not available on this device');\n return false;\n }\n return true;\n};\n\nexport const storekit1Mode = () => {\n iosNativeModule = RNIapIos;\n if (isStorekit2Avaiable()) {\n RNIapIosSk2.disable();\n return true;\n }\n return false;\n};\n\nexport const storekitHybridMode = () => {\n if (isStorekit2Avaiable()) {\n iosNativeModule = RNIapIosSk2;\n console.info('Using Storekit 2');\n return true;\n } else {\n iosNativeModule = RNIapIos;\n console.info('Using Storekit 1');\n return true;\n }\n};\n\nconst checkNativeIOSAvailable = (): void => {\n if (!RNIapIos && !isStorekit2Avaiable()) {\n throw new Error(ErrorCode.E_IAP_NOT_AVAILABLE);\n }\n};\n\nexport const getIosModule = (): typeof RNIapIos | typeof RNIapIosSk2 => {\n checkNativeIOSAvailable();\n\n return iosNativeModule\n ? iosNativeModule\n : RNIapIosSk2\n ? RNIapIosSk2\n : RNIapIos;\n};\n"],"mappings":";;;;;;;AAAA;;AAEA;;AAEA,MAAM;EAACA,QAAD;EAAWC,WAAX;EAAwBC,WAAxB;EAAqCC;AAArC,IAA0DC,0BAAhE;AAEO,MAAMC,KAAK,GAAGC,qBAAA,CAASC,EAAT,KAAgB,KAA9B;;AACA,MAAMC,SAAS,GAAGF,qBAAA,CAASC,EAAT,KAAgB,SAAlC;;AACA,MAAME,QAAQ,GAAGD,SAAS,IAAI,CAAC,CAACL,iBAAhC,C,CAEP;;;AAEA,IAAIO,mBAAmB,GAAGR,WAA1B;;AAEO,MAAMS,sBAAsB,GACjCC,YADoC,IAE3B;EACTF,mBAAmB,GAAGE,YAAtB;AACD,CAJM;;;;AAMA,MAAMC,2BAA2B,GAAG,MAAY;EACrD,IAAI,CAACX,WAAD,IAAgB,CAACC,iBAArB,EAAwC;IACtC,MAAM,IAAIW,KAAJ,CAAUC,wBAAA,CAAUC,mBAApB,CAAN;EACD;AACF,CAJM;;;;AAMA,MAAMC,gBAAgB,GAAG,MAEA;EAC9BJ,2BAA2B;EAE3B,OAAOH,mBAAmB,GACtBA,mBADsB,GAEtBR,WAAW,GACXA,WADW,GAEXC,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;;;AAYP,MAAMC,uBAAuB,GAAG,MAAY;EAC1C,IAAI,CAAChC,QAAD,IAAa,CAACqB,mBAAmB,EAArC,EAAyC;IACvC,MAAM,IAAIP,KAAJ,CAAUC,wBAAA,CAAUC,mBAApB,CAAN;EACD;AACF,CAJD;;AAMO,MAAMG,YAAY,GAAG,MAA4C;EACtEa,uBAAuB;EAEvB,OAAOZ,eAAe,GAClBA,eADkB,GAElBnB,WAAW,GACXA,WADW,GAEXD,QAJJ;AAKD,CARM"}
|
|
@@ -24,6 +24,7 @@ exports.ErrorCode = ErrorCode;
|
|
|
24
24
|
ErrorCode["E_BILLING_RESPONSE_JSON_PARSE_ERROR"] = "E_BILLING_RESPONSE_JSON_PARSE_ERROR";
|
|
25
25
|
ErrorCode["E_DEFERRED_PAYMENT"] = "E_DEFERRED_PAYMENT";
|
|
26
26
|
ErrorCode["E_INTERRUPTED"] = "E_INTERRUPTED";
|
|
27
|
+
ErrorCode["E_IAP_NOT_AVAILABLE"] = "E_IAP_NOT_AVAILABLE";
|
|
27
28
|
})(ErrorCode || (exports.ErrorCode = ErrorCode = {}));
|
|
28
29
|
|
|
29
30
|
class PurchaseError {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["ErrorCode","PurchaseError","constructor","name","message","responseCode","debugMessage","code","productId"],"sources":["purchaseError.ts"],"sourcesContent":["export enum ErrorCode {\n E_UNKNOWN = 'E_UNKNOWN',\n E_USER_CANCELLED = 'E_USER_CANCELLED',\n E_USER_ERROR = 'E_USER_ERROR',\n E_ITEM_UNAVAILABLE = 'E_ITEM_UNAVAILABLE',\n E_REMOTE_ERROR = 'E_REMOTE_ERROR',\n E_NETWORK_ERROR = 'E_NETWORK_ERROR',\n E_SERVICE_ERROR = 'E_SERVICE_ERROR',\n E_RECEIPT_FAILED = 'E_RECEIPT_FAILED',\n E_RECEIPT_FINISHED_FAILED = 'E_RECEIPT_FINISHED_FAILED',\n E_NOT_PREPARED = 'E_NOT_PREPARED',\n E_NOT_ENDED = 'E_NOT_ENDED',\n E_ALREADY_OWNED = 'E_ALREADY_OWNED',\n E_DEVELOPER_ERROR = 'E_DEVELOPER_ERROR',\n E_BILLING_RESPONSE_JSON_PARSE_ERROR = 'E_BILLING_RESPONSE_JSON_PARSE_ERROR',\n E_DEFERRED_PAYMENT = 'E_DEFERRED_PAYMENT',\n E_INTERRUPTED = 'E_INTERRUPTED',\n}\n\nexport class PurchaseError implements Error {\n constructor(\n public name: string,\n public message: string,\n public responseCode?: number,\n public debugMessage?: string,\n public code?: ErrorCode,\n public productId?: string,\n ) {\n this.name = '[react-native-iap]: PurchaseError';\n this.message = message;\n this.responseCode = responseCode;\n this.debugMessage = debugMessage;\n this.code = code;\n this.productId = productId;\n }\n}\n"],"mappings":";;;;;;IAAYA,S;;;WAAAA,S;EAAAA,S;EAAAA,S;EAAAA,S;EAAAA,S;EAAAA,S;EAAAA,S;EAAAA,S;EAAAA,S;EAAAA,S;EAAAA,S;EAAAA,S;EAAAA,S;EAAAA,S;EAAAA,S;EAAAA,S;EAAAA,S;GAAAA,S,yBAAAA,S;;
|
|
1
|
+
{"version":3,"names":["ErrorCode","PurchaseError","constructor","name","message","responseCode","debugMessage","code","productId"],"sources":["purchaseError.ts"],"sourcesContent":["export enum ErrorCode {\n E_UNKNOWN = 'E_UNKNOWN',\n E_USER_CANCELLED = 'E_USER_CANCELLED',\n E_USER_ERROR = 'E_USER_ERROR',\n E_ITEM_UNAVAILABLE = 'E_ITEM_UNAVAILABLE',\n E_REMOTE_ERROR = 'E_REMOTE_ERROR',\n E_NETWORK_ERROR = 'E_NETWORK_ERROR',\n E_SERVICE_ERROR = 'E_SERVICE_ERROR',\n E_RECEIPT_FAILED = 'E_RECEIPT_FAILED',\n E_RECEIPT_FINISHED_FAILED = 'E_RECEIPT_FINISHED_FAILED',\n E_NOT_PREPARED = 'E_NOT_PREPARED',\n E_NOT_ENDED = 'E_NOT_ENDED',\n E_ALREADY_OWNED = 'E_ALREADY_OWNED',\n E_DEVELOPER_ERROR = 'E_DEVELOPER_ERROR',\n E_BILLING_RESPONSE_JSON_PARSE_ERROR = 'E_BILLING_RESPONSE_JSON_PARSE_ERROR',\n E_DEFERRED_PAYMENT = 'E_DEFERRED_PAYMENT',\n E_INTERRUPTED = 'E_INTERRUPTED',\n E_IAP_NOT_AVAILABLE = 'E_IAP_NOT_AVAILABLE',\n}\n\nexport class PurchaseError implements Error {\n constructor(\n public name: string,\n public message: string,\n public responseCode?: number,\n public debugMessage?: string,\n public code?: ErrorCode,\n public productId?: string,\n ) {\n this.name = '[react-native-iap]: PurchaseError';\n this.message = message;\n this.responseCode = responseCode;\n this.debugMessage = debugMessage;\n this.code = code;\n this.productId = productId;\n }\n}\n"],"mappings":";;;;;;IAAYA,S;;;WAAAA,S;EAAAA,S;EAAAA,S;EAAAA,S;EAAAA,S;EAAAA,S;EAAAA,S;EAAAA,S;EAAAA,S;EAAAA,S;EAAAA,S;EAAAA,S;EAAAA,S;EAAAA,S;EAAAA,S;EAAAA,S;EAAAA,S;EAAAA,S;GAAAA,S,yBAAAA,S;;AAoBL,MAAMC,aAAN,CAAqC;EAC1CC,WAAW,CACFC,IADE,EAEFC,OAFE,EAGFC,YAHE,EAIFC,YAJE,EAKFC,IALE,EAMFC,SANE,EAOT;IAAA,KANOL,IAMP,GANOA,IAMP;IAAA,KALOC,OAKP,GALOA,OAKP;IAAA,KAJOC,YAIP,GAJOA,YAIP;IAAA,KAHOC,YAGP,GAHOA,YAGP;IAAA,KAFOC,IAEP,GAFOA,IAEP;IAAA,KADOC,SACP,GADOA,SACP;IACA,KAAKL,IAAL,GAAY,mCAAZ;IACA,KAAKC,OAAL,GAAeA,OAAf;IACA,KAAKC,YAAL,GAAoBA,YAApB;IACA,KAAKC,YAAL,GAAoBA,YAApB;IACA,KAAKC,IAAL,GAAYA,IAAZ;IACA,KAAKC,SAAL,GAAiBA,SAAjB;EACD;;AAfyC"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { NativeModules, Platform } from 'react-native';
|
|
2
|
+
import { ErrorCode } from '../purchaseError';
|
|
2
3
|
const {
|
|
3
4
|
RNIapIos,
|
|
4
5
|
RNIapIosSk2,
|
|
@@ -15,7 +16,7 @@ export const setAndroidNativeModule = nativeModule => {
|
|
|
15
16
|
};
|
|
16
17
|
export const checkNativeAndroidAvailable = () => {
|
|
17
18
|
if (!RNIapModule && !RNIapAmazonModule) {
|
|
18
|
-
throw new Error(
|
|
19
|
+
throw new Error(ErrorCode.E_IAP_NOT_AVAILABLE);
|
|
19
20
|
}
|
|
20
21
|
};
|
|
21
22
|
export const getAndroidModule = () => {
|
|
@@ -71,7 +72,7 @@ export const storekitHybridMode = () => {
|
|
|
71
72
|
|
|
72
73
|
const checkNativeIOSAvailable = () => {
|
|
73
74
|
if (!RNIapIos && !isStorekit2Avaiable()) {
|
|
74
|
-
throw new Error(
|
|
75
|
+
throw new Error(ErrorCode.E_IAP_NOT_AVAILABLE);
|
|
75
76
|
}
|
|
76
77
|
};
|
|
77
78
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["NativeModules","Platform","RNIapIos","RNIapIosSk2","RNIapModule","RNIapAmazonModule","isIos","OS","isAndroid","isAmazon","androidNativeModule","setAndroidNativeModule","nativeModule","checkNativeAndroidAvailable","Error","getAndroidModule","getNativeModule","getIosModule","iosNativeModule","isStorekit2Avaiable","isAvailable","isIosStorekit2","setIosNativeModule","storekit2Mode","disable","console","warn","storekit1Mode","storekitHybridMode","info","checkNativeIOSAvailable"],"sources":["platform.ts"],"sourcesContent":["import {NativeModules, Platform} from 'react-native';\n\nconst {RNIapIos, RNIapIosSk2, RNIapModule, RNIapAmazonModule} = NativeModules;\n\nexport const isIos = Platform.OS === 'ios';\nexport const isAndroid = Platform.OS === 'android';\nexport const isAmazon = isAndroid && !!RNIapAmazonModule;\n\n// Android\n\nlet androidNativeModule = RNIapModule;\n\nexport const setAndroidNativeModule = (\n nativeModule: typeof RNIapModule,\n): void => {\n androidNativeModule = nativeModule;\n};\n\nexport const checkNativeAndroidAvailable = (): void => {\n if (!RNIapModule && !RNIapAmazonModule) {\n throw new Error(
|
|
1
|
+
{"version":3,"names":["NativeModules","Platform","ErrorCode","RNIapIos","RNIapIosSk2","RNIapModule","RNIapAmazonModule","isIos","OS","isAndroid","isAmazon","androidNativeModule","setAndroidNativeModule","nativeModule","checkNativeAndroidAvailable","Error","E_IAP_NOT_AVAILABLE","getAndroidModule","getNativeModule","getIosModule","iosNativeModule","isStorekit2Avaiable","isAvailable","isIosStorekit2","setIosNativeModule","storekit2Mode","disable","console","warn","storekit1Mode","storekitHybridMode","info","checkNativeIOSAvailable"],"sources":["platform.ts"],"sourcesContent":["import {NativeModules, Platform} from 'react-native';\n\nimport {ErrorCode} from '../purchaseError';\n\nconst {RNIapIos, RNIapIosSk2, RNIapModule, RNIapAmazonModule} = NativeModules;\n\nexport const isIos = Platform.OS === 'ios';\nexport const isAndroid = Platform.OS === 'android';\nexport const isAmazon = isAndroid && !!RNIapAmazonModule;\n\n// Android\n\nlet androidNativeModule = RNIapModule;\n\nexport const setAndroidNativeModule = (\n nativeModule: typeof RNIapModule,\n): void => {\n androidNativeModule = nativeModule;\n};\n\nexport const checkNativeAndroidAvailable = (): void => {\n if (!RNIapModule && !RNIapAmazonModule) {\n throw new Error(ErrorCode.E_IAP_NOT_AVAILABLE);\n }\n};\n\nexport const getAndroidModule = ():\n | typeof RNIapModule\n | typeof RNIapAmazonModule => {\n checkNativeAndroidAvailable();\n\n return androidNativeModule\n ? androidNativeModule\n : RNIapModule\n ? RNIapModule\n : RNIapAmazonModule;\n};\n\nexport const getNativeModule = ():\n | typeof RNIapModule\n | typeof RNIapAmazonModule\n | typeof RNIapIos\n | typeof RNIapIosSk2 => {\n return isAndroid ? getAndroidModule() : getIosModule();\n};\n\n// iOS\n\nlet iosNativeModule: typeof RNIapIos | typeof RNIapIosSk2 = RNIapIos;\n\nexport const isStorekit2Avaiable = (): boolean =>\n isIos && RNIapIosSk2?.isAvailable() === 1;\n\nexport const isIosStorekit2 = () =>\n isIos &&\n !!iosNativeModule &&\n iosNativeModule === RNIapIosSk2 &&\n isStorekit2Avaiable();\n\nexport const setIosNativeModule = (\n nativeModule: typeof RNIapIos | typeof RNIapIosSk2,\n): void => {\n iosNativeModule = nativeModule;\n};\n\nexport const storekit2Mode = () => {\n iosNativeModule = RNIapIosSk2;\n if (isStorekit2Avaiable()) {\n RNIapIos.disable();\n return true;\n }\n if (isIos) {\n console.warn('Storekit 2 is not available on this device');\n return false;\n }\n return true;\n};\n\nexport const storekit1Mode = () => {\n iosNativeModule = RNIapIos;\n if (isStorekit2Avaiable()) {\n RNIapIosSk2.disable();\n return true;\n }\n return false;\n};\n\nexport const storekitHybridMode = () => {\n if (isStorekit2Avaiable()) {\n iosNativeModule = RNIapIosSk2;\n console.info('Using Storekit 2');\n return true;\n } else {\n iosNativeModule = RNIapIos;\n console.info('Using Storekit 1');\n return true;\n }\n};\n\nconst checkNativeIOSAvailable = (): void => {\n if (!RNIapIos && !isStorekit2Avaiable()) {\n throw new Error(ErrorCode.E_IAP_NOT_AVAILABLE);\n }\n};\n\nexport const getIosModule = (): typeof RNIapIos | typeof RNIapIosSk2 => {\n checkNativeIOSAvailable();\n\n return iosNativeModule\n ? iosNativeModule\n : RNIapIosSk2\n ? RNIapIosSk2\n : RNIapIos;\n};\n"],"mappings":"AAAA,SAAQA,aAAR,EAAuBC,QAAvB,QAAsC,cAAtC;AAEA,SAAQC,SAAR,QAAwB,kBAAxB;AAEA,MAAM;EAACC,QAAD;EAAWC,WAAX;EAAwBC,WAAxB;EAAqCC;AAArC,IAA0DN,aAAhE;AAEA,OAAO,MAAMO,KAAK,GAAGN,QAAQ,CAACO,EAAT,KAAgB,KAA9B;AACP,OAAO,MAAMC,SAAS,GAAGR,QAAQ,CAACO,EAAT,KAAgB,SAAlC;AACP,OAAO,MAAME,QAAQ,GAAGD,SAAS,IAAI,CAAC,CAACH,iBAAhC,C,CAEP;;AAEA,IAA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jCT,eAAe,GAAGjB,QAAlB;;EACA,IAAIkB,mBAAmB,EAAvB,EAA2B;IACzBjB,WAAW,CAACsB,OAAZ;IACA,OAAO,IAAP;EACD;;EACD,OAAO,KAAP;AACD,CAPM;AASP,OAAO,MAAMI,kBAAkB,GAAG,MAAM;EACtC,IAAIT,mBAAmB,EAAvB,EAA2B;IACzBD,eAAe,GAAGhB,WAAlB;IACAuB,OAAO,CAACI,IAAR,CAAa,kBAAb;IACA,OAAO,IAAP;EACD,CAJD,MAIO;IACLX,eAAe,GAAGjB,QAAlB;IACAwB,OAAO,CAACI,IAAR,CAAa,kBAAb;IACA,OAAO,IAAP;EACD;AACF,CAVM;;AAYP,MAAMC,uBAAuB,GAAG,MAAY;EAC1C,IAAI,CAAC7B,QAAD,IAAa,CAACkB,mBAAmB,EAArC,EAAyC;IACvC,MAAM,IAAIN,KAAJ,CAAUb,SAAS,CAACc,mBAApB,CAAN;EACD;AACF,CAJD;;AAMA,OAAO,MAAMG,YAAY,GAAG,MAA4C;EACtEa,uBAAuB;EAEvB,OAAOZ,eAAe,GAClBA,eADkB,GAElBhB,WAAW,GACXA,WADW,GAEXD,QAJJ;AAKD,CARM"}
|
|
@@ -17,6 +17,7 @@ export let ErrorCode;
|
|
|
17
17
|
ErrorCode["E_BILLING_RESPONSE_JSON_PARSE_ERROR"] = "E_BILLING_RESPONSE_JSON_PARSE_ERROR";
|
|
18
18
|
ErrorCode["E_DEFERRED_PAYMENT"] = "E_DEFERRED_PAYMENT";
|
|
19
19
|
ErrorCode["E_INTERRUPTED"] = "E_INTERRUPTED";
|
|
20
|
+
ErrorCode["E_IAP_NOT_AVAILABLE"] = "E_IAP_NOT_AVAILABLE";
|
|
20
21
|
})(ErrorCode || (ErrorCode = {}));
|
|
21
22
|
|
|
22
23
|
export class PurchaseError {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["ErrorCode","PurchaseError","constructor","name","message","responseCode","debugMessage","code","productId"],"sources":["purchaseError.ts"],"sourcesContent":["export enum ErrorCode {\n E_UNKNOWN = 'E_UNKNOWN',\n E_USER_CANCELLED = 'E_USER_CANCELLED',\n E_USER_ERROR = 'E_USER_ERROR',\n E_ITEM_UNAVAILABLE = 'E_ITEM_UNAVAILABLE',\n E_REMOTE_ERROR = 'E_REMOTE_ERROR',\n E_NETWORK_ERROR = 'E_NETWORK_ERROR',\n E_SERVICE_ERROR = 'E_SERVICE_ERROR',\n E_RECEIPT_FAILED = 'E_RECEIPT_FAILED',\n E_RECEIPT_FINISHED_FAILED = 'E_RECEIPT_FINISHED_FAILED',\n E_NOT_PREPARED = 'E_NOT_PREPARED',\n E_NOT_ENDED = 'E_NOT_ENDED',\n E_ALREADY_OWNED = 'E_ALREADY_OWNED',\n E_DEVELOPER_ERROR = 'E_DEVELOPER_ERROR',\n E_BILLING_RESPONSE_JSON_PARSE_ERROR = 'E_BILLING_RESPONSE_JSON_PARSE_ERROR',\n E_DEFERRED_PAYMENT = 'E_DEFERRED_PAYMENT',\n E_INTERRUPTED = 'E_INTERRUPTED',\n}\n\nexport class PurchaseError implements Error {\n constructor(\n public name: string,\n public message: string,\n public responseCode?: number,\n public debugMessage?: string,\n public code?: ErrorCode,\n public productId?: string,\n ) {\n this.name = '[react-native-iap]: PurchaseError';\n this.message = message;\n this.responseCode = responseCode;\n this.debugMessage = debugMessage;\n this.code = code;\n this.productId = productId;\n }\n}\n"],"mappings":"AAAA,WAAYA,SAAZ;;WAAYA,S;EAAAA,S;EAAAA,S;EAAAA,S;EAAAA,S;EAAAA,S;EAAAA,S;EAAAA,S;EAAAA,S;EAAAA,S;EAAAA,S;EAAAA,S;EAAAA,S;EAAAA,S;EAAAA,S;EAAAA,S;EAAAA,S;GAAAA,S,KAAAA,S;;
|
|
1
|
+
{"version":3,"names":["ErrorCode","PurchaseError","constructor","name","message","responseCode","debugMessage","code","productId"],"sources":["purchaseError.ts"],"sourcesContent":["export enum ErrorCode {\n E_UNKNOWN = 'E_UNKNOWN',\n E_USER_CANCELLED = 'E_USER_CANCELLED',\n E_USER_ERROR = 'E_USER_ERROR',\n E_ITEM_UNAVAILABLE = 'E_ITEM_UNAVAILABLE',\n E_REMOTE_ERROR = 'E_REMOTE_ERROR',\n E_NETWORK_ERROR = 'E_NETWORK_ERROR',\n E_SERVICE_ERROR = 'E_SERVICE_ERROR',\n E_RECEIPT_FAILED = 'E_RECEIPT_FAILED',\n E_RECEIPT_FINISHED_FAILED = 'E_RECEIPT_FINISHED_FAILED',\n E_NOT_PREPARED = 'E_NOT_PREPARED',\n E_NOT_ENDED = 'E_NOT_ENDED',\n E_ALREADY_OWNED = 'E_ALREADY_OWNED',\n E_DEVELOPER_ERROR = 'E_DEVELOPER_ERROR',\n E_BILLING_RESPONSE_JSON_PARSE_ERROR = 'E_BILLING_RESPONSE_JSON_PARSE_ERROR',\n E_DEFERRED_PAYMENT = 'E_DEFERRED_PAYMENT',\n E_INTERRUPTED = 'E_INTERRUPTED',\n E_IAP_NOT_AVAILABLE = 'E_IAP_NOT_AVAILABLE',\n}\n\nexport class PurchaseError implements Error {\n constructor(\n public name: string,\n public message: string,\n public responseCode?: number,\n public debugMessage?: string,\n public code?: ErrorCode,\n public productId?: string,\n ) {\n this.name = '[react-native-iap]: PurchaseError';\n this.message = message;\n this.responseCode = responseCode;\n this.debugMessage = debugMessage;\n this.code = code;\n this.productId = productId;\n }\n}\n"],"mappings":"AAAA,WAAYA,SAAZ;;WAAYA,S;EAAAA,S;EAAAA,S;EAAAA,S;EAAAA,S;EAAAA,S;EAAAA,S;EAAAA,S;EAAAA,S;EAAAA,S;EAAAA,S;EAAAA,S;EAAAA,S;EAAAA,S;EAAAA,S;EAAAA,S;EAAAA,S;EAAAA,S;GAAAA,S,KAAAA,S;;AAoBZ,OAAO,MAAMC,aAAN,CAAqC;EAC1CC,WAAW,CACFC,IADE,EAEFC,OAFE,EAGFC,YAHE,EAIFC,YAJE,EAKFC,IALE,EAMFC,SANE,EAOT;IAAA,KANOL,IAMP,GANOA,IAMP;IAAA,KALOC,OAKP,GALOA,OAKP;IAAA,KAJOC,YAIP,GAJOA,YAIP;IAAA,KAHOC,YAGP,GAHOA,YAGP;IAAA,KAFOC,IAEP,GAFOA,IAEP;IAAA,KADOC,SACP,GADOA,SACP;IACA,KAAKL,IAAL,GAAY,mCAAZ;IACA,KAAKC,OAAL,GAAeA,OAAf;IACA,KAAKC,YAAL,GAAoBA,YAApB;IACA,KAAKC,YAAL,GAAoBA,YAApB;IACA,KAAKC,IAAL,GAAYA,IAAZ;IACA,KAAKC,SAAL,GAAiBA,SAAjB;EACD;;AAfyC"}
|
|
@@ -14,7 +14,8 @@ export declare enum ErrorCode {
|
|
|
14
14
|
E_DEVELOPER_ERROR = "E_DEVELOPER_ERROR",
|
|
15
15
|
E_BILLING_RESPONSE_JSON_PARSE_ERROR = "E_BILLING_RESPONSE_JSON_PARSE_ERROR",
|
|
16
16
|
E_DEFERRED_PAYMENT = "E_DEFERRED_PAYMENT",
|
|
17
|
-
E_INTERRUPTED = "E_INTERRUPTED"
|
|
17
|
+
E_INTERRUPTED = "E_INTERRUPTED",
|
|
18
|
+
E_IAP_NOT_AVAILABLE = "E_IAP_NOT_AVAILABLE"
|
|
18
19
|
}
|
|
19
20
|
export declare class PurchaseError implements Error {
|
|
20
21
|
name: string;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-native-iap",
|
|
3
|
-
"version": "11.0.
|
|
3
|
+
"version": "11.0.4",
|
|
4
4
|
"description": "React Native In App Purchase Module.",
|
|
5
5
|
"repository": "https://github.com/dooboolab/react-native-iap",
|
|
6
6
|
"author": "dooboolab <support@dooboolab.com> (https://github.com/dooboolab)",
|
package/src/internal/platform.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import {NativeModules, Platform} from 'react-native';
|
|
2
2
|
|
|
3
|
+
import {ErrorCode} from '../purchaseError';
|
|
4
|
+
|
|
3
5
|
const {RNIapIos, RNIapIosSk2, RNIapModule, RNIapAmazonModule} = NativeModules;
|
|
4
6
|
|
|
5
7
|
export const isIos = Platform.OS === 'ios';
|
|
@@ -18,7 +20,7 @@ export const setAndroidNativeModule = (
|
|
|
18
20
|
|
|
19
21
|
export const checkNativeAndroidAvailable = (): void => {
|
|
20
22
|
if (!RNIapModule && !RNIapAmazonModule) {
|
|
21
|
-
throw new Error(
|
|
23
|
+
throw new Error(ErrorCode.E_IAP_NOT_AVAILABLE);
|
|
22
24
|
}
|
|
23
25
|
};
|
|
24
26
|
|
|
@@ -97,7 +99,7 @@ export const storekitHybridMode = () => {
|
|
|
97
99
|
|
|
98
100
|
const checkNativeIOSAvailable = (): void => {
|
|
99
101
|
if (!RNIapIos && !isStorekit2Avaiable()) {
|
|
100
|
-
throw new Error(
|
|
102
|
+
throw new Error(ErrorCode.E_IAP_NOT_AVAILABLE);
|
|
101
103
|
}
|
|
102
104
|
};
|
|
103
105
|
|
package/src/purchaseError.ts
CHANGED
|
@@ -15,6 +15,7 @@ export enum ErrorCode {
|
|
|
15
15
|
E_BILLING_RESPONSE_JSON_PARSE_ERROR = 'E_BILLING_RESPONSE_JSON_PARSE_ERROR',
|
|
16
16
|
E_DEFERRED_PAYMENT = 'E_DEFERRED_PAYMENT',
|
|
17
17
|
E_INTERRUPTED = 'E_INTERRUPTED',
|
|
18
|
+
E_IAP_NOT_AVAILABLE = 'E_IAP_NOT_AVAILABLE',
|
|
18
19
|
}
|
|
19
20
|
|
|
20
21
|
export class PurchaseError implements Error {
|