react-native-iap 14.5.0 → 14.6.0-rc.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/android/src/main/java/com/margelo/nitro/iap/HybridRnIap.kt +173 -7
- package/ios/HybridRnIap.swift +24 -0
- package/ios/reactnativeiap.xcodeproj/project.xcworkspace/contents.xcworkspacedata +7 -0
- package/ios/reactnativeiap.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +8 -0
- package/lib/module/index.js +166 -0
- package/lib/module/index.js.map +1 -1
- package/lib/module/types.js +93 -0
- package/lib/module/types.js.map +1 -1
- package/lib/module/utils/type-bridge.js +2 -1
- package/lib/module/utils/type-bridge.js.map +1 -1
- package/lib/typescript/src/index.d.ts +124 -0
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/specs/RnIap.nitro.d.ts +125 -1
- package/lib/typescript/src/specs/RnIap.nitro.d.ts.map +1 -1
- package/lib/typescript/src/types.d.ts +227 -15
- package/lib/typescript/src/types.d.ts.map +1 -1
- package/lib/typescript/src/utils/type-bridge.d.ts.map +1 -1
- package/nitrogen/generated/android/c++/JBillingProgramAndroid.hpp +62 -0
- package/nitrogen/generated/android/c++/JExternalLinkLaunchModeAndroid.hpp +62 -0
- package/nitrogen/generated/android/c++/JExternalLinkTypeAndroid.hpp +62 -0
- package/nitrogen/generated/android/c++/JFunc_void_NitroProduct.hpp +13 -0
- package/nitrogen/generated/android/c++/JHybridRnIapSpec.cpp +100 -0
- package/nitrogen/generated/android/c++/JHybridRnIapSpec.hpp +4 -0
- package/nitrogen/generated/android/c++/JNitroBillingProgramAvailabilityResultAndroid.hpp +62 -0
- package/nitrogen/generated/android/c++/JNitroBillingProgramReportingDetailsAndroid.hpp +63 -0
- package/nitrogen/generated/android/c++/JNitroDiscountAmountAndroid.hpp +61 -0
- package/nitrogen/generated/android/c++/JNitroDiscountDisplayInfoAndroid.hpp +64 -0
- package/nitrogen/generated/android/c++/JNitroLaunchExternalLinkParamsAndroid.hpp +75 -0
- package/nitrogen/generated/android/c++/JNitroLimitedQuantityInfoAndroid.hpp +61 -0
- package/nitrogen/generated/android/c++/JNitroOneTimePurchaseOfferDetail.hpp +70 -3
- package/nitrogen/generated/android/c++/JNitroPreorderDetailsAndroid.hpp +61 -0
- package/nitrogen/generated/android/c++/JNitroProduct.hpp +35 -5
- package/nitrogen/generated/android/c++/JNitroPurchase.hpp +7 -3
- package/nitrogen/generated/android/c++/JNitroRentalDetailsAndroid.hpp +62 -0
- package/nitrogen/generated/android/c++/JNitroValidTimeWindowAndroid.hpp +61 -0
- package/nitrogen/generated/android/c++/JPurchaseAndroid.hpp +5 -1
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/iap/BillingProgramAndroid.kt +22 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/iap/ExternalLinkLaunchModeAndroid.kt +22 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/iap/ExternalLinkTypeAndroid.kt +22 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/iap/HybridRnIapSpec.kt +16 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/iap/NitroBillingProgramAvailabilityResultAndroid.kt +39 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/iap/NitroBillingProgramReportingDetailsAndroid.kt +39 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/iap/NitroDiscountAmountAndroid.kt +39 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/iap/NitroDiscountDisplayInfoAndroid.kt +39 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/iap/NitroLaunchExternalLinkParamsAndroid.kt +45 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/iap/NitroLimitedQuantityInfoAndroid.kt +39 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/iap/NitroOneTimePurchaseOfferDetail.kt +30 -3
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/iap/NitroPreorderDetailsAndroid.kt +39 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/iap/NitroProduct.kt +2 -2
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/iap/NitroPurchase.kt +6 -3
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/iap/NitroRentalDetailsAndroid.kt +39 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/iap/NitroValidTimeWindowAndroid.kt +39 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/iap/PurchaseAndroid.kt +5 -2
- package/nitrogen/generated/ios/NitroIap-Swift-Cxx-Bridge.cpp +16 -0
- package/nitrogen/generated/ios/NitroIap-Swift-Cxx-Bridge.hpp +232 -18
- package/nitrogen/generated/ios/NitroIap-Swift-Cxx-Umbrella.hpp +36 -0
- package/nitrogen/generated/ios/c++/HybridRnIapSpecSwift.hpp +66 -0
- package/nitrogen/generated/ios/swift/BillingProgramAndroid.swift +44 -0
- package/nitrogen/generated/ios/swift/ExternalLinkLaunchModeAndroid.swift +44 -0
- package/nitrogen/generated/ios/swift/ExternalLinkTypeAndroid.swift +44 -0
- package/nitrogen/generated/ios/swift/Func_void_NitroBillingProgramAvailabilityResultAndroid.swift +47 -0
- package/nitrogen/generated/ios/swift/Func_void_NitroBillingProgramReportingDetailsAndroid.swift +47 -0
- package/nitrogen/generated/ios/swift/HybridRnIapSpec.swift +4 -0
- package/nitrogen/generated/ios/swift/HybridRnIapSpec_cxx.swift +68 -0
- package/nitrogen/generated/ios/swift/NitroBillingProgramAvailabilityResultAndroid.swift +46 -0
- package/nitrogen/generated/ios/swift/NitroBillingProgramReportingDetailsAndroid.swift +46 -0
- package/nitrogen/generated/ios/swift/NitroDiscountAmountAndroid.swift +46 -0
- package/nitrogen/generated/ios/swift/NitroDiscountDisplayInfoAndroid.swift +70 -0
- package/nitrogen/generated/ios/swift/NitroLaunchExternalLinkParamsAndroid.swift +68 -0
- package/nitrogen/generated/ios/swift/NitroLimitedQuantityInfoAndroid.swift +46 -0
- package/nitrogen/generated/ios/swift/NitroOneTimePurchaseOfferDetail.swift +211 -2
- package/nitrogen/generated/ios/swift/NitroPreorderDetailsAndroid.swift +46 -0
- package/nitrogen/generated/ios/swift/NitroProduct.swift +26 -7
- package/nitrogen/generated/ios/swift/NitroPurchase.swift +31 -1
- package/nitrogen/generated/ios/swift/NitroRentalDetailsAndroid.swift +65 -0
- package/nitrogen/generated/ios/swift/NitroValidTimeWindowAndroid.swift +46 -0
- package/nitrogen/generated/ios/swift/PurchaseAndroid.swift +32 -2
- package/nitrogen/generated/shared/c++/BillingProgramAndroid.hpp +80 -0
- package/nitrogen/generated/shared/c++/ExternalLinkLaunchModeAndroid.hpp +80 -0
- package/nitrogen/generated/shared/c++/ExternalLinkTypeAndroid.hpp +80 -0
- package/nitrogen/generated/shared/c++/HybridRnIapSpec.cpp +4 -0
- package/nitrogen/generated/shared/c++/HybridRnIapSpec.hpp +16 -0
- package/nitrogen/generated/shared/c++/NitroBillingProgramAvailabilityResultAndroid.hpp +80 -0
- package/nitrogen/generated/shared/c++/NitroBillingProgramReportingDetailsAndroid.hpp +81 -0
- package/nitrogen/generated/shared/c++/NitroDiscountAmountAndroid.hpp +79 -0
- package/nitrogen/generated/shared/c++/NitroDiscountDisplayInfoAndroid.hpp +81 -0
- package/nitrogen/generated/shared/c++/NitroLaunchExternalLinkParamsAndroid.hpp +95 -0
- package/nitrogen/generated/shared/c++/NitroLimitedQuantityInfoAndroid.hpp +79 -0
- package/nitrogen/generated/shared/c++/NitroOneTimePurchaseOfferDetail.hpp +55 -3
- package/nitrogen/generated/shared/c++/NitroPreorderDetailsAndroid.hpp +79 -0
- package/nitrogen/generated/shared/c++/NitroProduct.hpp +6 -5
- package/nitrogen/generated/shared/c++/NitroPurchase.hpp +6 -2
- package/nitrogen/generated/shared/c++/NitroRentalDetailsAndroid.hpp +80 -0
- package/nitrogen/generated/shared/c++/NitroValidTimeWindowAndroid.hpp +79 -0
- package/nitrogen/generated/shared/c++/PurchaseAndroid.hpp +5 -1
- package/openiap-versions.json +2 -2
- package/package.json +1 -1
- package/plugin/build/src/withIAP.d.ts +3 -0
- package/plugin/build/src/withIAP.js +81 -0
- package/plugin/build/tsconfig.tsbuildinfo +1 -0
- package/plugin/tsconfig.tsbuildinfo +1 -1
- package/src/index.ts +218 -0
- package/src/specs/RnIap.nitro.ts +161 -1
- package/src/types.ts +243 -15
- package/src/utils/type-bridge.ts +1 -0
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const config_plugins_1 = require("expo/config-plugins");
|
|
4
|
+
const pkg = require('../../package.json');
|
|
5
|
+
// Global flag to prevent duplicate logs
|
|
6
|
+
let hasLoggedPluginExecution = false;
|
|
7
|
+
const addLineToGradle = (content, anchor, lineToAdd, offset = 1) => {
|
|
8
|
+
const lines = content.split('\n');
|
|
9
|
+
const index = lines.findIndex((line) => line.match(anchor));
|
|
10
|
+
if (index === -1) {
|
|
11
|
+
console.warn(`Anchor "${anchor}" not found in build.gradle. Appending to end.`);
|
|
12
|
+
lines.push(lineToAdd);
|
|
13
|
+
}
|
|
14
|
+
else {
|
|
15
|
+
lines.splice(index + offset, 0, lineToAdd);
|
|
16
|
+
}
|
|
17
|
+
return lines.join('\n');
|
|
18
|
+
};
|
|
19
|
+
const modifyAppBuildGradle = (gradle) => {
|
|
20
|
+
let modified = gradle;
|
|
21
|
+
// Add billing library dependencies to app-level build.gradle
|
|
22
|
+
const billingDep = ` implementation "com.android.billingclient:billing-ktx:8.0.0"`;
|
|
23
|
+
const gmsDep = ` implementation "com.google.android.gms:play-services-base:18.1.0"`;
|
|
24
|
+
let hasAddedDependency = false;
|
|
25
|
+
if (!modified.includes(billingDep)) {
|
|
26
|
+
modified = addLineToGradle(modified, /dependencies\s*{/, billingDep);
|
|
27
|
+
hasAddedDependency = true;
|
|
28
|
+
}
|
|
29
|
+
if (!modified.includes(gmsDep)) {
|
|
30
|
+
modified = addLineToGradle(modified, /dependencies\s*{/, gmsDep, 1);
|
|
31
|
+
hasAddedDependency = true;
|
|
32
|
+
}
|
|
33
|
+
// Log only once and only if we actually added dependencies
|
|
34
|
+
if (hasAddedDependency && !hasLoggedPluginExecution) {
|
|
35
|
+
console.log('🛠️ react-native-iap: Added billing dependencies to build.gradle');
|
|
36
|
+
}
|
|
37
|
+
return modified;
|
|
38
|
+
};
|
|
39
|
+
const withIapAndroid = (config) => {
|
|
40
|
+
// Add IAP dependencies to app build.gradle
|
|
41
|
+
config = (0, config_plugins_1.withAppBuildGradle)(config, (config) => {
|
|
42
|
+
config.modResults.contents = modifyAppBuildGradle(config.modResults.contents);
|
|
43
|
+
return config;
|
|
44
|
+
});
|
|
45
|
+
config = (0, config_plugins_1.withAndroidManifest)(config, (config) => {
|
|
46
|
+
const manifest = config.modResults;
|
|
47
|
+
if (!manifest.manifest['uses-permission']) {
|
|
48
|
+
manifest.manifest['uses-permission'] = [];
|
|
49
|
+
}
|
|
50
|
+
const permissions = manifest.manifest['uses-permission'];
|
|
51
|
+
const billingPerm = { $: { 'android:name': 'com.android.vending.BILLING' } };
|
|
52
|
+
const alreadyExists = permissions.some((p) => p.$['android:name'] === 'com.android.vending.BILLING');
|
|
53
|
+
if (!alreadyExists) {
|
|
54
|
+
permissions.push(billingPerm);
|
|
55
|
+
if (!hasLoggedPluginExecution) {
|
|
56
|
+
console.log('✅ Added com.android.vending.BILLING to AndroidManifest.xml');
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
else {
|
|
60
|
+
if (!hasLoggedPluginExecution) {
|
|
61
|
+
console.log('ℹ️ com.android.vending.BILLING already exists in AndroidManifest.xml');
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
return config;
|
|
65
|
+
});
|
|
66
|
+
return config;
|
|
67
|
+
};
|
|
68
|
+
const withIAP = (config, _props) => {
|
|
69
|
+
try {
|
|
70
|
+
const result = withIapAndroid(config);
|
|
71
|
+
// Set flag after first execution to prevent duplicate logs
|
|
72
|
+
hasLoggedPluginExecution = true;
|
|
73
|
+
return result;
|
|
74
|
+
}
|
|
75
|
+
catch (error) {
|
|
76
|
+
config_plugins_1.WarningAggregator.addWarningAndroid('react-native-iap', `react-native-iap plugin encountered an error: ${error}`);
|
|
77
|
+
console.error('react-native-iap plugin error:', error);
|
|
78
|
+
return config;
|
|
79
|
+
}
|
|
80
|
+
};
|
|
81
|
+
exports.default = (0, config_plugins_1.createRunOncePlugin)(withIAP, pkg.name, pkg.version);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"root":["../src/withiap.ts"],"version":"5.9.2"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"root":["./src/
|
|
1
|
+
{"root":["./src/withiap.ts"],"version":"5.9.2"}
|
package/src/index.ts
CHANGED
|
@@ -2153,6 +2153,224 @@ export const createAlternativeBillingTokenAndroid: MutationField<
|
|
|
2153
2153
|
}
|
|
2154
2154
|
};
|
|
2155
2155
|
|
|
2156
|
+
// ------------------------------
|
|
2157
|
+
// Billing Programs API (Android 8.2.0+)
|
|
2158
|
+
// ------------------------------
|
|
2159
|
+
|
|
2160
|
+
/**
|
|
2161
|
+
* Billing program type for external content links and external offers.
|
|
2162
|
+
* @platform Android
|
|
2163
|
+
* @since Google Play Billing Library 8.2.0+
|
|
2164
|
+
*/
|
|
2165
|
+
export type BillingProgramAndroid =
|
|
2166
|
+
| 'unspecified'
|
|
2167
|
+
| 'external-content-link'
|
|
2168
|
+
| 'external-offer';
|
|
2169
|
+
|
|
2170
|
+
/**
|
|
2171
|
+
* Launch mode for external link flow.
|
|
2172
|
+
* @platform Android
|
|
2173
|
+
* @since Google Play Billing Library 8.2.0+
|
|
2174
|
+
*/
|
|
2175
|
+
export type ExternalLinkLaunchModeAndroid =
|
|
2176
|
+
| 'unspecified'
|
|
2177
|
+
| 'launch-in-external-browser-or-app'
|
|
2178
|
+
| 'caller-will-launch-link';
|
|
2179
|
+
|
|
2180
|
+
/**
|
|
2181
|
+
* Link type for external link flow.
|
|
2182
|
+
* @platform Android
|
|
2183
|
+
* @since Google Play Billing Library 8.2.0+
|
|
2184
|
+
*/
|
|
2185
|
+
export type ExternalLinkTypeAndroid =
|
|
2186
|
+
| 'unspecified'
|
|
2187
|
+
| 'link-to-digital-content-offer'
|
|
2188
|
+
| 'link-to-app-download';
|
|
2189
|
+
|
|
2190
|
+
/**
|
|
2191
|
+
* Parameters for launching an external link (Android 8.2.0+).
|
|
2192
|
+
*/
|
|
2193
|
+
export interface LaunchExternalLinkParamsAndroid {
|
|
2194
|
+
/** The billing program (external-content-link or external-offer) */
|
|
2195
|
+
billingProgram: BillingProgramAndroid;
|
|
2196
|
+
/** The external link launch mode */
|
|
2197
|
+
launchMode: ExternalLinkLaunchModeAndroid;
|
|
2198
|
+
/** The type of the external link */
|
|
2199
|
+
linkType: ExternalLinkTypeAndroid;
|
|
2200
|
+
/** The URI where the content will be accessed from */
|
|
2201
|
+
linkUri: string;
|
|
2202
|
+
}
|
|
2203
|
+
|
|
2204
|
+
/**
|
|
2205
|
+
* Result of checking billing program availability (Android 8.2.0+).
|
|
2206
|
+
*/
|
|
2207
|
+
export interface BillingProgramAvailabilityResultAndroid {
|
|
2208
|
+
/** The billing program that was checked */
|
|
2209
|
+
billingProgram: BillingProgramAndroid;
|
|
2210
|
+
/** Whether the billing program is available for the user */
|
|
2211
|
+
isAvailable: boolean;
|
|
2212
|
+
}
|
|
2213
|
+
|
|
2214
|
+
/**
|
|
2215
|
+
* Reporting details for external transactions (Android 8.2.0+).
|
|
2216
|
+
*/
|
|
2217
|
+
export interface BillingProgramReportingDetailsAndroid {
|
|
2218
|
+
/** The billing program that the reporting details are associated with */
|
|
2219
|
+
billingProgram: BillingProgramAndroid;
|
|
2220
|
+
/** External transaction token used to report transactions to Google */
|
|
2221
|
+
externalTransactionToken: string;
|
|
2222
|
+
}
|
|
2223
|
+
|
|
2224
|
+
/**
|
|
2225
|
+
* Enable a billing program before initConnection (Android only).
|
|
2226
|
+
* Must be called BEFORE initConnection() to configure the BillingClient.
|
|
2227
|
+
*
|
|
2228
|
+
* @param program - The billing program to enable (external-content-link or external-offer)
|
|
2229
|
+
* @platform Android
|
|
2230
|
+
* @since Google Play Billing Library 8.2.0+
|
|
2231
|
+
*
|
|
2232
|
+
* @example
|
|
2233
|
+
* ```typescript
|
|
2234
|
+
* // Enable external offers before connecting
|
|
2235
|
+
* enableBillingProgramAndroid('external-offer');
|
|
2236
|
+
* await initConnection();
|
|
2237
|
+
* ```
|
|
2238
|
+
*/
|
|
2239
|
+
export const enableBillingProgramAndroid = (
|
|
2240
|
+
program: BillingProgramAndroid,
|
|
2241
|
+
): void => {
|
|
2242
|
+
if (Platform.OS !== 'android') {
|
|
2243
|
+
RnIapConsole.warn(
|
|
2244
|
+
'enableBillingProgramAndroid is only supported on Android',
|
|
2245
|
+
);
|
|
2246
|
+
return;
|
|
2247
|
+
}
|
|
2248
|
+
try {
|
|
2249
|
+
IAP.instance.enableBillingProgramAndroid(program as any);
|
|
2250
|
+
} catch (error) {
|
|
2251
|
+
RnIapConsole.error('Failed to enable billing program:', error);
|
|
2252
|
+
}
|
|
2253
|
+
};
|
|
2254
|
+
|
|
2255
|
+
/**
|
|
2256
|
+
* Check if a billing program is available for this user/device (Android only).
|
|
2257
|
+
*
|
|
2258
|
+
* @param program - The billing program to check
|
|
2259
|
+
* @returns Promise with availability result
|
|
2260
|
+
* @platform Android
|
|
2261
|
+
* @since Google Play Billing Library 8.2.0+
|
|
2262
|
+
*
|
|
2263
|
+
* @example
|
|
2264
|
+
* ```typescript
|
|
2265
|
+
* const result = await isBillingProgramAvailableAndroid('external-offer');
|
|
2266
|
+
* if (result.isAvailable) {
|
|
2267
|
+
* // External offers are available for this user
|
|
2268
|
+
* }
|
|
2269
|
+
* ```
|
|
2270
|
+
*/
|
|
2271
|
+
export const isBillingProgramAvailableAndroid = async (
|
|
2272
|
+
program: BillingProgramAndroid,
|
|
2273
|
+
): Promise<BillingProgramAvailabilityResultAndroid> => {
|
|
2274
|
+
if (Platform.OS !== 'android') {
|
|
2275
|
+
throw new Error('Billing Programs API is only supported on Android');
|
|
2276
|
+
}
|
|
2277
|
+
try {
|
|
2278
|
+
const result = await IAP.instance.isBillingProgramAvailableAndroid(
|
|
2279
|
+
program as any,
|
|
2280
|
+
);
|
|
2281
|
+
return {
|
|
2282
|
+
billingProgram: result.billingProgram as unknown as BillingProgramAndroid,
|
|
2283
|
+
isAvailable: result.isAvailable,
|
|
2284
|
+
};
|
|
2285
|
+
} catch (error) {
|
|
2286
|
+
RnIapConsole.error('Failed to check billing program availability:', error);
|
|
2287
|
+
throw error;
|
|
2288
|
+
}
|
|
2289
|
+
};
|
|
2290
|
+
|
|
2291
|
+
/**
|
|
2292
|
+
* Create billing program reporting details for external transactions (Android only).
|
|
2293
|
+
* Used to get the external transaction token needed for reporting to Google.
|
|
2294
|
+
*
|
|
2295
|
+
* @param program - The billing program to create reporting details for
|
|
2296
|
+
* @returns Promise with reporting details including external transaction token
|
|
2297
|
+
* @platform Android
|
|
2298
|
+
* @since Google Play Billing Library 8.2.0+
|
|
2299
|
+
*
|
|
2300
|
+
* @example
|
|
2301
|
+
* ```typescript
|
|
2302
|
+
* const details = await createBillingProgramReportingDetailsAndroid('external-offer');
|
|
2303
|
+
* // Use details.externalTransactionToken to report the transaction
|
|
2304
|
+
* await fetch('/api/report-external-transaction', {
|
|
2305
|
+
* method: 'POST',
|
|
2306
|
+
* body: JSON.stringify({ token: details.externalTransactionToken })
|
|
2307
|
+
* });
|
|
2308
|
+
* ```
|
|
2309
|
+
*/
|
|
2310
|
+
export const createBillingProgramReportingDetailsAndroid = async (
|
|
2311
|
+
program: BillingProgramAndroid,
|
|
2312
|
+
): Promise<BillingProgramReportingDetailsAndroid> => {
|
|
2313
|
+
if (Platform.OS !== 'android') {
|
|
2314
|
+
throw new Error('Billing Programs API is only supported on Android');
|
|
2315
|
+
}
|
|
2316
|
+
try {
|
|
2317
|
+
const result =
|
|
2318
|
+
await IAP.instance.createBillingProgramReportingDetailsAndroid(
|
|
2319
|
+
program as any,
|
|
2320
|
+
);
|
|
2321
|
+
return {
|
|
2322
|
+
billingProgram: result.billingProgram as unknown as BillingProgramAndroid,
|
|
2323
|
+
externalTransactionToken: result.externalTransactionToken,
|
|
2324
|
+
};
|
|
2325
|
+
} catch (error) {
|
|
2326
|
+
RnIapConsole.error(
|
|
2327
|
+
'Failed to create billing program reporting details:',
|
|
2328
|
+
error,
|
|
2329
|
+
);
|
|
2330
|
+
throw error;
|
|
2331
|
+
}
|
|
2332
|
+
};
|
|
2333
|
+
|
|
2334
|
+
/**
|
|
2335
|
+
* Launch external link for external offers or app download (Android only).
|
|
2336
|
+
*
|
|
2337
|
+
* @param params - Parameters for launching the external link
|
|
2338
|
+
* @returns Promise<boolean> - true if user accepted, false otherwise
|
|
2339
|
+
* @platform Android
|
|
2340
|
+
* @since Google Play Billing Library 8.2.0+
|
|
2341
|
+
*
|
|
2342
|
+
* @example
|
|
2343
|
+
* ```typescript
|
|
2344
|
+
* const success = await launchExternalLinkAndroid({
|
|
2345
|
+
* billingProgram: 'external-offer',
|
|
2346
|
+
* launchMode: 'launch-in-external-browser-or-app',
|
|
2347
|
+
* linkType: 'link-to-digital-content-offer',
|
|
2348
|
+
* linkUri: 'https://your-website.com/purchase'
|
|
2349
|
+
* });
|
|
2350
|
+
* if (success) {
|
|
2351
|
+
* console.log('User accepted external link');
|
|
2352
|
+
* }
|
|
2353
|
+
* ```
|
|
2354
|
+
*/
|
|
2355
|
+
export const launchExternalLinkAndroid = async (
|
|
2356
|
+
params: LaunchExternalLinkParamsAndroid,
|
|
2357
|
+
): Promise<boolean> => {
|
|
2358
|
+
if (Platform.OS !== 'android') {
|
|
2359
|
+
throw new Error('Billing Programs API is only supported on Android');
|
|
2360
|
+
}
|
|
2361
|
+
try {
|
|
2362
|
+
return await IAP.instance.launchExternalLinkAndroid({
|
|
2363
|
+
billingProgram: params.billingProgram as any,
|
|
2364
|
+
launchMode: params.launchMode as any,
|
|
2365
|
+
linkType: params.linkType as any,
|
|
2366
|
+
linkUri: params.linkUri,
|
|
2367
|
+
});
|
|
2368
|
+
} catch (error) {
|
|
2369
|
+
RnIapConsole.error('Failed to launch external link:', error);
|
|
2370
|
+
throw error;
|
|
2371
|
+
}
|
|
2372
|
+
};
|
|
2373
|
+
|
|
2156
2374
|
// ------------------------------
|
|
2157
2375
|
// iOS External Purchase
|
|
2158
2376
|
// ------------------------------
|
package/src/specs/RnIap.nitro.ts
CHANGED
|
@@ -44,6 +44,22 @@ export type IapStore = 'unknown' | 'apple' | 'google' | 'horizon';
|
|
|
44
44
|
// Note: Nitro requires at least 2 values for union types
|
|
45
45
|
export type PurchaseVerificationProvider = 'iapkit' | 'none';
|
|
46
46
|
|
|
47
|
+
// Billing Programs API types (Android 8.2.0+)
|
|
48
|
+
export type BillingProgramAndroid =
|
|
49
|
+
| 'unspecified'
|
|
50
|
+
| 'external-content-link'
|
|
51
|
+
| 'external-offer';
|
|
52
|
+
|
|
53
|
+
export type ExternalLinkLaunchModeAndroid =
|
|
54
|
+
| 'unspecified'
|
|
55
|
+
| 'launch-in-external-browser-or-app'
|
|
56
|
+
| 'caller-will-launch-link';
|
|
57
|
+
|
|
58
|
+
export type ExternalLinkTypeAndroid =
|
|
59
|
+
| 'unspecified'
|
|
60
|
+
| 'link-to-digital-content-offer'
|
|
61
|
+
| 'link-to-app-download';
|
|
62
|
+
|
|
47
63
|
// ╔══════════════════════════════════════════════════════════════════════════╗
|
|
48
64
|
// ║ PARAMS ║
|
|
49
65
|
// ╚══════════════════════════════════════════════════════════════════════════╝
|
|
@@ -147,6 +163,20 @@ export interface NitroDeepLinkOptionsAndroid {
|
|
|
147
163
|
packageNameAndroid?: DeepLinkOptions['packageNameAndroid'];
|
|
148
164
|
}
|
|
149
165
|
|
|
166
|
+
/**
|
|
167
|
+
* Parameters for launching an external link (Android 8.2.0+)
|
|
168
|
+
*/
|
|
169
|
+
export interface NitroLaunchExternalLinkParamsAndroid {
|
|
170
|
+
/** The billing program (external-content-link or external-offer) */
|
|
171
|
+
billingProgram: BillingProgramAndroid;
|
|
172
|
+
/** The external link launch mode */
|
|
173
|
+
launchMode: ExternalLinkLaunchModeAndroid;
|
|
174
|
+
/** The type of the external link */
|
|
175
|
+
linkType: ExternalLinkTypeAndroid;
|
|
176
|
+
/** The URI where the content will be accessed from */
|
|
177
|
+
linkUri: string;
|
|
178
|
+
}
|
|
179
|
+
|
|
150
180
|
// ╔══════════════════════════════════════════════════════════════════════════╗
|
|
151
181
|
// ║ TYPES ║
|
|
152
182
|
// ╚══════════════════════════════════════════════════════════════════════════╝
|
|
@@ -251,13 +281,91 @@ export interface NitroVerifyPurchaseWithProviderResult {
|
|
|
251
281
|
provider: PurchaseVerificationProvider;
|
|
252
282
|
}
|
|
253
283
|
|
|
284
|
+
/**
|
|
285
|
+
* Result of checking billing program availability (Android 8.2.0+)
|
|
286
|
+
*/
|
|
287
|
+
export interface NitroBillingProgramAvailabilityResultAndroid {
|
|
288
|
+
/** The billing program that was checked */
|
|
289
|
+
billingProgram: BillingProgramAndroid;
|
|
290
|
+
/** Whether the billing program is available for the user */
|
|
291
|
+
isAvailable: boolean;
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
/**
|
|
295
|
+
* Reporting details for external transactions (Android 8.2.0+)
|
|
296
|
+
*/
|
|
297
|
+
export interface NitroBillingProgramReportingDetailsAndroid {
|
|
298
|
+
/** The billing program that the reporting details are associated with */
|
|
299
|
+
billingProgram: BillingProgramAndroid;
|
|
300
|
+
/** External transaction token used to report transactions to Google */
|
|
301
|
+
externalTransactionToken: string;
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
/**
|
|
305
|
+
* Discount amount details for one-time purchase offers (Android)
|
|
306
|
+
*/
|
|
307
|
+
export interface NitroDiscountAmountAndroid {
|
|
308
|
+
discountAmountMicros: string;
|
|
309
|
+
formattedDiscountAmount: string;
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
/**
|
|
313
|
+
* Discount display information for one-time purchase offers (Android)
|
|
314
|
+
*/
|
|
315
|
+
export interface NitroDiscountDisplayInfoAndroid {
|
|
316
|
+
discountAmount?: NitroDiscountAmountAndroid | null;
|
|
317
|
+
percentageDiscount?: number | null;
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
/**
|
|
321
|
+
* Limited quantity information for one-time purchase offers (Android)
|
|
322
|
+
*/
|
|
323
|
+
export interface NitroLimitedQuantityInfoAndroid {
|
|
324
|
+
maximumQuantity: number;
|
|
325
|
+
remainingQuantity: number;
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
/**
|
|
329
|
+
* Pre-order details for one-time purchase products (Android)
|
|
330
|
+
*/
|
|
331
|
+
export interface NitroPreorderDetailsAndroid {
|
|
332
|
+
preorderPresaleEndTimeMillis: string;
|
|
333
|
+
preorderReleaseTimeMillis: string;
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
/**
|
|
337
|
+
* Rental details for one-time purchase products (Android)
|
|
338
|
+
*/
|
|
339
|
+
export interface NitroRentalDetailsAndroid {
|
|
340
|
+
rentalExpirationPeriod?: string | null;
|
|
341
|
+
rentalPeriod: string;
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
/**
|
|
345
|
+
* Valid time window for when an offer is available (Android)
|
|
346
|
+
*/
|
|
347
|
+
export interface NitroValidTimeWindowAndroid {
|
|
348
|
+
endTimeMillis: string;
|
|
349
|
+
startTimeMillis: string;
|
|
350
|
+
}
|
|
351
|
+
|
|
254
352
|
/**
|
|
255
353
|
* Android one-time purchase offer details
|
|
354
|
+
* Available in Google Play Billing Library 7.0+
|
|
256
355
|
*/
|
|
257
356
|
export interface NitroOneTimePurchaseOfferDetail {
|
|
357
|
+
discountDisplayInfo?: NitroDiscountDisplayInfoAndroid | null;
|
|
258
358
|
formattedPrice: string;
|
|
359
|
+
fullPriceMicros?: string | null;
|
|
360
|
+
limitedQuantityInfo?: NitroLimitedQuantityInfoAndroid | null;
|
|
361
|
+
offerId?: string | null;
|
|
362
|
+
offerTags: string[];
|
|
363
|
+
offerToken: string;
|
|
364
|
+
preorderDetailsAndroid?: NitroPreorderDetailsAndroid | null;
|
|
259
365
|
priceAmountMicros: string;
|
|
260
366
|
priceCurrencyCode: string;
|
|
367
|
+
rentalDetailsAndroid?: NitroRentalDetailsAndroid | null;
|
|
368
|
+
validTimeWindow?: NitroValidTimeWindowAndroid | null;
|
|
261
369
|
}
|
|
262
370
|
|
|
263
371
|
export interface NitroPurchase {
|
|
@@ -306,6 +414,7 @@ export interface NitroPurchase {
|
|
|
306
414
|
obfuscatedAccountIdAndroid?: string | null;
|
|
307
415
|
obfuscatedProfileIdAndroid?: string | null;
|
|
308
416
|
developerPayloadAndroid?: string | null;
|
|
417
|
+
isSuspendedAndroid?: boolean | null;
|
|
309
418
|
}
|
|
310
419
|
|
|
311
420
|
/**
|
|
@@ -380,7 +489,7 @@ export interface NitroProduct {
|
|
|
380
489
|
subscriptionPeriodAndroid?: string | null;
|
|
381
490
|
freeTrialPeriodAndroid?: string | null;
|
|
382
491
|
subscriptionOfferDetailsAndroid?: string | null;
|
|
383
|
-
oneTimePurchaseOfferDetailsAndroid?: NitroOneTimePurchaseOfferDetail | null;
|
|
492
|
+
oneTimePurchaseOfferDetailsAndroid?: NitroOneTimePurchaseOfferDetail[] | null;
|
|
384
493
|
}
|
|
385
494
|
|
|
386
495
|
// ╔══════════════════════════════════════════════════════════════════════════╗
|
|
@@ -811,6 +920,57 @@ export interface RnIap extends HybridObject<{ios: 'swift'; android: 'kotlin'}> {
|
|
|
811
920
|
listener: (details: UserChoiceBillingDetails) => void,
|
|
812
921
|
): void;
|
|
813
922
|
|
|
923
|
+
// ╔════════════════════════════════════════════════════════════════════════╗
|
|
924
|
+
// ║ BILLING PROGRAMS API (Android 8.2.0+) ║
|
|
925
|
+
// ╚════════════════════════════════════════════════════════════════════════╝
|
|
926
|
+
|
|
927
|
+
/**
|
|
928
|
+
* Enable a billing program before initConnection (Android only).
|
|
929
|
+
* Must be called BEFORE initConnection() to configure the BillingClient.
|
|
930
|
+
*
|
|
931
|
+
* @param program - The billing program to enable
|
|
932
|
+
* @platform Android
|
|
933
|
+
* @since Billing Library 8.2.0+
|
|
934
|
+
*/
|
|
935
|
+
enableBillingProgramAndroid(program: BillingProgramAndroid): void;
|
|
936
|
+
|
|
937
|
+
/**
|
|
938
|
+
* Check if a billing program is available for this user/device (Android only).
|
|
939
|
+
*
|
|
940
|
+
* @param program - The billing program to check
|
|
941
|
+
* @returns Promise with availability result
|
|
942
|
+
* @platform Android
|
|
943
|
+
* @since Billing Library 8.2.0+
|
|
944
|
+
*/
|
|
945
|
+
isBillingProgramAvailableAndroid(
|
|
946
|
+
program: BillingProgramAndroid,
|
|
947
|
+
): Promise<NitroBillingProgramAvailabilityResultAndroid>;
|
|
948
|
+
|
|
949
|
+
/**
|
|
950
|
+
* Create billing program reporting details for external transactions (Android only).
|
|
951
|
+
* Used to get the external transaction token needed for reporting to Google.
|
|
952
|
+
*
|
|
953
|
+
* @param program - The billing program to create reporting details for
|
|
954
|
+
* @returns Promise with reporting details including external transaction token
|
|
955
|
+
* @platform Android
|
|
956
|
+
* @since Billing Library 8.2.0+
|
|
957
|
+
*/
|
|
958
|
+
createBillingProgramReportingDetailsAndroid(
|
|
959
|
+
program: BillingProgramAndroid,
|
|
960
|
+
): Promise<NitroBillingProgramReportingDetailsAndroid>;
|
|
961
|
+
|
|
962
|
+
/**
|
|
963
|
+
* Launch external link for external offers or app download (Android only).
|
|
964
|
+
*
|
|
965
|
+
* @param params - Parameters for launching the external link
|
|
966
|
+
* @returns Promise<boolean> - true if user accepted, false otherwise
|
|
967
|
+
* @platform Android
|
|
968
|
+
* @since Billing Library 8.2.0+
|
|
969
|
+
*/
|
|
970
|
+
launchExternalLinkAndroid(
|
|
971
|
+
params: NitroLaunchExternalLinkParamsAndroid,
|
|
972
|
+
): Promise<boolean>;
|
|
973
|
+
|
|
814
974
|
// ╔════════════════════════════════════════════════════════════════════════╗
|
|
815
975
|
// ║ EXTERNAL PURCHASE LINKS (iOS 16.0+) ║
|
|
816
976
|
// ╚════════════════════════════════════════════════════════════════════════╝
|