react-native-iap 15.2.0 → 15.2.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 +117 -114
- package/android/src/main/java/com/margelo/nitro/iap/ProductQueryHelpers.kt +42 -0
- package/android/src/test/java/com/margelo/nitro/iap/ProductQueryHelpersTest.kt +140 -0
- package/ios/HybridRnIap.swift +33 -0
- package/lib/module/hooks/useIAP.js.map +1 -1
- package/lib/module/hooks/useWebhookEvents.js +113 -0
- package/lib/module/hooks/useWebhookEvents.js.map +1 -0
- package/lib/module/index.js +331 -131
- package/lib/module/index.js.map +1 -1
- package/lib/module/kit-api.js +161 -0
- package/lib/module/kit-api.js.map +1 -0
- package/lib/module/types.js +16 -0
- package/lib/module/types.js.map +1 -1
- package/lib/module/utils/error.js.map +1 -1
- package/lib/module/utils/errorMapping.js +6 -0
- package/lib/module/utils/errorMapping.js.map +1 -1
- package/lib/module/webhook-client.js +164 -0
- package/lib/module/webhook-client.js.map +1 -0
- package/lib/typescript/plugin/src/withIAP.d.ts +1 -1
- package/lib/typescript/src/hooks/useIAP.d.ts +162 -2
- package/lib/typescript/src/hooks/useIAP.d.ts.map +1 -1
- package/lib/typescript/src/hooks/useWebhookEvents.d.ts +55 -0
- package/lib/typescript/src/hooks/useWebhookEvents.d.ts.map +1 -0
- package/lib/typescript/src/index.d.ts +282 -129
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/kit-api.d.ts +54 -0
- package/lib/typescript/src/kit-api.d.ts.map +1 -0
- package/lib/typescript/src/specs/RnIap.nitro.d.ts +7 -0
- package/lib/typescript/src/specs/RnIap.nitro.d.ts.map +1 -1
- package/lib/typescript/src/types.d.ts +304 -74
- package/lib/typescript/src/types.d.ts.map +1 -1
- package/lib/typescript/src/utils/error.d.ts +3 -0
- package/lib/typescript/src/utils/error.d.ts.map +1 -1
- package/lib/typescript/src/utils/errorMapping.d.ts +6 -0
- package/lib/typescript/src/utils/errorMapping.d.ts.map +1 -1
- package/lib/typescript/src/webhook-client.d.ts +82 -0
- package/lib/typescript/src/webhook-client.d.ts.map +1 -0
- package/nitrogen/generated/android/NitroIap+autolinking.cmake +3 -0
- package/nitrogen/generated/android/c++/JAdvancedCommerceInfoIOS.hpp +118 -0
- package/nitrogen/generated/android/c++/JAdvancedCommerceItemDetailsIOS.hpp +62 -0
- package/nitrogen/generated/android/c++/JAdvancedCommerceItemIOS.hpp +78 -0
- package/nitrogen/generated/android/c++/JAdvancedCommerceRefundIOS.hpp +62 -0
- package/nitrogen/generated/android/c++/JHybridRnIapSpec.cpp +44 -0
- package/nitrogen/generated/android/c++/JHybridRnIapSpec.hpp +1 -0
- package/nitrogen/generated/android/c++/JPurchase.hpp +11 -0
- package/nitrogen/generated/android/c++/JPurchaseIOS.hpp +16 -1
- package/nitrogen/generated/android/c++/JRequestPurchaseResult.hpp +11 -0
- package/nitrogen/generated/android/c++/JVariant_NullType_AdvancedCommerceInfoIOS.cpp +26 -0
- package/nitrogen/generated/android/c++/JVariant_NullType_AdvancedCommerceInfoIOS.hpp +84 -0
- package/nitrogen/generated/android/c++/JVariant_NullType_AdvancedCommerceItemDetailsIOS.cpp +26 -0
- package/nitrogen/generated/android/c++/JVariant_NullType_AdvancedCommerceItemDetailsIOS.hpp +74 -0
- package/nitrogen/generated/android/c++/JVariant_NullType_Array_AdvancedCommerceRefundIOS_.cpp +35 -0
- package/nitrogen/generated/android/c++/JVariant_NullType_Array_AdvancedCommerceRefundIOS_.hpp +84 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/iap/AdvancedCommerceInfoIOS.kt +59 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/iap/AdvancedCommerceItemDetailsIOS.kt +38 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/iap/AdvancedCommerceItemIOS.kt +44 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/iap/AdvancedCommerceRefundIOS.kt +38 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/iap/HybridRnIapSpec.kt +4 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/iap/PurchaseIOS.kt +5 -2
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/iap/Variant_NullType_AdvancedCommerceInfoIOS.kt +53 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/iap/Variant_NullType_AdvancedCommerceItemDetailsIOS.kt +53 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/iap/Variant_NullType_Array_AdvancedCommerceRefundIOS_.kt +53 -0
- package/nitrogen/generated/ios/NitroIap-Swift-Cxx-Bridge.hpp +166 -0
- package/nitrogen/generated/ios/NitroIap-Swift-Cxx-Umbrella.hpp +12 -0
- package/nitrogen/generated/ios/c++/HybridRnIapSpecSwift.hpp +20 -0
- package/nitrogen/generated/ios/swift/AdvancedCommerceInfoIOS.swift +294 -0
- package/nitrogen/generated/ios/swift/AdvancedCommerceItemDetailsIOS.swift +61 -0
- package/nitrogen/generated/ios/swift/AdvancedCommerceItemIOS.swift +141 -0
- package/nitrogen/generated/ios/swift/AdvancedCommerceRefundIOS.swift +61 -0
- package/nitrogen/generated/ios/swift/HybridRnIapSpec.swift +1 -0
- package/nitrogen/generated/ios/swift/HybridRnIapSpec_cxx.swift +25 -0
- package/nitrogen/generated/ios/swift/PurchaseIOS.swift +39 -2
- package/nitrogen/generated/ios/swift/Variant_NullType_AdvancedCommerceInfoIOS.swift +18 -0
- package/nitrogen/generated/ios/swift/Variant_NullType_AdvancedCommerceItemDetailsIOS.swift +18 -0
- package/nitrogen/generated/ios/swift/Variant_NullType__AdvancedCommerceRefundIOS_.swift +18 -0
- package/nitrogen/generated/shared/c++/AdvancedCommerceInfoIOS.hpp +117 -0
- package/nitrogen/generated/shared/c++/AdvancedCommerceItemDetailsIOS.hpp +86 -0
- package/nitrogen/generated/shared/c++/AdvancedCommerceItemIOS.hpp +99 -0
- package/nitrogen/generated/shared/c++/AdvancedCommerceRefundIOS.hpp +86 -0
- package/nitrogen/generated/shared/c++/HybridRnIapSpec.cpp +1 -0
- package/nitrogen/generated/shared/c++/HybridRnIapSpec.hpp +1 -0
- package/nitrogen/generated/shared/c++/PurchaseIOS.hpp +9 -2
- package/openiap-versions.json +3 -3
- package/package.json +1 -1
- package/plugin/build/withIAP.d.ts +1 -1
- package/plugin/src/withIAP.ts +1 -1
- package/src/hooks/useIAP.ts +162 -2
- package/src/hooks/useWebhookEvents.ts +180 -0
- package/src/index.ts +348 -130
- package/src/kit-api.ts +225 -0
- package/src/specs/RnIap.nitro.ts +8 -0
- package/src/types.ts +314 -74
- package/src/utils/error.ts +3 -0
- package/src/utils/errorMapping.ts +12 -0
- package/src/webhook-client.ts +312 -0
package/src/index.ts
CHANGED
|
@@ -124,6 +124,30 @@ export interface EventSubscription {
|
|
|
124
124
|
|
|
125
125
|
// Export hooks
|
|
126
126
|
export {useIAP} from './hooks/useIAP';
|
|
127
|
+
export {useWebhookEvents} from './hooks/useWebhookEvents';
|
|
128
|
+
export type {
|
|
129
|
+
UseWebhookEventsOptions,
|
|
130
|
+
UseWebhookEventsResult,
|
|
131
|
+
} from './hooks/useWebhookEvents';
|
|
132
|
+
export {
|
|
133
|
+
connectWebhookStream,
|
|
134
|
+
parseWebhookEventData,
|
|
135
|
+
} from './webhook-client';
|
|
136
|
+
export type {
|
|
137
|
+
WebhookEventPayload,
|
|
138
|
+
WebhookEventStream,
|
|
139
|
+
WebhookEventType as WebhookEventTypeName,
|
|
140
|
+
WebhookListener,
|
|
141
|
+
WebhookListenerError,
|
|
142
|
+
WebhookListenerOptions,
|
|
143
|
+
} from './webhook-client';
|
|
144
|
+
export {kitApi, KitApiError} from './kit-api';
|
|
145
|
+
export type {
|
|
146
|
+
KitApiOptions,
|
|
147
|
+
KitSubscription,
|
|
148
|
+
EntitlementsResponse,
|
|
149
|
+
StatusResponse,
|
|
150
|
+
} from './kit-api';
|
|
127
151
|
|
|
128
152
|
// Restore completed transactions (cross-platform)
|
|
129
153
|
// Development utilities removed - use type bridge functions directly if needed
|
|
@@ -662,20 +686,28 @@ export const subscriptionBillingIssueListener = (
|
|
|
662
686
|
// ------------------------------
|
|
663
687
|
|
|
664
688
|
/**
|
|
665
|
-
*
|
|
666
|
-
* @param params - Product request configuration
|
|
667
|
-
* @param params.skus - Array of product SKUs to fetch
|
|
668
|
-
* @param params.type - Optional filter: 'in-app' (default) for products, 'subs' for subscriptions, or 'all' for both.
|
|
669
|
-
* @returns Promise<Product[]> - Array of products from the store
|
|
689
|
+
* Retrieve products or subscriptions from the store by SKU.
|
|
670
690
|
*
|
|
671
|
-
* @
|
|
672
|
-
*
|
|
673
|
-
*
|
|
674
|
-
*
|
|
691
|
+
* @param request `ProductRequest` — `skus` (string[]) and optional `type`
|
|
692
|
+
* (`'in-app' | 'subs' | 'all'`, defaults to `'in-app'`).
|
|
693
|
+
* @returns Promise resolving to a `FetchProductsResult` union — `Product[]` for `'in-app'`,
|
|
694
|
+
* `ProductSubscription[]` for `'subs'`, a mixed array for `'all'`, or `null`
|
|
695
|
+
* (the schema retains the nullable branch for backwards compatibility).
|
|
696
|
+
* @throws When the store rejects the request (empty `skus`, not connected,
|
|
697
|
+
* network/store error). Unknown SKUs are simply omitted from the result, not thrown.
|
|
675
698
|
*
|
|
676
|
-
*
|
|
677
|
-
*
|
|
699
|
+
* @example
|
|
700
|
+
* ```ts
|
|
701
|
+
* const products = await fetchProducts({
|
|
702
|
+
* skus: ['com.app.coins_100', 'com.app.premium'],
|
|
703
|
+
* type: 'in-app',
|
|
704
|
+
* });
|
|
678
705
|
* ```
|
|
706
|
+
*
|
|
707
|
+
* @remarks This is a regular promise-based call. Don't confuse with `request*` APIs
|
|
708
|
+
* (`requestPurchase`), which are event-based.
|
|
709
|
+
*
|
|
710
|
+
* @see {@link https://www.openiap.dev/docs/apis/fetch-products}
|
|
679
711
|
*/
|
|
680
712
|
export const fetchProducts: QueryField<'fetchProducts'> = async (request) => {
|
|
681
713
|
const {skus, type} = request;
|
|
@@ -784,22 +816,40 @@ export const fetchProducts: QueryField<'fetchProducts'> = async (request) => {
|
|
|
784
816
|
return convertedProducts as FetchProductsResult;
|
|
785
817
|
} catch (error) {
|
|
786
818
|
RnIapConsole.error('[fetchProducts] Failed:', error);
|
|
787
|
-
|
|
819
|
+
const parsedError = parseErrorStringToJsonObj(error);
|
|
820
|
+
throw createPurchaseError({
|
|
821
|
+
code: parsedError.code,
|
|
822
|
+
message: parsedError.message,
|
|
823
|
+
responseCode: parsedError.responseCode,
|
|
824
|
+
debugMessage: parsedError.debugMessage,
|
|
825
|
+
productId: parsedError.productId,
|
|
826
|
+
productIds: parsedError.productIds,
|
|
827
|
+
productType: parsedError.productType,
|
|
828
|
+
isEmptyProductList: parsedError.isEmptyProductList,
|
|
829
|
+
platform: Platform.OS === 'ios' ? 'ios' : 'android',
|
|
830
|
+
});
|
|
788
831
|
}
|
|
789
832
|
};
|
|
790
833
|
|
|
791
834
|
/**
|
|
792
|
-
*
|
|
793
|
-
*
|
|
794
|
-
*
|
|
795
|
-
* @param
|
|
835
|
+
* List the user's unfinished purchases — non-consumables, active subscriptions, and any
|
|
836
|
+
* pending transactions not yet finished.
|
|
837
|
+
*
|
|
838
|
+
* @param options Optional `PurchaseOptions`.
|
|
839
|
+
* - iOS: `alsoPublishToEventListenerIOS`, `onlyIncludeActiveItemsIOS`.
|
|
840
|
+
* - Android: `includeSuspendedAndroid` (include subscriptions in a paused/grace state).
|
|
841
|
+
* @returns Promise resolving to an array of `Purchase` currently held by the store.
|
|
842
|
+
* @throws When the platform query fails.
|
|
796
843
|
*
|
|
797
844
|
* @example
|
|
798
|
-
* ```
|
|
799
|
-
* const purchases = await getAvailablePurchases(
|
|
800
|
-
*
|
|
801
|
-
* });
|
|
845
|
+
* ```ts
|
|
846
|
+
* const purchases = await getAvailablePurchases();
|
|
847
|
+
* for (const p of purchases) {
|
|
848
|
+
* if (await verifyOnServer(p)) await finishTransaction({ purchase: p, isConsumable: false });
|
|
849
|
+
* }
|
|
802
850
|
* ```
|
|
851
|
+
*
|
|
852
|
+
* @see {@link https://www.openiap.dev/docs/apis/get-available-purchases}
|
|
803
853
|
*/
|
|
804
854
|
export const getAvailablePurchases: QueryField<
|
|
805
855
|
'getAvailablePurchases'
|
|
@@ -866,6 +916,8 @@ export const getAvailablePurchases: QueryField<
|
|
|
866
916
|
* Request the promoted product from the App Store (iOS only)
|
|
867
917
|
* @returns Promise<Product | null> - The promoted product or null if none available
|
|
868
918
|
* @platform iOS
|
|
919
|
+
*
|
|
920
|
+
* @see {@link https://www.openiap.dev/docs/apis/ios/get-promoted-product-ios}
|
|
869
921
|
*/
|
|
870
922
|
export const getPromotedProductIOS: QueryField<
|
|
871
923
|
'getPromotedProductIOS'
|
|
@@ -898,6 +950,19 @@ export const getPromotedProductIOS: QueryField<
|
|
|
898
950
|
|
|
899
951
|
export const requestPromotedProductIOS = getPromotedProductIOS;
|
|
900
952
|
|
|
953
|
+
/**
|
|
954
|
+
* Get the storefront identifier for the user's App Store account (iOS only)
|
|
955
|
+
* @returns Promise<string> - The storefront identifier (e.g., 'USA' for United States)
|
|
956
|
+
* @platform iOS
|
|
957
|
+
*
|
|
958
|
+
* @example
|
|
959
|
+
* ```typescript
|
|
960
|
+
* const storefront = await getStorefrontIOS();
|
|
961
|
+
* console.log('User storefront:', storefront); // e.g., 'USA', 'GBR', 'KOR'
|
|
962
|
+
* ```
|
|
963
|
+
*
|
|
964
|
+
* @see {@link https://www.openiap.dev/docs/apis/ios/get-storefront-ios}
|
|
965
|
+
*/
|
|
901
966
|
export const getStorefrontIOS: QueryField<'getStorefrontIOS'> = async () => {
|
|
902
967
|
if (Platform.OS !== 'ios') {
|
|
903
968
|
throw new Error('getStorefrontIOS is only available on iOS');
|
|
@@ -912,6 +977,11 @@ export const getStorefrontIOS: QueryField<'getStorefrontIOS'> = async () => {
|
|
|
912
977
|
}
|
|
913
978
|
};
|
|
914
979
|
|
|
980
|
+
/**
|
|
981
|
+
* Return the user's storefront country code.
|
|
982
|
+
*
|
|
983
|
+
* @see {@link https://www.openiap.dev/docs/apis/get-storefront}
|
|
984
|
+
*/
|
|
915
985
|
export const getStorefront: QueryField<'getStorefront'> = async () => {
|
|
916
986
|
if (Platform.OS !== 'ios' && Platform.OS !== 'android') {
|
|
917
987
|
RnIapConsole.warn(
|
|
@@ -945,6 +1015,27 @@ export const getStorefront: QueryField<'getStorefront'> = async () => {
|
|
|
945
1015
|
}
|
|
946
1016
|
};
|
|
947
1017
|
|
|
1018
|
+
/**
|
|
1019
|
+
* iOS only - Gets the original app transaction ID if the app was purchased from the App Store
|
|
1020
|
+
* @platform iOS
|
|
1021
|
+
* @description
|
|
1022
|
+
* This function retrieves the original app transaction information if the app was purchased
|
|
1023
|
+
* from the App Store. Returns null if the app was not purchased (e.g., free app or TestFlight).
|
|
1024
|
+
*
|
|
1025
|
+
* @returns {Promise<string | null>} The original app transaction ID or null
|
|
1026
|
+
*
|
|
1027
|
+
* @example
|
|
1028
|
+
* ```typescript
|
|
1029
|
+
* const appTransaction = await getAppTransactionIOS();
|
|
1030
|
+
* if (appTransaction) {
|
|
1031
|
+
* console.log('App was purchased, transaction ID:', appTransaction);
|
|
1032
|
+
* } else {
|
|
1033
|
+
* console.log('App was not purchased from App Store');
|
|
1034
|
+
* }
|
|
1035
|
+
* ```
|
|
1036
|
+
*
|
|
1037
|
+
* @see {@link https://www.openiap.dev/docs/apis/ios/get-app-transaction-ios}
|
|
1038
|
+
*/
|
|
948
1039
|
export const getAppTransactionIOS: QueryField<
|
|
949
1040
|
'getAppTransactionIOS'
|
|
950
1041
|
> = async () => {
|
|
@@ -977,6 +1068,15 @@ export const getAppTransactionIOS: QueryField<
|
|
|
977
1068
|
}
|
|
978
1069
|
};
|
|
979
1070
|
|
|
1071
|
+
/**
|
|
1072
|
+
* Get subscription status for a product (iOS only)
|
|
1073
|
+
* @param sku - The product SKU
|
|
1074
|
+
* @returns Promise<SubscriptionStatusIOS[]> - Array of subscription status objects
|
|
1075
|
+
* @throws Error when called on non-iOS platforms or when IAP is not initialized
|
|
1076
|
+
* @platform iOS
|
|
1077
|
+
*
|
|
1078
|
+
* @see {@link https://www.openiap.dev/docs/apis/ios/subscription-status-ios}
|
|
1079
|
+
*/
|
|
980
1080
|
export const subscriptionStatusIOS: QueryField<
|
|
981
1081
|
'subscriptionStatusIOS'
|
|
982
1082
|
> = async (sku) => {
|
|
@@ -1002,6 +1102,14 @@ export const subscriptionStatusIOS: QueryField<
|
|
|
1002
1102
|
}
|
|
1003
1103
|
};
|
|
1004
1104
|
|
|
1105
|
+
/**
|
|
1106
|
+
* Get current entitlement for a product (iOS only)
|
|
1107
|
+
* @param sku - The product SKU
|
|
1108
|
+
* @returns Promise<Purchase | null> - Current entitlement or null
|
|
1109
|
+
* @platform iOS
|
|
1110
|
+
*
|
|
1111
|
+
* @see {@link https://www.openiap.dev/docs/apis/ios/current-entitlement-ios}
|
|
1112
|
+
*/
|
|
1005
1113
|
export const currentEntitlementIOS: QueryField<
|
|
1006
1114
|
'currentEntitlementIOS'
|
|
1007
1115
|
> = async (sku) => {
|
|
@@ -1028,6 +1136,14 @@ export const currentEntitlementIOS: QueryField<
|
|
|
1028
1136
|
}
|
|
1029
1137
|
};
|
|
1030
1138
|
|
|
1139
|
+
/**
|
|
1140
|
+
* Get latest transaction for a product (iOS only)
|
|
1141
|
+
* @param sku - The product SKU
|
|
1142
|
+
* @returns Promise<Purchase | null> - Latest transaction or null
|
|
1143
|
+
* @platform iOS
|
|
1144
|
+
*
|
|
1145
|
+
* @see {@link https://www.openiap.dev/docs/apis/ios/latest-transaction-ios}
|
|
1146
|
+
*/
|
|
1031
1147
|
export const latestTransactionIOS: QueryField<'latestTransactionIOS'> = async (
|
|
1032
1148
|
sku,
|
|
1033
1149
|
) => {
|
|
@@ -1054,6 +1170,13 @@ export const latestTransactionIOS: QueryField<'latestTransactionIOS'> = async (
|
|
|
1054
1170
|
}
|
|
1055
1171
|
};
|
|
1056
1172
|
|
|
1173
|
+
/**
|
|
1174
|
+
* Get pending transactions (iOS only)
|
|
1175
|
+
* @returns Promise<Purchase[]> - Array of pending transactions
|
|
1176
|
+
* @platform iOS
|
|
1177
|
+
*
|
|
1178
|
+
* @see {@link https://www.openiap.dev/docs/apis/ios/get-pending-transactions-ios}
|
|
1179
|
+
*/
|
|
1057
1180
|
export const getPendingTransactionsIOS: QueryField<
|
|
1058
1181
|
'getPendingTransactionsIOS'
|
|
1059
1182
|
> = async () => {
|
|
@@ -1080,6 +1203,44 @@ export const getPendingTransactionsIOS: QueryField<
|
|
|
1080
1203
|
}
|
|
1081
1204
|
};
|
|
1082
1205
|
|
|
1206
|
+
/**
|
|
1207
|
+
* List every StoreKit transaction (finished + unfinished) for the current user.
|
|
1208
|
+
*
|
|
1209
|
+
* @see {@link https://www.openiap.dev/docs/apis/ios/get-all-transactions-ios}
|
|
1210
|
+
*/
|
|
1211
|
+
export const getAllTransactionsIOS: QueryField<
|
|
1212
|
+
'getAllTransactionsIOS'
|
|
1213
|
+
> = async () => {
|
|
1214
|
+
if (Platform.OS !== 'ios') {
|
|
1215
|
+
return [];
|
|
1216
|
+
}
|
|
1217
|
+
|
|
1218
|
+
try {
|
|
1219
|
+
const nitroPurchases = await IAP.instance.getAllTransactionsIOS();
|
|
1220
|
+
return nitroPurchases
|
|
1221
|
+
.map(convertNitroPurchaseToPurchase)
|
|
1222
|
+
.filter(
|
|
1223
|
+
(purchase): purchase is PurchaseIOS => purchase.platform === 'ios',
|
|
1224
|
+
);
|
|
1225
|
+
} catch (error) {
|
|
1226
|
+
RnIapConsole.error('[getAllTransactionsIOS] Failed:', error);
|
|
1227
|
+
const parsedError = parseErrorStringToJsonObj(error);
|
|
1228
|
+
throw createPurchaseError({
|
|
1229
|
+
code: parsedError.code,
|
|
1230
|
+
message: parsedError.message,
|
|
1231
|
+
responseCode: parsedError.responseCode,
|
|
1232
|
+
debugMessage: parsedError.debugMessage,
|
|
1233
|
+
});
|
|
1234
|
+
}
|
|
1235
|
+
};
|
|
1236
|
+
|
|
1237
|
+
/**
|
|
1238
|
+
* Show manage subscriptions screen (iOS only)
|
|
1239
|
+
* @returns Promise<Purchase[]> - Subscriptions where auto-renewal status changed
|
|
1240
|
+
* @platform iOS
|
|
1241
|
+
*
|
|
1242
|
+
* @see {@link https://www.openiap.dev/docs/apis/ios/show-manage-subscriptions-ios}
|
|
1243
|
+
*/
|
|
1083
1244
|
export const showManageSubscriptionsIOS: MutationField<
|
|
1084
1245
|
'showManageSubscriptionsIOS'
|
|
1085
1246
|
> = async () => {
|
|
@@ -1106,6 +1267,14 @@ export const showManageSubscriptionsIOS: MutationField<
|
|
|
1106
1267
|
}
|
|
1107
1268
|
};
|
|
1108
1269
|
|
|
1270
|
+
/**
|
|
1271
|
+
* Check if user is eligible for intro offer (iOS only)
|
|
1272
|
+
* @param groupID - The subscription group ID
|
|
1273
|
+
* @returns Promise<boolean> - Eligibility status
|
|
1274
|
+
* @platform iOS
|
|
1275
|
+
*
|
|
1276
|
+
* @see {@link https://www.openiap.dev/docs/apis/ios/is-eligible-for-intro-offer-ios}
|
|
1277
|
+
*/
|
|
1109
1278
|
export const isEligibleForIntroOfferIOS: QueryField<
|
|
1110
1279
|
'isEligibleForIntroOfferIOS'
|
|
1111
1280
|
> = async (groupID) => {
|
|
@@ -1127,6 +1296,13 @@ export const isEligibleForIntroOfferIOS: QueryField<
|
|
|
1127
1296
|
}
|
|
1128
1297
|
};
|
|
1129
1298
|
|
|
1299
|
+
/**
|
|
1300
|
+
* Get receipt data (iOS only)
|
|
1301
|
+
* @returns Promise<string> - Base64 encoded receipt data
|
|
1302
|
+
* @platform iOS
|
|
1303
|
+
*
|
|
1304
|
+
* @see {@link https://www.openiap.dev/docs/apis/ios/get-receipt-data-ios}
|
|
1305
|
+
*/
|
|
1130
1306
|
export const getReceiptDataIOS: QueryField<'getReceiptDataIOS'> = async () => {
|
|
1131
1307
|
if (Platform.OS !== 'ios') {
|
|
1132
1308
|
throw new Error('getReceiptDataIOS is only available on iOS');
|
|
@@ -1208,6 +1384,14 @@ export const requestReceiptRefreshIOS = async (): Promise<string> => {
|
|
|
1208
1384
|
}
|
|
1209
1385
|
};
|
|
1210
1386
|
|
|
1387
|
+
/**
|
|
1388
|
+
* Check if transaction is verified (iOS only)
|
|
1389
|
+
* @param sku - The product SKU
|
|
1390
|
+
* @returns Promise<boolean> - Verification status
|
|
1391
|
+
* @platform iOS
|
|
1392
|
+
*
|
|
1393
|
+
* @see {@link https://www.openiap.dev/docs/apis/ios/is-transaction-verified-ios}
|
|
1394
|
+
*/
|
|
1211
1395
|
export const isTransactionVerifiedIOS: QueryField<
|
|
1212
1396
|
'isTransactionVerifiedIOS'
|
|
1213
1397
|
> = async (sku) => {
|
|
@@ -1229,6 +1413,14 @@ export const isTransactionVerifiedIOS: QueryField<
|
|
|
1229
1413
|
}
|
|
1230
1414
|
};
|
|
1231
1415
|
|
|
1416
|
+
/**
|
|
1417
|
+
* Get transaction JWS representation (iOS only)
|
|
1418
|
+
* @param sku - The product SKU
|
|
1419
|
+
* @returns Promise<string | null> - JWS representation or null
|
|
1420
|
+
* @platform iOS
|
|
1421
|
+
*
|
|
1422
|
+
* @see {@link https://www.openiap.dev/docs/apis/ios/get-transaction-jws-ios}
|
|
1423
|
+
*/
|
|
1232
1424
|
export const getTransactionJwsIOS: QueryField<'getTransactionJwsIOS'> = async (
|
|
1233
1425
|
sku,
|
|
1234
1426
|
) => {
|
|
@@ -1255,25 +1447,23 @@ export const getTransactionJwsIOS: QueryField<'getTransactionJwsIOS'> = async (
|
|
|
1255
1447
|
// ------------------------------
|
|
1256
1448
|
|
|
1257
1449
|
/**
|
|
1258
|
-
* Initialize connection
|
|
1259
|
-
*
|
|
1260
|
-
* @param config
|
|
1450
|
+
* Initialize the store connection. Must be called before any other IAP API.
|
|
1451
|
+
*
|
|
1452
|
+
* @param config Optional connection config. Use `enableBillingProgramAndroid` (Android,
|
|
1453
|
+
* Play Billing 8.2.0+) to opt into External Payments etc. iOS ignores Android-specific fields.
|
|
1454
|
+
* @returns Promise resolving to `true` when the platform billing client is connected.
|
|
1455
|
+
* @throws When the platform billing client fails to initialize.
|
|
1261
1456
|
*
|
|
1262
1457
|
* @example
|
|
1263
|
-
* ```
|
|
1264
|
-
* // Standard billing (default)
|
|
1458
|
+
* ```ts
|
|
1265
1459
|
* await initConnection();
|
|
1460
|
+
* await initConnection({ enableBillingProgramAndroid: 'external-offer' });
|
|
1461
|
+
* ```
|
|
1266
1462
|
*
|
|
1267
|
-
*
|
|
1268
|
-
*
|
|
1269
|
-
* alternativeBillingModeAndroid: 'user-choice'
|
|
1270
|
-
* });
|
|
1463
|
+
* @remarks When using `useIAP()`, connection is auto-managed on mount/unmount —
|
|
1464
|
+
* pass options to the hook instead of calling this directly.
|
|
1271
1465
|
*
|
|
1272
|
-
*
|
|
1273
|
-
* await initConnection({
|
|
1274
|
-
* alternativeBillingModeAndroid: 'alternative-only'
|
|
1275
|
-
* });
|
|
1276
|
-
* ```
|
|
1466
|
+
* @see {@link https://www.openiap.dev/docs/apis/init-connection}
|
|
1277
1467
|
*/
|
|
1278
1468
|
export const initConnection: MutationField<'initConnection'> = async (
|
|
1279
1469
|
config,
|
|
@@ -1295,7 +1485,9 @@ export const initConnection: MutationField<'initConnection'> = async (
|
|
|
1295
1485
|
};
|
|
1296
1486
|
|
|
1297
1487
|
/**
|
|
1298
|
-
*
|
|
1488
|
+
* Close the store connection and release resources.
|
|
1489
|
+
*
|
|
1490
|
+
* @see {@link https://www.openiap.dev/docs/apis/end-connection}
|
|
1299
1491
|
*/
|
|
1300
1492
|
export const endConnection: MutationField<'endConnection'> = async () => {
|
|
1301
1493
|
try {
|
|
@@ -1315,6 +1507,11 @@ export const endConnection: MutationField<'endConnection'> = async () => {
|
|
|
1315
1507
|
}
|
|
1316
1508
|
};
|
|
1317
1509
|
|
|
1510
|
+
/**
|
|
1511
|
+
* Restore non-consumable and active subscription purchases.
|
|
1512
|
+
*
|
|
1513
|
+
* @see {@link https://www.openiap.dev/docs/apis/restore-purchases}
|
|
1514
|
+
*/
|
|
1318
1515
|
export const restorePurchases: MutationField<'restorePurchases'> = async () => {
|
|
1319
1516
|
try {
|
|
1320
1517
|
if (Platform.OS === 'ios') {
|
|
@@ -1338,9 +1535,30 @@ export const restorePurchases: MutationField<'restorePurchases'> = async () => {
|
|
|
1338
1535
|
};
|
|
1339
1536
|
|
|
1340
1537
|
/**
|
|
1341
|
-
*
|
|
1342
|
-
*
|
|
1343
|
-
*
|
|
1538
|
+
* Initiate a purchase or subscription flow. The result is delivered through
|
|
1539
|
+
* `purchaseUpdatedListener` — NOT the return value.
|
|
1540
|
+
*
|
|
1541
|
+
* @param request `RequestPurchaseProps`, discriminated by `type`:
|
|
1542
|
+
* - `type: 'in-app'` — pass `request.apple.sku` (iOS) and/or `request.google.skus` (Android).
|
|
1543
|
+
* - `type: 'subs'` — same shape, plus `request.google.subscriptionOffers: [{ sku, offerToken }]`.
|
|
1544
|
+
* @returns The dispatched purchase payload. **Do not rely on it** for the actual outcome.
|
|
1545
|
+
* @throws Synchronous rejection from the store (e.g. `E_NOT_PREPARED`, validation failure).
|
|
1546
|
+
*
|
|
1547
|
+
* @example
|
|
1548
|
+
* ```ts
|
|
1549
|
+
* await requestPurchase({
|
|
1550
|
+
* request: {
|
|
1551
|
+
* apple: { sku: 'com.app.premium' },
|
|
1552
|
+
* google: { skus: ['com.app.premium'] },
|
|
1553
|
+
* },
|
|
1554
|
+
* type: 'in-app',
|
|
1555
|
+
* });
|
|
1556
|
+
* ```
|
|
1557
|
+
*
|
|
1558
|
+
* @remarks Event-based. Listen for the result via {@link purchaseUpdatedListener} /
|
|
1559
|
+
* {@link purchaseErrorListener}, or use `useIAP({ onPurchaseSuccess, onPurchaseError })`.
|
|
1560
|
+
*
|
|
1561
|
+
* @see {@link https://www.openiap.dev/docs/apis/request-purchase}
|
|
1344
1562
|
*/
|
|
1345
1563
|
export const requestPurchase: MutationField<'requestPurchase'> = async (
|
|
1346
1564
|
request,
|
|
@@ -1487,19 +1705,28 @@ export const requestPurchase: MutationField<'requestPurchase'> = async (
|
|
|
1487
1705
|
};
|
|
1488
1706
|
|
|
1489
1707
|
/**
|
|
1490
|
-
*
|
|
1491
|
-
*
|
|
1492
|
-
*
|
|
1493
|
-
* @param
|
|
1494
|
-
* @
|
|
1708
|
+
* Complete a purchase transaction. Call after server-side verification to remove it
|
|
1709
|
+
* from the queue.
|
|
1710
|
+
*
|
|
1711
|
+
* @param args.purchase The `Purchase` to finalize.
|
|
1712
|
+
* @param args.isConsumable `true` for consumables (consumes the token so the SKU can be
|
|
1713
|
+
* re-bought, e.g. coins); `false` (default) for non-consumables and subscriptions.
|
|
1714
|
+
* @returns Promise that resolves once the platform finalizes the transaction.
|
|
1715
|
+
* @throws When the platform finalize call fails.
|
|
1495
1716
|
*
|
|
1496
1717
|
* @example
|
|
1497
|
-
* ```
|
|
1498
|
-
*
|
|
1499
|
-
* purchase
|
|
1500
|
-
*
|
|
1718
|
+
* ```ts
|
|
1719
|
+
* purchaseUpdatedListener(async (purchase) => {
|
|
1720
|
+
* if (await verifyOnServer(purchase)) {
|
|
1721
|
+
* await finishTransaction({ purchase, isConsumable: false });
|
|
1722
|
+
* }
|
|
1501
1723
|
* });
|
|
1502
1724
|
* ```
|
|
1725
|
+
*
|
|
1726
|
+
* @remarks **Critical:** Android purchases must be finalized within 3 days or Google
|
|
1727
|
+
* auto-refunds. iOS unfinished transactions replay on every app launch.
|
|
1728
|
+
*
|
|
1729
|
+
* @see {@link https://www.openiap.dev/docs/apis/finish-transaction}
|
|
1503
1730
|
*/
|
|
1504
1731
|
export const finishTransaction: MutationField<'finishTransaction'> = async (
|
|
1505
1732
|
args,
|
|
@@ -1567,6 +1794,8 @@ export const finishTransaction: MutationField<'finishTransaction'> = async (
|
|
|
1567
1794
|
* ```typescript
|
|
1568
1795
|
* await acknowledgePurchaseAndroid('purchase_token_here');
|
|
1569
1796
|
* ```
|
|
1797
|
+
*
|
|
1798
|
+
* @see {@link https://www.openiap.dev/docs/apis/android/acknowledge-purchase-android}
|
|
1570
1799
|
*/
|
|
1571
1800
|
export const acknowledgePurchaseAndroid: MutationField<
|
|
1572
1801
|
'acknowledgePurchaseAndroid'
|
|
@@ -1606,6 +1835,8 @@ export const acknowledgePurchaseAndroid: MutationField<
|
|
|
1606
1835
|
* ```typescript
|
|
1607
1836
|
* await consumePurchaseAndroid('purchase_token_here');
|
|
1608
1837
|
* ```
|
|
1838
|
+
*
|
|
1839
|
+
* @see {@link https://www.openiap.dev/docs/apis/android/consume-purchase-android}
|
|
1609
1840
|
*/
|
|
1610
1841
|
export const consumePurchaseAndroid: MutationField<
|
|
1611
1842
|
'consumePurchaseAndroid'
|
|
@@ -1661,6 +1892,8 @@ export const consumePurchaseAndroid: MutationField<
|
|
|
1661
1892
|
* }
|
|
1662
1893
|
* });
|
|
1663
1894
|
* ```
|
|
1895
|
+
*
|
|
1896
|
+
* @see {@link https://www.openiap.dev/docs/apis/validate-receipt}
|
|
1664
1897
|
*/
|
|
1665
1898
|
export const validateReceipt: MutationField<'validateReceipt'> = async (
|
|
1666
1899
|
options,
|
|
@@ -1790,9 +2023,30 @@ export const validateReceipt: MutationField<'validateReceipt'> = async (
|
|
|
1790
2023
|
*
|
|
1791
2024
|
* @param options - Receipt validation options containing the SKU
|
|
1792
2025
|
* @returns Promise resolving to receipt validation result
|
|
2026
|
+
*
|
|
2027
|
+
* @see {@link https://www.openiap.dev/docs/features/validation#verify-purchase}
|
|
1793
2028
|
*/
|
|
1794
2029
|
export const verifyPurchase: MutationField<'verifyPurchase'> = validateReceipt;
|
|
1795
2030
|
|
|
2031
|
+
/**
|
|
2032
|
+
* iOS-only receipt validation alias.
|
|
2033
|
+
*
|
|
2034
|
+
* @deprecated Use `verifyPurchase` (or `validateReceipt`) instead. Kept so
|
|
2035
|
+
* consumers who imported `validateReceiptIOS` — which is still declared on the
|
|
2036
|
+
* OpenIAP Query interface — keep working. Throws on non-iOS platforms.
|
|
2037
|
+
*
|
|
2038
|
+
* @see {@link https://www.openiap.dev/docs/apis/ios/validate-receipt-ios}
|
|
2039
|
+
*/
|
|
2040
|
+
export const validateReceiptIOS: QueryField<'validateReceiptIOS'> = async (
|
|
2041
|
+
options,
|
|
2042
|
+
) => {
|
|
2043
|
+
if (Platform.OS !== 'ios') {
|
|
2044
|
+
throw new Error('validateReceiptIOS is only available on iOS');
|
|
2045
|
+
}
|
|
2046
|
+
const result = await validateReceipt(options);
|
|
2047
|
+
return result as VerifyPurchaseResultIOS;
|
|
2048
|
+
};
|
|
2049
|
+
|
|
1796
2050
|
/**
|
|
1797
2051
|
* Verify purchase with a specific provider (e.g., IAPKit)
|
|
1798
2052
|
*
|
|
@@ -1813,6 +2067,8 @@ export const verifyPurchase: MutationField<'verifyPurchase'> = validateReceipt;
|
|
|
1813
2067
|
* },
|
|
1814
2068
|
* });
|
|
1815
2069
|
* ```
|
|
2070
|
+
*
|
|
2071
|
+
* @see {@link https://www.openiap.dev/docs/features/validation#verify-purchase-with-provider}
|
|
1816
2072
|
*/
|
|
1817
2073
|
export const verifyPurchaseWithProvider: MutationField<
|
|
1818
2074
|
'verifyPurchaseWithProvider'
|
|
@@ -1856,6 +2112,8 @@ export const verifyPurchaseWithProvider: MutationField<
|
|
|
1856
2112
|
* Sync iOS purchases with App Store (iOS only)
|
|
1857
2113
|
* @returns Promise<boolean>
|
|
1858
2114
|
* @platform iOS
|
|
2115
|
+
*
|
|
2116
|
+
* @see {@link https://www.openiap.dev/docs/apis/ios/sync-ios}
|
|
1859
2117
|
*/
|
|
1860
2118
|
export const syncIOS: MutationField<'syncIOS'> = async () => {
|
|
1861
2119
|
if (Platform.OS !== 'ios') {
|
|
@@ -1881,6 +2139,8 @@ export const syncIOS: MutationField<'syncIOS'> = async () => {
|
|
|
1881
2139
|
* Present the code redemption sheet for offer codes (iOS only)
|
|
1882
2140
|
* @returns Promise<boolean> - Indicates whether the redemption sheet was presented
|
|
1883
2141
|
* @platform iOS
|
|
2142
|
+
*
|
|
2143
|
+
* @see {@link https://www.openiap.dev/docs/apis/ios/present-code-redemption-sheet-ios}
|
|
1884
2144
|
*/
|
|
1885
2145
|
export const presentCodeRedemptionSheetIOS: MutationField<
|
|
1886
2146
|
'presentCodeRedemptionSheetIOS'
|
|
@@ -1923,6 +2183,8 @@ export const presentCodeRedemptionSheetIOS: MutationField<
|
|
|
1923
2183
|
*
|
|
1924
2184
|
* @returns Promise<boolean> - true when the request triggers successfully
|
|
1925
2185
|
* @platform iOS
|
|
2186
|
+
*
|
|
2187
|
+
* @see {@link https://www.openiap.dev/docs/apis/ios/request-purchase-on-promoted-product-ios}
|
|
1926
2188
|
*/
|
|
1927
2189
|
export const requestPurchaseOnPromotedProductIOS =
|
|
1928
2190
|
async (): Promise<boolean> => {
|
|
@@ -1965,6 +2227,8 @@ export const requestPurchaseOnPromotedProductIOS =
|
|
|
1965
2227
|
* Clear unfinished transactions on iOS
|
|
1966
2228
|
* @returns Promise<boolean>
|
|
1967
2229
|
* @platform iOS
|
|
2230
|
+
*
|
|
2231
|
+
* @see {@link https://www.openiap.dev/docs/apis/ios/clear-transaction-ios}
|
|
1968
2232
|
*/
|
|
1969
2233
|
export const clearTransactionIOS: MutationField<
|
|
1970
2234
|
'clearTransactionIOS'
|
|
@@ -1993,6 +2257,8 @@ export const clearTransactionIOS: MutationField<
|
|
|
1993
2257
|
* @param sku - The product SKU to refund
|
|
1994
2258
|
* @returns Promise<string | null> - The refund status or null if not available
|
|
1995
2259
|
* @platform iOS
|
|
2260
|
+
*
|
|
2261
|
+
* @see {@link https://www.openiap.dev/docs/apis/ios/begin-refund-request-ios}
|
|
1996
2262
|
*/
|
|
1997
2263
|
export const beginRefundRequestIOS: MutationField<
|
|
1998
2264
|
'beginRefundRequestIOS'
|
|
@@ -2016,72 +2282,11 @@ export const beginRefundRequestIOS: MutationField<
|
|
|
2016
2282
|
}
|
|
2017
2283
|
};
|
|
2018
2284
|
|
|
2019
|
-
/**
|
|
2020
|
-
* Get subscription status for a product (iOS only)
|
|
2021
|
-
* @param sku - The product SKU
|
|
2022
|
-
* @returns Promise<SubscriptionStatusIOS[]> - Array of subscription status objects
|
|
2023
|
-
* @throws Error when called on non-iOS platforms or when IAP is not initialized
|
|
2024
|
-
* @platform iOS
|
|
2025
|
-
*/
|
|
2026
|
-
/**
|
|
2027
|
-
* Get current entitlement for a product (iOS only)
|
|
2028
|
-
* @param sku - The product SKU
|
|
2029
|
-
* @returns Promise<Purchase | null> - Current entitlement or null
|
|
2030
|
-
* @platform iOS
|
|
2031
|
-
*/
|
|
2032
|
-
/**
|
|
2033
|
-
* Get latest transaction for a product (iOS only)
|
|
2034
|
-
* @param sku - The product SKU
|
|
2035
|
-
* @returns Promise<Purchase | null> - Latest transaction or null
|
|
2036
|
-
* @platform iOS
|
|
2037
|
-
*/
|
|
2038
|
-
/**
|
|
2039
|
-
* Get pending transactions (iOS only)
|
|
2040
|
-
* @returns Promise<Purchase[]> - Array of pending transactions
|
|
2041
|
-
* @platform iOS
|
|
2042
|
-
*/
|
|
2043
|
-
/**
|
|
2044
|
-
* Show manage subscriptions screen (iOS only)
|
|
2045
|
-
* @returns Promise<Purchase[]> - Subscriptions where auto-renewal status changed
|
|
2046
|
-
* @platform iOS
|
|
2047
|
-
*/
|
|
2048
|
-
/**
|
|
2049
|
-
* Check if user is eligible for intro offer (iOS only)
|
|
2050
|
-
* @param groupID - The subscription group ID
|
|
2051
|
-
* @returns Promise<boolean> - Eligibility status
|
|
2052
|
-
* @platform iOS
|
|
2053
|
-
*/
|
|
2054
|
-
/**
|
|
2055
|
-
* Get receipt data (iOS only)
|
|
2056
|
-
* @returns Promise<string> - Base64 encoded receipt data
|
|
2057
|
-
* @platform iOS
|
|
2058
|
-
*/
|
|
2059
|
-
/**
|
|
2060
|
-
* Check if transaction is verified (iOS only)
|
|
2061
|
-
* @param sku - The product SKU
|
|
2062
|
-
* @returns Promise<boolean> - Verification status
|
|
2063
|
-
* @platform iOS
|
|
2064
|
-
*/
|
|
2065
|
-
/**
|
|
2066
|
-
* Get transaction JWS representation (iOS only)
|
|
2067
|
-
* @param sku - The product SKU
|
|
2068
|
-
* @returns Promise<string | null> - JWS representation or null
|
|
2069
|
-
* @platform iOS
|
|
2070
|
-
*/
|
|
2071
|
-
/**
|
|
2072
|
-
* Get the storefront identifier for the user's App Store account (iOS only)
|
|
2073
|
-
* @returns Promise<string> - The storefront identifier (e.g., 'USA' for United States)
|
|
2074
|
-
* @platform iOS
|
|
2075
|
-
*
|
|
2076
|
-
* @example
|
|
2077
|
-
* ```typescript
|
|
2078
|
-
* const storefront = await getStorefrontIOS();
|
|
2079
|
-
* console.log('User storefront:', storefront); // e.g., 'USA', 'GBR', 'KOR'
|
|
2080
|
-
* ```
|
|
2081
|
-
*/
|
|
2082
2285
|
/**
|
|
2083
2286
|
* Deeplinks to native interface that allows users to manage their subscriptions
|
|
2084
2287
|
* Cross-platform alias aligning with expo-iap
|
|
2288
|
+
*
|
|
2289
|
+
* @see {@link https://www.openiap.dev/docs/apis/deep-link-to-subscriptions}
|
|
2085
2290
|
*/
|
|
2086
2291
|
export const deepLinkToSubscriptions: MutationField<
|
|
2087
2292
|
'deepLinkToSubscriptions'
|
|
@@ -2131,25 +2336,6 @@ export const deepLinkToSubscriptionsIOS = async (): Promise<boolean> => {
|
|
|
2131
2336
|
}
|
|
2132
2337
|
};
|
|
2133
2338
|
|
|
2134
|
-
/**
|
|
2135
|
-
* iOS only - Gets the original app transaction ID if the app was purchased from the App Store
|
|
2136
|
-
* @platform iOS
|
|
2137
|
-
* @description
|
|
2138
|
-
* This function retrieves the original app transaction information if the app was purchased
|
|
2139
|
-
* from the App Store. Returns null if the app was not purchased (e.g., free app or TestFlight).
|
|
2140
|
-
*
|
|
2141
|
-
* @returns {Promise<string | null>} The original app transaction ID or null
|
|
2142
|
-
*
|
|
2143
|
-
* @example
|
|
2144
|
-
* ```typescript
|
|
2145
|
-
* const appTransaction = await getAppTransactionIOS();
|
|
2146
|
-
* if (appTransaction) {
|
|
2147
|
-
* console.log('App was purchased, transaction ID:', appTransaction);
|
|
2148
|
-
* } else {
|
|
2149
|
-
* console.log('App was not purchased from App Store');
|
|
2150
|
-
* }
|
|
2151
|
-
* ```
|
|
2152
|
-
*/
|
|
2153
2339
|
/**
|
|
2154
2340
|
* Get all active subscriptions with detailed information (OpenIAP compliant)
|
|
2155
2341
|
* Returns an array of active subscriptions. If subscriptionIds is not provided,
|
|
@@ -2162,6 +2348,8 @@ export const deepLinkToSubscriptionsIOS = async (): Promise<boolean> => {
|
|
|
2162
2348
|
*
|
|
2163
2349
|
* @param subscriptionIds - Optional array of subscription IDs to filter by
|
|
2164
2350
|
* @returns Promise<ActiveSubscription[]> - Array of active subscriptions
|
|
2351
|
+
*
|
|
2352
|
+
* @see {@link https://www.openiap.dev/docs/apis/get-active-subscriptions}
|
|
2165
2353
|
*/
|
|
2166
2354
|
export const getActiveSubscriptions: QueryField<
|
|
2167
2355
|
'getActiveSubscriptions'
|
|
@@ -2321,6 +2509,8 @@ export const getActiveSubscriptions_OLD: QueryField<
|
|
|
2321
2509
|
*
|
|
2322
2510
|
* @param subscriptionIds - Optional array of subscription IDs to check
|
|
2323
2511
|
* @returns Promise<boolean> - True if there are active subscriptions
|
|
2512
|
+
*
|
|
2513
|
+
* @see {@link https://www.openiap.dev/docs/apis/has-active-subscriptions}
|
|
2324
2514
|
*/
|
|
2325
2515
|
export const hasActiveSubscriptions: QueryField<
|
|
2326
2516
|
'hasActiveSubscriptions'
|
|
@@ -2448,6 +2638,8 @@ const normalizeProductQueryType = (
|
|
|
2448
2638
|
* // Proceed with alternative billing flow
|
|
2449
2639
|
* }
|
|
2450
2640
|
* ```
|
|
2641
|
+
*
|
|
2642
|
+
* @see {@link https://www.openiap.dev/docs/apis/android/check-alternative-billing-availability-android}
|
|
2451
2643
|
*/
|
|
2452
2644
|
export const checkAlternativeBillingAvailabilityAndroid: MutationField<
|
|
2453
2645
|
'checkAlternativeBillingAvailabilityAndroid'
|
|
@@ -2488,6 +2680,8 @@ export const checkAlternativeBillingAvailabilityAndroid: MutationField<
|
|
|
2488
2680
|
* }
|
|
2489
2681
|
* }
|
|
2490
2682
|
* ```
|
|
2683
|
+
*
|
|
2684
|
+
* @see {@link https://www.openiap.dev/docs/apis/android/show-alternative-billing-dialog-android}
|
|
2491
2685
|
*/
|
|
2492
2686
|
export const showAlternativeBillingDialogAndroid: MutationField<
|
|
2493
2687
|
'showAlternativeBillingDialogAndroid'
|
|
@@ -2525,6 +2719,8 @@ export const showAlternativeBillingDialogAndroid: MutationField<
|
|
|
2525
2719
|
* });
|
|
2526
2720
|
* }
|
|
2527
2721
|
* ```
|
|
2722
|
+
*
|
|
2723
|
+
* @see {@link https://www.openiap.dev/docs/apis/android/create-alternative-billing-token-android}
|
|
2528
2724
|
*/
|
|
2529
2725
|
export const createAlternativeBillingTokenAndroid: MutationField<
|
|
2530
2726
|
'createAlternativeBillingTokenAndroid'
|
|
@@ -2620,6 +2816,8 @@ export const enableBillingProgramAndroid = (
|
|
|
2620
2816
|
* // External offers are available for this user
|
|
2621
2817
|
* }
|
|
2622
2818
|
* ```
|
|
2819
|
+
*
|
|
2820
|
+
* @see {@link https://www.openiap.dev/docs/apis/android/is-billing-program-available-android}
|
|
2623
2821
|
*/
|
|
2624
2822
|
export const isBillingProgramAvailableAndroid: MutationField<
|
|
2625
2823
|
'isBillingProgramAvailableAndroid'
|
|
@@ -2659,6 +2857,8 @@ export const isBillingProgramAvailableAndroid: MutationField<
|
|
|
2659
2857
|
* body: JSON.stringify({ token: details.externalTransactionToken })
|
|
2660
2858
|
* });
|
|
2661
2859
|
* ```
|
|
2860
|
+
*
|
|
2861
|
+
* @see {@link https://www.openiap.dev/docs/apis/android/create-billing-program-reporting-details-android}
|
|
2662
2862
|
*/
|
|
2663
2863
|
export const createBillingProgramReportingDetailsAndroid: MutationField<
|
|
2664
2864
|
'createBillingProgramReportingDetailsAndroid'
|
|
@@ -2704,6 +2904,8 @@ export const createBillingProgramReportingDetailsAndroid: MutationField<
|
|
|
2704
2904
|
* console.log('User accepted external link');
|
|
2705
2905
|
* }
|
|
2706
2906
|
* ```
|
|
2907
|
+
*
|
|
2908
|
+
* @see {@link https://www.openiap.dev/docs/apis/android/launch-external-link-android}
|
|
2707
2909
|
*/
|
|
2708
2910
|
export const launchExternalLinkAndroid: MutationField<
|
|
2709
2911
|
'launchExternalLinkAndroid'
|
|
@@ -2729,7 +2931,11 @@ export const launchExternalLinkAndroid: MutationField<
|
|
|
2729
2931
|
// ------------------------------
|
|
2730
2932
|
|
|
2731
2933
|
/**
|
|
2732
|
-
* Check if the device can present an external purchase notice sheet (iOS
|
|
2934
|
+
* Check if the device can present an external purchase notice sheet (iOS 17.4+).
|
|
2935
|
+
*
|
|
2936
|
+
* Wraps `ExternalPurchase.canPresent`, which Apple introduced in iOS 17.4.
|
|
2937
|
+
* Note: the notice sheet itself (`presentExternalPurchaseNoticeSheetIOS`)
|
|
2938
|
+
* still requires iOS 18.2+; only the eligibility check is available earlier.
|
|
2733
2939
|
*
|
|
2734
2940
|
* @returns Promise<boolean> - true if notice sheet can be presented
|
|
2735
2941
|
* @platform iOS
|
|
@@ -2742,6 +2948,8 @@ export const launchExternalLinkAndroid: MutationField<
|
|
|
2742
2948
|
* const result = await presentExternalPurchaseNoticeSheetIOS();
|
|
2743
2949
|
* }
|
|
2744
2950
|
* ```
|
|
2951
|
+
*
|
|
2952
|
+
* @see {@link https://www.openiap.dev/docs/apis/ios/can-present-external-purchase-notice-ios}
|
|
2745
2953
|
*/
|
|
2746
2954
|
export const canPresentExternalPurchaseNoticeIOS: QueryField<
|
|
2747
2955
|
'canPresentExternalPurchaseNoticeIOS'
|
|
@@ -2775,6 +2983,8 @@ export const canPresentExternalPurchaseNoticeIOS: QueryField<
|
|
|
2775
2983
|
* await presentExternalPurchaseLinkIOS('https://your-website.com/purchase');
|
|
2776
2984
|
* }
|
|
2777
2985
|
* ```
|
|
2986
|
+
*
|
|
2987
|
+
* @see {@link https://www.openiap.dev/docs/apis/ios/present-external-purchase-notice-sheet-ios}
|
|
2778
2988
|
*/
|
|
2779
2989
|
export const presentExternalPurchaseNoticeSheetIOS =
|
|
2780
2990
|
async (): Promise<ExternalPurchaseNoticeResultIOS> => {
|
|
@@ -2806,6 +3016,8 @@ export const presentExternalPurchaseNoticeSheetIOS =
|
|
|
2806
3016
|
* console.log('User completed external purchase');
|
|
2807
3017
|
* }
|
|
2808
3018
|
* ```
|
|
3019
|
+
*
|
|
3020
|
+
* @see {@link https://www.openiap.dev/docs/apis/ios/present-external-purchase-link-ios}
|
|
2809
3021
|
*/
|
|
2810
3022
|
export const presentExternalPurchaseLinkIOS: MutationField<
|
|
2811
3023
|
'presentExternalPurchaseLinkIOS'
|
|
@@ -2840,6 +3052,8 @@ export const presentExternalPurchaseLinkIOS: MutationField<
|
|
|
2840
3052
|
* // App can use custom external purchase links
|
|
2841
3053
|
* }
|
|
2842
3054
|
* ```
|
|
3055
|
+
*
|
|
3056
|
+
* @see {@link https://www.openiap.dev/docs/apis/ios/is-eligible-for-external-purchase-custom-link-ios}
|
|
2843
3057
|
*/
|
|
2844
3058
|
export const isEligibleForExternalPurchaseCustomLinkIOS =
|
|
2845
3059
|
async (): Promise<boolean> => {
|
|
@@ -2875,6 +3089,8 @@ export const isEligibleForExternalPurchaseCustomLinkIOS =
|
|
|
2875
3089
|
* await reportToApple(result.token);
|
|
2876
3090
|
* }
|
|
2877
3091
|
* ```
|
|
3092
|
+
*
|
|
3093
|
+
* @see {@link https://www.openiap.dev/docs/apis/ios/get-external-purchase-custom-link-token-ios}
|
|
2878
3094
|
*/
|
|
2879
3095
|
export const getExternalPurchaseCustomLinkTokenIOS = async (
|
|
2880
3096
|
tokenType: ExternalPurchaseCustomLinkTokenTypeIOS,
|
|
@@ -2913,6 +3129,8 @@ export const getExternalPurchaseCustomLinkTokenIOS = async (
|
|
|
2913
3129
|
* await Linking.openURL('https://your-store.com/checkout');
|
|
2914
3130
|
* }
|
|
2915
3131
|
* ```
|
|
3132
|
+
*
|
|
3133
|
+
* @see {@link https://www.openiap.dev/docs/apis/ios/show-external-purchase-custom-link-notice-ios}
|
|
2916
3134
|
*/
|
|
2917
3135
|
export const showExternalPurchaseCustomLinkNoticeIOS = async (
|
|
2918
3136
|
noticeType: ExternalPurchaseCustomLinkNoticeTypeIOS,
|