expo-iap 2.9.3 → 2.9.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/build/ExpoIap.types.d.ts +36 -28
- package/build/ExpoIap.types.d.ts.map +1 -1
- package/build/ExpoIap.types.js +56 -64
- package/build/ExpoIap.types.js.map +1 -1
- package/build/utils/errorMapping.d.ts.map +1 -1
- package/build/utils/errorMapping.js +2 -0
- package/build/utils/errorMapping.js.map +1 -1
- package/ios/ExpoIap.podspec +1 -1
- package/ios/ExpoIapModule.swift +9 -6
- package/package.json +1 -1
- package/src/ExpoIap.types.ts +63 -67
- package/src/utils/errorMapping.ts +2 -0
package/build/ExpoIap.types.d.ts
CHANGED
|
@@ -64,6 +64,7 @@ export declare enum ErrorCode {
|
|
|
64
64
|
E_NETWORK_ERROR = "E_NETWORK_ERROR",
|
|
65
65
|
E_SERVICE_ERROR = "E_SERVICE_ERROR",
|
|
66
66
|
E_RECEIPT_FAILED = "E_RECEIPT_FAILED",
|
|
67
|
+
E_RECEIPT_FINISHED = "E_RECEIPT_FINISHED",
|
|
67
68
|
E_RECEIPT_FINISHED_FAILED = "E_RECEIPT_FINISHED_FAILED",
|
|
68
69
|
E_NOT_PREPARED = "E_NOT_PREPARED",
|
|
69
70
|
E_NOT_ENDED = "E_NOT_ENDED",
|
|
@@ -90,36 +91,42 @@ export declare enum ErrorCode {
|
|
|
90
91
|
E_FEATURE_NOT_SUPPORTED = "E_FEATURE_NOT_SUPPORTED",
|
|
91
92
|
E_EMPTY_SKU_LIST = "E_EMPTY_SKU_LIST"
|
|
92
93
|
}
|
|
93
|
-
/**
|
|
94
|
-
* Platform-specific error code mappings
|
|
95
|
-
* Maps ErrorCode enum values to platform-specific integer codes
|
|
96
|
-
*/
|
|
97
94
|
export declare const ErrorCodeMapping: {
|
|
98
95
|
readonly ios: {
|
|
99
|
-
readonly E_UNKNOWN:
|
|
100
|
-
readonly
|
|
101
|
-
readonly
|
|
102
|
-
readonly
|
|
103
|
-
readonly
|
|
104
|
-
readonly
|
|
105
|
-
readonly
|
|
106
|
-
readonly E_RECEIPT_FAILED:
|
|
107
|
-
readonly
|
|
108
|
-
readonly
|
|
109
|
-
readonly
|
|
110
|
-
readonly
|
|
111
|
-
readonly
|
|
112
|
-
readonly
|
|
113
|
-
readonly
|
|
114
|
-
readonly
|
|
115
|
-
readonly
|
|
116
|
-
readonly
|
|
117
|
-
readonly
|
|
118
|
-
readonly
|
|
119
|
-
readonly
|
|
120
|
-
readonly
|
|
121
|
-
readonly
|
|
122
|
-
readonly
|
|
96
|
+
readonly E_UNKNOWN: "E_UNKNOWN";
|
|
97
|
+
readonly E_USER_CANCELLED: "E_USER_CANCELLED";
|
|
98
|
+
readonly E_USER_ERROR: "E_USER_ERROR";
|
|
99
|
+
readonly E_ITEM_UNAVAILABLE: "E_ITEM_UNAVAILABLE";
|
|
100
|
+
readonly E_REMOTE_ERROR: "E_REMOTE_ERROR";
|
|
101
|
+
readonly E_NETWORK_ERROR: "E_NETWORK_ERROR";
|
|
102
|
+
readonly E_SERVICE_ERROR: "E_SERVICE_ERROR";
|
|
103
|
+
readonly E_RECEIPT_FAILED: "E_RECEIPT_FAILED";
|
|
104
|
+
readonly E_RECEIPT_FINISHED: "E_RECEIPT_FINISHED";
|
|
105
|
+
readonly E_RECEIPT_FINISHED_FAILED: "E_RECEIPT_FINISHED_FAILED";
|
|
106
|
+
readonly E_NOT_PREPARED: "E_NOT_PREPARED";
|
|
107
|
+
readonly E_NOT_ENDED: "E_NOT_ENDED";
|
|
108
|
+
readonly E_ALREADY_OWNED: "E_ALREADY_OWNED";
|
|
109
|
+
readonly E_DEVELOPER_ERROR: "E_DEVELOPER_ERROR";
|
|
110
|
+
readonly E_BILLING_RESPONSE_JSON_PARSE_ERROR: "E_BILLING_RESPONSE_JSON_PARSE_ERROR";
|
|
111
|
+
readonly E_DEFERRED_PAYMENT: "E_DEFERRED_PAYMENT";
|
|
112
|
+
readonly E_INTERRUPTED: "E_INTERRUPTED";
|
|
113
|
+
readonly E_IAP_NOT_AVAILABLE: "E_IAP_NOT_AVAILABLE";
|
|
114
|
+
readonly E_PURCHASE_ERROR: "E_PURCHASE_ERROR";
|
|
115
|
+
readonly E_SYNC_ERROR: "E_SYNC_ERROR";
|
|
116
|
+
readonly E_TRANSACTION_VALIDATION_FAILED: "E_TRANSACTION_VALIDATION_FAILED";
|
|
117
|
+
readonly E_ACTIVITY_UNAVAILABLE: "E_ACTIVITY_UNAVAILABLE";
|
|
118
|
+
readonly E_ALREADY_PREPARED: "E_ALREADY_PREPARED";
|
|
119
|
+
readonly E_PENDING: "E_PENDING";
|
|
120
|
+
readonly E_CONNECTION_CLOSED: "E_CONNECTION_CLOSED";
|
|
121
|
+
readonly E_INIT_CONNECTION: "E_INIT_CONNECTION";
|
|
122
|
+
readonly E_SERVICE_DISCONNECTED: "E_SERVICE_DISCONNECTED";
|
|
123
|
+
readonly E_QUERY_PRODUCT: "E_QUERY_PRODUCT";
|
|
124
|
+
readonly E_SKU_NOT_FOUND: "E_SKU_NOT_FOUND";
|
|
125
|
+
readonly E_SKU_OFFER_MISMATCH: "E_SKU_OFFER_MISMATCH";
|
|
126
|
+
readonly E_ITEM_NOT_OWNED: "E_ITEM_NOT_OWNED";
|
|
127
|
+
readonly E_BILLING_UNAVAILABLE: "E_BILLING_UNAVAILABLE";
|
|
128
|
+
readonly E_FEATURE_NOT_SUPPORTED: "E_FEATURE_NOT_SUPPORTED";
|
|
129
|
+
readonly E_EMPTY_SKU_LIST: "E_EMPTY_SKU_LIST";
|
|
123
130
|
};
|
|
124
131
|
readonly android: {
|
|
125
132
|
readonly E_UNKNOWN: "E_UNKNOWN";
|
|
@@ -130,6 +137,7 @@ export declare const ErrorCodeMapping: {
|
|
|
130
137
|
readonly E_NETWORK_ERROR: "E_NETWORK_ERROR";
|
|
131
138
|
readonly E_SERVICE_ERROR: "E_SERVICE_ERROR";
|
|
132
139
|
readonly E_RECEIPT_FAILED: "E_RECEIPT_FAILED";
|
|
140
|
+
readonly E_RECEIPT_FINISHED: "E_RECEIPT_FINISHED";
|
|
133
141
|
readonly E_RECEIPT_FINISHED_FAILED: "E_RECEIPT_FINISHED_FAILED";
|
|
134
142
|
readonly E_NOT_PREPARED: "E_NOT_PREPARED";
|
|
135
143
|
readonly E_NOT_ENDED: "E_NOT_ENDED";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ExpoIap.types.d.ts","sourceRoot":"","sources":["../src/ExpoIap.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,cAAc,EACd,eAAe,EACf,0BAA0B,EAC3B,MAAM,8BAA8B,CAAC;AACtC,OAAO,KAAK,EACV,UAAU,EACV,WAAW,EACX,sBAAsB,EACvB,MAAM,0BAA0B,CAAC;AAGlC,MAAM,MAAM,kBAAkB,GAAG;IAC/B,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AAEF,MAAM,MAAM,WAAW,GAAG,OAAO,GAAG,MAAM,CAAC;AAM3C,MAAM,MAAM,aAAa,GAAG;IAC1B,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,MAAM,CAAC;IACpB,IAAI,EAAE,WAAW,CAAC;IAClB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,YAAY,EAAE,MAAM,CAAC;IACrB,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF,MAAM,MAAM,cAAc,GAAG;IAC3B,EAAE,EAAE,MAAM,CAAC;IACX,SAAS,EAAE,MAAM,CAAC;IAClB,GAAG,CAAC,EAAE,MAAM,EAAE,CAAC;IACf,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,eAAe,EAAE,MAAM,CAAC;IACxB,kBAAkB,EAAE,MAAM,CAAC;IAC3B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C;CACpD;AAED;;;GAGG;AACH,MAAM,MAAM,oBAAoB,GAAG,+BAA+B,CAAC;AAEnE;;;GAGG;AACH,MAAM,MAAM,wBAAwB,GAAG,mCAAmC,CAAC"}
|
package/build/ExpoIap.types.js
CHANGED
|
@@ -16,6 +16,7 @@ export var ErrorCode;
|
|
|
16
16
|
ErrorCode["E_NETWORK_ERROR"] = "E_NETWORK_ERROR";
|
|
17
17
|
ErrorCode["E_SERVICE_ERROR"] = "E_SERVICE_ERROR";
|
|
18
18
|
ErrorCode["E_RECEIPT_FAILED"] = "E_RECEIPT_FAILED";
|
|
19
|
+
ErrorCode["E_RECEIPT_FINISHED"] = "E_RECEIPT_FINISHED";
|
|
19
20
|
ErrorCode["E_RECEIPT_FINISHED_FAILED"] = "E_RECEIPT_FINISHED_FAILED";
|
|
20
21
|
ErrorCode["E_NOT_PREPARED"] = "E_NOT_PREPARED";
|
|
21
22
|
ErrorCode["E_NOT_ENDED"] = "E_NOT_ENDED";
|
|
@@ -43,72 +44,54 @@ export var ErrorCode;
|
|
|
43
44
|
ErrorCode["E_FEATURE_NOT_SUPPORTED"] = "E_FEATURE_NOT_SUPPORTED";
|
|
44
45
|
ErrorCode["E_EMPTY_SKU_LIST"] = "E_EMPTY_SKU_LIST";
|
|
45
46
|
})(ErrorCode || (ErrorCode = {}));
|
|
47
|
+
// Fast lookup set for validating standardized error code strings
|
|
48
|
+
const OPENIAP_ERROR_CODE_SET = new Set(Object.values(ErrorCode));
|
|
46
49
|
/**
|
|
47
50
|
* Platform-specific error code mappings
|
|
48
51
|
* Maps ErrorCode enum values to platform-specific integer codes
|
|
49
52
|
*/
|
|
53
|
+
// Shared OpenIAP string code mapping for both platforms
|
|
54
|
+
const COMMON_ERROR_CODE_MAP = {
|
|
55
|
+
[ErrorCode.E_UNKNOWN]: 'E_UNKNOWN',
|
|
56
|
+
[ErrorCode.E_USER_CANCELLED]: 'E_USER_CANCELLED',
|
|
57
|
+
[ErrorCode.E_USER_ERROR]: 'E_USER_ERROR',
|
|
58
|
+
[ErrorCode.E_ITEM_UNAVAILABLE]: 'E_ITEM_UNAVAILABLE',
|
|
59
|
+
[ErrorCode.E_REMOTE_ERROR]: 'E_REMOTE_ERROR',
|
|
60
|
+
[ErrorCode.E_NETWORK_ERROR]: 'E_NETWORK_ERROR',
|
|
61
|
+
[ErrorCode.E_SERVICE_ERROR]: 'E_SERVICE_ERROR',
|
|
62
|
+
[ErrorCode.E_RECEIPT_FAILED]: 'E_RECEIPT_FAILED',
|
|
63
|
+
[ErrorCode.E_RECEIPT_FINISHED]: 'E_RECEIPT_FINISHED',
|
|
64
|
+
[ErrorCode.E_RECEIPT_FINISHED_FAILED]: 'E_RECEIPT_FINISHED_FAILED',
|
|
65
|
+
[ErrorCode.E_NOT_PREPARED]: 'E_NOT_PREPARED',
|
|
66
|
+
[ErrorCode.E_NOT_ENDED]: 'E_NOT_ENDED',
|
|
67
|
+
[ErrorCode.E_ALREADY_OWNED]: 'E_ALREADY_OWNED',
|
|
68
|
+
[ErrorCode.E_DEVELOPER_ERROR]: 'E_DEVELOPER_ERROR',
|
|
69
|
+
[ErrorCode.E_BILLING_RESPONSE_JSON_PARSE_ERROR]: 'E_BILLING_RESPONSE_JSON_PARSE_ERROR',
|
|
70
|
+
[ErrorCode.E_DEFERRED_PAYMENT]: 'E_DEFERRED_PAYMENT',
|
|
71
|
+
[ErrorCode.E_INTERRUPTED]: 'E_INTERRUPTED',
|
|
72
|
+
[ErrorCode.E_IAP_NOT_AVAILABLE]: 'E_IAP_NOT_AVAILABLE',
|
|
73
|
+
[ErrorCode.E_PURCHASE_ERROR]: 'E_PURCHASE_ERROR',
|
|
74
|
+
[ErrorCode.E_SYNC_ERROR]: 'E_SYNC_ERROR',
|
|
75
|
+
[ErrorCode.E_TRANSACTION_VALIDATION_FAILED]: 'E_TRANSACTION_VALIDATION_FAILED',
|
|
76
|
+
[ErrorCode.E_ACTIVITY_UNAVAILABLE]: 'E_ACTIVITY_UNAVAILABLE',
|
|
77
|
+
[ErrorCode.E_ALREADY_PREPARED]: 'E_ALREADY_PREPARED',
|
|
78
|
+
[ErrorCode.E_PENDING]: 'E_PENDING',
|
|
79
|
+
[ErrorCode.E_CONNECTION_CLOSED]: 'E_CONNECTION_CLOSED',
|
|
80
|
+
[ErrorCode.E_INIT_CONNECTION]: 'E_INIT_CONNECTION',
|
|
81
|
+
[ErrorCode.E_SERVICE_DISCONNECTED]: 'E_SERVICE_DISCONNECTED',
|
|
82
|
+
[ErrorCode.E_QUERY_PRODUCT]: 'E_QUERY_PRODUCT',
|
|
83
|
+
[ErrorCode.E_SKU_NOT_FOUND]: 'E_SKU_NOT_FOUND',
|
|
84
|
+
[ErrorCode.E_SKU_OFFER_MISMATCH]: 'E_SKU_OFFER_MISMATCH',
|
|
85
|
+
[ErrorCode.E_ITEM_NOT_OWNED]: 'E_ITEM_NOT_OWNED',
|
|
86
|
+
[ErrorCode.E_BILLING_UNAVAILABLE]: 'E_BILLING_UNAVAILABLE',
|
|
87
|
+
[ErrorCode.E_FEATURE_NOT_SUPPORTED]: 'E_FEATURE_NOT_SUPPORTED',
|
|
88
|
+
[ErrorCode.E_EMPTY_SKU_LIST]: 'E_EMPTY_SKU_LIST',
|
|
89
|
+
};
|
|
50
90
|
export const ErrorCodeMapping = {
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
[ErrorCode.E_USER_ERROR]: 3,
|
|
56
|
-
[ErrorCode.E_ITEM_UNAVAILABLE]: 4,
|
|
57
|
-
[ErrorCode.E_REMOTE_ERROR]: 5,
|
|
58
|
-
[ErrorCode.E_NETWORK_ERROR]: 6,
|
|
59
|
-
[ErrorCode.E_RECEIPT_FAILED]: 7,
|
|
60
|
-
[ErrorCode.E_RECEIPT_FINISHED_FAILED]: 8,
|
|
61
|
-
[ErrorCode.E_DEVELOPER_ERROR]: 9,
|
|
62
|
-
[ErrorCode.E_PURCHASE_ERROR]: 10,
|
|
63
|
-
[ErrorCode.E_SYNC_ERROR]: 11,
|
|
64
|
-
[ErrorCode.E_DEFERRED_PAYMENT]: 12,
|
|
65
|
-
[ErrorCode.E_TRANSACTION_VALIDATION_FAILED]: 13,
|
|
66
|
-
[ErrorCode.E_NOT_PREPARED]: 14,
|
|
67
|
-
[ErrorCode.E_NOT_ENDED]: 15,
|
|
68
|
-
[ErrorCode.E_ALREADY_OWNED]: 16,
|
|
69
|
-
[ErrorCode.E_BILLING_RESPONSE_JSON_PARSE_ERROR]: 17,
|
|
70
|
-
[ErrorCode.E_INTERRUPTED]: 18,
|
|
71
|
-
[ErrorCode.E_IAP_NOT_AVAILABLE]: 19,
|
|
72
|
-
[ErrorCode.E_ACTIVITY_UNAVAILABLE]: 20,
|
|
73
|
-
[ErrorCode.E_ALREADY_PREPARED]: 21,
|
|
74
|
-
[ErrorCode.E_PENDING]: 22,
|
|
75
|
-
[ErrorCode.E_CONNECTION_CLOSED]: 23,
|
|
76
|
-
},
|
|
77
|
-
android: {
|
|
78
|
-
[ErrorCode.E_UNKNOWN]: 'E_UNKNOWN',
|
|
79
|
-
[ErrorCode.E_USER_CANCELLED]: 'E_USER_CANCELLED',
|
|
80
|
-
[ErrorCode.E_USER_ERROR]: 'E_USER_ERROR',
|
|
81
|
-
[ErrorCode.E_ITEM_UNAVAILABLE]: 'E_ITEM_UNAVAILABLE',
|
|
82
|
-
[ErrorCode.E_REMOTE_ERROR]: 'E_REMOTE_ERROR',
|
|
83
|
-
[ErrorCode.E_NETWORK_ERROR]: 'E_NETWORK_ERROR',
|
|
84
|
-
[ErrorCode.E_SERVICE_ERROR]: 'E_SERVICE_ERROR',
|
|
85
|
-
[ErrorCode.E_RECEIPT_FAILED]: 'E_RECEIPT_FAILED',
|
|
86
|
-
[ErrorCode.E_RECEIPT_FINISHED_FAILED]: 'E_RECEIPT_FINISHED_FAILED',
|
|
87
|
-
[ErrorCode.E_NOT_PREPARED]: 'E_NOT_PREPARED',
|
|
88
|
-
[ErrorCode.E_NOT_ENDED]: 'E_NOT_ENDED',
|
|
89
|
-
[ErrorCode.E_ALREADY_OWNED]: 'E_ALREADY_OWNED',
|
|
90
|
-
[ErrorCode.E_DEVELOPER_ERROR]: 'E_DEVELOPER_ERROR',
|
|
91
|
-
[ErrorCode.E_BILLING_RESPONSE_JSON_PARSE_ERROR]: 'E_BILLING_RESPONSE_JSON_PARSE_ERROR',
|
|
92
|
-
[ErrorCode.E_DEFERRED_PAYMENT]: 'E_DEFERRED_PAYMENT',
|
|
93
|
-
[ErrorCode.E_INTERRUPTED]: 'E_INTERRUPTED',
|
|
94
|
-
[ErrorCode.E_IAP_NOT_AVAILABLE]: 'E_IAP_NOT_AVAILABLE',
|
|
95
|
-
[ErrorCode.E_PURCHASE_ERROR]: 'E_PURCHASE_ERROR',
|
|
96
|
-
[ErrorCode.E_SYNC_ERROR]: 'E_SYNC_ERROR',
|
|
97
|
-
[ErrorCode.E_TRANSACTION_VALIDATION_FAILED]: 'E_TRANSACTION_VALIDATION_FAILED',
|
|
98
|
-
[ErrorCode.E_ACTIVITY_UNAVAILABLE]: 'E_ACTIVITY_UNAVAILABLE',
|
|
99
|
-
[ErrorCode.E_ALREADY_PREPARED]: 'E_ALREADY_PREPARED',
|
|
100
|
-
[ErrorCode.E_PENDING]: 'E_PENDING',
|
|
101
|
-
[ErrorCode.E_CONNECTION_CLOSED]: 'E_CONNECTION_CLOSED',
|
|
102
|
-
[ErrorCode.E_INIT_CONNECTION]: 'E_INIT_CONNECTION',
|
|
103
|
-
[ErrorCode.E_SERVICE_DISCONNECTED]: 'E_SERVICE_DISCONNECTED',
|
|
104
|
-
[ErrorCode.E_QUERY_PRODUCT]: 'E_QUERY_PRODUCT',
|
|
105
|
-
[ErrorCode.E_SKU_NOT_FOUND]: 'E_SKU_NOT_FOUND',
|
|
106
|
-
[ErrorCode.E_SKU_OFFER_MISMATCH]: 'E_SKU_OFFER_MISMATCH',
|
|
107
|
-
[ErrorCode.E_ITEM_NOT_OWNED]: 'E_ITEM_NOT_OWNED',
|
|
108
|
-
[ErrorCode.E_BILLING_UNAVAILABLE]: 'E_BILLING_UNAVAILABLE',
|
|
109
|
-
[ErrorCode.E_FEATURE_NOT_SUPPORTED]: 'E_FEATURE_NOT_SUPPORTED',
|
|
110
|
-
[ErrorCode.E_EMPTY_SKU_LIST]: 'E_EMPTY_SKU_LIST',
|
|
111
|
-
},
|
|
91
|
+
// iOS: standardized OpenIAP string codes
|
|
92
|
+
ios: COMMON_ERROR_CODE_MAP,
|
|
93
|
+
// Android: standardized OpenIAP string codes
|
|
94
|
+
android: COMMON_ERROR_CODE_MAP,
|
|
112
95
|
};
|
|
113
96
|
export class PurchaseError {
|
|
114
97
|
name;
|
|
@@ -190,11 +173,20 @@ export const ErrorCodeUtils = {
|
|
|
190
173
|
* @returns Corresponding ErrorCode enum value or E_UNKNOWN if not found
|
|
191
174
|
*/
|
|
192
175
|
fromPlatformCode: (platformCode, platform) => {
|
|
176
|
+
// If native sent standardized string code, accept it directly
|
|
177
|
+
if (typeof platformCode === 'string' && platformCode.startsWith('E_')) {
|
|
178
|
+
if (OPENIAP_ERROR_CODE_SET.has(platformCode)) {
|
|
179
|
+
return platformCode;
|
|
180
|
+
}
|
|
181
|
+
}
|
|
193
182
|
// Prefer dynamic native mapping for iOS to avoid drift
|
|
194
183
|
if (platform === 'ios') {
|
|
195
|
-
for (const [
|
|
184
|
+
for (const [, value] of Object.entries(NATIVE_ERROR_CODES || {})) {
|
|
196
185
|
if (value === platformCode) {
|
|
197
|
-
|
|
186
|
+
// Native maps friendly keys to standardized 'E_*' codes
|
|
187
|
+
if (typeof value === 'string' && OPENIAP_ERROR_CODE_SET.has(value)) {
|
|
188
|
+
return value;
|
|
189
|
+
}
|
|
198
190
|
}
|
|
199
191
|
}
|
|
200
192
|
}
|
|
@@ -219,7 +211,7 @@ export const ErrorCodeUtils = {
|
|
|
219
211
|
return native;
|
|
220
212
|
}
|
|
221
213
|
const mapping = ErrorCodeMapping[platform];
|
|
222
|
-
return mapping[errorCode] ??
|
|
214
|
+
return mapping[errorCode] ?? 'E_UNKNOWN';
|
|
223
215
|
},
|
|
224
216
|
/**
|
|
225
217
|
* Checks if an error code is valid for the specified platform
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ExpoIap.types.js","sourceRoot":"","sources":["../src/ExpoIap.types.ts"],"names":[],"mappings":"AAUA,OAAO,EAAC,kBAAkB,EAAC,MAAM,iBAAiB,CAAC;AAqDnD,8DAA8D;AAC9D,cAAc,8BAA8B,CAAC;AAC7C,cAAc,0BAA0B,CAAC;AAoBzC;;;GAGG;AACH,MAAM,CAAN,IAAY,SAmCX;AAnCD,WAAY,SAAS;IACnB,oCAAuB,CAAA;IACvB,kDAAqC,CAAA;IACrC,0CAA6B,CAAA;IAC7B,sDAAyC,CAAA;IACzC,8CAAiC,CAAA;IACjC,gDAAmC,CAAA;IACnC,gDAAmC,CAAA;IACnC,kDAAqC,CAAA;IACrC,oEAAuD,CAAA;IACvD,8CAAiC,CAAA;IACjC,wCAA2B,CAAA;IAC3B,gDAAmC,CAAA;IACnC,oDAAuC,CAAA;IACvC,wFAA2E,CAAA;IAC3E,sDAAyC,CAAA;IACzC,4CAA+B,CAAA;IAC/B,wDAA2C,CAAA;IAC3C,kDAAqC,CAAA;IACrC,0CAA6B,CAAA;IAC7B,gFAAmE,CAAA;IACnE,8DAAiD,CAAA;IACjD,sDAAyC,CAAA;IACzC,oCAAuB,CAAA;IACvB,wDAA2C,CAAA;IAC3C,oEAAoE;IACpE,oDAAuC,CAAA;IACvC,8DAAiD,CAAA;IACjD,gDAAmC,CAAA;IACnC,gDAAmC,CAAA;IACnC,0DAA6C,CAAA;IAC7C,kDAAqC,CAAA;IACrC,4DAA+C,CAAA;IAC/C,gEAAmD,CAAA;IACnD,kDAAqC,CAAA;AACvC,CAAC,EAnCW,SAAS,KAAT,SAAS,QAmCpB;AAED;;;GAGG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG;IAC9B,GAAG,EAAE;QACH,CAAC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CAAC,QAAQ,CAAC,CAAC;IACjD,CAAC;CACF,CAAC","sourcesContent":["import type {\n ProductAndroid,\n PurchaseAndroid,\n ProductSubscriptionAndroid,\n} from './types/ExpoIapAndroid.types';\nimport type {\n ProductIOS,\n PurchaseIOS,\n ProductSubscriptionIOS,\n} from './types/ExpoIapIOS.types';\nimport {NATIVE_ERROR_CODES} from './ExpoIapModule';\n\nexport type ChangeEventPayload = {\n value: string;\n};\n\nexport type ProductType = 'inapp' | 'subs';\n\n// =============================================================================\n// COMMON TYPES (Base types shared across all platforms)\n// =============================================================================\n\nexport type ProductCommon = {\n id: string;\n title: string;\n description: string;\n type: ProductType;\n displayName?: string;\n displayPrice: string;\n currency: string;\n price?: number;\n debugDescription?: string;\n platform?: string;\n};\n\nexport type PurchaseCommon = {\n id: string; // Transaction identifier - used by finishTransaction\n productId: string; // Product identifier - which product was purchased\n ids?: string[]; // Product identifiers for purchases that include multiple products\n transactionId?: string; // @deprecated - use id instead\n transactionDate: number;\n transactionReceipt: string;\n purchaseToken?: string; // Unified purchase token (jwsRepresentation for iOS, purchaseToken for Android)\n platform?: string;\n};\n\nexport type ProductSubscriptionCommon = ProductCommon & {\n type: 'subs';\n};\n\n// Define literal platform types for better type discrimination\nexport type IosPlatform = {platform: 'ios'};\nexport type AndroidPlatform = {platform: 'android'};\n\n// Platform-agnostic unified product types (public API)\nexport type Product =\n | (ProductAndroid & AndroidPlatform)\n | (ProductIOS & IosPlatform);\n\nexport type SubscriptionProduct =\n | (ProductSubscriptionAndroid & AndroidPlatform)\n | (ProductSubscriptionIOS & IosPlatform);\n\n// Re-export all platform-specific types to avoid deep imports\nexport * from './types/ExpoIapAndroid.types';\nexport * from './types/ExpoIapIOS.types';\n\n// Unified purchase type for both products and subscriptions\nexport type Purchase =\n | (PurchaseAndroid & AndroidPlatform)\n | (PurchaseIOS & IosPlatform);\n\n// Removed legacy type aliases `ProductPurchase` and `SubscriptionPurchase` in v2.9.0\n\nexport type PurchaseResult = {\n responseCode?: number;\n debugMessage?: string;\n code?: string;\n message?: string;\n /**\n * @deprecated Use `purchaseToken` instead. This field will be removed in a future version.\n */\n purchaseTokenAndroid?: string;\n purchaseToken?: string;\n};\n/**\n * Centralized error codes for expo-iap\n * These are mapped to platform-specific error codes and provide consistent error handling\n */\nexport 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 E_PURCHASE_ERROR = 'E_PURCHASE_ERROR',\n E_SYNC_ERROR = 'E_SYNC_ERROR',\n E_TRANSACTION_VALIDATION_FAILED = 'E_TRANSACTION_VALIDATION_FAILED',\n E_ACTIVITY_UNAVAILABLE = 'E_ACTIVITY_UNAVAILABLE',\n E_ALREADY_PREPARED = 'E_ALREADY_PREPARED',\n E_PENDING = 'E_PENDING',\n E_CONNECTION_CLOSED = 'E_CONNECTION_CLOSED',\n // Additional detailed errors (Android-focused, kept cross-platform)\n E_INIT_CONNECTION = 'E_INIT_CONNECTION',\n E_SERVICE_DISCONNECTED = 'E_SERVICE_DISCONNECTED',\n E_QUERY_PRODUCT = 'E_QUERY_PRODUCT',\n E_SKU_NOT_FOUND = 'E_SKU_NOT_FOUND',\n E_SKU_OFFER_MISMATCH = 'E_SKU_OFFER_MISMATCH',\n E_ITEM_NOT_OWNED = 'E_ITEM_NOT_OWNED',\n E_BILLING_UNAVAILABLE = 'E_BILLING_UNAVAILABLE',\n E_FEATURE_NOT_SUPPORTED = 'E_FEATURE_NOT_SUPPORTED',\n E_EMPTY_SKU_LIST = 'E_EMPTY_SKU_LIST',\n}\n\n/**\n * Platform-specific error code mappings\n * Maps ErrorCode enum values to platform-specific integer codes\n */\nexport const ErrorCodeMapping = {\n ios: {\n [ErrorCode.E_UNKNOWN]: 0,\n [ErrorCode.E_SERVICE_ERROR]: 1,\n [ErrorCode.E_USER_CANCELLED]: 2,\n [ErrorCode.E_USER_ERROR]: 3,\n [ErrorCode.E_ITEM_UNAVAILABLE]: 4,\n [ErrorCode.E_REMOTE_ERROR]: 5,\n [ErrorCode.E_NETWORK_ERROR]: 6,\n [ErrorCode.E_RECEIPT_FAILED]: 7,\n [ErrorCode.E_RECEIPT_FINISHED_FAILED]: 8,\n [ErrorCode.E_DEVELOPER_ERROR]: 9,\n [ErrorCode.E_PURCHASE_ERROR]: 10,\n [ErrorCode.E_SYNC_ERROR]: 11,\n [ErrorCode.E_DEFERRED_PAYMENT]: 12,\n [ErrorCode.E_TRANSACTION_VALIDATION_FAILED]: 13,\n [ErrorCode.E_NOT_PREPARED]: 14,\n [ErrorCode.E_NOT_ENDED]: 15,\n [ErrorCode.E_ALREADY_OWNED]: 16,\n [ErrorCode.E_BILLING_RESPONSE_JSON_PARSE_ERROR]: 17,\n [ErrorCode.E_INTERRUPTED]: 18,\n [ErrorCode.E_IAP_NOT_AVAILABLE]: 19,\n [ErrorCode.E_ACTIVITY_UNAVAILABLE]: 20,\n [ErrorCode.E_ALREADY_PREPARED]: 21,\n [ErrorCode.E_PENDING]: 22,\n [ErrorCode.E_CONNECTION_CLOSED]: 23,\n },\n android: {\n [ErrorCode.E_UNKNOWN]: 'E_UNKNOWN',\n [ErrorCode.E_USER_CANCELLED]: 'E_USER_CANCELLED',\n [ErrorCode.E_USER_ERROR]: 'E_USER_ERROR',\n [ErrorCode.E_ITEM_UNAVAILABLE]: 'E_ITEM_UNAVAILABLE',\n [ErrorCode.E_REMOTE_ERROR]: 'E_REMOTE_ERROR',\n [ErrorCode.E_NETWORK_ERROR]: 'E_NETWORK_ERROR',\n [ErrorCode.E_SERVICE_ERROR]: 'E_SERVICE_ERROR',\n [ErrorCode.E_RECEIPT_FAILED]: 'E_RECEIPT_FAILED',\n [ErrorCode.E_RECEIPT_FINISHED_FAILED]: 'E_RECEIPT_FINISHED_FAILED',\n [ErrorCode.E_NOT_PREPARED]: 'E_NOT_PREPARED',\n [ErrorCode.E_NOT_ENDED]: 'E_NOT_ENDED',\n [ErrorCode.E_ALREADY_OWNED]: 'E_ALREADY_OWNED',\n [ErrorCode.E_DEVELOPER_ERROR]: 'E_DEVELOPER_ERROR',\n [ErrorCode.E_BILLING_RESPONSE_JSON_PARSE_ERROR]:\n 'E_BILLING_RESPONSE_JSON_PARSE_ERROR',\n [ErrorCode.E_DEFERRED_PAYMENT]: 'E_DEFERRED_PAYMENT',\n [ErrorCode.E_INTERRUPTED]: 'E_INTERRUPTED',\n [ErrorCode.E_IAP_NOT_AVAILABLE]: 'E_IAP_NOT_AVAILABLE',\n [ErrorCode.E_PURCHASE_ERROR]: 'E_PURCHASE_ERROR',\n [ErrorCode.E_SYNC_ERROR]: 'E_SYNC_ERROR',\n [ErrorCode.E_TRANSACTION_VALIDATION_FAILED]:\n 'E_TRANSACTION_VALIDATION_FAILED',\n [ErrorCode.E_ACTIVITY_UNAVAILABLE]: 'E_ACTIVITY_UNAVAILABLE',\n [ErrorCode.E_ALREADY_PREPARED]: 'E_ALREADY_PREPARED',\n [ErrorCode.E_PENDING]: 'E_PENDING',\n [ErrorCode.E_CONNECTION_CLOSED]: 'E_CONNECTION_CLOSED',\n [ErrorCode.E_INIT_CONNECTION]: 'E_INIT_CONNECTION',\n [ErrorCode.E_SERVICE_DISCONNECTED]: 'E_SERVICE_DISCONNECTED',\n [ErrorCode.E_QUERY_PRODUCT]: 'E_QUERY_PRODUCT',\n [ErrorCode.E_SKU_NOT_FOUND]: 'E_SKU_NOT_FOUND',\n [ErrorCode.E_SKU_OFFER_MISMATCH]: 'E_SKU_OFFER_MISMATCH',\n [ErrorCode.E_ITEM_NOT_OWNED]: 'E_ITEM_NOT_OWNED',\n [ErrorCode.E_BILLING_UNAVAILABLE]: 'E_BILLING_UNAVAILABLE',\n [ErrorCode.E_FEATURE_NOT_SUPPORTED]: 'E_FEATURE_NOT_SUPPORTED',\n [ErrorCode.E_EMPTY_SKU_LIST]: 'E_EMPTY_SKU_LIST',\n },\n} as const;\n\nexport type PurchaseErrorProps = {\n message: string;\n responseCode?: number;\n debugMessage?: string;\n code?: ErrorCode;\n productId?: string;\n platform?: 'ios' | 'android';\n};\n\nexport class PurchaseError implements Error {\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 public platform?: 'ios' | 'android';\n\n // Backwards-compatible constructor: accepts either props object or legacy positional args\n constructor(messageOrProps: string | PurchaseErrorProps, ...rest: any[]) {\n this.name = '[expo-iap]: PurchaseError';\n\n if (typeof messageOrProps === 'string') {\n // Legacy signature: (name, message, responseCode?, debugMessage?, code?, productId?, platform?)\n // The first legacy argument was a name which we always override, so treat it as message here\n const message = messageOrProps;\n this.message = message;\n this.responseCode = rest[0];\n this.debugMessage = rest[1];\n this.code = rest[2];\n this.productId = rest[3];\n this.platform = rest[4];\n } else {\n const props = messageOrProps;\n this.message = props.message;\n this.responseCode = props.responseCode;\n this.debugMessage = props.debugMessage;\n this.code = props.code;\n this.productId = props.productId;\n this.platform = props.platform;\n }\n }\n\n /**\n * Creates a PurchaseError from platform-specific error data\n * @param errorData Raw error data from native modules\n * @param platform Platform where the error occurred\n * @returns Properly typed PurchaseError instance\n */\n static fromPlatformError(\n errorData: any,\n platform: 'ios' | 'android',\n ): PurchaseError {\n const errorCode = errorData.code\n ? ErrorCodeUtils.fromPlatformCode(errorData.code, platform)\n : ErrorCode.E_UNKNOWN;\n\n return new PurchaseError({\n message: errorData.message || 'Unknown error occurred',\n responseCode: errorData.responseCode,\n debugMessage: errorData.debugMessage,\n code: errorCode,\n productId: errorData.productId,\n platform,\n });\n }\n\n /**\n * Gets the platform-specific error code for this error\n * @returns Platform-specific error code\n */\n getPlatformCode(): string | number | undefined {\n if (!this.code || !this.platform) return undefined;\n return ErrorCodeUtils.toPlatformCode(this.code, this.platform);\n }\n}\n\n/**\n * Utility functions for error code mapping and validation\n */\nexport const ErrorCodeUtils = {\n /**\n * Gets the native error code for the current platform\n * @param errorCode ErrorCode enum value\n * @returns Platform-specific error code from native constants\n */\n getNativeErrorCode: (errorCode: ErrorCode): string => {\n return NATIVE_ERROR_CODES[errorCode] || errorCode;\n },\n\n /**\n * Maps a platform-specific error code back to the standardized ErrorCode enum\n * @param platformCode Platform-specific error code (string for Android, number for iOS)\n * @param platform Target platform\n * @returns Corresponding ErrorCode enum value or E_UNKNOWN if not found\n */\n fromPlatformCode: (\n platformCode: string | number,\n platform: 'ios' | 'android',\n ): ErrorCode => {\n // Prefer dynamic native mapping for iOS to avoid drift\n if (platform === 'ios') {\n for (const [key, value] of Object.entries(NATIVE_ERROR_CODES || {})) {\n if (value === platformCode) {\n return key as ErrorCode;\n }\n }\n }\n\n const mapping = ErrorCodeMapping[platform];\n for (const [errorCode, mappedCode] of Object.entries(mapping)) {\n if (mappedCode === platformCode) {\n return errorCode as ErrorCode;\n }\n }\n\n return ErrorCode.E_UNKNOWN;\n },\n\n /**\n * Maps an ErrorCode enum to platform-specific code\n * @param errorCode ErrorCode enum value\n * @param platform Target platform\n * @returns Platform-specific error code\n */\n toPlatformCode: (\n errorCode: ErrorCode,\n platform: 'ios' | 'android',\n ): string | number => {\n if (platform === 'ios') {\n const native = NATIVE_ERROR_CODES?.[errorCode];\n if (native !== undefined) return native;\n }\n const mapping = ErrorCodeMapping[platform] as Record<\n ErrorCode,\n string | number\n >;\n return mapping[errorCode] ?? (platform === 'ios' ? 0 : 'E_UNKNOWN');\n },\n\n /**\n * Checks if an error code is valid for the specified platform\n * @param errorCode ErrorCode enum value\n * @param platform Target platform\n * @returns True if the error code is supported on the platform\n */\n isValidForPlatform: (\n errorCode: ErrorCode,\n platform: 'ios' | 'android',\n ): boolean => {\n return errorCode in ErrorCodeMapping[platform];\n },\n};\n\n// ============================================================================\n// Enhanced Unified Request Types\n// ============================================================================\n\n/**\n * Unified request props that work on both iOS and Android platforms\n * iOS will use 'sku', Android will use 'skus' (or convert sku to skus array)\n */\nexport interface UnifiedRequestPurchaseProps {\n // Universal properties - works on both platforms\n readonly sku?: string; // Single SKU (iOS native, Android fallback)\n readonly skus?: string[]; // Multiple SKUs (Android native, iOS uses first item)\n\n // iOS-specific properties (ignored on Android)\n readonly andDangerouslyFinishTransactionAutomatically?: boolean;\n readonly appAccountToken?: string;\n readonly quantity?: number;\n readonly withOffer?: import('./types/ExpoIapIOS.types').PaymentDiscount;\n\n // Android-specific properties (ignored on iOS)\n readonly obfuscatedAccountIdAndroid?: string;\n readonly obfuscatedProfileIdAndroid?: string;\n readonly isOfferPersonalized?: boolean;\n}\n\n// ============================================================================\n// New Platform-Specific Request Types (v2.7.0+)\n// ============================================================================\n\n/**\n * iOS-specific purchase request parameters\n */\nexport interface RequestPurchaseIosProps {\n readonly sku: string;\n readonly andDangerouslyFinishTransactionAutomatically?: boolean;\n readonly appAccountToken?: string;\n readonly quantity?: number;\n readonly withOffer?: import('./types/ExpoIapIOS.types').PaymentDiscount;\n}\n\n/**\n * Android-specific purchase request parameters\n */\nexport interface RequestPurchaseAndroidProps {\n readonly skus: string[];\n readonly obfuscatedAccountIdAndroid?: string;\n readonly obfuscatedProfileIdAndroid?: string;\n readonly isOfferPersonalized?: boolean;\n}\n\n/**\n * Android-specific subscription request parameters\n */\nexport interface RequestSubscriptionAndroidProps\n extends RequestPurchaseAndroidProps {\n readonly purchaseTokenAndroid?: string;\n readonly replacementModeAndroid?: number;\n readonly subscriptionOffers: {\n sku: string;\n offerToken: string;\n }[];\n}\n\n/**\n * Modern platform-specific request structure (v2.7.0+)\n * Allows clear separation of iOS and Android parameters\n */\nexport interface RequestPurchasePropsByPlatforms {\n readonly ios?: RequestPurchaseIosProps;\n readonly android?: RequestPurchaseAndroidProps;\n}\n\n/**\n * Modern platform-specific subscription request structure (v2.7.0+)\n */\nexport interface RequestSubscriptionPropsByPlatforms {\n readonly ios?: RequestPurchaseIosProps;\n readonly android?: RequestSubscriptionAndroidProps;\n}\n\n/**\n * Modern request purchase parameters (v2.7.0+)\n * This is the recommended API moving forward\n */\nexport type RequestPurchaseProps = RequestPurchasePropsByPlatforms;\n\n/**\n * Modern request subscription parameters (v2.7.0+)\n * This is the recommended API moving forward\n */\nexport type RequestSubscriptionProps = RequestSubscriptionPropsByPlatforms;\n"]}
|
|
1
|
+
{"version":3,"file":"ExpoIap.types.js","sourceRoot":"","sources":["../src/ExpoIap.types.ts"],"names":[],"mappings":"AAUA,OAAO,EAAC,kBAAkB,EAAC,MAAM,iBAAiB,CAAC;AAqDnD,8DAA8D;AAC9D,cAAc,8BAA8B,CAAC;AAC7C,cAAc,0BAA0B,CAAC;AAoBzC;;;GAGG;AACH,MAAM,CAAN,IAAY,SAoCX;AApCD,WAAY,SAAS;IACnB,oCAAuB,CAAA;IACvB,kDAAqC,CAAA;IACrC,0CAA6B,CAAA;IAC7B,sDAAyC,CAAA;IACzC,8CAAiC,CAAA;IACjC,gDAAmC,CAAA;IACnC,gDAAmC,CAAA;IACnC,kDAAqC,CAAA;IACrC,sDAAyC,CAAA;IACzC,oEAAuD,CAAA;IACvD,8CAAiC,CAAA;IACjC,wCAA2B,CAAA;IAC3B,gDAAmC,CAAA;IACnC,oDAAuC,CAAA;IACvC,wFAA2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AAC,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,kBAAkB,IAAI,EAAE,CAAC,EAAE,CAAC;gBACjE,IAAI,KAAK,KAAK,YAAY,EAAE,CAAC;oBAC3B,wDAAwD;oBACxD,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,sBAAsB,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC;wBACnE,OAAO,KAAkB,CAAC;oBAC5B,CAAC;gBACH,CAAC;YACH,CAAC;QACH,CAAC;QAED,MAAM,OAAO,GAAG,gBAAgB,CAAC,QAAQ,CAAC,CAAC;QAC3C,KAAK,MAAM,CAAC,SAAS,EAAE,UAAU,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC;YAC9D,IAAI,UAAU,KAAK,YAAY,EAAE,CAAC;gBAChC,OAAO,SAAsB,CAAC;YAChC,CAAC;QACH,CAAC;QAED,OAAO,SAAS,CAAC,SAAS,CAAC;IAC7B,CAAC;IAED;;;;;OAKG;IACH,cAAc,EAAE,CACd,SAAoB,EACpB,QAA2B,EACV,EAAE;QACnB,IAAI,QAAQ,KAAK,KAAK,EAAE,CAAC;YACvB,MAAM,MAAM,GAAI,kBAA0B,EAAE,CAAC,SAAS,CAAC,CAAC;YACxD,IAAI,MAAM,KAAK,SAAS;gBAAE,OAAO,MAAM,CAAC;QAC1C,CAAC;QACD,MAAM,OAAO,GAAG,gBAAgB,CAAC,QAAQ,CAGxC,CAAC;QACF,OAAO,OAAO,CAAC,SAAS,CAAC,IAAI,WAAW,CAAC;IAC3C,CAAC;IAED;;;;;OAKG;IACH,kBAAkB,EAAE,CAClB,SAAoB,EACpB,QAA2B,EAClB,EAAE;QACX,OAAO,SAAS,IAAI,gBAAgB,CAAC,QAAQ,CAAC,CAAC;IACjD,CAAC;CACF,CAAC","sourcesContent":["import type {\n ProductAndroid,\n PurchaseAndroid,\n ProductSubscriptionAndroid,\n} from './types/ExpoIapAndroid.types';\nimport type {\n ProductIOS,\n PurchaseIOS,\n ProductSubscriptionIOS,\n} from './types/ExpoIapIOS.types';\nimport {NATIVE_ERROR_CODES} from './ExpoIapModule';\n\nexport type ChangeEventPayload = {\n value: string;\n};\n\nexport type ProductType = 'inapp' | 'subs';\n\n// =============================================================================\n// COMMON TYPES (Base types shared across all platforms)\n// =============================================================================\n\nexport type ProductCommon = {\n id: string;\n title: string;\n description: string;\n type: ProductType;\n displayName?: string;\n displayPrice: string;\n currency: string;\n price?: number;\n debugDescription?: string;\n platform?: string;\n};\n\nexport type PurchaseCommon = {\n id: string; // Transaction identifier - used by finishTransaction\n productId: string; // Product identifier - which product was purchased\n ids?: string[]; // Product identifiers for purchases that include multiple products\n transactionId?: string; // @deprecated - use id instead\n transactionDate: number;\n transactionReceipt: string;\n purchaseToken?: string; // Unified purchase token (jwsRepresentation for iOS, purchaseToken for Android)\n platform?: string;\n};\n\nexport type ProductSubscriptionCommon = ProductCommon & {\n type: 'subs';\n};\n\n// Define literal platform types for better type discrimination\nexport type IosPlatform = {platform: 'ios'};\nexport type AndroidPlatform = {platform: 'android'};\n\n// Platform-agnostic unified product types (public API)\nexport type Product =\n | (ProductAndroid & AndroidPlatform)\n | (ProductIOS & IosPlatform);\n\nexport type SubscriptionProduct =\n | (ProductSubscriptionAndroid & AndroidPlatform)\n | (ProductSubscriptionIOS & IosPlatform);\n\n// Re-export all platform-specific types to avoid deep imports\nexport * from './types/ExpoIapAndroid.types';\nexport * from './types/ExpoIapIOS.types';\n\n// Unified purchase type for both products and subscriptions\nexport type Purchase =\n | (PurchaseAndroid & AndroidPlatform)\n | (PurchaseIOS & IosPlatform);\n\n// Removed legacy type aliases `ProductPurchase` and `SubscriptionPurchase` in v2.9.0\n\nexport type PurchaseResult = {\n responseCode?: number;\n debugMessage?: string;\n code?: string;\n message?: string;\n /**\n * @deprecated Use `purchaseToken` instead. This field will be removed in a future version.\n */\n purchaseTokenAndroid?: string;\n purchaseToken?: string;\n};\n/**\n * Centralized error codes for expo-iap\n * These are mapped to platform-specific error codes and provide consistent error handling\n */\nexport 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 = 'E_RECEIPT_FINISHED',\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 E_PURCHASE_ERROR = 'E_PURCHASE_ERROR',\n E_SYNC_ERROR = 'E_SYNC_ERROR',\n E_TRANSACTION_VALIDATION_FAILED = 'E_TRANSACTION_VALIDATION_FAILED',\n E_ACTIVITY_UNAVAILABLE = 'E_ACTIVITY_UNAVAILABLE',\n E_ALREADY_PREPARED = 'E_ALREADY_PREPARED',\n E_PENDING = 'E_PENDING',\n E_CONNECTION_CLOSED = 'E_CONNECTION_CLOSED',\n // Additional detailed errors (Android-focused, kept cross-platform)\n E_INIT_CONNECTION = 'E_INIT_CONNECTION',\n E_SERVICE_DISCONNECTED = 'E_SERVICE_DISCONNECTED',\n E_QUERY_PRODUCT = 'E_QUERY_PRODUCT',\n E_SKU_NOT_FOUND = 'E_SKU_NOT_FOUND',\n E_SKU_OFFER_MISMATCH = 'E_SKU_OFFER_MISMATCH',\n E_ITEM_NOT_OWNED = 'E_ITEM_NOT_OWNED',\n E_BILLING_UNAVAILABLE = 'E_BILLING_UNAVAILABLE',\n E_FEATURE_NOT_SUPPORTED = 'E_FEATURE_NOT_SUPPORTED',\n E_EMPTY_SKU_LIST = 'E_EMPTY_SKU_LIST',\n}\n\n// Fast lookup set for validating standardized error code strings\nconst OPENIAP_ERROR_CODE_SET: Set<string> = new Set(\n Object.values(ErrorCode) as string[],\n);\n\n/**\n * Platform-specific error code mappings\n * Maps ErrorCode enum values to platform-specific integer codes\n */\n// Shared OpenIAP string code mapping for both platforms\nconst COMMON_ERROR_CODE_MAP = {\n [ErrorCode.E_UNKNOWN]: 'E_UNKNOWN',\n [ErrorCode.E_USER_CANCELLED]: 'E_USER_CANCELLED',\n [ErrorCode.E_USER_ERROR]: 'E_USER_ERROR',\n [ErrorCode.E_ITEM_UNAVAILABLE]: 'E_ITEM_UNAVAILABLE',\n [ErrorCode.E_REMOTE_ERROR]: 'E_REMOTE_ERROR',\n [ErrorCode.E_NETWORK_ERROR]: 'E_NETWORK_ERROR',\n [ErrorCode.E_SERVICE_ERROR]: 'E_SERVICE_ERROR',\n [ErrorCode.E_RECEIPT_FAILED]: 'E_RECEIPT_FAILED',\n [ErrorCode.E_RECEIPT_FINISHED]: 'E_RECEIPT_FINISHED',\n [ErrorCode.E_RECEIPT_FINISHED_FAILED]: 'E_RECEIPT_FINISHED_FAILED',\n [ErrorCode.E_NOT_PREPARED]: 'E_NOT_PREPARED',\n [ErrorCode.E_NOT_ENDED]: 'E_NOT_ENDED',\n [ErrorCode.E_ALREADY_OWNED]: 'E_ALREADY_OWNED',\n [ErrorCode.E_DEVELOPER_ERROR]: 'E_DEVELOPER_ERROR',\n [ErrorCode.E_BILLING_RESPONSE_JSON_PARSE_ERROR]:\n 'E_BILLING_RESPONSE_JSON_PARSE_ERROR',\n [ErrorCode.E_DEFERRED_PAYMENT]: 'E_DEFERRED_PAYMENT',\n [ErrorCode.E_INTERRUPTED]: 'E_INTERRUPTED',\n [ErrorCode.E_IAP_NOT_AVAILABLE]: 'E_IAP_NOT_AVAILABLE',\n [ErrorCode.E_PURCHASE_ERROR]: 'E_PURCHASE_ERROR',\n [ErrorCode.E_SYNC_ERROR]: 'E_SYNC_ERROR',\n [ErrorCode.E_TRANSACTION_VALIDATION_FAILED]:\n 'E_TRANSACTION_VALIDATION_FAILED',\n [ErrorCode.E_ACTIVITY_UNAVAILABLE]: 'E_ACTIVITY_UNAVAILABLE',\n [ErrorCode.E_ALREADY_PREPARED]: 'E_ALREADY_PREPARED',\n [ErrorCode.E_PENDING]: 'E_PENDING',\n [ErrorCode.E_CONNECTION_CLOSED]: 'E_CONNECTION_CLOSED',\n [ErrorCode.E_INIT_CONNECTION]: 'E_INIT_CONNECTION',\n [ErrorCode.E_SERVICE_DISCONNECTED]: 'E_SERVICE_DISCONNECTED',\n [ErrorCode.E_QUERY_PRODUCT]: 'E_QUERY_PRODUCT',\n [ErrorCode.E_SKU_NOT_FOUND]: 'E_SKU_NOT_FOUND',\n [ErrorCode.E_SKU_OFFER_MISMATCH]: 'E_SKU_OFFER_MISMATCH',\n [ErrorCode.E_ITEM_NOT_OWNED]: 'E_ITEM_NOT_OWNED',\n [ErrorCode.E_BILLING_UNAVAILABLE]: 'E_BILLING_UNAVAILABLE',\n [ErrorCode.E_FEATURE_NOT_SUPPORTED]: 'E_FEATURE_NOT_SUPPORTED',\n [ErrorCode.E_EMPTY_SKU_LIST]: 'E_EMPTY_SKU_LIST',\n} as const;\n\nexport const ErrorCodeMapping = {\n // iOS: standardized OpenIAP string codes\n ios: COMMON_ERROR_CODE_MAP,\n // Android: standardized OpenIAP string codes\n android: COMMON_ERROR_CODE_MAP,\n} as const;\n\nexport type PurchaseErrorProps = {\n message: string;\n responseCode?: number;\n debugMessage?: string;\n code?: ErrorCode;\n productId?: string;\n platform?: 'ios' | 'android';\n};\n\nexport class PurchaseError implements Error {\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 public platform?: 'ios' | 'android';\n\n // Backwards-compatible constructor: accepts either props object or legacy positional args\n constructor(messageOrProps: string | PurchaseErrorProps, ...rest: any[]) {\n this.name = '[expo-iap]: PurchaseError';\n\n if (typeof messageOrProps === 'string') {\n // Legacy signature: (name, message, responseCode?, debugMessage?, code?, productId?, platform?)\n // The first legacy argument was a name which we always override, so treat it as message here\n const message = messageOrProps;\n this.message = message;\n this.responseCode = rest[0];\n this.debugMessage = rest[1];\n this.code = rest[2];\n this.productId = rest[3];\n this.platform = rest[4];\n } else {\n const props = messageOrProps;\n this.message = props.message;\n this.responseCode = props.responseCode;\n this.debugMessage = props.debugMessage;\n this.code = props.code;\n this.productId = props.productId;\n this.platform = props.platform;\n }\n }\n\n /**\n * Creates a PurchaseError from platform-specific error data\n * @param errorData Raw error data from native modules\n * @param platform Platform where the error occurred\n * @returns Properly typed PurchaseError instance\n */\n static fromPlatformError(\n errorData: any,\n platform: 'ios' | 'android',\n ): PurchaseError {\n const errorCode = errorData.code\n ? ErrorCodeUtils.fromPlatformCode(errorData.code, platform)\n : ErrorCode.E_UNKNOWN;\n\n return new PurchaseError({\n message: errorData.message || 'Unknown error occurred',\n responseCode: errorData.responseCode,\n debugMessage: errorData.debugMessage,\n code: errorCode,\n productId: errorData.productId,\n platform,\n });\n }\n\n /**\n * Gets the platform-specific error code for this error\n * @returns Platform-specific error code\n */\n getPlatformCode(): string | number | undefined {\n if (!this.code || !this.platform) return undefined;\n return ErrorCodeUtils.toPlatformCode(this.code, this.platform);\n }\n}\n\n/**\n * Utility functions for error code mapping and validation\n */\nexport const ErrorCodeUtils = {\n /**\n * Gets the native error code for the current platform\n * @param errorCode ErrorCode enum value\n * @returns Platform-specific error code from native constants\n */\n getNativeErrorCode: (errorCode: ErrorCode): string => {\n return NATIVE_ERROR_CODES[errorCode] || errorCode;\n },\n\n /**\n * Maps a platform-specific error code back to the standardized ErrorCode enum\n * @param platformCode Platform-specific error code (string for Android, number for iOS)\n * @param platform Target platform\n * @returns Corresponding ErrorCode enum value or E_UNKNOWN if not found\n */\n fromPlatformCode: (\n platformCode: string | number,\n platform: 'ios' | 'android',\n ): ErrorCode => {\n // If native sent standardized string code, accept it directly\n if (typeof platformCode === 'string' && platformCode.startsWith('E_')) {\n if (OPENIAP_ERROR_CODE_SET.has(platformCode)) {\n return platformCode as ErrorCode;\n }\n }\n // Prefer dynamic native mapping for iOS to avoid drift\n if (platform === 'ios') {\n for (const [, value] of Object.entries(NATIVE_ERROR_CODES || {})) {\n if (value === platformCode) {\n // Native maps friendly keys to standardized 'E_*' codes\n if (typeof value === 'string' && OPENIAP_ERROR_CODE_SET.has(value)) {\n return value as ErrorCode;\n }\n }\n }\n }\n\n const mapping = ErrorCodeMapping[platform];\n for (const [errorCode, mappedCode] of Object.entries(mapping)) {\n if (mappedCode === platformCode) {\n return errorCode as ErrorCode;\n }\n }\n\n return ErrorCode.E_UNKNOWN;\n },\n\n /**\n * Maps an ErrorCode enum to platform-specific code\n * @param errorCode ErrorCode enum value\n * @param platform Target platform\n * @returns Platform-specific error code\n */\n toPlatformCode: (\n errorCode: ErrorCode,\n platform: 'ios' | 'android',\n ): string | number => {\n if (platform === 'ios') {\n const native = (NATIVE_ERROR_CODES as any)?.[errorCode];\n if (native !== undefined) return native;\n }\n const mapping = ErrorCodeMapping[platform] as Record<\n ErrorCode,\n string | number\n >;\n return mapping[errorCode] ?? 'E_UNKNOWN';\n },\n\n /**\n * Checks if an error code is valid for the specified platform\n * @param errorCode ErrorCode enum value\n * @param platform Target platform\n * @returns True if the error code is supported on the platform\n */\n isValidForPlatform: (\n errorCode: ErrorCode,\n platform: 'ios' | 'android',\n ): boolean => {\n return errorCode in ErrorCodeMapping[platform];\n },\n};\n\n// ============================================================================\n// Enhanced Unified Request Types\n// ============================================================================\n\n/**\n * Unified request props that work on both iOS and Android platforms\n * iOS will use 'sku', Android will use 'skus' (or convert sku to skus array)\n */\nexport interface UnifiedRequestPurchaseProps {\n // Universal properties - works on both platforms\n readonly sku?: string; // Single SKU (iOS native, Android fallback)\n readonly skus?: string[]; // Multiple SKUs (Android native, iOS uses first item)\n\n // iOS-specific properties (ignored on Android)\n readonly andDangerouslyFinishTransactionAutomatically?: boolean;\n readonly appAccountToken?: string;\n readonly quantity?: number;\n readonly withOffer?: import('./types/ExpoIapIOS.types').PaymentDiscount;\n\n // Android-specific properties (ignored on iOS)\n readonly obfuscatedAccountIdAndroid?: string;\n readonly obfuscatedProfileIdAndroid?: string;\n readonly isOfferPersonalized?: boolean;\n}\n\n// ============================================================================\n// New Platform-Specific Request Types (v2.7.0+)\n// ============================================================================\n\n/**\n * iOS-specific purchase request parameters\n */\nexport interface RequestPurchaseIosProps {\n readonly sku: string;\n readonly andDangerouslyFinishTransactionAutomatically?: boolean;\n readonly appAccountToken?: string;\n readonly quantity?: number;\n readonly withOffer?: import('./types/ExpoIapIOS.types').PaymentDiscount;\n}\n\n/**\n * Android-specific purchase request parameters\n */\nexport interface RequestPurchaseAndroidProps {\n readonly skus: string[];\n readonly obfuscatedAccountIdAndroid?: string;\n readonly obfuscatedProfileIdAndroid?: string;\n readonly isOfferPersonalized?: boolean;\n}\n\n/**\n * Android-specific subscription request parameters\n */\nexport interface RequestSubscriptionAndroidProps\n extends RequestPurchaseAndroidProps {\n readonly purchaseTokenAndroid?: string;\n readonly replacementModeAndroid?: number;\n readonly subscriptionOffers: {\n sku: string;\n offerToken: string;\n }[];\n}\n\n/**\n * Modern platform-specific request structure (v2.7.0+)\n * Allows clear separation of iOS and Android parameters\n */\nexport interface RequestPurchasePropsByPlatforms {\n readonly ios?: RequestPurchaseIosProps;\n readonly android?: RequestPurchaseAndroidProps;\n}\n\n/**\n * Modern platform-specific subscription request structure (v2.7.0+)\n */\nexport interface RequestSubscriptionPropsByPlatforms {\n readonly ios?: RequestPurchaseIosProps;\n readonly android?: RequestSubscriptionAndroidProps;\n}\n\n/**\n * Modern request purchase parameters (v2.7.0+)\n * This is the recommended API moving forward\n */\nexport type RequestPurchaseProps = RequestPurchasePropsByPlatforms;\n\n/**\n * Modern request subscription parameters (v2.7.0+)\n * This is the recommended API moving forward\n */\nexport type RequestSubscriptionProps = RequestSubscriptionPropsByPlatforms;\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errorMapping.d.ts","sourceRoot":"","sources":["../../src/utils/errorMapping.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,GAAG,GAAG,OAAO,CAUxD;AAED;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,GAAG,GAAG,OAAO,CAWlD;AAED;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,GAAG,GAAG,OAAO,CActD;AAED;;;;GAIG;AACH,wBAAgB,2BAA2B,CAAC,KAAK,EAAE,GAAG,GAAG,MAAM,
|
|
1
|
+
{"version":3,"file":"errorMapping.d.ts","sourceRoot":"","sources":["../../src/utils/errorMapping.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,GAAG,GAAG,OAAO,CAUxD;AAED;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,GAAG,GAAG,OAAO,CAWlD;AAED;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,GAAG,GAAG,OAAO,CActD;AAED;;;;GAIG;AACH,wBAAgB,2BAA2B,CAAC,KAAK,EAAE,GAAG,GAAG,MAAM,CA6C9D"}
|
|
@@ -64,6 +64,8 @@ export function getUserFriendlyErrorMessage(error) {
|
|
|
64
64
|
return 'Purchase was cancelled by user';
|
|
65
65
|
case ErrorCode.E_NETWORK_ERROR:
|
|
66
66
|
return 'Network connection error. Please check your internet connection and try again.';
|
|
67
|
+
case ErrorCode.E_RECEIPT_FINISHED:
|
|
68
|
+
return 'Receipt already finished';
|
|
67
69
|
case ErrorCode.E_SERVICE_DISCONNECTED:
|
|
68
70
|
return 'Billing service disconnected. Please try again.';
|
|
69
71
|
case ErrorCode.E_BILLING_UNAVAILABLE:
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errorMapping.js","sourceRoot":"","sources":["../../src/utils/errorMapping.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAC,SAAS,EAAC,MAAM,kBAAkB,CAAC;AAE3C;;;;GAIG;AACH,MAAM,UAAU,oBAAoB,CAAC,KAAU;IAC7C,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QAC9B,OAAO,KAAK,KAAK,SAAS,CAAC,gBAAgB,CAAC;IAC9C,CAAC;IAED,IAAI,KAAK,IAAI,KAAK,CAAC,IAAI,EAAE,CAAC;QACxB,OAAO,KAAK,CAAC,IAAI,KAAK,SAAS,CAAC,gBAAgB,CAAC;IACnD,CAAC;IAED,OAAO,KAAK,CAAC;AACf,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,cAAc,CAAC,KAAU;IACvC,MAAM,aAAa,GAAG;QACpB,SAAS,CAAC,eAAe;QACzB,SAAS,CAAC,cAAc;QACxB,SAAS,CAAC,eAAe;QACzB,SAAS,CAAC,sBAAsB;QAChC,SAAS,CAAC,qBAAqB;KAChC,CAAC;IAEF,MAAM,SAAS,GAAG,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,EAAE,IAAI,CAAC;IAClE,OAAO,aAAa,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC;AAC3C,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,kBAAkB,CAAC,KAAU;IAC3C,MAAM,iBAAiB,GAAG;QACxB,SAAS,CAAC,eAAe;QACzB,SAAS,CAAC,cAAc;QACxB,SAAS,CAAC,eAAe;QACzB,SAAS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,KAAK,SAAS,CAAC,uBAAuB;YACpC,OAAO,+CAA+C,CAAC;QACzD,KAAK,SAAS,CAAC,+BAA+B;YAC5C,OAAO,mCAAmC,CAAC;QAC7C,KAAK,SAAS,CAAC,gBAAgB;YAC7B,OAAO,2BAA2B,CAAC;QACrC,KAAK,SAAS,CAAC,gBAAgB;YAC7B,OAAO,yBAAyB,CAAC;QACnC,KAAK,SAAS,CAAC,iBAAiB;YAC9B,OAAO,yCAAyC,CAAC;QACnD,KAAK,SAAS,CAAC,eAAe;YAC5B,OAAO,mDAAmD,CAAC;QAC7D;YACE,OAAO,KAAK,EAAE,OAAO,IAAI,8BAA8B,CAAC;IAC5D,CAAC;AACH,CAAC","sourcesContent":["/**\n * Error mapping utilities for expo-iap\n * Provides helper functions for handling platform-specific errors\n */\n\nimport {ErrorCode} from '../ExpoIap.types';\n\n/**\n * Checks if an error is a user cancellation\n * @param error Error object or error code\n * @returns True if the error represents user cancellation\n */\nexport function isUserCancelledError(error: any): boolean {\n if (typeof error === 'string') {\n return error === ErrorCode.E_USER_CANCELLED;\n }\n\n if (error && error.code) {\n return error.code === ErrorCode.E_USER_CANCELLED;\n }\n\n return false;\n}\n\n/**\n * Checks if an error is related to network connectivity\n * @param error Error object or error code\n * @returns True if the error is network-related\n */\nexport function isNetworkError(error: any): boolean {\n const networkErrors = [\n ErrorCode.E_NETWORK_ERROR,\n ErrorCode.E_REMOTE_ERROR,\n ErrorCode.E_SERVICE_ERROR,\n ErrorCode.E_SERVICE_DISCONNECTED,\n ErrorCode.E_BILLING_UNAVAILABLE,\n ];\n\n const errorCode = typeof error === 'string' ? error : error?.code;\n return networkErrors.includes(errorCode);\n}\n\n/**\n * Checks if an error is recoverable (user can retry)\n * @param error Error object or error code\n * @returns True if the error is potentially recoverable\n */\nexport function isRecoverableError(error: any): boolean {\n const recoverableErrors = [\n ErrorCode.E_NETWORK_ERROR,\n ErrorCode.E_REMOTE_ERROR,\n ErrorCode.E_SERVICE_ERROR,\n ErrorCode.E_INTERRUPTED,\n ErrorCode.E_SERVICE_DISCONNECTED,\n ErrorCode.E_BILLING_UNAVAILABLE,\n ErrorCode.E_QUERY_PRODUCT,\n ErrorCode.E_INIT_CONNECTION,\n ];\n\n const errorCode = typeof error === 'string' ? error : error?.code;\n return recoverableErrors.includes(errorCode);\n}\n\n/**\n * Gets a user-friendly error message for display\n * @param error Error object or error code\n * @returns User-friendly error message\n */\nexport function getUserFriendlyErrorMessage(error: any): string {\n const errorCode = typeof error === 'string' ? error : error?.code;\n\n switch (errorCode) {\n case ErrorCode.E_USER_CANCELLED:\n return 'Purchase was cancelled by user';\n case ErrorCode.E_NETWORK_ERROR:\n return 'Network connection error. Please check your internet connection and try again.';\n case ErrorCode.E_SERVICE_DISCONNECTED:\n return 'Billing service disconnected. Please try again.';\n case ErrorCode.E_BILLING_UNAVAILABLE:\n return 'Billing is unavailable on this device or account.';\n case ErrorCode.E_ITEM_UNAVAILABLE:\n return 'This item is not available for purchase';\n case ErrorCode.E_ITEM_NOT_OWNED:\n return \"You don't own this item\";\n case ErrorCode.E_ALREADY_OWNED:\n return 'You already own this item';\n case ErrorCode.E_SKU_NOT_FOUND:\n return 'Requested product could not be found';\n case ErrorCode.E_SKU_OFFER_MISMATCH:\n return 'Selected offer does not match the SKU';\n case ErrorCode.E_DEFERRED_PAYMENT:\n return 'Payment is pending approval';\n case ErrorCode.E_NOT_PREPARED:\n return 'In-app purchase is not ready. Please try again later.';\n case ErrorCode.E_SERVICE_ERROR:\n return 'Store service error. Please try again later.';\n case ErrorCode.E_FEATURE_NOT_SUPPORTED:\n return 'This feature is not supported on this device.';\n case ErrorCode.E_TRANSACTION_VALIDATION_FAILED:\n return 'Transaction could not be verified';\n case ErrorCode.E_RECEIPT_FAILED:\n return 'Receipt processing failed';\n case ErrorCode.E_EMPTY_SKU_LIST:\n return 'No product IDs provided';\n case ErrorCode.E_INIT_CONNECTION:\n return 'Failed to initialize billing connection';\n case ErrorCode.E_QUERY_PRODUCT:\n return 'Failed to query products. Please try again later.';\n default:\n return error?.message || 'An unexpected error occurred';\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"errorMapping.js","sourceRoot":"","sources":["../../src/utils/errorMapping.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAC,SAAS,EAAC,MAAM,kBAAkB,CAAC;AAE3C;;;;GAIG;AACH,MAAM,UAAU,oBAAoB,CAAC,KAAU;IAC7C,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QAC9B,OAAO,KAAK,KAAK,SAAS,CAAC,gBAAgB,CAAC;IAC9C,CAAC;IAED,IAAI,KAAK,IAAI,KAAK,CAAC,IAAI,EAAE,CAAC;QACxB,OAAO,KAAK,CAAC,IAAI,KAAK,SAAS,CAAC,gBAAgB,CAAC;IACnD,CAAC;IAED,OAAO,KAAK,CAAC;AACf,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,cAAc,CAAC,KAAU;IACvC,MAAM,aAAa,GAAG;QACpB,SAAS,CAAC,eAAe;QACzB,SAAS,CAAC,cAAc;QACxB,SAAS,CAAC,eAAe;QACzB,SAAS,CAAC,sBAAsB;QAChC,SAAS,CAAC,qBAAqB;KAChC,CAAC;IAEF,MAAM,SAAS,GAAG,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,EAAE,IAAI,CAAC;IAClE,OAAO,aAAa,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC;AAC3C,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,kBAAkB,CAAC,KAAU;IAC3C,MAAM,iBAAiB,GAAG;QACxB,SAAS,CAAC,eAAe;QACzB,SAAS,CAAC,cAAc;QACxB,SAAS,CAAC,eAAe;QACzB,SAAS,CAAC,aAAa;QACvB,SAAS,CAAC,sBAAsB;QAChC,SAAS,CAAC,qBAAqB;QAC/B,SAAS,CAAC,eAAe;QACzB,SAAS,CAAC,iBAAiB;KAC5B,CAAC;IAEF,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,+BAA+B;YAC5C,OAAO,mCAAmC,CAAC;QAC7C,KAAK,SAAS,CAAC,gBAAgB;YAC7B,OAAO,2BAA2B,CAAC;QACrC,KAAK,SAAS,CAAC,gBAAgB;YAC7B,OAAO,yBAAyB,CAAC;QACnC,KAAK,SAAS,CAAC,iBAAiB;YAC9B,OAAO,yCAAyC,CAAC;QACnD,KAAK,SAAS,CAAC,eAAe;YAC5B,OAAO,mDAAmD,CAAC;QAC7D;YACE,OAAO,KAAK,EAAE,OAAO,IAAI,8BAA8B,CAAC;IAC5D,CAAC;AACH,CAAC","sourcesContent":["/**\n * Error mapping utilities for expo-iap\n * Provides helper functions for handling platform-specific errors\n */\n\nimport {ErrorCode} from '../ExpoIap.types';\n\n/**\n * Checks if an error is a user cancellation\n * @param error Error object or error code\n * @returns True if the error represents user cancellation\n */\nexport function isUserCancelledError(error: any): boolean {\n if (typeof error === 'string') {\n return error === ErrorCode.E_USER_CANCELLED;\n }\n\n if (error && error.code) {\n return error.code === ErrorCode.E_USER_CANCELLED;\n }\n\n return false;\n}\n\n/**\n * Checks if an error is related to network connectivity\n * @param error Error object or error code\n * @returns True if the error is network-related\n */\nexport function isNetworkError(error: any): boolean {\n const networkErrors = [\n ErrorCode.E_NETWORK_ERROR,\n ErrorCode.E_REMOTE_ERROR,\n ErrorCode.E_SERVICE_ERROR,\n ErrorCode.E_SERVICE_DISCONNECTED,\n ErrorCode.E_BILLING_UNAVAILABLE,\n ];\n\n const errorCode = typeof error === 'string' ? error : error?.code;\n return networkErrors.includes(errorCode);\n}\n\n/**\n * Checks if an error is recoverable (user can retry)\n * @param error Error object or error code\n * @returns True if the error is potentially recoverable\n */\nexport function isRecoverableError(error: any): boolean {\n const recoverableErrors = [\n ErrorCode.E_NETWORK_ERROR,\n ErrorCode.E_REMOTE_ERROR,\n ErrorCode.E_SERVICE_ERROR,\n ErrorCode.E_INTERRUPTED,\n ErrorCode.E_SERVICE_DISCONNECTED,\n ErrorCode.E_BILLING_UNAVAILABLE,\n ErrorCode.E_QUERY_PRODUCT,\n ErrorCode.E_INIT_CONNECTION,\n ];\n\n const errorCode = typeof error === 'string' ? error : error?.code;\n return recoverableErrors.includes(errorCode);\n}\n\n/**\n * Gets a user-friendly error message for display\n * @param error Error object or error code\n * @returns User-friendly error message\n */\nexport function getUserFriendlyErrorMessage(error: any): string {\n const errorCode = typeof error === 'string' ? error : error?.code;\n\n switch (errorCode) {\n case ErrorCode.E_USER_CANCELLED:\n return 'Purchase was cancelled by user';\n case ErrorCode.E_NETWORK_ERROR:\n return 'Network connection error. Please check your internet connection and try again.';\n case ErrorCode.E_RECEIPT_FINISHED:\n return 'Receipt already finished';\n case ErrorCode.E_SERVICE_DISCONNECTED:\n return 'Billing service disconnected. Please try again.';\n case ErrorCode.E_BILLING_UNAVAILABLE:\n return 'Billing is unavailable on this device or account.';\n case ErrorCode.E_ITEM_UNAVAILABLE:\n return 'This item is not available for purchase';\n case ErrorCode.E_ITEM_NOT_OWNED:\n return \"You don't own this item\";\n case ErrorCode.E_ALREADY_OWNED:\n return 'You already own this item';\n case ErrorCode.E_SKU_NOT_FOUND:\n return 'Requested product could not be found';\n case ErrorCode.E_SKU_OFFER_MISMATCH:\n return 'Selected offer does not match the SKU';\n case ErrorCode.E_DEFERRED_PAYMENT:\n return 'Payment is pending approval';\n case ErrorCode.E_NOT_PREPARED:\n return 'In-app purchase is not ready. Please try again later.';\n case ErrorCode.E_SERVICE_ERROR:\n return 'Store service error. Please try again later.';\n case ErrorCode.E_FEATURE_NOT_SUPPORTED:\n return 'This feature is not supported on this device.';\n case ErrorCode.E_TRANSACTION_VALIDATION_FAILED:\n return 'Transaction could not be verified';\n case ErrorCode.E_RECEIPT_FAILED:\n return 'Receipt processing failed';\n case ErrorCode.E_EMPTY_SKU_LIST:\n return 'No product IDs provided';\n case ErrorCode.E_INIT_CONNECTION:\n return 'Failed to initialize billing connection';\n case ErrorCode.E_QUERY_PRODUCT:\n return 'Failed to query products. Please try again later.';\n default:\n return error?.message || 'An unexpected error occurred';\n }\n}\n"]}
|
package/ios/ExpoIap.podspec
CHANGED
package/ios/ExpoIapModule.swift
CHANGED
|
@@ -107,7 +107,7 @@ public class ExpoIapModule: Module {
|
|
|
107
107
|
// Validate SKUs
|
|
108
108
|
guard !skus.isEmpty else {
|
|
109
109
|
logDebug("ERROR: Empty SKUs array!")
|
|
110
|
-
throw
|
|
110
|
+
throw OpenIapError.emptySkuList()
|
|
111
111
|
}
|
|
112
112
|
|
|
113
113
|
// Convert string to OpenIapRequestProductType enum
|
|
@@ -146,7 +146,7 @@ public class ExpoIapModule: Module {
|
|
|
146
146
|
AsyncFunction("requestPurchase") { (params: [String: Any]) async throws in
|
|
147
147
|
// Extract and validate required fields
|
|
148
148
|
guard let sku = params["sku"] as? String, !sku.isEmpty else {
|
|
149
|
-
throw
|
|
149
|
+
throw OpenIapError.make(code: OpenIapError.E_PURCHASE_ERROR, message: "Missing required 'sku'")
|
|
150
150
|
}
|
|
151
151
|
|
|
152
152
|
// Optional fields
|
|
@@ -197,7 +197,10 @@ public class ExpoIapModule: Module {
|
|
|
197
197
|
logDebug("Purchase request completed successfully")
|
|
198
198
|
} catch {
|
|
199
199
|
logDebug("Purchase request failed with error: \(error)")
|
|
200
|
-
|
|
200
|
+
if let openIapError = error as? OpenIapError {
|
|
201
|
+
throw openIapError
|
|
202
|
+
}
|
|
203
|
+
throw OpenIapError.make(code: OpenIapError.E_PURCHASE_ERROR, message: error.localizedDescription)
|
|
201
204
|
}
|
|
202
205
|
}
|
|
203
206
|
|
|
@@ -276,7 +279,7 @@ public class ExpoIapModule: Module {
|
|
|
276
279
|
"latestTransaction": result.latestTransaction.map { OpenIapSerialization.purchase($0) },
|
|
277
280
|
]
|
|
278
281
|
} catch {
|
|
279
|
-
throw
|
|
282
|
+
throw OpenIapError.make(code: OpenIapError.E_RECEIPT_FAILED)
|
|
280
283
|
}
|
|
281
284
|
}
|
|
282
285
|
|
|
@@ -402,7 +405,7 @@ public class ExpoIapModule: Module {
|
|
|
402
405
|
}
|
|
403
406
|
return nil
|
|
404
407
|
} catch {
|
|
405
|
-
throw
|
|
408
|
+
throw OpenIapError.make(code: OpenIapError.E_SKU_NOT_FOUND, productId: sku)
|
|
406
409
|
}
|
|
407
410
|
}
|
|
408
411
|
|
|
@@ -414,7 +417,7 @@ public class ExpoIapModule: Module {
|
|
|
414
417
|
}
|
|
415
418
|
return nil
|
|
416
419
|
} catch {
|
|
417
|
-
throw
|
|
420
|
+
throw OpenIapError.make(code: OpenIapError.E_SKU_NOT_FOUND, productId: sku)
|
|
418
421
|
}
|
|
419
422
|
}
|
|
420
423
|
}
|
package/package.json
CHANGED
package/src/ExpoIap.types.ts
CHANGED
|
@@ -96,6 +96,7 @@ export enum ErrorCode {
|
|
|
96
96
|
E_NETWORK_ERROR = 'E_NETWORK_ERROR',
|
|
97
97
|
E_SERVICE_ERROR = 'E_SERVICE_ERROR',
|
|
98
98
|
E_RECEIPT_FAILED = 'E_RECEIPT_FAILED',
|
|
99
|
+
E_RECEIPT_FINISHED = 'E_RECEIPT_FINISHED',
|
|
99
100
|
E_RECEIPT_FINISHED_FAILED = 'E_RECEIPT_FINISHED_FAILED',
|
|
100
101
|
E_NOT_PREPARED = 'E_NOT_PREPARED',
|
|
101
102
|
E_NOT_ENDED = 'E_NOT_ENDED',
|
|
@@ -124,74 +125,60 @@ export enum ErrorCode {
|
|
|
124
125
|
E_EMPTY_SKU_LIST = 'E_EMPTY_SKU_LIST',
|
|
125
126
|
}
|
|
126
127
|
|
|
128
|
+
// Fast lookup set for validating standardized error code strings
|
|
129
|
+
const OPENIAP_ERROR_CODE_SET: Set<string> = new Set(
|
|
130
|
+
Object.values(ErrorCode) as string[],
|
|
131
|
+
);
|
|
132
|
+
|
|
127
133
|
/**
|
|
128
134
|
* Platform-specific error code mappings
|
|
129
135
|
* Maps ErrorCode enum values to platform-specific integer codes
|
|
130
136
|
*/
|
|
137
|
+
// Shared OpenIAP string code mapping for both platforms
|
|
138
|
+
const COMMON_ERROR_CODE_MAP = {
|
|
139
|
+
[ErrorCode.E_UNKNOWN]: 'E_UNKNOWN',
|
|
140
|
+
[ErrorCode.E_USER_CANCELLED]: 'E_USER_CANCELLED',
|
|
141
|
+
[ErrorCode.E_USER_ERROR]: 'E_USER_ERROR',
|
|
142
|
+
[ErrorCode.E_ITEM_UNAVAILABLE]: 'E_ITEM_UNAVAILABLE',
|
|
143
|
+
[ErrorCode.E_REMOTE_ERROR]: 'E_REMOTE_ERROR',
|
|
144
|
+
[ErrorCode.E_NETWORK_ERROR]: 'E_NETWORK_ERROR',
|
|
145
|
+
[ErrorCode.E_SERVICE_ERROR]: 'E_SERVICE_ERROR',
|
|
146
|
+
[ErrorCode.E_RECEIPT_FAILED]: 'E_RECEIPT_FAILED',
|
|
147
|
+
[ErrorCode.E_RECEIPT_FINISHED]: 'E_RECEIPT_FINISHED',
|
|
148
|
+
[ErrorCode.E_RECEIPT_FINISHED_FAILED]: 'E_RECEIPT_FINISHED_FAILED',
|
|
149
|
+
[ErrorCode.E_NOT_PREPARED]: 'E_NOT_PREPARED',
|
|
150
|
+
[ErrorCode.E_NOT_ENDED]: 'E_NOT_ENDED',
|
|
151
|
+
[ErrorCode.E_ALREADY_OWNED]: 'E_ALREADY_OWNED',
|
|
152
|
+
[ErrorCode.E_DEVELOPER_ERROR]: 'E_DEVELOPER_ERROR',
|
|
153
|
+
[ErrorCode.E_BILLING_RESPONSE_JSON_PARSE_ERROR]:
|
|
154
|
+
'E_BILLING_RESPONSE_JSON_PARSE_ERROR',
|
|
155
|
+
[ErrorCode.E_DEFERRED_PAYMENT]: 'E_DEFERRED_PAYMENT',
|
|
156
|
+
[ErrorCode.E_INTERRUPTED]: 'E_INTERRUPTED',
|
|
157
|
+
[ErrorCode.E_IAP_NOT_AVAILABLE]: 'E_IAP_NOT_AVAILABLE',
|
|
158
|
+
[ErrorCode.E_PURCHASE_ERROR]: 'E_PURCHASE_ERROR',
|
|
159
|
+
[ErrorCode.E_SYNC_ERROR]: 'E_SYNC_ERROR',
|
|
160
|
+
[ErrorCode.E_TRANSACTION_VALIDATION_FAILED]:
|
|
161
|
+
'E_TRANSACTION_VALIDATION_FAILED',
|
|
162
|
+
[ErrorCode.E_ACTIVITY_UNAVAILABLE]: 'E_ACTIVITY_UNAVAILABLE',
|
|
163
|
+
[ErrorCode.E_ALREADY_PREPARED]: 'E_ALREADY_PREPARED',
|
|
164
|
+
[ErrorCode.E_PENDING]: 'E_PENDING',
|
|
165
|
+
[ErrorCode.E_CONNECTION_CLOSED]: 'E_CONNECTION_CLOSED',
|
|
166
|
+
[ErrorCode.E_INIT_CONNECTION]: 'E_INIT_CONNECTION',
|
|
167
|
+
[ErrorCode.E_SERVICE_DISCONNECTED]: 'E_SERVICE_DISCONNECTED',
|
|
168
|
+
[ErrorCode.E_QUERY_PRODUCT]: 'E_QUERY_PRODUCT',
|
|
169
|
+
[ErrorCode.E_SKU_NOT_FOUND]: 'E_SKU_NOT_FOUND',
|
|
170
|
+
[ErrorCode.E_SKU_OFFER_MISMATCH]: 'E_SKU_OFFER_MISMATCH',
|
|
171
|
+
[ErrorCode.E_ITEM_NOT_OWNED]: 'E_ITEM_NOT_OWNED',
|
|
172
|
+
[ErrorCode.E_BILLING_UNAVAILABLE]: 'E_BILLING_UNAVAILABLE',
|
|
173
|
+
[ErrorCode.E_FEATURE_NOT_SUPPORTED]: 'E_FEATURE_NOT_SUPPORTED',
|
|
174
|
+
[ErrorCode.E_EMPTY_SKU_LIST]: 'E_EMPTY_SKU_LIST',
|
|
175
|
+
} as const;
|
|
176
|
+
|
|
131
177
|
export const ErrorCodeMapping = {
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
[ErrorCode.E_USER_ERROR]: 3,
|
|
137
|
-
[ErrorCode.E_ITEM_UNAVAILABLE]: 4,
|
|
138
|
-
[ErrorCode.E_REMOTE_ERROR]: 5,
|
|
139
|
-
[ErrorCode.E_NETWORK_ERROR]: 6,
|
|
140
|
-
[ErrorCode.E_RECEIPT_FAILED]: 7,
|
|
141
|
-
[ErrorCode.E_RECEIPT_FINISHED_FAILED]: 8,
|
|
142
|
-
[ErrorCode.E_DEVELOPER_ERROR]: 9,
|
|
143
|
-
[ErrorCode.E_PURCHASE_ERROR]: 10,
|
|
144
|
-
[ErrorCode.E_SYNC_ERROR]: 11,
|
|
145
|
-
[ErrorCode.E_DEFERRED_PAYMENT]: 12,
|
|
146
|
-
[ErrorCode.E_TRANSACTION_VALIDATION_FAILED]: 13,
|
|
147
|
-
[ErrorCode.E_NOT_PREPARED]: 14,
|
|
148
|
-
[ErrorCode.E_NOT_ENDED]: 15,
|
|
149
|
-
[ErrorCode.E_ALREADY_OWNED]: 16,
|
|
150
|
-
[ErrorCode.E_BILLING_RESPONSE_JSON_PARSE_ERROR]: 17,
|
|
151
|
-
[ErrorCode.E_INTERRUPTED]: 18,
|
|
152
|
-
[ErrorCode.E_IAP_NOT_AVAILABLE]: 19,
|
|
153
|
-
[ErrorCode.E_ACTIVITY_UNAVAILABLE]: 20,
|
|
154
|
-
[ErrorCode.E_ALREADY_PREPARED]: 21,
|
|
155
|
-
[ErrorCode.E_PENDING]: 22,
|
|
156
|
-
[ErrorCode.E_CONNECTION_CLOSED]: 23,
|
|
157
|
-
},
|
|
158
|
-
android: {
|
|
159
|
-
[ErrorCode.E_UNKNOWN]: 'E_UNKNOWN',
|
|
160
|
-
[ErrorCode.E_USER_CANCELLED]: 'E_USER_CANCELLED',
|
|
161
|
-
[ErrorCode.E_USER_ERROR]: 'E_USER_ERROR',
|
|
162
|
-
[ErrorCode.E_ITEM_UNAVAILABLE]: 'E_ITEM_UNAVAILABLE',
|
|
163
|
-
[ErrorCode.E_REMOTE_ERROR]: 'E_REMOTE_ERROR',
|
|
164
|
-
[ErrorCode.E_NETWORK_ERROR]: 'E_NETWORK_ERROR',
|
|
165
|
-
[ErrorCode.E_SERVICE_ERROR]: 'E_SERVICE_ERROR',
|
|
166
|
-
[ErrorCode.E_RECEIPT_FAILED]: 'E_RECEIPT_FAILED',
|
|
167
|
-
[ErrorCode.E_RECEIPT_FINISHED_FAILED]: 'E_RECEIPT_FINISHED_FAILED',
|
|
168
|
-
[ErrorCode.E_NOT_PREPARED]: 'E_NOT_PREPARED',
|
|
169
|
-
[ErrorCode.E_NOT_ENDED]: 'E_NOT_ENDED',
|
|
170
|
-
[ErrorCode.E_ALREADY_OWNED]: 'E_ALREADY_OWNED',
|
|
171
|
-
[ErrorCode.E_DEVELOPER_ERROR]: 'E_DEVELOPER_ERROR',
|
|
172
|
-
[ErrorCode.E_BILLING_RESPONSE_JSON_PARSE_ERROR]:
|
|
173
|
-
'E_BILLING_RESPONSE_JSON_PARSE_ERROR',
|
|
174
|
-
[ErrorCode.E_DEFERRED_PAYMENT]: 'E_DEFERRED_PAYMENT',
|
|
175
|
-
[ErrorCode.E_INTERRUPTED]: 'E_INTERRUPTED',
|
|
176
|
-
[ErrorCode.E_IAP_NOT_AVAILABLE]: 'E_IAP_NOT_AVAILABLE',
|
|
177
|
-
[ErrorCode.E_PURCHASE_ERROR]: 'E_PURCHASE_ERROR',
|
|
178
|
-
[ErrorCode.E_SYNC_ERROR]: 'E_SYNC_ERROR',
|
|
179
|
-
[ErrorCode.E_TRANSACTION_VALIDATION_FAILED]:
|
|
180
|
-
'E_TRANSACTION_VALIDATION_FAILED',
|
|
181
|
-
[ErrorCode.E_ACTIVITY_UNAVAILABLE]: 'E_ACTIVITY_UNAVAILABLE',
|
|
182
|
-
[ErrorCode.E_ALREADY_PREPARED]: 'E_ALREADY_PREPARED',
|
|
183
|
-
[ErrorCode.E_PENDING]: 'E_PENDING',
|
|
184
|
-
[ErrorCode.E_CONNECTION_CLOSED]: 'E_CONNECTION_CLOSED',
|
|
185
|
-
[ErrorCode.E_INIT_CONNECTION]: 'E_INIT_CONNECTION',
|
|
186
|
-
[ErrorCode.E_SERVICE_DISCONNECTED]: 'E_SERVICE_DISCONNECTED',
|
|
187
|
-
[ErrorCode.E_QUERY_PRODUCT]: 'E_QUERY_PRODUCT',
|
|
188
|
-
[ErrorCode.E_SKU_NOT_FOUND]: 'E_SKU_NOT_FOUND',
|
|
189
|
-
[ErrorCode.E_SKU_OFFER_MISMATCH]: 'E_SKU_OFFER_MISMATCH',
|
|
190
|
-
[ErrorCode.E_ITEM_NOT_OWNED]: 'E_ITEM_NOT_OWNED',
|
|
191
|
-
[ErrorCode.E_BILLING_UNAVAILABLE]: 'E_BILLING_UNAVAILABLE',
|
|
192
|
-
[ErrorCode.E_FEATURE_NOT_SUPPORTED]: 'E_FEATURE_NOT_SUPPORTED',
|
|
193
|
-
[ErrorCode.E_EMPTY_SKU_LIST]: 'E_EMPTY_SKU_LIST',
|
|
194
|
-
},
|
|
178
|
+
// iOS: standardized OpenIAP string codes
|
|
179
|
+
ios: COMMON_ERROR_CODE_MAP,
|
|
180
|
+
// Android: standardized OpenIAP string codes
|
|
181
|
+
android: COMMON_ERROR_CODE_MAP,
|
|
195
182
|
} as const;
|
|
196
183
|
|
|
197
184
|
export type PurchaseErrorProps = {
|
|
@@ -294,11 +281,20 @@ export const ErrorCodeUtils = {
|
|
|
294
281
|
platformCode: string | number,
|
|
295
282
|
platform: 'ios' | 'android',
|
|
296
283
|
): ErrorCode => {
|
|
284
|
+
// If native sent standardized string code, accept it directly
|
|
285
|
+
if (typeof platformCode === 'string' && platformCode.startsWith('E_')) {
|
|
286
|
+
if (OPENIAP_ERROR_CODE_SET.has(platformCode)) {
|
|
287
|
+
return platformCode as ErrorCode;
|
|
288
|
+
}
|
|
289
|
+
}
|
|
297
290
|
// Prefer dynamic native mapping for iOS to avoid drift
|
|
298
291
|
if (platform === 'ios') {
|
|
299
|
-
for (const [
|
|
292
|
+
for (const [, value] of Object.entries(NATIVE_ERROR_CODES || {})) {
|
|
300
293
|
if (value === platformCode) {
|
|
301
|
-
|
|
294
|
+
// Native maps friendly keys to standardized 'E_*' codes
|
|
295
|
+
if (typeof value === 'string' && OPENIAP_ERROR_CODE_SET.has(value)) {
|
|
296
|
+
return value as ErrorCode;
|
|
297
|
+
}
|
|
302
298
|
}
|
|
303
299
|
}
|
|
304
300
|
}
|
|
@@ -324,14 +320,14 @@ export const ErrorCodeUtils = {
|
|
|
324
320
|
platform: 'ios' | 'android',
|
|
325
321
|
): string | number => {
|
|
326
322
|
if (platform === 'ios') {
|
|
327
|
-
const native = NATIVE_ERROR_CODES?.[errorCode];
|
|
323
|
+
const native = (NATIVE_ERROR_CODES as any)?.[errorCode];
|
|
328
324
|
if (native !== undefined) return native;
|
|
329
325
|
}
|
|
330
326
|
const mapping = ErrorCodeMapping[platform] as Record<
|
|
331
327
|
ErrorCode,
|
|
332
328
|
string | number
|
|
333
329
|
>;
|
|
334
|
-
return mapping[errorCode] ??
|
|
330
|
+
return mapping[errorCode] ?? 'E_UNKNOWN';
|
|
335
331
|
},
|
|
336
332
|
|
|
337
333
|
/**
|
|
@@ -74,6 +74,8 @@ export function getUserFriendlyErrorMessage(error: any): string {
|
|
|
74
74
|
return 'Purchase was cancelled by user';
|
|
75
75
|
case ErrorCode.E_NETWORK_ERROR:
|
|
76
76
|
return 'Network connection error. Please check your internet connection and try again.';
|
|
77
|
+
case ErrorCode.E_RECEIPT_FINISHED:
|
|
78
|
+
return 'Receipt already finished';
|
|
77
79
|
case ErrorCode.E_SERVICE_DISCONNECTED:
|
|
78
80
|
return 'Billing service disconnected. Please try again.';
|
|
79
81
|
case ErrorCode.E_BILLING_UNAVAILABLE:
|