react-native-iap 11.0.0-beta.1 → 11.0.0-rc.2

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.
Files changed (55) hide show
  1. package/README.md +0 -1
  2. package/ios/IapSerializationUtils.swift +30 -0
  3. package/ios/RNIapIosSk2.m +5 -0
  4. package/ios/RNIapIosSk2.swift +63 -49
  5. package/lib/commonjs/eventEmitter.js +4 -4
  6. package/lib/commonjs/eventEmitter.js.map +1 -1
  7. package/lib/commonjs/hooks/withIAPContext.js +1 -1
  8. package/lib/commonjs/hooks/withIAPContext.js.map +1 -1
  9. package/lib/commonjs/iap.js +50 -297
  10. package/lib/commonjs/iap.js.map +1 -1
  11. package/lib/commonjs/internal/platform.js +75 -2
  12. package/lib/commonjs/internal/platform.js.map +1 -1
  13. package/lib/commonjs/modules/amazon.js +28 -1
  14. package/lib/commonjs/modules/amazon.js.map +1 -1
  15. package/lib/commonjs/modules/android.js +73 -1
  16. package/lib/commonjs/modules/android.js.map +1 -1
  17. package/lib/commonjs/modules/ios.js +126 -0
  18. package/lib/commonjs/modules/ios.js.map +1 -1
  19. package/lib/commonjs/modules/iosSk2.js +47 -0
  20. package/lib/commonjs/modules/iosSk2.js.map +1 -1
  21. package/lib/commonjs/types/appleSk2.js.map +1 -1
  22. package/lib/module/eventEmitter.js +2 -2
  23. package/lib/module/eventEmitter.js.map +1 -1
  24. package/lib/module/hooks/withIAPContext.js +2 -2
  25. package/lib/module/hooks/withIAPContext.js.map +1 -1
  26. package/lib/module/iap.js +8 -223
  27. package/lib/module/iap.js.map +1 -1
  28. package/lib/module/internal/platform.js +48 -1
  29. package/lib/module/internal/platform.js.map +1 -1
  30. package/lib/module/modules/amazon.js +23 -0
  31. package/lib/module/modules/amazon.js.map +1 -1
  32. package/lib/module/modules/android.js +59 -1
  33. package/lib/module/modules/android.js.map +1 -1
  34. package/lib/module/modules/ios.js +102 -1
  35. package/lib/module/modules/ios.js.map +1 -1
  36. package/lib/module/modules/iosSk2.js +30 -1
  37. package/lib/module/modules/iosSk2.js.map +1 -1
  38. package/lib/module/types/appleSk2.js.map +1 -1
  39. package/lib/typescript/iap.d.ts +7 -120
  40. package/lib/typescript/internal/platform.d.ts +9 -0
  41. package/lib/typescript/modules/amazon.d.ts +17 -0
  42. package/lib/typescript/modules/android.d.ts +38 -1
  43. package/lib/typescript/modules/ios.d.ts +56 -0
  44. package/lib/typescript/modules/iosSk2.d.ts +27 -1
  45. package/lib/typescript/types/appleSk2.d.ts +4 -0
  46. package/package.json +1 -1
  47. package/src/eventEmitter.ts +4 -3
  48. package/src/hooks/withIAPContext.tsx +2 -2
  49. package/src/iap.ts +20 -297
  50. package/src/internal/platform.ts +78 -1
  51. package/src/modules/amazon.ts +29 -1
  52. package/src/modules/android.ts +83 -2
  53. package/src/modules/ios.ts +121 -0
  54. package/src/modules/iosSk2.ts +45 -1
  55. package/src/types/appleSk2.ts +12 -0
@@ -1,2 +1,103 @@
1
- export {};
1
+ import { enhancedFetch, getIosModule, isIosStorekit2 } from '../internal';
2
+
3
+ /**
4
+ * Get the current receipt base64 encoded in IOS.
5
+ * @param {forceRefresh?:boolean}
6
+ * @returns {Promise<ProductPurchase[]>}
7
+ */
8
+ export const getPendingPurchasesIOS = async () => getIosModule().getPendingTransactions();
9
+ /**
10
+ * Get the current receipt base64 encoded in IOS.
11
+ * @param {forceRefresh?:boolean}
12
+ * @returns {Promise<string>}
13
+ */
14
+
15
+ export const getReceiptIOS = async _ref => {
16
+ let {
17
+ forceRefresh
18
+ } = _ref;
19
+ return getIosModule().requestReceipt(forceRefresh ?? false);
20
+ };
21
+ /**
22
+ * Launches a modal to register the redeem offer code in IOS.
23
+ * @returns {Promise<null>}
24
+ */
25
+
26
+ export const presentCodeRedemptionSheetIOS = async () => getIosModule().presentCodeRedemptionSheet();
27
+ /**
28
+ * Should Add Store Payment (iOS only)
29
+ * Indicates the the App Store purchase should continue from the app instead of the App Store.
30
+ * @returns {Promise<Product | null>} promoted product
31
+ */
32
+
33
+ export const getPromotedProductIOS = () => {
34
+ if (!isIosStorekit2()) {
35
+ return getIosModule().promotedProduct();
36
+ } else {
37
+ return Promise.reject('Only available on SK1');
38
+ }
39
+ };
40
+ /**
41
+ * Buy the currently selected promoted product (iOS only)
42
+ * Initiates the payment process for a promoted product. Should only be called in response to the `iap-promoted-product` event.
43
+ * @returns {Promise<void>}
44
+ */
45
+
46
+ export const buyPromotedProductIOS = () => getIosModule().buyPromotedProduct();
47
+ const TEST_RECEIPT = 21007;
48
+
49
+ const requestAgnosticReceiptValidationIos = async receiptBody => {
50
+ const response = await enhancedFetch('https://buy.itunes.apple.com/verifyReceipt', {
51
+ method: 'POST',
52
+ body: receiptBody
53
+ }); // Best practice is to check for test receipt and check sandbox instead
54
+ // https://developer.apple.com/documentation/appstorereceipts/verifyreceipt
55
+
56
+ if (response && response.status === TEST_RECEIPT) {
57
+ const testResponse = await enhancedFetch('https://sandbox.itunes.apple.com/verifyReceipt', {
58
+ method: 'POST',
59
+ body: receiptBody
60
+ });
61
+ return testResponse;
62
+ }
63
+
64
+ return response;
65
+ };
66
+ /**
67
+ * Validate receipt for iOS.
68
+ * @param {object} receiptBody the receipt body to send to apple server.
69
+ * @param {boolean} isTest whether this is in test environment which is sandbox.
70
+ * @returns {Promise<Apple.ReceiptValidationResponse | false>}
71
+ */
72
+
73
+
74
+ export const validateReceiptIos = async _ref2 => {
75
+ let {
76
+ receiptBody,
77
+ isTest
78
+ } = _ref2;
79
+
80
+ if (isTest == null) {
81
+ return await requestAgnosticReceiptValidationIos(receiptBody);
82
+ }
83
+
84
+ const url = isTest ? 'https://sandbox.itunes.apple.com/verifyReceipt' : 'https://buy.itunes.apple.com/verifyReceipt';
85
+ return await enhancedFetch(url);
86
+ };
87
+ /**
88
+ * Clear Transaction (iOS only)
89
+ * Finish remaining transactions. Related to issue #257 and #801
90
+ * link : https://github.com/dooboolab/react-native-iap/issues/257
91
+ * https://github.com/dooboolab/react-native-iap/issues/801
92
+ * @returns {Promise<void>}
93
+ */
94
+
95
+ export const clearTransactionIOS = () => getIosModule().clearTransaction();
96
+ /**
97
+ * Clear valid Products (iOS only)
98
+ * Remove all products which are validated by Apple server.
99
+ * @returns {void}
100
+ */
101
+
102
+ export const clearProductsIOS = () => getIosModule().clearProducts();
2
103
  //# sourceMappingURL=ios.js.map
@@ -1 +1 @@
1
- {"version":3,"names":[],"sources":["ios.ts"],"sourcesContent":["import type {\n Product,\n ProductPurchase,\n Purchase,\n Sku,\n Subscription,\n} from '../types';\nimport type {PaymentDiscount} from '../types/apple';\n\nimport type {NativeModuleProps} from './common';\n\ntype getItems = (skus: Sku[]) => Promise<Product[] | Subscription[]>;\n\ntype getAvailableItems = () => Promise<Purchase[]>;\n\nexport type BuyProduct = (\n sku: Sku,\n andDangerouslyFinishTransactionAutomaticallyIOS: boolean,\n applicationUsername: string | undefined,\n quantity: number,\n withOffer: PaymentDiscount | undefined,\n) => Promise<Purchase>;\n\ntype clearTransaction = () => Promise<void>;\ntype clearProducts = () => Promise<void>;\ntype promotedProduct = () => Promise<Product | null>;\ntype buyPromotedProduct = () => Promise<void>;\ntype requestReceipt = (refresh: boolean) => Promise<string>;\n\ntype finishTransaction = (transactionIdentifier: string) => Promise<boolean>;\n\ntype getPendingTransactions = () => Promise<ProductPurchase[]>;\ntype presentCodeRedemptionSheet = () => Promise<null>;\n\nexport interface IosModuleProps extends NativeModuleProps {\n getItems: getItems;\n getAvailableItems: getAvailableItems;\n buyProduct: BuyProduct;\n clearTransaction: clearTransaction;\n clearProducts: clearProducts;\n promotedProduct: promotedProduct;\n buyPromotedProduct: buyPromotedProduct;\n requestReceipt: requestReceipt;\n finishTransaction: finishTransaction;\n getPendingTransactions: getPendingTransactions;\n presentCodeRedemptionSheet: presentCodeRedemptionSheet;\n}\n"],"mappings":""}
1
+ {"version":3,"names":["enhancedFetch","getIosModule","isIosStorekit2","getPendingPurchasesIOS","getPendingTransactions","getReceiptIOS","forceRefresh","requestReceipt","presentCodeRedemptionSheetIOS","presentCodeRedemptionSheet","getPromotedProductIOS","promotedProduct","Promise","reject","buyPromotedProductIOS","buyPromotedProduct","TEST_RECEIPT","requestAgnosticReceiptValidationIos","receiptBody","response","method","body","status","testResponse","validateReceiptIos","isTest","url","clearTransactionIOS","clearTransaction","clearProductsIOS","clearProducts"],"sources":["ios.ts"],"sourcesContent":["import type {ResponseBody as ReceiptValidationResponse} from '@jeremybarbet/apple-api-types';\n\nimport {enhancedFetch, getIosModule, isIosStorekit2} from '../internal';\nimport type {\n Product,\n ProductPurchase,\n Purchase,\n Sku,\n Subscription,\n} from '../types';\nimport type {PaymentDiscount} from '../types/apple';\n\nimport type {NativeModuleProps} from './common';\n\ntype getItems = (skus: Sku[]) => Promise<Product[] | Subscription[]>;\n\ntype getAvailableItems = () => Promise<Purchase[]>;\n\nexport type BuyProduct = (\n sku: Sku,\n andDangerouslyFinishTransactionAutomaticallyIOS: boolean,\n applicationUsername: string | undefined,\n quantity: number,\n withOffer: PaymentDiscount | undefined,\n) => Promise<Purchase>;\n\ntype clearTransaction = () => Promise<void>;\ntype clearProducts = () => Promise<void>;\ntype promotedProduct = () => Promise<Product | null>;\ntype buyPromotedProduct = () => Promise<void>;\ntype requestReceipt = (refresh: boolean) => Promise<string>;\n\ntype finishTransaction = (transactionIdentifier: string) => Promise<boolean>;\n\ntype getPendingTransactions = () => Promise<ProductPurchase[]>;\ntype presentCodeRedemptionSheet = () => Promise<null>;\n\nexport interface IosModuleProps extends NativeModuleProps {\n getItems: getItems;\n getAvailableItems: getAvailableItems;\n buyProduct: BuyProduct;\n clearTransaction: clearTransaction;\n clearProducts: clearProducts;\n promotedProduct: promotedProduct;\n buyPromotedProduct: buyPromotedProduct;\n requestReceipt: requestReceipt;\n finishTransaction: finishTransaction;\n getPendingTransactions: getPendingTransactions;\n presentCodeRedemptionSheet: presentCodeRedemptionSheet;\n}\n\n/**\n * Get the current receipt base64 encoded in IOS.\n * @param {forceRefresh?:boolean}\n * @returns {Promise<ProductPurchase[]>}\n */\nexport const getPendingPurchasesIOS = async (): Promise<ProductPurchase[]> =>\n getIosModule().getPendingTransactions();\n\n/**\n * Get the current receipt base64 encoded in IOS.\n * @param {forceRefresh?:boolean}\n * @returns {Promise<string>}\n */\nexport const getReceiptIOS = async ({\n forceRefresh,\n}: {\n forceRefresh?: boolean;\n}): Promise<string> => getIosModule().requestReceipt(forceRefresh ?? false);\n\n/**\n * Launches a modal to register the redeem offer code in IOS.\n * @returns {Promise<null>}\n */\nexport const presentCodeRedemptionSheetIOS = async (): Promise<null> =>\n getIosModule().presentCodeRedemptionSheet();\n\n/**\n * Should Add Store Payment (iOS only)\n * Indicates the the App Store purchase should continue from the app instead of the App Store.\n * @returns {Promise<Product | null>} promoted product\n */\nexport const getPromotedProductIOS = (): Promise<Product | null> => {\n if (!isIosStorekit2()) {\n return getIosModule().promotedProduct();\n } else {\n return Promise.reject('Only available on SK1');\n }\n};\n\n/**\n * Buy the currently selected promoted product (iOS only)\n * Initiates the payment process for a promoted product. Should only be called in response to the `iap-promoted-product` event.\n * @returns {Promise<void>}\n */\nexport const buyPromotedProductIOS = (): Promise<void> =>\n getIosModule().buyPromotedProduct();\n\nconst TEST_RECEIPT = 21007;\nconst requestAgnosticReceiptValidationIos = async (\n receiptBody: Record<string, unknown>,\n): Promise<ReceiptValidationResponse | false> => {\n const response = await enhancedFetch<ReceiptValidationResponse>(\n 'https://buy.itunes.apple.com/verifyReceipt',\n {\n method: 'POST',\n body: receiptBody,\n },\n );\n\n // Best practice is to check for test receipt and check sandbox instead\n // https://developer.apple.com/documentation/appstorereceipts/verifyreceipt\n if (response && response.status === TEST_RECEIPT) {\n const testResponse = await enhancedFetch<ReceiptValidationResponse>(\n 'https://sandbox.itunes.apple.com/verifyReceipt',\n {\n method: 'POST',\n body: receiptBody,\n },\n );\n\n return testResponse;\n }\n\n return response;\n};\n\n/**\n * Validate receipt for iOS.\n * @param {object} receiptBody the receipt body to send to apple server.\n * @param {boolean} isTest whether this is in test environment which is sandbox.\n * @returns {Promise<Apple.ReceiptValidationResponse | false>}\n */\nexport const validateReceiptIos = async ({\n receiptBody,\n isTest,\n}: {\n receiptBody: Record<string, unknown>;\n isTest?: boolean;\n}): Promise<ReceiptValidationResponse | false> => {\n if (isTest == null) {\n return await requestAgnosticReceiptValidationIos(receiptBody);\n }\n\n const url = isTest\n ? 'https://sandbox.itunes.apple.com/verifyReceipt'\n : 'https://buy.itunes.apple.com/verifyReceipt';\n\n return await enhancedFetch<ReceiptValidationResponse>(url);\n};\n\n/**\n * Clear Transaction (iOS only)\n * Finish remaining transactions. Related to issue #257 and #801\n * link : https://github.com/dooboolab/react-native-iap/issues/257\n * https://github.com/dooboolab/react-native-iap/issues/801\n * @returns {Promise<void>}\n */\nexport const clearTransactionIOS = (): Promise<void> =>\n getIosModule().clearTransaction();\n\n/**\n * Clear valid Products (iOS only)\n * Remove all products which are validated by Apple server.\n * @returns {void}\n */\nexport const clearProductsIOS = (): Promise<void> =>\n getIosModule().clearProducts();\n"],"mappings":"AAEA,SAAQA,aAAR,EAAuBC,YAAvB,EAAqCC,cAArC,QAA0D,aAA1D;;AAiDA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,sBAAsB,GAAG,YACpCF,YAAY,GAAGG,sBAAf,EADK;AAGP;AACA;AACA;AACA;AACA;;AACA,OAAO,MAAMC,aAAa,GAAG;EAAA,IAAO;IAClCC;EADkC,CAAP;EAAA,OAINL,YAAY,GAAGM,cAAf,CAA8BD,YAAY,IAAI,KAA9C,CAJM;AAAA,CAAtB;AAMP;AACA;AACA;AACA;;AACA,OAAO,MAAME,6BAA6B,GAAG,YAC3CP,YAAY,GAAGQ,0BAAf,EADK;AAGP;AACA;AACA;AACA;AACA;;AACA,OAAO,MAAMC,qBAAqB,GAAG,MAA+B;EAClE,IAAI,CAACR,cAAc,EAAnB,EAAuB;IACrB,OAAOD,YAAY,GAAGU,eAAf,EAAP;EACD,CAFD,MAEO;IACL,OAAOC,OAAO,CAACC,MAAR,CAAe,uBAAf,CAAP;EACD;AACF,CANM;AAQP;AACA;AACA;AACA;AACA;;AACA,OAAO,MAAMC,qBAAqB,GAAG,MACnCb,YAAY,GAAGc,kBAAf,EADK;AAGP,MAAMC,YAAY,GAAG,KAArB;;AACA,MAAMC,mCAAmC,GAAG,MAC1CC,WAD0C,IAEK;EAC/C,MAAMC,QAAQ,GAAG,MAAMnB,aAAa,CAClC,4CADkC,EAElC;IACEoB,MAAM,EAAE,MADV;IAEEC,IAAI,EAAEH;EAFR,CAFkC,CAApC,CAD+C,CAS/C;EACA;;EACA,IAAIC,QAAQ,IAAIA,QAAQ,CAACG,MAAT,KAAoBN,YAApC,EAAkD;IAChD,MAAMO,YAAY,GAAG,MAAMvB,aAAa,CACtC,gDADsC,EAEtC;MACEoB,MAAM,EAAE,MADV;MAEEC,IAAI,EAAEH;IAFR,CAFsC,CAAxC;IAQA,OAAOK,YAAP;EACD;;EAED,OAAOJ,QAAP;AACD,CA1BD;AA4BA;AACA;AACA;AACA;AACA;AACA;;;AACA,OAAO,MAAMK,kBAAkB,GAAG,eAMgB;EAAA,IANT;IACvCN,WADuC;IAEvCO;EAFuC,CAMS;;EAChD,IAAIA,MAAM,IAAI,IAAd,EAAoB;IAClB,OAAO,MAAMR,mCAAmC,CAACC,WAAD,CAAhD;EACD;;EAED,MAAMQ,GAAG,GAAGD,MAAM,GACd,gDADc,GAEd,4CAFJ;EAIA,OAAO,MAAMzB,aAAa,CAA4B0B,GAA5B,CAA1B;AACD,CAhBM;AAkBP;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,MAAMC,mBAAmB,GAAG,MACjC1B,YAAY,GAAG2B,gBAAf,EADK;AAGP;AACA;AACA;AACA;AACA;;AACA,OAAO,MAAMC,gBAAgB,GAAG,MAC9B5B,YAAY,GAAG6B,aAAf,EADK"}
@@ -1,2 +1,31 @@
1
- export {};
1
+ import { NativeModules } from 'react-native';
2
+ const {
3
+ RNIapIosSk2
4
+ } = NativeModules;
5
+
6
+ /**
7
+ * Sync state with Appstore (iOS only)
8
+ * https://developer.apple.com/documentation/storekit/appstore/3791906-sync
9
+ */
10
+ export const sync = () => RNIapIosSk2.sync();
11
+ /**
12
+ *
13
+ */
14
+
15
+ export const isEligibleForIntroOffer = groupID => RNIapIosSk2.isEligibleForIntroOffer(groupID);
16
+ /**
17
+ *
18
+ */
19
+
20
+ export const subscriptionStatus = sku => RNIapIosSk2.subscriptionStatus(sku);
21
+ /**
22
+ *
23
+ */
24
+
25
+ export const currentEntitlement = sku => RNIapIosSk2.currentEntitlement(sku);
26
+ /**
27
+ *
28
+ */
29
+
30
+ export const latestTransaction = sku => RNIapIosSk2.latestTransaction(sku);
2
31
  //# sourceMappingURL=iosSk2.js.map
@@ -1 +1 @@
1
- {"version":3,"names":[],"sources":["iosSk2.ts"],"sourcesContent":["import type {Product, ProductPurchase, Purchase, Sku} from '../types';\nimport type {PaymentDiscountSk2, ProductSk2} from '../types/appleSk2';\n\nimport type {NativeModuleProps} from './common';\n\ntype getItems = (skus: Sku[]) => Promise<ProductSk2[]>;\n\ntype getAvailableItems = () => Promise<Purchase[]>;\n\nexport type BuyProduct = (\n sku: Sku,\n andDangerouslyFinishTransactionAutomaticallyIOS: boolean,\n applicationUsername: string | undefined,\n quantity: number,\n withOffer: PaymentDiscountSk2 | undefined,\n) => Promise<Purchase>;\n\ntype clearTransaction = () => Promise<void>;\ntype clearProducts = () => Promise<void>;\ntype promotedProduct = () => Promise<Product | null>;\ntype buyPromotedProduct = () => Promise<void>;\ntype requestReceipt = (refresh: boolean) => Promise<string>;\n\ntype finishTransaction = (transactionIdentifier: string) => Promise<boolean>;\n\ntype getPendingTransactions = () => Promise<ProductPurchase[]>;\ntype presentCodeRedemptionSheet = () => Promise<null>;\n\nexport interface IosModulePropsSk2 extends NativeModuleProps {\n getItems: getItems;\n getAvailableItems: getAvailableItems;\n buyProduct: BuyProduct;\n clearTransaction: clearTransaction;\n clearProducts: clearProducts;\n promotedProduct: promotedProduct;\n buyPromotedProduct: buyPromotedProduct;\n requestReceipt: requestReceipt;\n finishTransaction: finishTransaction;\n getPendingTransactions: getPendingTransactions;\n presentCodeRedemptionSheet: presentCodeRedemptionSheet;\n}\n"],"mappings":""}
1
+ {"version":3,"names":["NativeModules","RNIapIosSk2","sync","isEligibleForIntroOffer","groupID","subscriptionStatus","sku","currentEntitlement","latestTransaction"],"sources":["iosSk2.ts"],"sourcesContent":["import {NativeModules} from 'react-native';\n\nimport type {Product, ProductPurchase, Purchase, Sku} from '../types';\nimport type {\n PaymentDiscountSk2,\n ProductSk2,\n ProductStatus,\n TransactionSk2,\n} from '../types/appleSk2';\n\nimport type {NativeModuleProps} from './common';\nconst {RNIapIosSk2} = NativeModules;\n\ntype getItems = (skus: Sku[]) => Promise<ProductSk2[]>;\n\ntype getAvailableItems = () => Promise<Purchase[]>;\n\nexport type BuyProduct = (\n sku: Sku,\n andDangerouslyFinishTransactionAutomaticallyIOS: boolean,\n applicationUsername: string | undefined,\n quantity: number,\n withOffer: PaymentDiscountSk2 | undefined,\n) => Promise<Purchase>;\n\ntype clearTransaction = () => Promise<void>;\ntype clearProducts = () => Promise<void>;\ntype promotedProduct = () => Promise<Product | null>;\ntype buyPromotedProduct = () => Promise<void>;\ntype requestReceipt = (refresh: boolean) => Promise<string>;\n\ntype finishTransaction = (transactionIdentifier: string) => Promise<boolean>;\n\ntype getPendingTransactions = () => Promise<ProductPurchase[]>;\ntype presentCodeRedemptionSheet = () => Promise<null>;\n\nexport interface IosModulePropsSk2 extends NativeModuleProps {\n latestTransaction(sku: string): Promise<TransactionSk2>;\n currentEntitlement(sku: string): Promise<TransactionSk2>;\n subscriptionStatus(sku: string): Promise<ProductStatus[]>;\n isEligibleForIntroOffer(groupID: string): Promise<Boolean>;\n sync(): Promise<null>;\n getItems: getItems;\n getAvailableItems: getAvailableItems;\n buyProduct: BuyProduct;\n clearTransaction: clearTransaction;\n clearProducts: clearProducts;\n promotedProduct: promotedProduct;\n buyPromotedProduct: buyPromotedProduct;\n requestReceipt: requestReceipt;\n finishTransaction: finishTransaction;\n getPendingTransactions: getPendingTransactions;\n presentCodeRedemptionSheet: presentCodeRedemptionSheet;\n}\n\n/**\n * Sync state with Appstore (iOS only)\n * https://developer.apple.com/documentation/storekit/appstore/3791906-sync\n */\nexport const sync = (): Promise<null> => RNIapIosSk2.sync();\n\n/**\n *\n */\nexport const isEligibleForIntroOffer = (groupID: string): Promise<Boolean> =>\n RNIapIosSk2.isEligibleForIntroOffer(groupID);\n\n/**\n *\n */\n\nexport const subscriptionStatus = (sku: string): Promise<ProductStatus[]> =>\n RNIapIosSk2.subscriptionStatus(sku);\n\n/**\n *\n */\nexport const currentEntitlement = (sku: string): Promise<TransactionSk2> =>\n RNIapIosSk2.currentEntitlement(sku);\n\n/**\n *\n */\nexport const latestTransaction = (sku: string): Promise<TransactionSk2> =>\n RNIapIosSk2.latestTransaction(sku);\n"],"mappings":"AAAA,SAAQA,aAAR,QAA4B,cAA5B;AAWA,MAAM;EAACC;AAAD,IAAgBD,aAAtB;;AA4CA;AACA;AACA;AACA;AACA,OAAO,MAAME,IAAI,GAAG,MAAqBD,WAAW,CAACC,IAAZ,EAAlC;AAEP;AACA;AACA;;AACA,OAAO,MAAMC,uBAAuB,GAAIC,OAAD,IACrCH,WAAW,CAACE,uBAAZ,CAAoCC,OAApC,CADK;AAGP;AACA;AACA;;AAEA,OAAO,MAAMC,kBAAkB,GAAIC,GAAD,IAChCL,WAAW,CAACI,kBAAZ,CAA+BC,GAA/B,CADK;AAGP;AACA;AACA;;AACA,OAAO,MAAMC,kBAAkB,GAAID,GAAD,IAChCL,WAAW,CAACM,kBAAZ,CAA+BD,GAA/B,CADK;AAGP;AACA;AACA;;AACA,OAAO,MAAME,iBAAiB,GAAIF,GAAD,IAC/BL,WAAW,CAACO,iBAAZ,CAA8BF,GAA9B,CADK"}
@@ -1 +1 @@
1
- {"version":3,"names":["productSk2Map","id","description","displayName","price","displayPrice","prod","title","productId","String","type","localizedPrice","currency","subscriptionSk2Map","transactionSk2Map","originalPurchaseDate","productID","purchaseDate","purchasedQuantity","purchase","transactionId","transactionDate","transactionReceipt","purchaseToken","quantityIOS","originalTransactionDateIOS","originalTransactionIdentifierIOS","offerSk2Map","offer","undefined","offerID","identifier","keyID","keyIdentifier","nonce","signature","timestamp"],"sources":["appleSk2.ts"],"sourcesContent":["import type {ProductIOS, Purchase, SubscriptionIOS} from '.';\nimport type * as Apple from './apple';\nexport type ProductSk2 = {\n description: string;\n displayName: string;\n displayPrice: string;\n id: number;\n isFamilyShareable: boolean;\n jsonRepresentation: string;\n price: number;\n subscription: any; //TODO\n type: 'autoRenewable' | 'consumable' | 'nonConsumable' | 'nonRenewable';\n};\nexport const productSk2Map = ({\n id,\n description,\n displayName,\n price,\n displayPrice,\n}: ProductSk2): ProductIOS => {\n const prod: ProductIOS = {\n title: displayName,\n productId: String(id),\n description,\n type: 'iap',\n price: String(price),\n localizedPrice: displayPrice,\n currency: '', //TODO: Not avaiable on new API, use localizedPrice instead?\n };\n return prod;\n};\n\nexport const subscriptionSk2Map = ({\n id,\n description,\n displayName,\n price,\n displayPrice,\n}: ProductSk2): SubscriptionIOS => {\n const prod: SubscriptionIOS = {\n title: displayName,\n productId: String(id),\n description,\n type: 'subs',\n price: String(price),\n localizedPrice: displayPrice,\n currency: '', //TODO: Not avaiable on new API, use localizedPrice instead?\n };\n return prod;\n};\n\nexport type TransactionSk2 = {\n appAccountToken: string;\n appBundleID: string;\n debugDescription: string;\n deviceVerification: string;\n deviceVerificationNonce: string;\n expirationDate: number;\n id: number;\n isUpgraded: boolean;\n jsonRepresentation: string;\n offerID: string;\n offerType: string;\n originalID: string;\n originalPurchaseDate: number;\n ownershipType: string;\n productID: string;\n productType: string;\n purchaseDate: number;\n purchasedQuantity: number;\n revocationDate: number;\n revocationReason: string;\n signedDate: number;\n subscriptionGroupID: number;\n webOrderLineItemID: number;\n};\nexport const transactionSk2Map = ({\n id,\n originalPurchaseDate,\n productID,\n purchaseDate,\n purchasedQuantity,\n}: TransactionSk2): Purchase => {\n const purchase: Purchase = {\n productId: productID,\n transactionId: String(id),\n transactionDate: purchaseDate, //??\n transactionReceipt: '', // Not available\n purchaseToken: '', //Not avaiable\n quantityIOS: purchasedQuantity,\n originalTransactionDateIOS: String(originalPurchaseDate),\n originalTransactionIdentifierIOS: String(id), // ??\n };\n return purchase;\n};\n\n/**\n * Payment discount interface @see https://developer.apple.com/documentation/storekit/skpaymentdiscount?language=objc\n */\nexport interface PaymentDiscountSk2 {\n /**\n * A string used to uniquely identify a discount offer for a product.\n */\n offerID: string;\n\n /**\n * A string that identifies the key used to generate the signature.\n */\n keyID: string;\n\n /**\n * A universally unique ID (UUID) value that you define.\n */\n nonce: string;\n\n /**\n * A UTF-8 string representing the properties of a specific discount offer, cryptographically signed.\n */\n signature: string;\n\n /**\n * The date and time of the signature's creation in milliseconds, formatted in Unix epoch time.\n */\n timestamp: number;\n}\n\nexport const offerSk2Map = (\n offer: Apple.PaymentDiscount | undefined,\n): PaymentDiscountSk2 | undefined => {\n if (!offer) {\n return undefined;\n }\n return {\n offerID: offer.identifier,\n keyID: offer.keyIdentifier,\n nonce: offer.nonce,\n signature: offer.signature,\n timestamp: offer.timestamp,\n };\n};\n"],"mappings":"AAaA,OAAO,MAAMA,aAAa,GAAG,QAMC;EAAA,IANA;IAC5BC,EAD4B;IAE5BC,WAF4B;IAG5BC,WAH4B;IAI5BC,KAJ4B;IAK5BC;EAL4B,CAMA;EAC5B,MAAMC,IAAgB,GAAG;IACvBC,KAAK,EAAEJ,WADgB;IAEvBK,SAAS,EAAEC,MAAM,CAACR,EAAD,CAFM;IAGvBC,WAHuB;IAIvBQ,IAAI,EAAE,KAJiB;IAKvBN,KAAK,EAAEK,MAAM,CAACL,KAAD,CALU;IAMvBO,cAAc,EAAEN,YANO;IAOvBO,QAAQ,EAAE,EAPa,CAOT;;EAPS,CAAzB;EASA,OAAON,IAAP;AACD,CAjBM;AAmBP,OAAO,MAAMO,kBAAkB,GAAG,SAMC;EAAA,IANA;IACjCZ,EADiC;IAEjCC,WAFiC;IAGjCC,WAHiC;IAIjCC,KAJiC;IAKjCC;EALiC,CAMA;EACjC,MAAMC,IAAqB,GAAG;IAC5BC,KAAK,EAAEJ,WADqB;IAE5BK,SAAS,EAAEC,MAAM,CAACR,EAAD,CAFW;IAG5BC,WAH4B;IAI5BQ,IAAI,EAAE,MAJsB;IAK5BN,KAAK,EAAEK,MAAM,CAACL,KAAD,CALe;IAM5BO,cAAc,EAAEN,YANY;IAO5BO,QAAQ,EAAE,EAPkB,CAOd;;EAPc,CAA9B;EASA,OAAON,IAAP;AACD,CAjBM;AA4CP,OAAO,MAAMQ,iBAAiB,GAAG,SAMD;EAAA,IANE;IAChCb,EADgC;IAEhCc,oBAFgC;IAGhCC,SAHgC;IAIhCC,YAJgC;IAKhCC;EALgC,CAMF;EAC9B,MAAMC,QAAkB,GAAG;IACzBX,SAAS,EAAEQ,SADc;IAEzBI,aAAa,EAAEX,MAAM,CAACR,EAAD,CAFI;IAGzBoB,eAAe,EAAEJ,YAHQ;IAGM;IAC/BK,kBAAkB,EAAE,EAJK;IAID;IACxBC,aAAa,EAAE,EALU;IAKN;IACnBC,WAAW,EAAEN,iBANY;IAOzBO,0BAA0B,EAAEhB,MAAM,CAACM,oBAAD,CAPT;IAQzBW,gCAAgC,EAAEjB,MAAM,CAACR,EAAD,CARf,CAQqB;;EARrB,CAA3B;EAUA,OAAOkB,QAAP;AACD,CAlBM;AAoBP;AACA;AACA;;AA4BA,OAAO,MAAMQ,WAAW,GACtBC,KADyB,IAEU;EACnC,IAAI,CAACA,KAAL,EAAY;IACV,OAAOC,SAAP;EACD;;EACD,OAAO;IACLC,OAAO,EAAEF,KAAK,CAACG,UADV;IAELC,KAAK,EAAEJ,KAAK,CAACK,aAFR;IAGLC,KAAK,EAAEN,KAAK,CAACM,KAHR;IAILC,SAAS,EAAEP,KAAK,CAACO,SAJZ;IAKLC,SAAS,EAAER,KAAK,CAACQ;EALZ,CAAP;AAOD,CAbM"}
1
+ {"version":3,"names":["productSk2Map","id","description","displayName","price","displayPrice","prod","title","productId","String","type","localizedPrice","currency","subscriptionSk2Map","transactionSk2Map","originalPurchaseDate","productID","purchaseDate","purchasedQuantity","purchase","transactionId","transactionDate","transactionReceipt","purchaseToken","quantityIOS","originalTransactionDateIOS","originalTransactionIdentifierIOS","offerSk2Map","offer","undefined","offerID","identifier","keyID","keyIdentifier","nonce","signature","timestamp"],"sources":["appleSk2.ts"],"sourcesContent":["import type {ProductIOS, Purchase, SubscriptionIOS} from '.';\nimport type * as Apple from './apple';\nexport type ProductSk2 = {\n description: string;\n displayName: string;\n displayPrice: string;\n id: number;\n isFamilyShareable: boolean;\n jsonRepresentation: string;\n price: number;\n subscription: any; //TODO\n type: 'autoRenewable' | 'consumable' | 'nonConsumable' | 'nonRenewable';\n};\nexport const productSk2Map = ({\n id,\n description,\n displayName,\n price,\n displayPrice,\n}: ProductSk2): ProductIOS => {\n const prod: ProductIOS = {\n title: displayName,\n productId: String(id),\n description,\n type: 'iap',\n price: String(price),\n localizedPrice: displayPrice,\n currency: '', //TODO: Not avaiable on new API, use localizedPrice instead?\n };\n return prod;\n};\n\nexport const subscriptionSk2Map = ({\n id,\n description,\n displayName,\n price,\n displayPrice,\n}: ProductSk2): SubscriptionIOS => {\n const prod: SubscriptionIOS = {\n title: displayName,\n productId: String(id),\n description,\n type: 'subs',\n price: String(price),\n localizedPrice: displayPrice,\n currency: '', //TODO: Not avaiable on new API, use localizedPrice instead?\n };\n return prod;\n};\n\nexport type TransactionSk2 = {\n appAccountToken: string;\n appBundleID: string;\n debugDescription: string;\n deviceVerification: string;\n deviceVerificationNonce: string;\n expirationDate: number;\n id: number;\n isUpgraded: boolean;\n jsonRepresentation: string;\n offerID: string;\n offerType: string;\n originalID: string;\n originalPurchaseDate: number;\n ownershipType: string;\n productID: string;\n productType: string;\n purchaseDate: number;\n purchasedQuantity: number;\n revocationDate: number;\n revocationReason: string;\n signedDate: number;\n subscriptionGroupID: number;\n webOrderLineItemID: number;\n};\n\nexport type SubscriptionStatus =\n | 'expired'\n | 'inBillingRetryPeriod'\n | 'inGracePeriod'\n | 'revoked'\n | 'subscribed';\n\nexport type ProductStatus = {\n state: SubscriptionStatus;\n};\n\nexport const transactionSk2Map = ({\n id,\n originalPurchaseDate,\n productID,\n purchaseDate,\n purchasedQuantity,\n}: TransactionSk2): Purchase => {\n const purchase: Purchase = {\n productId: productID,\n transactionId: String(id),\n transactionDate: purchaseDate, //??\n transactionReceipt: '', // Not available\n purchaseToken: '', //Not avaiable\n quantityIOS: purchasedQuantity,\n originalTransactionDateIOS: String(originalPurchaseDate),\n originalTransactionIdentifierIOS: String(id), // ??\n };\n return purchase;\n};\n\n/**\n * Payment discount interface @see https://developer.apple.com/documentation/storekit/skpaymentdiscount?language=objc\n */\nexport interface PaymentDiscountSk2 {\n /**\n * A string used to uniquely identify a discount offer for a product.\n */\n offerID: string;\n\n /**\n * A string that identifies the key used to generate the signature.\n */\n keyID: string;\n\n /**\n * A universally unique ID (UUID) value that you define.\n */\n nonce: string;\n\n /**\n * A UTF-8 string representing the properties of a specific discount offer, cryptographically signed.\n */\n signature: string;\n\n /**\n * The date and time of the signature's creation in milliseconds, formatted in Unix epoch time.\n */\n timestamp: number;\n}\n\nexport const offerSk2Map = (\n offer: Apple.PaymentDiscount | undefined,\n): PaymentDiscountSk2 | undefined => {\n if (!offer) {\n return undefined;\n }\n return {\n offerID: offer.identifier,\n keyID: offer.keyIdentifier,\n nonce: offer.nonce,\n signature: offer.signature,\n timestamp: offer.timestamp,\n };\n};\n"],"mappings":"AAaA,OAAO,MAAMA,aAAa,GAAG,QAMC;EAAA,IANA;IAC5BC,EAD4B;IAE5BC,WAF4B;IAG5BC,WAH4B;IAI5BC,KAJ4B;IAK5BC;EAL4B,CAMA;EAC5B,MAAMC,IAAgB,GAAG;IACvBC,KAAK,EAAEJ,WADgB;IAEvBK,SAAS,EAAEC,MAAM,CAACR,EAAD,CAFM;IAGvBC,WAHuB;IAIvBQ,IAAI,EAAE,KAJiB;IAKvBN,KAAK,EAAEK,MAAM,CAACL,KAAD,CALU;IAMvBO,cAAc,EAAEN,YANO;IAOvBO,QAAQ,EAAE,EAPa,CAOT;;EAPS,CAAzB;EASA,OAAON,IAAP;AACD,CAjBM;AAmBP,OAAO,MAAMO,kBAAkB,GAAG,SAMC;EAAA,IANA;IACjCZ,EADiC;IAEjCC,WAFiC;IAGjCC,WAHiC;IAIjCC,KAJiC;IAKjCC;EALiC,CAMA;EACjC,MAAMC,IAAqB,GAAG;IAC5BC,KAAK,EAAEJ,WADqB;IAE5BK,SAAS,EAAEC,MAAM,CAACR,EAAD,CAFW;IAG5BC,WAH4B;IAI5BQ,IAAI,EAAE,MAJsB;IAK5BN,KAAK,EAAEK,MAAM,CAACL,KAAD,CALe;IAM5BO,cAAc,EAAEN,YANY;IAO5BO,QAAQ,EAAE,EAPkB,CAOd;;EAPc,CAA9B;EASA,OAAON,IAAP;AACD,CAjBM;AAwDP,OAAO,MAAMQ,iBAAiB,GAAG,SAMD;EAAA,IANE;IAChCb,EADgC;IAEhCc,oBAFgC;IAGhCC,SAHgC;IAIhCC,YAJgC;IAKhCC;EALgC,CAMF;EAC9B,MAAMC,QAAkB,GAAG;IACzBX,SAAS,EAAEQ,SADc;IAEzBI,aAAa,EAAEX,MAAM,CAACR,EAAD,CAFI;IAGzBoB,eAAe,EAAEJ,YAHQ;IAGM;IAC/BK,kBAAkB,EAAE,EAJK;IAID;IACxBC,aAAa,EAAE,EALU;IAKN;IACnBC,WAAW,EAAEN,iBANY;IAOzBO,0BAA0B,EAAEhB,MAAM,CAACM,oBAAD,CAPT;IAQzBW,gCAAgC,EAAEjB,MAAM,CAACR,EAAD,CARf,CAQqB;;EARrB,CAA3B;EAUA,OAAOkB,QAAP;AACD,CAlBM;AAoBP;AACA;AACA;;AA4BA,OAAO,MAAMQ,WAAW,GACtBC,KADyB,IAEU;EACnC,IAAI,CAACA,KAAL,EAAY;IACV,OAAOC,SAAP;EACD;;EACD,OAAO;IACLC,OAAO,EAAEF,KAAK,CAACG,UADV;IAELC,KAAK,EAAEJ,KAAK,CAACK,aAFR;IAGLC,KAAK,EAAEN,KAAK,CAACM,KAHR;IAILC,SAAS,EAAEP,KAAK,CAACO,SAJZ;IAKLC,SAAS,EAAER,KAAK,CAACQ;EALZ,CAAP;AAOD,CAbM"}
@@ -1,17 +1,10 @@
1
- import type { ResponseBody as ReceiptValidationResponse } from '@jeremybarbet/apple-api-types';
2
- import type * as Amazon from './types/amazon';
3
- import type * as Android from './types/android';
4
- import { Product, ProductPurchase, PurchaseResult, RequestPurchase, RequestSubscription, Sku, Subscription, SubscriptionPurchase } from './types';
5
- import { InstallSourceAndroid } from './types';
6
- export declare const getInstallSourceAndroid: () => InstallSourceAndroid;
7
- export declare const isIosStorekit2: () => boolean;
8
- export declare const isStorekit2Avaiable: () => boolean;
9
- export declare const enableStorekit2: () => boolean;
10
- export declare const setAndroidNativeModule: (nativeModule: import("./modules").AndroidModuleProps) => void;
11
- export declare const setIosNativeModule: (nativeModule: import("./modules").IosModuleProps | import("./modules/iosSk2").IosModulePropsSk2) => void;
12
- export declare const getAndroidModule: () => import("./modules").AmazonModuleProps | import("./modules").AndroidModuleProps;
13
- export declare const getIosModule: () => import("./modules").IosModuleProps | import("./modules/iosSk2").IosModulePropsSk2;
14
- export declare const getNativeModule: () => import("./modules").AmazonModuleProps | import("./modules").AndroidModuleProps | import("./modules").IosModuleProps | import("./modules/iosSk2").IosModulePropsSk2;
1
+ import * as IapAmazon from './modules/amazon';
2
+ import * as IapAndroid from './modules/android';
3
+ import * as IapIos from './modules/ios';
4
+ import * as IapIosSk2 from './modules/iosSk2';
5
+ import { enableStorekit2, isIosStorekit2 } from './internal';
6
+ import { Product, ProductPurchase, PurchaseResult, RequestPurchase, RequestSubscription, Subscription, SubscriptionPurchase } from './types';
7
+ export { IapAndroid, IapAmazon, IapIos, IapIosSk2, isIosStorekit2, enableStorekit2, };
15
8
  /**
16
9
  * Init module for purchase flow. Required on Android. In ios it will check whether user canMakePayment.
17
10
  * ## Usage
@@ -406,109 +399,3 @@ export declare const finishTransaction: ({ purchase, isConsumable, developerPayl
406
399
  isConsumable?: boolean | undefined;
407
400
  developerPayloadAndroid?: string | undefined;
408
401
  }) => Promise<PurchaseResult | boolean>;
409
- /**
410
- * Clear Transaction (iOS only)
411
- * Finish remaining transactions. Related to issue #257 and #801
412
- * link : https://github.com/dooboolab/react-native-iap/issues/257
413
- * https://github.com/dooboolab/react-native-iap/issues/801
414
- * @returns {Promise<void>}
415
- */
416
- export declare const clearTransactionIOS: () => Promise<void>;
417
- /**
418
- * Clear valid Products (iOS only)
419
- * Remove all products which are validated by Apple server.
420
- * @returns {void}
421
- */
422
- export declare const clearProductsIOS: () => Promise<void>;
423
- /**
424
- * Acknowledge a product (on Android.) No-op on iOS.
425
- * @param {string} token The product's token (on Android)
426
- * @returns {Promise<PurchaseResult | void>}
427
- */
428
- export declare const acknowledgePurchaseAndroid: ({ token, developerPayload, }: {
429
- token: string;
430
- developerPayload?: string | undefined;
431
- }) => Promise<PurchaseResult | boolean | void>;
432
- /**
433
- * Deep link to subscriptions screen on Android. No-op on iOS.
434
- * @param {string} sku The product's SKU (on Android)
435
- * @returns {Promise<void>}
436
- */
437
- export declare const deepLinkToSubscriptionsAndroid: ({ sku, }: {
438
- sku: Sku;
439
- }) => Promise<void>;
440
- /**
441
- * Should Add Store Payment (iOS only)
442
- * Indicates the the App Store purchase should continue from the app instead of the App Store.
443
- * @returns {Promise<Product | null>} promoted product
444
- */
445
- export declare const getPromotedProductIOS: () => Promise<Product | null>;
446
- /**
447
- * Buy the currently selected promoted product (iOS only)
448
- * Initiates the payment process for a promoted product. Should only be called in response to the `iap-promoted-product` event.
449
- * @returns {Promise<void>}
450
- */
451
- export declare const buyPromotedProductIOS: () => Promise<void>;
452
- /**
453
- * Validate receipt for iOS.
454
- * @param {object} receiptBody the receipt body to send to apple server.
455
- * @param {boolean} isTest whether this is in test environment which is sandbox.
456
- * @returns {Promise<Apple.ReceiptValidationResponse | false>}
457
- */
458
- export declare const validateReceiptIos: ({ receiptBody, isTest, }: {
459
- receiptBody: Record<string, unknown>;
460
- isTest?: boolean | undefined;
461
- }) => Promise<ReceiptValidationResponse | false>;
462
- /**
463
- * Validate receipt for Android. NOTE: This method is here for debugging purposes only. Including
464
- * your access token in the binary you ship to users is potentially dangerous.
465
- * Use server side validation instead for your production builds
466
- * @param {string} packageName package name of your app.
467
- * @param {string} productId product id for your in app product.
468
- * @param {string} productToken token for your purchase.
469
- * @param {string} accessToken accessToken from googleApis.
470
- * @param {boolean} isSub whether this is subscription or inapp. `true` for subscription.
471
- * @returns {Promise<object>}
472
- */
473
- export declare const validateReceiptAndroid: ({ packageName, productId, productToken, accessToken, isSub, }: {
474
- packageName: string;
475
- productId: string;
476
- productToken: string;
477
- accessToken: string;
478
- isSub?: boolean | undefined;
479
- }) => Promise<Android.ReceiptType>;
480
- /**
481
- * Validate receipt for Amazon. NOTE: This method is here for debugging purposes only. Including
482
- * your developer secret in the binary you ship to users is potentially dangerous.
483
- * Use server side validation instead for your production builds
484
- * @param {string} developerSecret: from the Amazon developer console.
485
- * @param {string} userId who purchased the item.
486
- * @param {string} receiptId long obfuscated string returned when purchasing the item
487
- * @param {boolean} useSandbox Defaults to true, use sandbox environment or production.
488
- * @returns {Promise<object>}
489
- */
490
- export declare const validateReceiptAmazon: ({ developerSecret, userId, receiptId, useSandbox, }: {
491
- developerSecret: string;
492
- userId: string;
493
- receiptId: string;
494
- useSandbox: boolean;
495
- }) => Promise<Amazon.ReceiptType>;
496
- /**
497
- * Get the current receipt base64 encoded in IOS.
498
- * @param {forceRefresh?:boolean}
499
- * @returns {Promise<ProductPurchase[]>}
500
- */
501
- export declare const getPendingPurchasesIOS: () => Promise<ProductPurchase[]>;
502
- /**
503
- * Get the current receipt base64 encoded in IOS.
504
- * @param {forceRefresh?:boolean}
505
- * @returns {Promise<string>}
506
- */
507
- export declare const getReceiptIOS: ({ forceRefresh, }: {
508
- forceRefresh?: boolean | undefined;
509
- }) => Promise<string>;
510
- /**
511
- * Launches a modal to register the redeem offer code in IOS.
512
- * @returns {Promise<null>}
513
- */
514
- export declare const presentCodeRedemptionSheetIOS: () => Promise<null>;
@@ -1,3 +1,12 @@
1
1
  export declare const isIos: boolean;
2
2
  export declare const isAndroid: boolean;
3
3
  export declare const isAmazon: boolean;
4
+ export declare const setAndroidNativeModule: (nativeModule: import("..").AndroidModuleProps) => void;
5
+ export declare const checkNativeAndroidAvailable: () => void;
6
+ export declare const getAndroidModule: () => import("..").AmazonModuleProps | import("..").AndroidModuleProps;
7
+ export declare const getNativeModule: () => import("..").AmazonModuleProps | import("..").IosModuleProps | import("../modules/iosSk2").IosModulePropsSk2 | import("..").AndroidModuleProps;
8
+ export declare const isIosStorekit2: () => boolean;
9
+ export declare const isStorekit2Avaiable: () => boolean;
10
+ export declare const setIosNativeModule: (nativeModule: import("..").IosModuleProps | import("../modules/iosSk2").IosModulePropsSk2) => void;
11
+ export declare const enableStorekit2: () => boolean;
12
+ export declare const getIosModule: () => import("..").IosModuleProps | import("../modules/iosSk2").IosModulePropsSk2;
@@ -1,5 +1,6 @@
1
1
  import type { Product, Purchase, Sku } from '../types';
2
2
  import type { UserDataAmazon } from '../types/amazon';
3
+ import type * as Amazon from '../types/amazon';
3
4
  import type { NativeModuleProps } from './common';
4
5
  declare type GetUser = () => Promise<UserDataAmazon>;
5
6
  declare type FlushFailedPurchasesCachedAsPending = () => Promise<boolean>;
@@ -20,4 +21,20 @@ export interface AmazonModuleProps extends NativeModuleProps {
20
21
  startListening: StartListening;
21
22
  }
22
23
  export declare const AmazonModule: AmazonModuleProps;
24
+ /**
25
+ * Validate receipt for Amazon. NOTE: This method is here for debugging purposes only. Including
26
+ * your developer secret in the binary you ship to users is potentially dangerous.
27
+ * Use server side validation instead for your production builds
28
+ * @param {string} developerSecret: from the Amazon developer console.
29
+ * @param {string} userId who purchased the item.
30
+ * @param {string} receiptId long obfuscated string returned when purchasing the item
31
+ * @param {boolean} useSandbox Defaults to true, use sandbox environment or production.
32
+ * @returns {Promise<object>}
33
+ */
34
+ export declare const validateReceiptAmazon: ({ developerSecret, userId, receiptId, useSandbox, }: {
35
+ developerSecret: string;
36
+ userId: string;
37
+ receiptId: string;
38
+ useSandbox: boolean;
39
+ }) => Promise<Amazon.ReceiptType>;
23
40
  export {};
@@ -1,4 +1,5 @@
1
- import type { Product, ProductType, ProrationModesAndroid, Purchase, PurchaseResult, Sku } from '../types';
1
+ import { InstallSourceAndroid, Product, ProductType, ProrationModesAndroid, Purchase, PurchaseResult, Sku } from '../types';
2
+ import type * as Android from '../types/android';
2
3
  import type { NativeModuleProps } from './common';
3
4
  declare type FlushFailedPurchasesCachedAsPending = () => Promise<boolean>;
4
5
  declare type GetItemsByType = <T = Product>(type: ProductType, skus: Sku[]) => Promise<T[]>;
@@ -21,4 +22,40 @@ export interface AndroidModuleProps extends NativeModuleProps {
21
22
  getPackageName: GetPackageName;
22
23
  }
23
24
  export declare const AndroidModule: AndroidModuleProps;
25
+ export declare const getInstallSourceAndroid: () => InstallSourceAndroid;
26
+ /**
27
+ * Deep link to subscriptions screen on Android. No-op on iOS.
28
+ * @param {string} sku The product's SKU (on Android)
29
+ * @returns {Promise<void>}
30
+ */
31
+ export declare const deepLinkToSubscriptionsAndroid: ({ sku, }: {
32
+ sku: Sku;
33
+ }) => Promise<void>;
34
+ /**
35
+ * Validate receipt for Android. NOTE: This method is here for debugging purposes only. Including
36
+ * your access token in the binary you ship to users is potentially dangerous.
37
+ * Use server side validation instead for your production builds
38
+ * @param {string} packageName package name of your app.
39
+ * @param {string} productId product id for your in app product.
40
+ * @param {string} productToken token for your purchase.
41
+ * @param {string} accessToken accessToken from googleApis.
42
+ * @param {boolean} isSub whether this is subscription or inapp. `true` for subscription.
43
+ * @returns {Promise<object>}
44
+ */
45
+ export declare const validateReceiptAndroid: ({ packageName, productId, productToken, accessToken, isSub, }: {
46
+ packageName: string;
47
+ productId: string;
48
+ productToken: string;
49
+ accessToken: string;
50
+ isSub?: boolean | undefined;
51
+ }) => Promise<Android.ReceiptType>;
52
+ /**
53
+ * Acknowledge a product (on Android.) No-op on iOS.
54
+ * @param {string} token The product's token (on Android)
55
+ * @returns {Promise<PurchaseResult | void>}
56
+ */
57
+ export declare const acknowledgePurchaseAndroid: ({ token, developerPayload, }: {
58
+ token: string;
59
+ developerPayload?: string | undefined;
60
+ }) => Promise<PurchaseResult | boolean | void>;
24
61
  export {};
@@ -1,3 +1,4 @@
1
+ import type { ResponseBody as ReceiptValidationResponse } from '@jeremybarbet/apple-api-types';
1
2
  import type { Product, ProductPurchase, Purchase, Sku, Subscription } from '../types';
2
3
  import type { PaymentDiscount } from '../types/apple';
3
4
  import type { NativeModuleProps } from './common';
@@ -25,4 +26,59 @@ export interface IosModuleProps extends NativeModuleProps {
25
26
  getPendingTransactions: getPendingTransactions;
26
27
  presentCodeRedemptionSheet: presentCodeRedemptionSheet;
27
28
  }
29
+ /**
30
+ * Get the current receipt base64 encoded in IOS.
31
+ * @param {forceRefresh?:boolean}
32
+ * @returns {Promise<ProductPurchase[]>}
33
+ */
34
+ export declare const getPendingPurchasesIOS: () => Promise<ProductPurchase[]>;
35
+ /**
36
+ * Get the current receipt base64 encoded in IOS.
37
+ * @param {forceRefresh?:boolean}
38
+ * @returns {Promise<string>}
39
+ */
40
+ export declare const getReceiptIOS: ({ forceRefresh, }: {
41
+ forceRefresh?: boolean | undefined;
42
+ }) => Promise<string>;
43
+ /**
44
+ * Launches a modal to register the redeem offer code in IOS.
45
+ * @returns {Promise<null>}
46
+ */
47
+ export declare const presentCodeRedemptionSheetIOS: () => Promise<null>;
48
+ /**
49
+ * Should Add Store Payment (iOS only)
50
+ * Indicates the the App Store purchase should continue from the app instead of the App Store.
51
+ * @returns {Promise<Product | null>} promoted product
52
+ */
53
+ export declare const getPromotedProductIOS: () => Promise<Product | null>;
54
+ /**
55
+ * Buy the currently selected promoted product (iOS only)
56
+ * Initiates the payment process for a promoted product. Should only be called in response to the `iap-promoted-product` event.
57
+ * @returns {Promise<void>}
58
+ */
59
+ export declare const buyPromotedProductIOS: () => Promise<void>;
60
+ /**
61
+ * Validate receipt for iOS.
62
+ * @param {object} receiptBody the receipt body to send to apple server.
63
+ * @param {boolean} isTest whether this is in test environment which is sandbox.
64
+ * @returns {Promise<Apple.ReceiptValidationResponse | false>}
65
+ */
66
+ export declare const validateReceiptIos: ({ receiptBody, isTest, }: {
67
+ receiptBody: Record<string, unknown>;
68
+ isTest?: boolean | undefined;
69
+ }) => Promise<ReceiptValidationResponse | false>;
70
+ /**
71
+ * Clear Transaction (iOS only)
72
+ * Finish remaining transactions. Related to issue #257 and #801
73
+ * link : https://github.com/dooboolab/react-native-iap/issues/257
74
+ * https://github.com/dooboolab/react-native-iap/issues/801
75
+ * @returns {Promise<void>}
76
+ */
77
+ export declare const clearTransactionIOS: () => Promise<void>;
78
+ /**
79
+ * Clear valid Products (iOS only)
80
+ * Remove all products which are validated by Apple server.
81
+ * @returns {void}
82
+ */
83
+ export declare const clearProductsIOS: () => Promise<void>;
28
84
  export {};
@@ -1,5 +1,5 @@
1
1
  import type { Product, ProductPurchase, Purchase, Sku } from '../types';
2
- import type { PaymentDiscountSk2, ProductSk2 } from '../types/appleSk2';
2
+ import type { PaymentDiscountSk2, ProductSk2, ProductStatus, TransactionSk2 } from '../types/appleSk2';
3
3
  import type { NativeModuleProps } from './common';
4
4
  declare type getItems = (skus: Sku[]) => Promise<ProductSk2[]>;
5
5
  declare type getAvailableItems = () => Promise<Purchase[]>;
@@ -13,6 +13,11 @@ declare type finishTransaction = (transactionIdentifier: string) => Promise<bool
13
13
  declare type getPendingTransactions = () => Promise<ProductPurchase[]>;
14
14
  declare type presentCodeRedemptionSheet = () => Promise<null>;
15
15
  export interface IosModulePropsSk2 extends NativeModuleProps {
16
+ latestTransaction(sku: string): Promise<TransactionSk2>;
17
+ currentEntitlement(sku: string): Promise<TransactionSk2>;
18
+ subscriptionStatus(sku: string): Promise<ProductStatus[]>;
19
+ isEligibleForIntroOffer(groupID: string): Promise<Boolean>;
20
+ sync(): Promise<null>;
16
21
  getItems: getItems;
17
22
  getAvailableItems: getAvailableItems;
18
23
  buyProduct: BuyProduct;
@@ -25,4 +30,25 @@ export interface IosModulePropsSk2 extends NativeModuleProps {
25
30
  getPendingTransactions: getPendingTransactions;
26
31
  presentCodeRedemptionSheet: presentCodeRedemptionSheet;
27
32
  }
33
+ /**
34
+ * Sync state with Appstore (iOS only)
35
+ * https://developer.apple.com/documentation/storekit/appstore/3791906-sync
36
+ */
37
+ export declare const sync: () => Promise<null>;
38
+ /**
39
+ *
40
+ */
41
+ export declare const isEligibleForIntroOffer: (groupID: string) => Promise<Boolean>;
42
+ /**
43
+ *
44
+ */
45
+ export declare const subscriptionStatus: (sku: string) => Promise<ProductStatus[]>;
46
+ /**
47
+ *
48
+ */
49
+ export declare const currentEntitlement: (sku: string) => Promise<TransactionSk2>;
50
+ /**
51
+ *
52
+ */
53
+ export declare const latestTransaction: (sku: string) => Promise<TransactionSk2>;
28
54
  export {};
@@ -38,6 +38,10 @@ export declare type TransactionSk2 = {
38
38
  subscriptionGroupID: number;
39
39
  webOrderLineItemID: number;
40
40
  };
41
+ export declare type SubscriptionStatus = 'expired' | 'inBillingRetryPeriod' | 'inGracePeriod' | 'revoked' | 'subscribed';
42
+ export declare type ProductStatus = {
43
+ state: SubscriptionStatus;
44
+ };
41
45
  export declare const transactionSk2Map: ({ id, originalPurchaseDate, productID, purchaseDate, purchasedQuantity, }: TransactionSk2) => Purchase;
42
46
  /**
43
47
  * Payment discount interface @see https://developer.apple.com/documentation/storekit/skpaymentdiscount?language=objc
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-iap",
3
- "version": "11.0.0-beta.1",
3
+ "version": "11.0.0-rc.2",
4
4
  "description": "React Native In App Purchase Module.",
5
5
  "repository": "https://github.com/dooboolab/react-native-iap",
6
6
  "author": "dooboolab <support@dooboolab.com> (https://github.com/dooboolab)",
@@ -1,13 +1,14 @@
1
1
  import {EmitterSubscription, NativeEventEmitter} from 'react-native';
2
2
 
3
3
  import {transactionSk2Map} from './types/appleSk2';
4
+ import {isIosStorekit2} from './iap';
4
5
  import {
5
6
  getAndroidModule,
6
7
  getIosModule,
7
8
  getNativeModule,
8
- isIosStorekit2,
9
- } from './iap';
10
- import {isAndroid, isIos} from './internal';
9
+ isAndroid,
10
+ isIos,
11
+ } from './internal';
11
12
  import type {PurchaseError} from './purchaseError';
12
13
  import type {Purchase} from './types';
13
14
 
@@ -5,7 +5,7 @@ import {
5
5
  purchaseErrorListener,
6
6
  purchaseUpdatedListener,
7
7
  } from '../eventEmitter';
8
- import {getPromotedProductIOS, initConnection} from '../iap';
8
+ import {IapIos, initConnection} from '../iap';
9
9
  import type {PurchaseError} from '../purchaseError';
10
10
  import type {
11
11
  Product,
@@ -135,7 +135,7 @@ export function withIAPContext<T>(Component: React.ComponentType<T>) {
135
135
  );
136
136
 
137
137
  const promotedProductSubscription = promotedProductListener(async () => {
138
- const product = await getPromotedProductIOS();
138
+ const product = await IapIos.getPromotedProductIOS();
139
139
 
140
140
  setPromotedProductsIOS((prevProducts) => [
141
141
  ...prevProducts,