react-native-iap 15.3.5 → 15.3.6
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/lib/module/index.js +37 -59
- package/lib/module/index.js.map +1 -1
- package/lib/module/utils/error.js +98 -15
- package/lib/module/utils/error.js.map +1 -1
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/utils/error.d.ts +1 -1
- package/lib/typescript/src/utils/error.d.ts.map +1 -1
- package/openiap-versions.json +1 -1
- package/package.json +1 -1
- package/src/index.ts +122 -59
- package/src/utils/error.ts +127 -14
|
@@ -5,12 +5,98 @@
|
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
7
|
import { ErrorCode } from "../types.js";
|
|
8
|
+
const parseJsonPayload = (payload, fallbackMessage) => {
|
|
9
|
+
const trimmed = payload.trim();
|
|
10
|
+
const candidates = [trimmed];
|
|
11
|
+
if (trimmed.includes('\\"')) {
|
|
12
|
+
candidates.push(trimmed.replace(/\\"/g, '"'));
|
|
13
|
+
}
|
|
14
|
+
for (const candidate of candidates) {
|
|
15
|
+
try {
|
|
16
|
+
const parsed = JSON.parse(candidate);
|
|
17
|
+
if (typeof parsed === 'object' && parsed !== null) {
|
|
18
|
+
const parsedError = parsed;
|
|
19
|
+
return {
|
|
20
|
+
code: parsedError.code || ErrorCode.Unknown,
|
|
21
|
+
message: parsedError.message || fallbackMessage,
|
|
22
|
+
...parsedError
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
} catch {
|
|
26
|
+
// Try the next candidate.
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
return null;
|
|
30
|
+
};
|
|
31
|
+
const extractBalancedJsonObject = (value, startIndex) => {
|
|
32
|
+
for (let index = startIndex; index < value.length; index += 1) {
|
|
33
|
+
if (value[index] !== '}') {
|
|
34
|
+
continue;
|
|
35
|
+
}
|
|
36
|
+
const candidate = value.substring(startIndex, index + 1);
|
|
37
|
+
if (parseJsonPayload(candidate, value)) {
|
|
38
|
+
return candidate;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
return null;
|
|
42
|
+
};
|
|
43
|
+
const parseNSErrorJsonPayload = rawString => {
|
|
44
|
+
const payloads = [];
|
|
45
|
+
const quotedPayloadMatch = /Code=-?\d+\s+"/.exec(rawString);
|
|
46
|
+
if (quotedPayloadMatch?.index !== undefined) {
|
|
47
|
+
const contentStart = quotedPayloadMatch.index + quotedPayloadMatch[0].length;
|
|
48
|
+
const userInfoIndex = rawString.indexOf('UserInfo=', contentStart);
|
|
49
|
+
const contentEnd = userInfoIndex > contentStart ? rawString.lastIndexOf('"', userInfoIndex) : rawString.lastIndexOf('"');
|
|
50
|
+
if (contentEnd > contentStart) {
|
|
51
|
+
payloads.push(rawString.substring(contentStart, contentEnd));
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
const localizedDescription = 'NSLocalizedDescription=';
|
|
55
|
+
const descriptionIndex = rawString.indexOf(localizedDescription);
|
|
56
|
+
if (descriptionIndex >= 0) {
|
|
57
|
+
let valueStart = descriptionIndex + localizedDescription.length;
|
|
58
|
+
while (/\s/.test(rawString[valueStart] ?? '')) {
|
|
59
|
+
valueStart += 1;
|
|
60
|
+
}
|
|
61
|
+
const firstBraceIndex = rawString.indexOf('{', valueStart);
|
|
62
|
+
if (firstBraceIndex >= 0 && firstBraceIndex <= valueStart + 2) {
|
|
63
|
+
const payload = extractBalancedJsonObject(rawString, firstBraceIndex);
|
|
64
|
+
if (payload) {
|
|
65
|
+
payloads.push(payload);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
for (const payload of payloads) {
|
|
70
|
+
const parsed = parseJsonPayload(payload, rawString);
|
|
71
|
+
if (parsed?.code && parsed.code !== ErrorCode.Unknown) {
|
|
72
|
+
return parsed;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
return null;
|
|
76
|
+
};
|
|
77
|
+
const parseStructuredError = error => {
|
|
78
|
+
const errorWithCode = error;
|
|
79
|
+
if (typeof errorWithCode.code === 'string' && errorWithCode.code.length > 0) {
|
|
80
|
+
const {
|
|
81
|
+
code,
|
|
82
|
+
message,
|
|
83
|
+
...extraFields
|
|
84
|
+
} = errorWithCode;
|
|
85
|
+
return {
|
|
86
|
+
...extraFields,
|
|
87
|
+
code,
|
|
88
|
+
message: typeof message === 'string' ? message : error.message
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
return null;
|
|
92
|
+
};
|
|
93
|
+
|
|
8
94
|
/**
|
|
9
95
|
* Parses error string from native modules into a structured error object
|
|
10
96
|
*
|
|
11
97
|
* Native modules return errors in different formats:
|
|
12
98
|
* - Android: JSON string like '{"code":"E_USER_CANCELLED","message":"User cancelled the purchase","responseCode":1}'
|
|
13
|
-
* - iOS: JSON string or plain message
|
|
99
|
+
* - iOS: JSON string, Nitro NSError string with embedded JSON, or plain message
|
|
14
100
|
* - Legacy: "CODE: message" format
|
|
15
101
|
*
|
|
16
102
|
* @param errorString - The error string from native module
|
|
@@ -19,6 +105,10 @@ import { ErrorCode } from "../types.js";
|
|
|
19
105
|
export function parseErrorStringToJsonObj(errorString) {
|
|
20
106
|
// Handle Error objects
|
|
21
107
|
if (errorString instanceof Error) {
|
|
108
|
+
const structuredError = parseStructuredError(errorString);
|
|
109
|
+
if (structuredError) {
|
|
110
|
+
return structuredError;
|
|
111
|
+
}
|
|
22
112
|
errorString = errorString.message;
|
|
23
113
|
}
|
|
24
114
|
|
|
@@ -29,20 +119,13 @@ export function parseErrorStringToJsonObj(errorString) {
|
|
|
29
119
|
message: 'Unknown error occurred'
|
|
30
120
|
};
|
|
31
121
|
}
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
code: parsed.code || ErrorCode.Unknown,
|
|
40
|
-
message: parsed.message || errorString,
|
|
41
|
-
...parsed
|
|
42
|
-
};
|
|
43
|
-
}
|
|
44
|
-
} catch {
|
|
45
|
-
// Not JSON, continue with other formats
|
|
122
|
+
const jsonPayload = parseJsonPayload(errorString, errorString);
|
|
123
|
+
if (jsonPayload) {
|
|
124
|
+
return jsonPayload;
|
|
125
|
+
}
|
|
126
|
+
const nsErrorPayload = parseNSErrorJsonPayload(errorString);
|
|
127
|
+
if (nsErrorPayload) {
|
|
128
|
+
return nsErrorPayload;
|
|
46
129
|
}
|
|
47
130
|
|
|
48
131
|
// Try to parse "CODE: message" format
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["ErrorCode","
|
|
1
|
+
{"version":3,"names":["ErrorCode","parseJsonPayload","payload","fallbackMessage","trimmed","trim","candidates","includes","push","replace","candidate","parsed","JSON","parse","parsedError","code","Unknown","message","extractBalancedJsonObject","value","startIndex","index","length","substring","parseNSErrorJsonPayload","rawString","payloads","quotedPayloadMatch","exec","undefined","contentStart","userInfoIndex","indexOf","contentEnd","lastIndexOf","localizedDescription","descriptionIndex","valueStart","test","firstBraceIndex","parseStructuredError","error","errorWithCode","extraFields","parseErrorStringToJsonObj","errorString","Error","structuredError","jsonPayload","nsErrorPayload","colonIndex","potentialCode","startsWith","isUserCancelledError","errorObj","UserCancelled","responseCode","isDuplicatePurchaseError","DUPLICATE_PURCHASE_CODE"],"sourceRoot":"../../../src","sources":["utils/error.ts"],"mappings":";;AAAA;AACA;AACA;;AAEA,SAAQA,SAAS,QAAO,aAAU;AAclC,MAAMC,gBAAgB,GAAGA,CACvBC,OAAe,EACfC,eAAuB,KACH;EACpB,MAAMC,OAAO,GAAGF,OAAO,CAACG,IAAI,CAAC,CAAC;EAC9B,MAAMC,UAAU,GAAG,CAACF,OAAO,CAAC;EAE5B,IAAIA,OAAO,CAACG,QAAQ,CAAC,KAAK,CAAC,EAAE;IAC3BD,UAAU,CAACE,IAAI,CAACJ,OAAO,CAACK,OAAO,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;EAC/C;EAEA,KAAK,MAAMC,SAAS,IAAIJ,UA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AAC,EAAE2B,UAAU,CAAC,CAAC7C,IAAI,CAAC,CAAC;IACjE;IACA,IAAI8C,aAAa,CAACC,UAAU,CAAC,IAAI,CAAC,IAAI,WAAW,CAACd,IAAI,CAACa,aAAa,CAAC,EAAE;MACrE,OAAO;QACLpC,IAAI,EAAEoC,aAAa;QACnBlC,OAAO,EAAE4B,WAAW,CAACtB,SAAS,CAAC2B,UAAU,GAAG,CAAC,CAAC,CAAC7C,IAAI,CAAC;MACtD,CAAC;IACH;EACF;;EAEA;EACA,OAAO;IACLU,IAAI,EAAEf,SAAS,CAACgB,OAAO;IACvBC,OAAO,EAAE4B;EACX,CAAC;AACH;;AAEA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASQ,oBAAoBA,CAClCZ,KAA0C,EACjC;EACT,MAAMa,QAAQ,GACZ,OAAOb,KAAK,KAAK,QAAQ,IAAIA,KAAK,KAAK,IAAI,IAAI,MAAM,IAAIA,KAAK,GACzDA,KAAK,GACNG,yBAAyB,CAACH,KAAK,CAAC;EAEtC,OACEa,QAAQ,CAACvC,IAAI,KAAKf,SAAS,CAACuD,aAAa,IACzCD,QAAQ,CAACvC,IAAI,KAAK,iBAAiB;EAAI;EACvCuC,QAAQ,CAACE,YAAY,KAAK,CAAC,CAC3B,CAAC;AACL;;AAEA;AACA,SACEC,wBAAwB,EACxBC,uBAAuB,QAClB,mBAAgB","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAGA,OAAO,4BAA4B,CAAC;AAcpC,OAAO,KAAK,EAGV,yCAAyC,EACzC,uCAAuC,EACvC,wCAAwC,EACxC,sCAAsC,EACtC,+BAA+B,EAE/B,aAAa,EACb,OAAO,EACP,UAAU,EAGV,QAAQ,EACR,aAAa,EACb,8BAA8B,EAE9B,UAAU,EAWV,sCAAsC,EACtC,wBAAwB,EACzB,MAAM,SAAS,CAAC;AA0BjB,OAAO,K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
* - Android: JSON string like '{"code":"E_USER_CANCELLED","message":"User cancelled the purchase","responseCode":1}'
|
|
20
|
-
* - iOS: JSON string or plain message
|
|
20
|
+
* - iOS: JSON string, Nitro NSError string with embedded JSON, or plain message
|
|
21
21
|
* - Legacy: "CODE: message" format
|
|
22
22
|
*
|
|
23
23
|
* @param errorString - The error string from native module
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"error.d.ts","sourceRoot":"","sources":["../../../../src/utils/error.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH,MAAM,WAAW,QAAQ;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC;IACtB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;CACpB;
|
|
1
|
+
{"version":3,"file":"error.d.ts","sourceRoot":"","sources":["../../../../src/utils/error.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH,MAAM,WAAW,QAAQ;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC;IACtB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;CACpB;AAmHD;;;;;;;;;;GAUG;AACH,wBAAgB,yBAAyB,CACvC,WAAW,EAAE,MAAM,GAAG,KAAK,GAAG,OAAO,GACpC,QAAQ,CAgDV;AAED;;;;GAIG;AACH,wBAAgB,oBAAoB,CAClC,KAAK,EAAE,QAAQ,GAAG,MAAM,GAAG,KAAK,GAAG,OAAO,GACzC,OAAO,CAWT;AAGD,OAAO,EACL,wBAAwB,EACxB,uBAAuB,GACxB,MAAM,gBAAgB,CAAC"}
|
package/openiap-versions.json
CHANGED
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -55,7 +55,7 @@ import {
|
|
|
55
55
|
validateNitroPurchase,
|
|
56
56
|
convertNitroSubscriptionStatusToSubscriptionStatusIOS,
|
|
57
57
|
} from './utils/type-bridge';
|
|
58
|
-
import {parseErrorStringToJsonObj} from './utils/error';
|
|
58
|
+
import {isUserCancelledError, parseErrorStringToJsonObj} from './utils/error';
|
|
59
59
|
import {
|
|
60
60
|
normalizeErrorCodeFromNative,
|
|
61
61
|
createPurchaseError,
|
|
@@ -121,6 +121,17 @@ const toErrorMessage = (error: unknown): string => {
|
|
|
121
121
|
return String(error ?? '');
|
|
122
122
|
};
|
|
123
123
|
|
|
124
|
+
const parseErrorAndLogIfNeeded = (
|
|
125
|
+
message: string,
|
|
126
|
+
error: unknown,
|
|
127
|
+
): ReturnType<typeof parseErrorStringToJsonObj> => {
|
|
128
|
+
const parsedError = parseErrorStringToJsonObj(error);
|
|
129
|
+
if (!isUserCancelledError(parsedError)) {
|
|
130
|
+
RnIapConsole.error(message, error);
|
|
131
|
+
}
|
|
132
|
+
return parsedError;
|
|
133
|
+
};
|
|
134
|
+
|
|
124
135
|
const unsupportedPlatformError = (): Error =>
|
|
125
136
|
new Error(`Unsupported platform: ${Platform.OS}`);
|
|
126
137
|
|
|
@@ -905,8 +916,10 @@ export const fetchProducts: QueryField<'fetchProducts'> = async (request) => {
|
|
|
905
916
|
|
|
906
917
|
return convertedProducts as FetchProductsResult;
|
|
907
918
|
} catch (error) {
|
|
908
|
-
|
|
909
|
-
|
|
919
|
+
const parsedError = parseErrorAndLogIfNeeded(
|
|
920
|
+
'[fetchProducts] Failed:',
|
|
921
|
+
error,
|
|
922
|
+
);
|
|
910
923
|
throw createPurchaseError({
|
|
911
924
|
code: parsedError.code,
|
|
912
925
|
message: parsedError.message,
|
|
@@ -1027,8 +1040,10 @@ export const getPromotedProductIOS: QueryField<
|
|
|
1027
1040
|
const converted = convertNitroProductToProduct(nitroProduct);
|
|
1028
1041
|
return converted.platform === 'ios' ? (converted as ProductIOS) : null;
|
|
1029
1042
|
} catch (error) {
|
|
1030
|
-
|
|
1031
|
-
|
|
1043
|
+
const parsedError = parseErrorAndLogIfNeeded(
|
|
1044
|
+
'[getPromotedProductIOS] Failed:',
|
|
1045
|
+
error,
|
|
1046
|
+
);
|
|
1032
1047
|
throw createPurchaseError({
|
|
1033
1048
|
code: parsedError.code,
|
|
1034
1049
|
message: parsedError.message,
|
|
@@ -1181,8 +1196,10 @@ export const subscriptionStatusIOS: QueryField<
|
|
|
1181
1196
|
.filter((status): status is NitroSubscriptionStatus => status != null)
|
|
1182
1197
|
.map(convertNitroSubscriptionStatusToSubscriptionStatusIOS);
|
|
1183
1198
|
} catch (error) {
|
|
1184
|
-
|
|
1185
|
-
|
|
1199
|
+
const parsedError = parseErrorAndLogIfNeeded(
|
|
1200
|
+
'[subscriptionStatusIOS] Failed:',
|
|
1201
|
+
error,
|
|
1202
|
+
);
|
|
1186
1203
|
throw createPurchaseError({
|
|
1187
1204
|
code: parsedError.code,
|
|
1188
1205
|
message: parsedError.message,
|
|
@@ -1215,8 +1232,10 @@ export const currentEntitlementIOS: QueryField<
|
|
|
1215
1232
|
}
|
|
1216
1233
|
return null;
|
|
1217
1234
|
} catch (error) {
|
|
1218
|
-
|
|
1219
|
-
|
|
1235
|
+
const parsedError = parseErrorAndLogIfNeeded(
|
|
1236
|
+
'[currentEntitlementIOS] Failed:',
|
|
1237
|
+
error,
|
|
1238
|
+
);
|
|
1220
1239
|
throw createPurchaseError({
|
|
1221
1240
|
code: parsedError.code,
|
|
1222
1241
|
message: parsedError.message,
|
|
@@ -1249,8 +1268,10 @@ export const latestTransactionIOS: QueryField<'latestTransactionIOS'> = async (
|
|
|
1249
1268
|
}
|
|
1250
1269
|
return null;
|
|
1251
1270
|
} catch (error) {
|
|
1252
|
-
|
|
1253
|
-
|
|
1271
|
+
const parsedError = parseErrorAndLogIfNeeded(
|
|
1272
|
+
'[latestTransactionIOS] Failed:',
|
|
1273
|
+
error,
|
|
1274
|
+
);
|
|
1254
1275
|
throw createPurchaseError({
|
|
1255
1276
|
code: parsedError.code,
|
|
1256
1277
|
message: parsedError.message,
|
|
@@ -1282,8 +1303,10 @@ export const getPendingTransactionsIOS: QueryField<
|
|
|
1282
1303
|
(purchase): purchase is PurchaseIOS => purchase.platform === 'ios',
|
|
1283
1304
|
);
|
|
1284
1305
|
} catch (error) {
|
|
1285
|
-
|
|
1286
|
-
|
|
1306
|
+
const parsedError = parseErrorAndLogIfNeeded(
|
|
1307
|
+
'[getPendingTransactionsIOS] Failed:',
|
|
1308
|
+
error,
|
|
1309
|
+
);
|
|
1287
1310
|
throw createPurchaseError({
|
|
1288
1311
|
code: parsedError.code,
|
|
1289
1312
|
message: parsedError.message,
|
|
@@ -1313,8 +1336,10 @@ export const getAllTransactionsIOS: QueryField<
|
|
|
1313
1336
|
(purchase): purchase is PurchaseIOS => purchase.platform === 'ios',
|
|
1314
1337
|
);
|
|
1315
1338
|
} catch (error) {
|
|
1316
|
-
|
|
1317
|
-
|
|
1339
|
+
const parsedError = parseErrorAndLogIfNeeded(
|
|
1340
|
+
'[getAllTransactionsIOS] Failed:',
|
|
1341
|
+
error,
|
|
1342
|
+
);
|
|
1318
1343
|
throw createPurchaseError({
|
|
1319
1344
|
code: parsedError.code,
|
|
1320
1345
|
message: parsedError.message,
|
|
@@ -1346,8 +1371,10 @@ export const showManageSubscriptionsIOS: MutationField<
|
|
|
1346
1371
|
(purchase): purchase is PurchaseIOS => purchase.platform === 'ios',
|
|
1347
1372
|
);
|
|
1348
1373
|
} catch (error) {
|
|
1349
|
-
|
|
1350
|
-
|
|
1374
|
+
const parsedError = parseErrorAndLogIfNeeded(
|
|
1375
|
+
'[showManageSubscriptionsIOS] Failed:',
|
|
1376
|
+
error,
|
|
1377
|
+
);
|
|
1351
1378
|
throw createPurchaseError({
|
|
1352
1379
|
code: parsedError.code,
|
|
1353
1380
|
message: parsedError.message,
|
|
@@ -1375,8 +1402,10 @@ export const isEligibleForIntroOfferIOS: QueryField<
|
|
|
1375
1402
|
try {
|
|
1376
1403
|
return await IAP.instance.isEligibleForIntroOfferIOS(groupID);
|
|
1377
1404
|
} catch (error) {
|
|
1378
|
-
|
|
1379
|
-
|
|
1405
|
+
const parsedError = parseErrorAndLogIfNeeded(
|
|
1406
|
+
'[isEligibleForIntroOfferIOS] Failed:',
|
|
1407
|
+
error,
|
|
1408
|
+
);
|
|
1380
1409
|
throw createPurchaseError({
|
|
1381
1410
|
code: parsedError.code,
|
|
1382
1411
|
message: parsedError.message,
|
|
@@ -1407,8 +1436,10 @@ export const getReceiptDataIOS: QueryField<'getReceiptDataIOS'> = async () => {
|
|
|
1407
1436
|
try {
|
|
1408
1437
|
return await IAP.instance.getReceiptDataIOS();
|
|
1409
1438
|
} catch (error) {
|
|
1410
|
-
|
|
1411
|
-
|
|
1439
|
+
const parsedError = parseErrorAndLogIfNeeded(
|
|
1440
|
+
'[getReceiptDataIOS] Failed:',
|
|
1441
|
+
error,
|
|
1442
|
+
);
|
|
1412
1443
|
throw createPurchaseError({
|
|
1413
1444
|
code: parsedError.code,
|
|
1414
1445
|
message: parsedError.message,
|
|
@@ -1435,8 +1466,10 @@ export const getReceiptIOS = async (): Promise<string> => {
|
|
|
1435
1466
|
}
|
|
1436
1467
|
return await IAP.instance.getReceiptDataIOS();
|
|
1437
1468
|
} catch (error) {
|
|
1438
|
-
|
|
1439
|
-
|
|
1469
|
+
const parsedError = parseErrorAndLogIfNeeded(
|
|
1470
|
+
'[getReceiptIOS] Failed:',
|
|
1471
|
+
error,
|
|
1472
|
+
);
|
|
1440
1473
|
throw createPurchaseError({
|
|
1441
1474
|
code: parsedError.code,
|
|
1442
1475
|
message: parsedError.message,
|
|
@@ -1463,8 +1496,10 @@ export const requestReceiptRefreshIOS = async (): Promise<string> => {
|
|
|
1463
1496
|
}
|
|
1464
1497
|
return await IAP.instance.getReceiptDataIOS();
|
|
1465
1498
|
} catch (error) {
|
|
1466
|
-
|
|
1467
|
-
|
|
1499
|
+
const parsedError = parseErrorAndLogIfNeeded(
|
|
1500
|
+
'[requestReceiptRefreshIOS] Failed:',
|
|
1501
|
+
error,
|
|
1502
|
+
);
|
|
1468
1503
|
throw createPurchaseError({
|
|
1469
1504
|
code: parsedError.code,
|
|
1470
1505
|
message: parsedError.message,
|
|
@@ -1492,8 +1527,10 @@ export const isTransactionVerifiedIOS: QueryField<
|
|
|
1492
1527
|
try {
|
|
1493
1528
|
return await IAP.instance.isTransactionVerifiedIOS(sku);
|
|
1494
1529
|
} catch (error) {
|
|
1495
|
-
|
|
1496
|
-
|
|
1530
|
+
const parsedError = parseErrorAndLogIfNeeded(
|
|
1531
|
+
'[isTransactionVerifiedIOS] Failed:',
|
|
1532
|
+
error,
|
|
1533
|
+
);
|
|
1497
1534
|
throw createPurchaseError({
|
|
1498
1535
|
code: parsedError.code,
|
|
1499
1536
|
message: parsedError.message,
|
|
@@ -1521,8 +1558,10 @@ export const getTransactionJwsIOS: QueryField<'getTransactionJwsIOS'> = async (
|
|
|
1521
1558
|
try {
|
|
1522
1559
|
return await IAP.instance.getTransactionJwsIOS(sku);
|
|
1523
1560
|
} catch (error) {
|
|
1524
|
-
|
|
1525
|
-
|
|
1561
|
+
const parsedError = parseErrorAndLogIfNeeded(
|
|
1562
|
+
'[getTransactionJwsIOS] Failed:',
|
|
1563
|
+
error,
|
|
1564
|
+
);
|
|
1526
1565
|
throw createPurchaseError({
|
|
1527
1566
|
code: parsedError.code,
|
|
1528
1567
|
message: parsedError.message,
|
|
@@ -1563,8 +1602,10 @@ export const initConnection: MutationField<'initConnection'> = async (
|
|
|
1563
1602
|
config as Record<string, unknown> | undefined,
|
|
1564
1603
|
);
|
|
1565
1604
|
} catch (error) {
|
|
1566
|
-
|
|
1567
|
-
|
|
1605
|
+
const parsedError = parseErrorAndLogIfNeeded(
|
|
1606
|
+
'Failed to initialize IAP connection:',
|
|
1607
|
+
error,
|
|
1608
|
+
);
|
|
1568
1609
|
throw createPurchaseError({
|
|
1569
1610
|
code: parsedError.code,
|
|
1570
1611
|
message: parsedError.message,
|
|
@@ -1586,8 +1627,10 @@ export const endConnection: MutationField<'endConnection'> = async () => {
|
|
|
1586
1627
|
resetListenerState();
|
|
1587
1628
|
return result;
|
|
1588
1629
|
} catch (error) {
|
|
1589
|
-
|
|
1590
|
-
|
|
1630
|
+
const parsedError = parseErrorAndLogIfNeeded(
|
|
1631
|
+
'Failed to end IAP connection:',
|
|
1632
|
+
error,
|
|
1633
|
+
);
|
|
1591
1634
|
throw createPurchaseError({
|
|
1592
1635
|
code: parsedError.code,
|
|
1593
1636
|
message: parsedError.message,
|
|
@@ -1613,8 +1656,10 @@ export const restorePurchases: MutationField<'restorePurchases'> = async () => {
|
|
|
1613
1656
|
onlyIncludeActiveItemsIOS: true,
|
|
1614
1657
|
});
|
|
1615
1658
|
} catch (error) {
|
|
1616
|
-
|
|
1617
|
-
|
|
1659
|
+
const parsedError = parseErrorAndLogIfNeeded(
|
|
1660
|
+
'Failed to restore purchases:',
|
|
1661
|
+
error,
|
|
1662
|
+
);
|
|
1618
1663
|
throw createPurchaseError({
|
|
1619
1664
|
code: parsedError.code,
|
|
1620
1665
|
message: parsedError.message,
|
|
@@ -1798,8 +1843,10 @@ export const requestPurchase: MutationField<'requestPurchase'> = async (
|
|
|
1798
1843
|
|
|
1799
1844
|
return await IAP.instance.requestPurchase(unifiedRequest);
|
|
1800
1845
|
} catch (error) {
|
|
1801
|
-
|
|
1802
|
-
|
|
1846
|
+
const parsedError = parseErrorAndLogIfNeeded(
|
|
1847
|
+
'Failed to request purchase:',
|
|
1848
|
+
error,
|
|
1849
|
+
);
|
|
1803
1850
|
throw createPurchaseError({
|
|
1804
1851
|
code: parsedError.code,
|
|
1805
1852
|
message: parsedError.message,
|
|
@@ -1921,8 +1968,10 @@ export const acknowledgePurchaseAndroid: MutationField<
|
|
|
1921
1968
|
});
|
|
1922
1969
|
return getSuccessFromPurchaseVariant(result, 'acknowledgePurchaseAndroid');
|
|
1923
1970
|
} catch (error) {
|
|
1924
|
-
|
|
1925
|
-
|
|
1971
|
+
const parsedError = parseErrorAndLogIfNeeded(
|
|
1972
|
+
'Failed to acknowledge purchase Android:',
|
|
1973
|
+
error,
|
|
1974
|
+
);
|
|
1926
1975
|
throw createPurchaseError({
|
|
1927
1976
|
code: parsedError.code,
|
|
1928
1977
|
message: parsedError.message,
|
|
@@ -1960,8 +2009,10 @@ export const consumePurchaseAndroid: MutationField<
|
|
|
1960
2009
|
});
|
|
1961
2010
|
return getSuccessFromPurchaseVariant(result, 'consumePurchaseAndroid');
|
|
1962
2011
|
} catch (error) {
|
|
1963
|
-
|
|
1964
|
-
|
|
2012
|
+
const parsedError = parseErrorAndLogIfNeeded(
|
|
2013
|
+
'Failed to consume purchase Android:',
|
|
2014
|
+
error,
|
|
2015
|
+
);
|
|
1965
2016
|
throw createPurchaseError({
|
|
1966
2017
|
code: parsedError.code,
|
|
1967
2018
|
message: parsedError.message,
|
|
@@ -2109,8 +2160,10 @@ export const validateReceipt: MutationField<'validateReceipt'> = async (
|
|
|
2109
2160
|
return result;
|
|
2110
2161
|
}
|
|
2111
2162
|
} catch (error) {
|
|
2112
|
-
|
|
2113
|
-
|
|
2163
|
+
const parsedError = parseErrorAndLogIfNeeded(
|
|
2164
|
+
'[validateReceipt] Failed:',
|
|
2165
|
+
error,
|
|
2166
|
+
);
|
|
2114
2167
|
throw createPurchaseError({
|
|
2115
2168
|
code: parsedError.code,
|
|
2116
2169
|
message: parsedError.message,
|
|
@@ -2203,8 +2256,10 @@ export const verifyPurchaseWithProvider: MutationField<
|
|
|
2203
2256
|
errors: result.errors ?? null,
|
|
2204
2257
|
};
|
|
2205
2258
|
} catch (error) {
|
|
2206
|
-
|
|
2207
|
-
|
|
2259
|
+
const parsedError = parseErrorAndLogIfNeeded(
|
|
2260
|
+
'[verifyPurchaseWithProvider] Failed:',
|
|
2261
|
+
error,
|
|
2262
|
+
);
|
|
2208
2263
|
throw createPurchaseError({
|
|
2209
2264
|
code: parsedError.code,
|
|
2210
2265
|
message: parsedError.message,
|
|
@@ -2230,8 +2285,7 @@ export const syncIOS: MutationField<'syncIOS'> = async () => {
|
|
|
2230
2285
|
const result = await IAP.instance.syncIOS();
|
|
2231
2286
|
return Boolean(result);
|
|
2232
2287
|
} catch (error) {
|
|
2233
|
-
|
|
2234
|
-
const parsedError = parseErrorStringToJsonObj(error);
|
|
2288
|
+
const parsedError = parseErrorAndLogIfNeeded('[syncIOS] Failed:', error);
|
|
2235
2289
|
throw createPurchaseError({
|
|
2236
2290
|
code: parsedError.code,
|
|
2237
2291
|
message: parsedError.message,
|
|
@@ -2259,8 +2313,10 @@ export const presentCodeRedemptionSheetIOS: MutationField<
|
|
|
2259
2313
|
const result = await IAP.instance.presentCodeRedemptionSheetIOS();
|
|
2260
2314
|
return Boolean(result);
|
|
2261
2315
|
} catch (error) {
|
|
2262
|
-
|
|
2263
|
-
|
|
2316
|
+
const parsedError = parseErrorAndLogIfNeeded(
|
|
2317
|
+
'[presentCodeRedemptionSheetIOS] Failed:',
|
|
2318
|
+
error,
|
|
2319
|
+
);
|
|
2264
2320
|
throw createPurchaseError({
|
|
2265
2321
|
code: parsedError.code,
|
|
2266
2322
|
message: parsedError.message,
|
|
@@ -2315,11 +2371,10 @@ export const requestPurchaseOnPromotedProductIOS =
|
|
|
2315
2371
|
|
|
2316
2372
|
return true;
|
|
2317
2373
|
} catch (error) {
|
|
2318
|
-
|
|
2374
|
+
const parsedError = parseErrorAndLogIfNeeded(
|
|
2319
2375
|
'[requestPurchaseOnPromotedProductIOS] Failed:',
|
|
2320
2376
|
error,
|
|
2321
2377
|
);
|
|
2322
|
-
const parsedError = parseErrorStringToJsonObj(error);
|
|
2323
2378
|
throw createPurchaseError({
|
|
2324
2379
|
code: parsedError.code,
|
|
2325
2380
|
message: parsedError.message,
|
|
@@ -2347,8 +2402,10 @@ export const clearTransactionIOS: MutationField<
|
|
|
2347
2402
|
await IAP.instance.clearTransactionIOS();
|
|
2348
2403
|
return true;
|
|
2349
2404
|
} catch (error) {
|
|
2350
|
-
|
|
2351
|
-
|
|
2405
|
+
const parsedError = parseErrorAndLogIfNeeded(
|
|
2406
|
+
'[clearTransactionIOS] Failed:',
|
|
2407
|
+
error,
|
|
2408
|
+
);
|
|
2352
2409
|
throw createPurchaseError({
|
|
2353
2410
|
code: parsedError.code,
|
|
2354
2411
|
message: parsedError.message,
|
|
@@ -2377,8 +2434,10 @@ export const beginRefundRequestIOS: MutationField<
|
|
|
2377
2434
|
const status = await IAP.instance.beginRefundRequestIOS(sku);
|
|
2378
2435
|
return status ?? null;
|
|
2379
2436
|
} catch (error) {
|
|
2380
|
-
|
|
2381
|
-
|
|
2437
|
+
const parsedError = parseErrorAndLogIfNeeded(
|
|
2438
|
+
'[beginRefundRequestIOS] Failed:',
|
|
2439
|
+
error,
|
|
2440
|
+
);
|
|
2382
2441
|
throw createPurchaseError({
|
|
2383
2442
|
code: parsedError.code,
|
|
2384
2443
|
message: parsedError.message,
|
|
@@ -2430,8 +2489,10 @@ export const deepLinkToSubscriptionsIOS = async (): Promise<boolean> => {
|
|
|
2430
2489
|
await IAP.instance.showManageSubscriptionsIOS();
|
|
2431
2490
|
return true;
|
|
2432
2491
|
} catch (error) {
|
|
2433
|
-
|
|
2434
|
-
|
|
2492
|
+
const parsedError = parseErrorAndLogIfNeeded(
|
|
2493
|
+
'[deepLinkToSubscriptionsIOS] Failed:',
|
|
2494
|
+
error,
|
|
2495
|
+
);
|
|
2435
2496
|
throw createPurchaseError({
|
|
2436
2497
|
code: parsedError.code,
|
|
2437
2498
|
message: parsedError.message,
|
|
@@ -2512,8 +2573,10 @@ export const getActiveSubscriptions: QueryField<
|
|
|
2512
2573
|
RnIapConsole.error('IAP connection not initialized:', error);
|
|
2513
2574
|
throw error;
|
|
2514
2575
|
}
|
|
2515
|
-
|
|
2516
|
-
|
|
2576
|
+
const parsedError = parseErrorAndLogIfNeeded(
|
|
2577
|
+
'Failed to get active subscriptions:',
|
|
2578
|
+
error,
|
|
2579
|
+
);
|
|
2517
2580
|
throw createPurchaseError({
|
|
2518
2581
|
code: parsedError.code,
|
|
2519
2582
|
message: parsedError.message,
|