react-native-iap 14.2.3 → 14.3.1
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/README.md +2 -6
- package/android/build.gradle +4 -5
- package/android/src/main/java/com/margelo/nitro/iap/HybridRnIap.kt +327 -547
- package/ios/HybridRnIap.swift +41 -19
- package/lib/module/helpers/subscription.js +2 -2
- package/lib/module/helpers/subscription.js.map +1 -1
- package/lib/module/index.js +44 -1
- package/lib/module/index.js.map +1 -1
- package/lib/module/types.js.map +1 -1
- package/lib/module/utils/type-bridge.js +1 -2
- package/lib/module/utils/type-bridge.js.map +1 -1
- package/lib/typescript/plugin/src/withIAP.d.ts.map +1 -1
- package/lib/typescript/src/helpers/subscription.d.ts.map +1 -1
- package/lib/typescript/src/index.d.ts +15 -0
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/specs/RnIap.nitro.d.ts +17 -0
- package/lib/typescript/src/specs/RnIap.nitro.d.ts.map +1 -1
- package/lib/typescript/src/types.d.ts +0 -2
- package/lib/typescript/src/types.d.ts.map +1 -1
- package/nitrogen/generated/android/c++/JHybridRnIapSpec.cpp +35 -0
- package/nitrogen/generated/android/c++/JHybridRnIapSpec.hpp +2 -0
- package/nitrogen/generated/android/c++/JNitroDeepLinkOptionsAndroid.hpp +58 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/iap/HybridRnIapSpec.kt +8 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/iap/NitroDeepLinkOptionsAndroid.kt +32 -0
- package/nitrogen/generated/ios/NitroIap-Swift-Cxx-Umbrella.hpp +3 -0
- package/nitrogen/generated/ios/c++/HybridRnIapSpecSwift.hpp +19 -0
- package/nitrogen/generated/ios/swift/HybridRnIapSpec.swift +2 -0
- package/nitrogen/generated/ios/swift/HybridRnIapSpec_cxx.swift +38 -0
- package/nitrogen/generated/ios/swift/NitroDeepLinkOptionsAndroid.swift +84 -0
- package/nitrogen/generated/shared/c++/HybridRnIapSpec.cpp +2 -0
- package/nitrogen/generated/shared/c++/HybridRnIapSpec.hpp +5 -0
- package/nitrogen/generated/shared/c++/NitroDeepLinkOptionsAndroid.hpp +72 -0
- package/package.json +1 -1
- package/plugin/build/withIAP.js +21 -18
- package/plugin/src/withIAP.ts +31 -23
- package/src/helpers/subscription.ts +2 -5
- package/src/index.ts +49 -2
- package/src/specs/RnIap.nitro.ts +22 -0
- package/src/types.ts +0 -2
- package/src/utils/type-bridge.ts +1 -1
package/src/index.ts
CHANGED
|
@@ -363,8 +363,7 @@ export const finishTransaction = async ({
|
|
|
363
363
|
};
|
|
364
364
|
} else if (Platform.OS === 'android') {
|
|
365
365
|
const androidPurchase = purchase as PurchaseAndroid;
|
|
366
|
-
const token =
|
|
367
|
-
androidPurchase.purchaseToken || androidPurchase.purchaseTokenAndroid;
|
|
366
|
+
const token = androidPurchase.purchaseToken;
|
|
368
367
|
|
|
369
368
|
if (!token) {
|
|
370
369
|
throw new Error('purchaseToken required to finish Android transaction');
|
|
@@ -1181,6 +1180,54 @@ export const getStorefrontIOS = async (): Promise<string> => {
|
|
|
1181
1180
|
}
|
|
1182
1181
|
};
|
|
1183
1182
|
|
|
1183
|
+
/**
|
|
1184
|
+
* Gets the storefront country code from the underlying native store.
|
|
1185
|
+
* Returns a two-letter country code such as 'US', 'KR', or empty string on failure.
|
|
1186
|
+
*
|
|
1187
|
+
* Cross-platform alias aligning with expo-iap.
|
|
1188
|
+
*/
|
|
1189
|
+
export const getStorefront = async (): Promise<string> => {
|
|
1190
|
+
if (Platform.OS === 'android') {
|
|
1191
|
+
try {
|
|
1192
|
+
// Optional since older builds may not have the method
|
|
1193
|
+
const result = await iap.getStorefrontAndroid?.();
|
|
1194
|
+
return result ?? '';
|
|
1195
|
+
} catch {
|
|
1196
|
+
return '';
|
|
1197
|
+
}
|
|
1198
|
+
}
|
|
1199
|
+
return getStorefrontIOS();
|
|
1200
|
+
};
|
|
1201
|
+
|
|
1202
|
+
/**
|
|
1203
|
+
* Deeplinks to native interface that allows users to manage their subscriptions
|
|
1204
|
+
* Cross-platform alias aligning with expo-iap
|
|
1205
|
+
*/
|
|
1206
|
+
export const deepLinkToSubscriptions = async (
|
|
1207
|
+
options: {
|
|
1208
|
+
skuAndroid?: string;
|
|
1209
|
+
packageNameAndroid?: string;
|
|
1210
|
+
} = {},
|
|
1211
|
+
): Promise<void> => {
|
|
1212
|
+
if (Platform.OS === 'android') {
|
|
1213
|
+
await iap.deepLinkToSubscriptionsAndroid?.({
|
|
1214
|
+
skuAndroid: options.skuAndroid,
|
|
1215
|
+
packageNameAndroid: options.packageNameAndroid,
|
|
1216
|
+
});
|
|
1217
|
+
return;
|
|
1218
|
+
}
|
|
1219
|
+
// iOS: Use manage subscriptions sheet (ignore returned purchases for deeplink parity)
|
|
1220
|
+
if (Platform.OS === 'ios') {
|
|
1221
|
+
try {
|
|
1222
|
+
await iap.showManageSubscriptionsIOS();
|
|
1223
|
+
} catch {
|
|
1224
|
+
// no-op
|
|
1225
|
+
}
|
|
1226
|
+
return;
|
|
1227
|
+
}
|
|
1228
|
+
return;
|
|
1229
|
+
};
|
|
1230
|
+
|
|
1184
1231
|
/**
|
|
1185
1232
|
* iOS only - Gets the original app transaction ID if the app was purchased from the App Store
|
|
1186
1233
|
* @platform iOS
|
package/src/specs/RnIap.nitro.ts
CHANGED
|
@@ -118,6 +118,14 @@ interface NitroFinishTransactionParams {
|
|
|
118
118
|
android?: NitroFinishTransactionAndroidParams;
|
|
119
119
|
}
|
|
120
120
|
|
|
121
|
+
/**
|
|
122
|
+
* Android deep link options for subscription management
|
|
123
|
+
*/
|
|
124
|
+
interface NitroDeepLinkOptionsAndroid {
|
|
125
|
+
skuAndroid?: string;
|
|
126
|
+
packageNameAndroid?: string;
|
|
127
|
+
}
|
|
128
|
+
|
|
121
129
|
// ╔══════════════════════════════════════════════════════════════════════════╗
|
|
122
130
|
// ║ TYPES ║
|
|
123
131
|
// ╚══════════════════════════════════════════════════════════════════════════╝
|
|
@@ -505,4 +513,18 @@ export interface RnIap extends HybridObject<{ios: 'swift'; android: 'kotlin'}> {
|
|
|
505
513
|
): Promise<
|
|
506
514
|
NitroReceiptValidationResultIOS | NitroReceiptValidationResultAndroid
|
|
507
515
|
>;
|
|
516
|
+
|
|
517
|
+
/**
|
|
518
|
+
* Get Google Play storefront country code (Android)
|
|
519
|
+
* @platform Android
|
|
520
|
+
*/
|
|
521
|
+
getStorefrontAndroid?(): Promise<string>;
|
|
522
|
+
|
|
523
|
+
/**
|
|
524
|
+
* Deep link to Play Store subscription management (Android)
|
|
525
|
+
* @platform Android
|
|
526
|
+
*/
|
|
527
|
+
deepLinkToSubscriptionsAndroid?(
|
|
528
|
+
options: NitroDeepLinkOptionsAndroid,
|
|
529
|
+
): Promise<void>;
|
|
508
530
|
}
|
package/src/types.ts
CHANGED
|
@@ -69,8 +69,6 @@ export type PurchaseCommon = {
|
|
|
69
69
|
transactionId?: string;
|
|
70
70
|
/** Transaction timestamp in milliseconds */
|
|
71
71
|
transactionDate: number;
|
|
72
|
-
/** Transaction receipt for validation */
|
|
73
|
-
transactionReceipt: string;
|
|
74
72
|
/** Unified purchase token (jwsRepresentation for iOS, purchaseToken for Android) */
|
|
75
73
|
purchaseToken?: string;
|
|
76
74
|
/** Platform identifier ('ios' or 'android') */
|
package/src/utils/type-bridge.ts
CHANGED
|
@@ -167,7 +167,7 @@ export function convertNitroPurchaseToPurchase(
|
|
|
167
167
|
id: nitroPurchase.id,
|
|
168
168
|
productId: nitroPurchase.productId,
|
|
169
169
|
transactionDate: nitroPurchase.transactionDate,
|
|
170
|
-
|
|
170
|
+
// Unified token (iOS JWS, Android purchaseToken)
|
|
171
171
|
purchaseToken: nitroPurchase.purchaseToken,
|
|
172
172
|
platform: nitroPurchase.platform as 'ios' | 'android',
|
|
173
173
|
// Common fields from NitroPurchase
|