react-native-iap 12.8.3 → 12.8.4

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 (96) hide show
  1. package/android/build.gradle +1 -1
  2. package/ios/RNIapIos.swift +28 -31
  3. package/lib/commonjs/eventEmitter.js.map +1 -1
  4. package/lib/commonjs/hooks/index.js.map +1 -1
  5. package/lib/commonjs/hooks/useIAP.js.map +1 -1
  6. package/lib/commonjs/hooks/withIAPContext.js.map +1 -1
  7. package/lib/commonjs/iap.js.map +1 -1
  8. package/lib/commonjs/index.js.map +1 -1
  9. package/lib/commonjs/internal/enhancedFetch.js.map +1 -1
  10. package/lib/commonjs/internal/fillProductsWithAdditionalData.js.map +1 -1
  11. package/lib/commonjs/internal/index.js.map +1 -1
  12. package/lib/commonjs/internal/platform.js.map +1 -1
  13. package/lib/commonjs/modules/amazon.js.map +1 -1
  14. package/lib/commonjs/modules/android.js.map +1 -1
  15. package/lib/commonjs/modules/common.js.map +1 -1
  16. package/lib/commonjs/modules/index.js.map +1 -1
  17. package/lib/commonjs/modules/ios.js +27 -8
  18. package/lib/commonjs/modules/ios.js.map +1 -1
  19. package/lib/commonjs/modules/iosSk2.js.map +1 -1
  20. package/lib/commonjs/purchaseError.js.map +1 -1
  21. package/lib/commonjs/types/amazon.js.map +1 -1
  22. package/lib/commonjs/types/android.js.map +1 -1
  23. package/lib/commonjs/types/apple.js.map +1 -1
  24. package/lib/commonjs/types/appleSk2.js.map +1 -1
  25. package/lib/commonjs/types/index.js.map +1 -1
  26. package/lib/module/eventEmitter.js.map +1 -1
  27. package/lib/module/hooks/index.js.map +1 -1
  28. package/lib/module/hooks/useIAP.js.map +1 -1
  29. package/lib/module/hooks/withIAPContext.js.map +1 -1
  30. package/lib/module/iap.js.map +1 -1
  31. package/lib/module/index.js.map +1 -1
  32. package/lib/module/internal/enhancedFetch.js.map +1 -1
  33. package/lib/module/internal/fillProductsWithAdditionalData.js.map +1 -1
  34. package/lib/module/internal/index.js.map +1 -1
  35. package/lib/module/internal/platform.js.map +1 -1
  36. package/lib/module/modules/amazon.js.map +1 -1
  37. package/lib/module/modules/android.js.map +1 -1
  38. package/lib/module/modules/common.js.map +1 -1
  39. package/lib/module/modules/index.js.map +1 -1
  40. package/lib/module/modules/ios.js +27 -8
  41. package/lib/module/modules/ios.js.map +1 -1
  42. package/lib/module/modules/iosSk2.js.map +1 -1
  43. package/lib/module/purchaseError.js.map +1 -1
  44. package/lib/module/types/amazon.js.map +1 -1
  45. package/lib/module/types/android.js.map +1 -1
  46. package/lib/module/types/apple.js.map +1 -1
  47. package/lib/module/types/appleSk2.js.map +1 -1
  48. package/lib/module/types/index.js.map +1 -1
  49. package/lib/typescript/plugin/src/withIAP.d.ts +1 -0
  50. package/lib/typescript/plugin/src/withIAP.d.ts.map +1 -0
  51. package/lib/typescript/src/eventEmitter.d.ts +1 -0
  52. package/lib/typescript/src/eventEmitter.d.ts.map +1 -0
  53. package/lib/typescript/src/hooks/index.d.ts +1 -0
  54. package/lib/typescript/src/hooks/index.d.ts.map +1 -0
  55. package/lib/typescript/src/hooks/useIAP.d.ts +1 -0
  56. package/lib/typescript/src/hooks/useIAP.d.ts.map +1 -0
  57. package/lib/typescript/src/hooks/withIAPContext.d.ts +1 -0
  58. package/lib/typescript/src/hooks/withIAPContext.d.ts.map +1 -0
  59. package/lib/typescript/src/iap.d.ts +1 -0
  60. package/lib/typescript/src/iap.d.ts.map +1 -0
  61. package/lib/typescript/src/index.d.ts +1 -0
  62. package/lib/typescript/src/index.d.ts.map +1 -0
  63. package/lib/typescript/src/internal/enhancedFetch.d.ts +1 -1
  64. package/lib/typescript/src/internal/enhancedFetch.d.ts.map +1 -0
  65. package/lib/typescript/src/internal/fillProductsWithAdditionalData.d.ts +1 -0
  66. package/lib/typescript/src/internal/fillProductsWithAdditionalData.d.ts.map +1 -0
  67. package/lib/typescript/src/internal/index.d.ts +1 -0
  68. package/lib/typescript/src/internal/index.d.ts.map +1 -0
  69. package/lib/typescript/src/internal/platform.d.ts +1 -0
  70. package/lib/typescript/src/internal/platform.d.ts.map +1 -0
  71. package/lib/typescript/src/modules/amazon.d.ts +1 -0
  72. package/lib/typescript/src/modules/amazon.d.ts.map +1 -0
  73. package/lib/typescript/src/modules/android.d.ts +1 -0
  74. package/lib/typescript/src/modules/android.d.ts.map +1 -0
  75. package/lib/typescript/src/modules/common.d.ts +1 -0
  76. package/lib/typescript/src/modules/common.d.ts.map +1 -0
  77. package/lib/typescript/src/modules/index.d.ts +1 -0
  78. package/lib/typescript/src/modules/index.d.ts.map +1 -0
  79. package/lib/typescript/src/modules/ios.d.ts +30 -10
  80. package/lib/typescript/src/modules/ios.d.ts.map +1 -0
  81. package/lib/typescript/src/modules/iosSk2.d.ts +1 -0
  82. package/lib/typescript/src/modules/iosSk2.d.ts.map +1 -0
  83. package/lib/typescript/src/purchaseError.d.ts +1 -0
  84. package/lib/typescript/src/purchaseError.d.ts.map +1 -0
  85. package/lib/typescript/src/types/amazon.d.ts +1 -0
  86. package/lib/typescript/src/types/amazon.d.ts.map +1 -0
  87. package/lib/typescript/src/types/android.d.ts +1 -0
  88. package/lib/typescript/src/types/android.d.ts.map +1 -0
  89. package/lib/typescript/src/types/apple.d.ts +1 -0
  90. package/lib/typescript/src/types/apple.d.ts.map +1 -0
  91. package/lib/typescript/src/types/appleSk2.d.ts +1 -0
  92. package/lib/typescript/src/types/appleSk2.d.ts.map +1 -0
  93. package/lib/typescript/src/types/index.d.ts +1 -0
  94. package/lib/typescript/src/types/index.d.ts.map +1 -0
  95. package/package.json +19 -19
  96. package/src/modules/ios.ts +29 -10
@@ -1 +1 @@
1
- {"version":3,"names":["ErrorCode","PurchaseError","constructor","name","message","responseCode","debugMessage","code","productId"],"sources":["purchaseError.ts"],"sourcesContent":["export enum ErrorCode {\n E_UNKNOWN = 'E_UNKNOWN',\n E_USER_CANCELLED = 'E_USER_CANCELLED',\n E_USER_ERROR = 'E_USER_ERROR',\n E_ITEM_UNAVAILABLE = 'E_ITEM_UNAVAILABLE',\n E_REMOTE_ERROR = 'E_REMOTE_ERROR',\n E_NETWORK_ERROR = 'E_NETWORK_ERROR',\n E_SERVICE_ERROR = 'E_SERVICE_ERROR',\n E_RECEIPT_FAILED = 'E_RECEIPT_FAILED',\n E_RECEIPT_FINISHED_FAILED = 'E_RECEIPT_FINISHED_FAILED',\n E_NOT_PREPARED = 'E_NOT_PREPARED',\n E_NOT_ENDED = 'E_NOT_ENDED',\n E_ALREADY_OWNED = 'E_ALREADY_OWNED',\n E_DEVELOPER_ERROR = 'E_DEVELOPER_ERROR',\n E_BILLING_RESPONSE_JSON_PARSE_ERROR = 'E_BILLING_RESPONSE_JSON_PARSE_ERROR',\n E_DEFERRED_PAYMENT = 'E_DEFERRED_PAYMENT',\n E_INTERRUPTED = 'E_INTERRUPTED',\n E_IAP_NOT_AVAILABLE = 'E_IAP_NOT_AVAILABLE',\n}\n\nexport class PurchaseError implements Error {\n constructor(\n public name: string,\n public message: string,\n public responseCode?: number,\n public debugMessage?: string,\n public code?: ErrorCode,\n public productId?: string,\n ) {\n this.name = '[react-native-iap]: PurchaseError';\n this.message = message;\n this.responseCode = responseCode;\n this.debugMessage = debugMessage;\n this.code = code;\n this.productId = productId;\n }\n}\n"],"mappings":";;;;;;IAAYA,S;;;WAAAA,S;EAAAA,S;EAAAA,S;EAAAA,S;EAAAA,S;EAAAA,S;EAAAA,S;EAAAA,S;EAAAA,S;EAAAA,S;EAAAA,S;EAAAA,S;EAAAA,S;EAAAA,S;EAAAA,S;EAAAA,S;EAAAA,S;EAAAA,S;GAAAA,S,yBAAAA,S;;AAoBL,MAAMC,aAAN,CAAqC;EAC1CC,WAAW,CACFC,IADE,EAEFC,OAFE,EAGFC,YAHE,EAIFC,YAJE,EAKFC,IALE,EAMFC,SANE,EAOT;IAAA,KANOL,IAMP,GANOA,IAMP;IAAA,KALOC,OAKP,GALOA,OAKP;IAAA,KAJOC,YAIP,GAJOA,YAIP;IAAA,KAHOC,YAGP,GAHOA,YAGP;IAAA,KAFOC,IAEP,GAFOA,IAEP;IAAA,KADOC,SACP,GADOA,SACP;IACA,KAAKL,IAAL,GAAY,mCAAZ;IACA,KAAKC,OAAL,GAAeA,OAAf;IACA,KAAKC,YAAL,GAAoBA,YAApB;IACA,KAAKC,YAAL,GAAoBA,YAApB;IACA,KAAKC,IAAL,GAAYA,IAAZ;IACA,KAAKC,SAAL,GAAiBA,SAAjB;EACD;;AAfyC"}
1
+ {"version":3,"names":["ErrorCode","PurchaseError","constructor","name","message","responseCode","debugMessage","code","productId"],"sourceRoot":"../../src","sources":["purchaseError.ts"],"mappings":";;;;;;IAAYA,S;;;WAAAA,S;EAAAA,S;EAAAA,S;EAAAA,S;EAAAA,S;EAAAA,S;EAAAA,S;EAAAA,S;EAAAA,S;EAAAA,S;EAAAA,S;EAAAA,S;EAAAA,S;EAAAA,S;EAAAA,S;EAAAA,S;EAAAA,S;EAAAA,S;GAAAA,S,yBAAAA,S;;AAoBL,MAAMC,aAAN,CAAqC;EAC1CC,WAAW,CACFC,IADE,EAEFC,OAFE,EAGFC,YAHE,EAIFC,YAJE,EAKFC,IALE,EAMFC,SANE,EAOT;IAAA,KANOL,IAMP,GANOA,IAMP;IAAA,KALOC,OAKP,GALOA,OAKP;IAAA,KAJOC,YAIP,GAJOA,YAIP;IAAA,KAHOC,YAGP,GAHOA,YAGP;IAAA,KAFOC,IAEP,GAFOA,IAEP;IAAA,KADOC,SACP,GADOA,SACP;IACA,KAAKL,IAAL,GAAY,mCAAZ;IACA,KAAKC,OAAL,GAAeA,OAAf;IACA,KAAKC,YAAL,GAAoBA,YAApB;IACA,KAAKC,YAAL,GAAoBA,YAApB;IACA,KAAKC,IAAL,GAAYA,IAAZ;IACA,KAAKC,SAAL,GAAiBA,SAAjB;EACD;;AAfyC"}
@@ -1 +1 @@
1
- {"version":3,"names":[],"sources":["amazon.ts"],"sourcesContent":["export interface UserDataAmazon {\n userIdAmazon?: string;\n userMarketplaceAmazon?: string;\n userJsonAmazon?: string;\n}\n\nexport interface ProductPurchaseAmazon extends UserDataAmazon {\n isCanceledAmazon?: boolean;\n}\n/**\n * From: https://developer.amazon.com/es/docs/in-app-purchasing/iap-rvs-examples.html\n */\nexport type ReceiptType = {\n autoRenewing: boolean;\n betaProduct: boolean;\n cancelDate: number | null;\n cancelReason: string;\n deferredDate: number | null;\n deferredSku: number | null;\n freeTrialEndDate: number;\n gracePeriodEndDate: number;\n parentProductId: string;\n productId: string;\n productType: string;\n purchaseDate: number;\n quantity: number;\n receiptId: string;\n renewalDate: number;\n term: string;\n termSku: string;\n testTransaction: boolean;\n} & Record<string, unknown>;\n\nexport type AmazonLicensingStatus =\n | 'LICENSED'\n | 'NOT_LICENSED'\n | 'EXPIRED'\n | 'ERROR_VERIFICATION'\n | 'ERROR_INVALID_LICENSING_KEYS'\n | 'UNKNOWN_ERROR';\n"],"mappings":""}
1
+ {"version":3,"names":[],"sourceRoot":"../../../src","sources":["types/amazon.ts"],"mappings":""}
@@ -1 +1 @@
1
- {"version":3,"names":["AndroidPurchaseState","AndroidPurchaseType","AndroidConsumptionState","AndroidAcknowledgementState","singleProductAndroidMap","originalProd","prod","price","oneTimePurchaseOfferDetails","formattedPrice","localizedPrice","currency","priceCurrencyCode"],"sources":["android.ts"],"sourcesContent":["import type {ProductAndroid} from '.';\n\nexport enum AndroidPurchaseState {\n purchased = 0,\n canceled = 1,\n pending = 2,\n}\n\nexport enum AndroidPurchaseType {\n test = 0,\n promo = 1,\n rewarded = 2,\n}\n\nexport enum AndroidConsumptionState {\n yet = 0,\n consumed = 1,\n}\n\nexport enum AndroidAcknowledgementState {\n yet = 0,\n acknowledged = 1,\n}\n\n/**\n * Get a list of products (consumable and non-consumable items, but not subscriptions)\n * @param {number} startTimeMillis The time the product was purchased, in milliseconds since the epoch (Jan 1, 1970).\n * @param {number} expiryTimeMillis The time the product expires, in milliseconds since the epoch (Jan 1, 1970).\n * @param {boolean} autoRenewing Check if it is a renewable product.\n * @param {string} priceCurrencyCode The price currency.\n * @param {number} priceAmountMicros Price amount int micros.\n * @param {string} countryCode Country code.\n * @param {string} developerPayload Developer payload.\n * @param {string} orderId Order id.\n * @param {AndroidPurchaseType} purchaseType Purchase type.\n * @param {AndroidAcknowledgementState} acknowledgementState Check if product is acknowledged.\n * @param {string} kind\n */\nexport type ReceiptType = {\n startTimeMillis: number;\n expiryTimeMillis: number;\n autoRenewing: boolean;\n priceCurrencyCode: string;\n priceAmountMicros: number;\n countryCode: string;\n developerPayload: string;\n orderId: string;\n consumptionState?: AndroidConsumptionState;\n purchaseState: AndroidPurchaseState;\n purchaseType: AndroidPurchaseType;\n acknowledgementState: AndroidAcknowledgementState;\n kind: string;\n} & Record<string, unknown>;\n\n/** Added to maintain backwards compatibility */\nexport const singleProductAndroidMap = (\n originalProd: ProductAndroid,\n): ProductAndroid => {\n const prod: ProductAndroid = {\n ...originalProd,\n //legacy properties\n price:\n originalProd.oneTimePurchaseOfferDetails?.formattedPrice ??\n originalProd.price,\n localizedPrice:\n originalProd.oneTimePurchaseOfferDetails?.formattedPrice ??\n originalProd.price,\n currency:\n originalProd.oneTimePurchaseOfferDetails?.priceCurrencyCode ??\n originalProd.currency,\n };\n return prod;\n};\n"],"mappings":";;;;;;IAEYA,oB;;;WAAAA,oB;EAAAA,oB,CAAAA,oB;EAAAA,oB,CAAAA,oB;EAAAA,oB,CAAAA,oB;GAAAA,oB,oCAAAA,oB;;IAMAC,mB;;;WAAAA,mB;EAAAA,mB,CAAAA,mB;EAAAA,mB,CAAAA,mB;EAAAA,mB,CAAAA,mB;GAAAA,mB,mCAAAA,mB;;IAMAC,uB;;;WAAAA,uB;EAAAA,uB,CAAAA,uB;EAAAA,uB,CAAAA,uB;GAAAA,uB,uCAAAA,uB;;IAKAC,2B;AAKZ;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;WAlBYA,2B;EAAAA,2B,CAAAA,2B;EAAAA,2B,CAAAA,2B;GAAAA,2B,2CAAAA,2B;;AAmCZ;AACO,MAAMC,uBAAuB,GAClCC,YADqC,IAElB;EAAA;;EACnB,MAAMC,IAAoB,GAAG,EAC3B,GAAGD,YADwB;IAE3B;IACAE,KAAK,EACH,0BAAAF,YAAY,CAACG,2BAAb,gFAA0CC,cAA1C,KACAJ,YAAY,CAACE,KALY;IAM3BG,cAAc,EACZ,2BAAAL,YAAY,CAACG,2BAAb,kFAA0CC,cAA1C,KACAJ,YAAY,CAACE,KARY;IAS3BI,QAAQ,EACN,2BAAAN,YAAY,CAACG,2BAAb,kFAA0CI,iBAA1C,KACAP,YAAY,CAACM;EAXY,CAA7B;EAaA,OAAOL,IAAP;AACD,CAjBM"}
1
+ {"version":3,"names":["AndroidPurchaseState","AndroidPurchaseType","AndroidConsumptionState","AndroidAcknowledgementState","singleProductAndroidMap","originalProd","prod","price","oneTimePurchaseOfferDetails","formattedPrice","localizedPrice","currency","priceCurrencyCode"],"sourceRoot":"../../../src","sources":["types/android.ts"],"mappings":";;;;;;IAEYA,oB;;;WAAAA,oB;EAAAA,oB,CAAAA,oB;EAAAA,oB,CAAAA,oB;EAAAA,oB,CAAAA,oB;GAAAA,oB,oCAAAA,oB;;IAMAC,mB;;;WAAAA,mB;EAAAA,mB,CAAAA,mB;EAAAA,mB,CAAAA,mB;EAAAA,mB,CAAAA,mB;GAAAA,mB,mCAAAA,mB;;IAMAC,uB;;;WAAAA,uB;EAAAA,uB,CAAAA,uB;EAAAA,uB,CAAAA,uB;GAAAA,uB,uCAAAA,uB;;IAKAC,2B;AAKZ;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;WAlBYA,2B;EAAAA,2B,CAAAA,2B;EAAAA,2B,CAAAA,2B;GAAAA,2B,2CAAAA,2B;;AAmCZ;AACO,MAAMC,uBAAuB,GAClCC,YADqC,IAElB;EAAA;;EACnB,MAAMC,IAAoB,GAAG,EAC3B,GAAGD,YADwB;IAE3B;IACAE,KAAK,EACH,0BAAAF,YAAY,CAACG,2BAAb,gFAA0CC,cAA1C,KACAJ,YAAY,CAACE,KALY;IAM3BG,cAAc,EACZ,2BAAAL,YAAY,CAACG,2BAAb,kFAA0CC,cAA1C,KACAJ,YAAY,CAACE,KARY;IAS3BI,QAAQ,EACN,2BAAAN,YAAY,CAACG,2BAAb,kFAA0CI,iBAA1C,KACAP,YAAY,CAACM;EAXY,CAA7B;EAaA,OAAOL,IAAP;AACD,CAjBM"}
@@ -1 +1 @@
1
- {"version":3,"names":["offerToRecord","offer","undefined","identifier","keyIdentifier","nonce","signature","timestamp","toString"],"sources":["apple.ts"],"sourcesContent":["/**\n * Payment discount interface @see https://developer.apple.com/documentation/storekit/skpaymentdiscount?language=objc\n */\nexport interface PaymentDiscount {\n /**\n * A string used to uniquely identify a discount offer for a product.\n */\n identifier: string;\n\n /**\n * A string that identifies the key used to generate the signature.\n */\n keyIdentifier: 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 offerToRecord = (\n offer: PaymentDiscount | undefined,\n): Record<keyof PaymentDiscount, string> | undefined => {\n if (!offer) {\n return undefined;\n }\n return {\n identifier: offer.identifier,\n keyIdentifier: offer.keyIdentifier,\n nonce: offer.nonce,\n signature: offer.signature,\n timestamp: offer.timestamp.toString(),\n };\n};\n"],"mappings":";;;;;;;AAAA;AACA;AACA;AA4BO,MAAMA,aAAa,GACxBC,KAD2B,IAE2B;EACtD,IAAI,CAACA,KAAL,EAAY;IACV,OAAOC,SAAP;EACD;;EACD,OAAO;IACLC,UAAU,EAAEF,KAAK,CAACE,UADb;IAELC,aAAa,EAAEH,KAAK,CAACG,aAFhB;IAGLC,KAAK,EAAEJ,KAAK,CAACI,KAHR;IAILC,SAAS,EAAEL,KAAK,CAACK,SAJZ;IAKLC,SAAS,EAAEN,KAAK,CAACM,SAAN,CAAgBC,QAAhB;EALN,CAAP;AAOD,CAbM"}
1
+ {"version":3,"names":["offerToRecord","offer","undefined","identifier","keyIdentifier","nonce","signature","timestamp","toString"],"sourceRoot":"../../../src","sources":["types/apple.ts"],"mappings":";;;;;;;AAAA;AACA;AACA;AA4BO,MAAMA,aAAa,GACxBC,KAD2B,IAE2B;EACtD,IAAI,CAACA,KAAL,EAAY;IACV,OAAOC,SAAP;EACD;;EACD,OAAO;IACLC,UAAU,EAAEF,KAAK,CAACE,UADb;IAELC,aAAa,EAAEH,KAAK,CAACG,aAFhB;IAGLC,KAAK,EAAEJ,KAAK,CAACI,KAHR;IAILC,SAAS,EAAEL,KAAK,CAACK,SAJZ;IAKLC,SAAS,EAAEN,KAAK,CAACM,SAAN,CAAgBC,QAAhB;EALN,CAAP;AAOD,CAbM"}
@@ -1 +1 @@
1
- {"version":3,"names":["productSk2Map","id","description","displayName","price","displayPrice","prod","title","productId","String","type","localizedPrice","currency","subscriptionSk2Map","subscription","platform","SubscriptionPlatform","ios","subscriptionPeriodNumberIOS","subscriptionPeriod","value","subscriptionPeriodUnitIOS","unit","toUpperCase","transactionSk2ToPurchaseMap","originalPurchaseDate","productID","purchaseDate","purchasedQuantity","originalID","purchase","transactionId","transactionDate","transactionReceipt","purchaseToken","quantityIOS","originalTransactionDateIOS","originalTransactionIdentifierIOS","offerSk2Map","offer","undefined","offerID","identifier","keyID","keyIdentifier","nonce","signature","timestamp","toString"],"sources":["appleSk2.ts"],"sourcesContent":["import type {PurchaseError} from '../purchaseError';\n\nimport type {\n ProductIOS,\n Purchase,\n SubscriptionIOS,\n SubscriptionIosPeriod,\n} from '.';\nimport type * as Apple from './apple';\nimport {SubscriptionPlatform} from '.';\n\nexport type SubscriptionPeriod = {\n unit: 'day' | 'week' | 'month' | 'year';\n value: number;\n};\n\nexport type PaymentMode = 'freeTrial' | 'payAsYouGo' | 'payUpFront';\n\nexport type SubscriptionOffer = {\n displayPrice: string;\n id: string;\n paymentMode: PaymentMode;\n period: SubscriptionPeriod;\n periodCount: number;\n price: number;\n type: 'introductory' | 'promotional';\n};\n\nexport type SubscriptionInfo = {\n introductoryOffer?: SubscriptionOffer;\n promotionalOffers?: SubscriptionOffer[];\n subscriptionGroupID: string;\n subscriptionPeriod: SubscriptionPeriod;\n};\n\nexport type RefundRequestStatus = 'success' | 'userCancelled';\n\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: SubscriptionInfo;\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: '', // 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 subscription,\n}: ProductSk2): SubscriptionIOS => {\n const prod: SubscriptionIOS = {\n platform: SubscriptionPlatform.ios,\n title: displayName,\n productId: String(id),\n description,\n type: 'subs',\n price: String(price),\n localizedPrice: displayPrice,\n currency: '', // Not avaiable on new API, use localizedPrice instead\n subscriptionPeriodNumberIOS: `${subscription?.subscriptionPeriod?.value}`,\n subscriptionPeriodUnitIOS:\n subscription?.subscriptionPeriod?.unit.toUpperCase() as SubscriptionIosPeriod,\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 environment?: 'Production' | 'Sandbox' | 'Xcode'; // Could be undefined in some cases on iOS 15, but it's stable since iOS 16\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 TransactionError = PurchaseError;\n\n/**\n * Only one of `transaction` and `error` is not undefined at the time\n */\nexport type TransactionEvent = {\n transaction?: TransactionSk2;\n error?: TransactionError;\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 transactionSk2ToPurchaseMap = ({\n id,\n originalPurchaseDate,\n productID,\n purchaseDate,\n purchasedQuantity,\n originalID,\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: originalPurchaseDate,\n originalTransactionIdentifierIOS: originalID,\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): Record<keyof PaymentDiscountSk2, string> | 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.toString(),\n };\n};\n"],"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CwB,oBAF0C;IAG1CC,SAH0C;IAI1CC,YAJ0C;IAK1CC,iBAL0C;IAM1CC;EAN0C,CAOZ;EAC9B,MAAMC,QAAkB,GAAG;IACzBtB,SAAS,EAAEkB,SADc;IAEzBK,aAAa,EAAEtB,MAAM,CAACR,EAAD,CAFI;IAGzB+B,eAAe,EAAEL,YAHQ;IAGM;IAC/BM,kBAAkB,EAAE,EAJK;IAID;IACxBC,aAAa,EAAE,EALU;IAKN;IACnBC,WAAW,EAAEP,iBANY;IAOzBQ,0BAA0B,EAAEX,oBAPH;IAQzBY,gCAAgC,EAAER;EART,CAA3B;EAUA,OAAOC,QAAP;AACD,CAnBM;AAqBP;AACA;AACA;;;;;AA4BO,MAAMQ,WAAW,GACtBC,KADyB,IAEgC;EACzD,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,SAAN,CAAgBC,QAAhB;EALN,CAAP;AAOD,CAbM"}
1
+ {"version":3,"names":["productSk2Map","id","description","displayName","price","displayPrice","prod","title","productId","String","type","localizedPrice","currency","subscriptionSk2Map","subscription","platform","SubscriptionPlatform","ios","subscriptionPeriodNumberIOS","subscriptionPeriod","value","subscriptionPeriodUnitIOS","unit","toUpperCase","transactionSk2ToPurchaseMap","originalPurchaseDate","productID","purchaseDate","purchasedQuantity","originalID","purchase","transactionId","transactionDate","transactionReceipt","purchaseToken","quantityIOS","originalTransactionDateIOS","originalTransactionIdentifierIOS","offerSk2Map","offer","undefined","offerID","identifier","keyID","keyIdentifier","nonce","signature","timestamp","toString"],"sourceRoot":"../../../src","sources":["types/appleSk2.ts"],"mappings":";;;;;;;AASA;;AAuCO,MAAMA,aAAa,GAAG,QAMC;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C,iBAL0C;IAM1CC;EAN0C,CAOZ;EAC9B,MAAMC,QAAkB,GAAG;IACzBtB,SAAS,EAAEkB,SADc;IAEzBK,aAAa,EAAEtB,MAAM,CAACR,EAAD,CAFI;IAGzB+B,eAAe,EAAEL,YAHQ;IAGM;IAC/BM,kBAAkB,EAAE,EAJK;IAID;IACxBC,aAAa,EAAE,EALU;IAKN;IACnBC,WAAW,EAAEP,iBANY;IAOzBQ,0BAA0B,EAAEX,oBAPH;IAQzBY,gCAAgC,EAAER;EART,CAA3B;EAUA,OAAOC,QAAP;AACD,CAnBM;AAqBP;AACA;AACA;;;;;AA4BO,MAAMQ,WAAW,GACtBC,KADyB,IAEgC;EACzD,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,SAAN,CAAgBC,QAAhB;EALN,CAAP;AAOD,CAbM"}
@@ -1 +1 @@
1
- {"version":3,"names":["ProrationModesAndroid","PurchaseStateAndroid","PROMOTED_PRODUCT","InstallSourceAndroid","ProductType","SubscriptionPlatform"],"sources":["index.ts"],"sourcesContent":["import type {\n AmazonModuleProps,\n AndroidModuleProps,\n IosModuleProps,\n} from '../modules';\nimport type {IosModulePropsSk2} from '../modules/iosSk2';\n\nimport type * as Apple from './apple';\n\nexport type Sku = string;\n\nexport enum ProrationModesAndroid {\n IMMEDIATE_WITH_TIME_PRORATION = 1,\n IMMEDIATE_AND_CHARGE_PRORATED_PRICE = 2,\n IMMEDIATE_WITHOUT_PRORATION = 3,\n DEFERRED = 4,\n IMMEDIATE_AND_CHARGE_FULL_PRICE = 5,\n UNKNOWN_SUBSCRIPTION_UPGRADE_DOWNGRADE_POLICY = 0,\n}\n\nexport enum PurchaseStateAndroid {\n UNSPECIFIED_STATE = 0,\n PURCHASED = 1,\n PENDING = 2,\n}\n\nexport const PROMOTED_PRODUCT = 'iap-promoted-product';\n\nexport enum InstallSourceAndroid {\n NOT_SET = 0,\n GOOGLE_PLAY = 1,\n AMAZON = 2,\n}\n\nexport enum ProductType {\n /** Subscription */\n subs = 'subs',\n\n /** Subscription */\n sub = 'sub',\n\n /** Consumable */\n inapp = 'inapp',\n\n /** Consumable */\n iap = 'iap',\n}\n\nexport interface ProductCommon {\n type: 'subs' | 'sub' | 'inapp' | 'iap';\n productId: string; //iOS\n productIds?: string[];\n title: string;\n description: string;\n price: string;\n currency: string;\n localizedPrice: string;\n countryCode?: string;\n}\n\nexport interface ProductPurchase {\n productId: string;\n transactionId?: string;\n transactionDate: number;\n transactionReceipt: string;\n purchaseToken?: string;\n //iOS\n quantityIOS?: number;\n originalTransactionDateIOS?: number;\n originalTransactionIdentifierIOS?: string;\n //Android\n productIds?: string[];\n dataAndroid?: string;\n signatureAndroid?: string;\n autoRenewingAndroid?: boolean;\n purchaseStateAndroid?: PurchaseStateAndroid;\n isAcknowledgedAndroid?: boolean;\n packageNameAndroid?: string;\n developerPayloadAndroid?: string;\n obfuscatedAccountIdAndroid?: string;\n obfuscatedProfileIdAndroid?: string;\n //Amazon\n userIdAmazon?: string;\n userMarketplaceAmazon?: string;\n userJsonAmazon?: string;\n isCanceledAmazon?: boolean;\n}\n\nexport interface PurchaseResult {\n responseCode?: number;\n debugMessage?: string;\n code?: string;\n message?: string;\n purchaseToken?: string;\n}\n\nexport interface SubscriptionPurchase extends ProductPurchase {\n autoRenewingAndroid?: boolean;\n originalTransactionDateIOS?: number;\n originalTransactionIdentifierIOS?: string;\n}\n\nexport type Purchase = ProductPurchase | SubscriptionPurchase;\n\nexport interface Discount {\n identifier: string;\n type: string;\n numberOfPeriods: string;\n price: string;\n localizedPrice: string;\n paymentMode: '' | 'FREETRIAL' | 'PAYASYOUGO' | 'PAYUPFRONT';\n subscriptionPeriod: string;\n}\n\nexport interface ProductAndroid extends ProductCommon {\n type: 'inapp' | 'iap';\n oneTimePurchaseOfferDetails?: {\n priceCurrencyCode: string;\n formattedPrice: string;\n priceAmountMicros: string;\n };\n}\nexport interface ProductIOS extends ProductCommon {\n type: 'inapp' | 'iap';\n}\n\nexport type Product = ProductAndroid & ProductIOS;\n\n/**\n * Can be used to distinguish the different platforms' subscription information\n */\nexport enum SubscriptionPlatform {\n android = 'android',\n amazon = 'amazon',\n ios = 'ios',\n}\n\n/** Android Billing v5 type */\nexport interface SubscriptionAndroid {\n platform: SubscriptionPlatform.android;\n productType: 'subs';\n name: string;\n title: string;\n description: string;\n productId: string;\n subscriptionOfferDetails: SubscriptionOfferAndroid[];\n}\n\nexport interface SubscriptionOfferAndroid {\n basePlanId: string;\n offerId: string | null;\n offerToken: string;\n pricingPhases: {\n pricingPhaseList: PricingPhaseAndroid[];\n };\n offerTags: string[];\n}\n\nexport interface PricingPhaseAndroid {\n formattedPrice: string;\n priceCurrencyCode: string;\n /**\n * P1W, P1M, P1Y\n */\n billingPeriod: string;\n billingCycleCount: number;\n priceAmountMicros: string;\n recurrenceMode: number;\n}\n\n/**\n * TODO: As of 2022-10-10, this typing is not verified against the real\n * Amazon API. Please update this if you have a more accurate type.\n */\nexport interface SubscriptionAmazon extends ProductCommon {\n platform: SubscriptionPlatform.amazon;\n type: 'subs';\n\n productType?: string;\n name?: string;\n}\n\nexport type SubscriptionIosPeriod = 'DAY' | 'WEEK' | 'MONTH' | 'YEAR' | '';\nexport interface SubscriptionIOS extends ProductCommon {\n platform: SubscriptionPlatform.ios;\n type: 'subs';\n discounts?: Discount[];\n introductoryPrice?: string;\n introductoryPriceAsAmountIOS?: string;\n introductoryPricePaymentModeIOS?:\n | ''\n | 'FREETRIAL'\n | 'PAYASYOUGO'\n | 'PAYUPFRONT';\n introductoryPriceNumberOfPeriodsIOS?: string;\n introductoryPriceSubscriptionPeriodIOS?: SubscriptionIosPeriod;\n\n subscriptionPeriodNumberIOS?: string;\n subscriptionPeriodUnitIOS?: SubscriptionIosPeriod;\n}\n\nexport type Subscription =\n | SubscriptionAndroid\n | SubscriptionAmazon\n | SubscriptionIOS;\n\nexport interface RequestPurchaseBaseAndroid {\n obfuscatedAccountIdAndroid?: string;\n obfuscatedProfileIdAndroid?: string;\n isOfferPersonalized?: boolean; // For AndroidBilling V5 https://developer.android.com/google/play/billing/integrate#personalized-price\n}\n\nexport interface RequestPurchaseAndroid extends RequestPurchaseBaseAndroid {\n skus: Sku[];\n}\n\nexport interface RequestPurchaseIOS {\n sku: Sku;\n andDangerouslyFinishTransactionAutomaticallyIOS?: boolean;\n /**\n * UUID representing user account\n */\n appAccountToken?: string;\n quantity?: number;\n withOffer?: Apple.PaymentDiscount;\n}\n\n/** As of 2022-10-12, we only use the `sku` field for Amazon purchases */\nexport type RequestPurchaseAmazon = RequestPurchaseIOS;\n\nexport type RequestPurchase =\n | RequestPurchaseAndroid\n | RequestPurchaseAmazon\n | RequestPurchaseIOS;\n\n/**\n * In order to purchase a new subscription, every sku must have a selected offerToken\n * @see SubscriptionAndroid.subscriptionOfferDetails.offerToken\n */\nexport interface SubscriptionOffer {\n sku: Sku;\n offerToken: string;\n}\n\nexport interface RequestSubscriptionAndroid extends RequestPurchaseBaseAndroid {\n purchaseTokenAndroid?: string;\n prorationModeAndroid?: ProrationModesAndroid;\n subscriptionOffers: SubscriptionOffer[];\n}\n\nexport type RequestSubscriptionIOS = RequestPurchaseIOS;\n\n/** As of 2022-10-12, we only use the `sku` field for Amazon subscriptions */\nexport type RequestSubscriptionAmazon = RequestSubscriptionIOS;\n\nexport type RequestSubscription =\n | RequestSubscriptionAndroid\n | RequestSubscriptionAmazon\n | RequestSubscriptionIOS;\n\ndeclare module 'react-native' {\n interface NativeModulesStatic {\n RNIapIos: IosModuleProps;\n RNIapIosSk2: IosModulePropsSk2;\n RNIapModule: AndroidModuleProps;\n RNIapAmazonModule: AmazonModuleProps;\n }\n}\n"],"mappings":";;;;;;IAWYA,qB;;;WAAAA,qB;EAAAA,qB,CAAAA,qB;EAAAA,qB,CAAAA,qB;EAAAA,qB,CAAAA,qB;EAAAA,qB,CAAAA,qB;EAAAA,qB,CAAAA,qB;EAAAA,qB,CAAAA,qB;GAAAA,qB,qCAAAA,qB;;IASAC,oB;;;WAAAA,oB;EAAAA,oB,CAAAA,oB;EAAAA,oB,CAAAA,oB;EAAAA,oB,CAAAA,oB;GAAAA,oB,oCAAAA,oB;;AAML,MAAMC,gBAAgB,GAAG,sBAAzB;;IAEKC,oB;;;WAAAA,oB;EAAAA,oB,CAAAA,oB;EAAAA,oB,CAAAA,oB;EAAAA,oB,CAAAA,oB;GAAAA,oB,oCAAAA,oB;;IAMAC,W;;;WAAAA,W;EAAAA,W;EAAAA,W;EAAAA,W;EAAAA,W;GAAAA,W,2BAAAA,W;;AA8FZ;AACA;AACA;IACYC,oB;AAMZ;;;;WANYA,oB;EAAAA,oB;EAAAA,oB;EAAAA,oB;GAAAA,oB,oCAAAA,oB"}
1
+ {"version":3,"names":["ProrationModesAndroid","PurchaseStateAndroid","PROMOTED_PRODUCT","InstallSourceAndroid","ProductType","SubscriptionPlatform"],"sourceRoot":"../../../src","sources":["types/index.ts"],"mappings":";;;;;;IAWYA,qB;;;WAAAA,qB;EAAAA,qB,CAAAA,qB;EAAAA,qB,CAAAA,qB;EAAAA,qB,CAAAA,qB;EAAAA,qB,CAAAA,qB;EAAAA,qB,CAAAA,qB;EAAAA,qB,CAAAA,qB;GAAAA,qB,qCAAAA,qB;;IASAC,oB;;;WAAAA,oB;EAAAA,oB,CAAAA,oB;EAAAA,oB,CAAAA,oB;EAAAA,oB,CAAAA,oB;GAAAA,oB,oCAAAA,oB;;AAML,MAAMC,gBAAgB,GAAG,sBAAzB;;IAEKC,oB;;;WAAAA,oB;EAAAA,oB,CAAAA,oB;EAAAA,oB,CAAAA,oB;EAAAA,oB,CAAAA,oB;GAAAA,oB,oCAAAA,oB;;IAMAC,W;;;WAAAA,W;EAAAA,W;EAAAA,W;EAAAA,W;EAAAA,W;GAAAA,W,2BAAAA,W;;AA8FZ;AACA;AACA;IACYC,oB;AAMZ;;;;WANYA,oB;EAAAA,oB;EAAAA,oB;EAAAA,oB;GAAAA,oB,oCAAAA,oB"}
@@ -1 +1 @@
1
- {"version":3,"names":["NativeEventEmitter","transactionSk2ToPurchaseMap","isIosStorekit2","getIosModule","getNativeModule","isIos","purchaseUpdatedListener","listener","eventEmitter","proxyListener","event","emitterSubscription","addListener","purchaseErrorListener","promotedProductListener","transactionListener"],"sources":["eventEmitter.ts"],"sourcesContent":["import {EmitterSubscription, NativeEventEmitter} from 'react-native';\n\nimport {TransactionEvent, transactionSk2ToPurchaseMap} from './types/appleSk2';\nimport {isIosStorekit2} from './iap';\nimport {getIosModule, getNativeModule, isIos} from './internal';\nimport type {PurchaseError} from './purchaseError';\nimport type {Purchase} from './types';\n\n/**\n * Add IAP purchase event\n * Register a callback that gets called when the store has any updates to purchases that have not yet been finished, consumed or acknowledged. Returns a React Native `EmitterSubscription` on which you can call `.remove()` to stop receiving updates. Register you listener as soon as possible and react to updates at all times.\n\n## Signature\n\n```ts\npurchaseUpdatedListener((purchase: Purchase) => {});\n```\n\n## Usage\n\n```tsx\nimport React, {useEffect} from 'react';\nimport {View} from 'react-native';\nimport {purchaseUpdatedListener} from 'react-native-iap';\n\nconst App = () => {\n useEffect(() => {\n const subscription = purchaseUpdatedListener((purchase: Purchase) => {\n console.log(purchase);\n });\n\n return () => {\n subscription.remove();\n };\n }, []);\n\n return <View />;\n};\n```\n */\nexport const purchaseUpdatedListener = (\n listener: (event: Purchase) => void,\n) => {\n const eventEmitter = new NativeEventEmitter(getNativeModule());\n const proxyListener = isIosStorekit2()\n ? (event: Purchase) => {\n listener(transactionSk2ToPurchaseMap(event as any));\n }\n : listener;\n const emitterSubscription = eventEmitter.addListener(\n 'purchase-updated',\n proxyListener,\n );\n\n return emitterSubscription;\n};\n\n/**\n * Add IAP purchase error event\n * Register a callback that gets called when there has been an error with a purchase. Returns a React Native `EmitterSubscription` on which you can call `.remove()` to stop receiving updates.\n\n## Signature\n\n```ts\npurchaseErrorListener((error: PurchaseError) => {});\n```\n\n## Usage\n\n```tsx\nimport React, {useEffect} from 'react';\nimport {View} from 'react-native';\nimport {purchaseErrorListener} from 'react-native-iap';\n\nconst App = () => {\n useEffect(() => {\n const subscription = purchaseErrorListener((error: PurchaseError) => {\n console.log(error);\n });\n\n return () => {\n subscription.remove();\n };\n }, []);\n\n return <View />;\n};\n```\n\n */\nexport const purchaseErrorListener = (\n listener: (error: PurchaseError) => void,\n): EmitterSubscription => {\n const eventEmitter = new NativeEventEmitter(getNativeModule());\n return eventEmitter.addListener('purchase-error', listener);\n};\n\n/**\n * Add IAP promoted subscription event\n * Add IAP promoted subscription event.\n\n## Signature\n\n```ts\npromotedProductListener((productId?: string) => {});\n```\n\n## Usage\n\n```tsx\nimport React, {useEffect} from 'react';\nimport {View} from 'react-native';\nimport {promotedProductListener} from 'react-native-iap';\n\nconst App = () => {\n useEffect(() => {\n const subscription = promotedProductListener((productId) => {\n console.log(productId);\n });\n\n return () => {\n subscription.remove();\n };\n }, []);\n\n return <View />;\n};\n```\n\n *\n * @platform iOS\n */\nexport const promotedProductListener = (listener: () => void) => {\n if (isIos && !isIosStorekit2()) {\n const eventEmitter = new NativeEventEmitter(getIosModule());\n return eventEmitter.addListener('iap-promoted-product', listener);\n }\n\n return null;\n};\n\n/**\n * Updated transactions for iOS Sk2\n * Register a callback that gets called when the store has any updates to transactions related to purchases that have not yet been finished, consumed or acknowledged. \n * Returns a React Native `EmitterSubscription` on which you can call `.remove()` to stop receiving updates. Register you listener as soon as possible and react to updates at all times.\n\n**Warning**\nThis is only available for iOS 15 and higher and Storekit 2 is activated\n\n## Signature\n\n```ts\npurchaseUpdatedListener((transactionOrError: TransactionOrError) => {});\n```\n\n## Usage\n\n```tsx\nimport React, {useEffect} from 'react';\nimport {View} from 'react-native';\nimport {purchaseUpdatedListener} from 'react-native-iap';\n\nconst App = () => {\n useEffect(() => {\n const subscription = purchaseUpdatedListener((transactionOrError: TransactionOrError) => {\n if(transactionOrError.transaction){\n console.log(\"There's an update to a transaction\", transactionOrError.transaction);\n }else{\n console.log(\"There's been an error with a received transaction\")\n }\n });\n\n return () => {\n subscription.remove();\n };\n }, []);\n\n return <View />;\n};\n```\n *\n * @platform iOS (Sk2)\n */\nexport const transactionListener = (\n listener: (event: TransactionEvent) => void,\n) => {\n if (isIos && isIosStorekit2()) {\n const eventEmitter = new NativeEventEmitter(getIosModule());\n return eventEmitter.addListener('iap-transaction-updated', listener);\n }\n\n return null;\n};\n"],"mappings":"AAAA,SAA6BA,kBAA7B,QAAsD,cAAtD;AAEA,SAA0BC,2BAA1B,QAA4D,kBAA5D;AACA,SAAQC,cAAR,QAA6B,OAA7B;AACA,SAAQC,YAAR,EAAsBC,eAAtB,EAAuCC,KAAvC,QAAmD,YAAnD;;AAIA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,uBAAuB,GAClCC,QADqC,IAElC;EACH,MAAMC,YAAY,GAAG,IAAIR,kBAAJ,CAAuBI,eAAe,EAAtC,CAArB;EACA,MAAMK,aAAa,GAAGP,cAAc,KAC/BQ,KAAD,IAAqB;IACnBH,QAAQ,CAACN,2BAA2B,CAACS,KAAD,CAA5B,CAAR;EACD,CAH+B,GAIhCH,QAJJ;EAKA,MAAMI,mBAAmB,GAAGH,YAAY,CAACI,WAAb,CAC1B,kBAD0B,EAE1BH,aAF0B,CAA5B;EAKA,OAAOE,mBAAP;AACD,CAfM;AAiBP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,MAAME,qBAAqB,GAChCN,QADmC,IAEX;EACxB,MAAMC,YAAY,GAAG,IAAIR,kBAAJ,CAAuBI,eAAe,EAAtC,CAArB;EACA,OAAOI,YAAY,CAACI,WAAb,CAAyB,gBAAzB,EAA2CL,QAA3C,CAAP;AACD,CALM;AAOP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,MAAMO,uBAAuB,GAAIP,QAAD,IAA0B;EAC/D,IAAIF,KAAK,IAAI,CAACH,cAAc,EAA5B,EAAgC;IAC9B,MAAMM,YAAY,GAAG,IAAIR,kBAAJ,CAAuBG,YAAY,EAAnC,CAArB;IACA,OAAOK,YAAY,CAACI,WAAb,CAAyB,sBAAzB,EAAiDL,QAAjD,CAAP;EACD;;EAED,OAAO,IAAP;AACD,CAPM;AASP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,MAAMQ,mBAAmB,GAC9BR,QADiC,IAE9B;EACH,IAAIF,KAAK,IAAIH,cAAc,EAA3B,EAA+B;IAC7B,MAAMM,YAAY,GAAG,IAAIR,kBAAJ,CAAuBG,YAAY,EAAnC,CAArB;IACA,OAAOK,YAAY,CAACI,WAAb,CAAyB,yBAAzB,EAAoDL,QAApD,CAAP;EACD;;EAED,OAAO,IAAP;AACD,CATM"}
1
+ {"version":3,"names":["NativeEventEmitter","transactionSk2ToPurchaseMap","isIosStorekit2","getIosModule","getNativeModule","isIos","purchaseUpdatedListener","listener","eventEmitter","proxyListener","event","emitterSubscription","addListener","purchaseErrorListener","promotedProductListener","transactionListener"],"sourceRoot":"../../src","sources":["eventEmitter.ts"],"mappings":"AAAA,SAA6BA,kBAA7B,QAAsD,cAAtD;AAEA,SAA0BC,2BAA1B,QAA4D,kBAA5D;AACA,SAAQC,cAAR,QAA6B,OAA7B;AACA,SAAQC,YAAR,EAAsBC,eAAtB,EAAuCC,KAAvC,QAAmD,YAAnD;;AAIA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,uBAAuB,GAClCC,QADqC,IAElC;EACH,MAAMC,YAAY,GAAG,IAAIR,kBAAJ,CAAuBI,eAAe,EAAtC,CAArB;EACA,MAAMK,aAAa,GAAGP,cAAc,KAC/BQ,KAAD,IAAqB;IACnBH,QAAQ,CAACN,2BAA2B,CAACS,KAAD,CAA5B,CAAR;EACD,CAH+B,GAIhCH,QAJJ;EAKA,MAAMI,mBAAmB,GAAGH,YAAY,CAACI,WAAb,CAC1B,kBAD0B,EAE1BH,aAF0B,CAA5B;EAKA,OAAOE,mBAAP;AACD,CAfM;AAiBP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,MAAME,qBAAqB,GAChCN,QADmC,IAEX;EACxB,MAAMC,YAAY,GAAG,IAAIR,kBAAJ,CAAuBI,eAAe,EAAtC,CAArB;EACA,OAAOI,YAAY,CAACI,WAAb,CAAyB,gBAAzB,EAA2CL,QAA3C,CAAP;AACD,CALM;AAOP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,MAAMO,uBAAuB,GAAIP,QAAD,IAA0B;EAC/D,IAAIF,KAAK,IAAI,CAACH,cAAc,EAA5B,EAAgC;IAC9B,MAAMM,YAAY,GAAG,IAAIR,kBAAJ,CAAuBG,YAAY,EAAnC,CAArB;IACA,OAAOK,YAAY,CAACI,WAAb,CAAyB,sBAAzB,EAAiDL,QAAjD,CAAP;EACD;;EAED,OAAO,IAAP;AACD,CAPM;AASP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,MAAMQ,mBAAmB,GAC9BR,QADiC,IAE9B;EACH,IAAIF,KAAK,IAAIH,cAAc,EAA3B,EAA+B;IAC7B,MAAMM,YAAY,GAAG,IAAIR,kBAAJ,CAAuBG,YAAY,EAAnC,CAArB;IACA,OAAOK,YAAY,CAACI,WAAb,CAAyB,yBAAzB,EAAoDL,QAApD,CAAP;EACD;;EAED,OAAO,IAAP;AACD,CATM"}
@@ -1 +1 @@
1
- {"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export * from './useIAP';\n"],"mappings":"AAAA,cAAc,UAAd"}
1
+ {"version":3,"names":[],"sourceRoot":"../../../src","sources":["hooks/index.ts"],"mappings":"AAAA,cAAc,UAAd"}
@@ -1 +1 @@
1
- {"version":3,"names":["useCallback","finishTransaction","iapFinishTransaction","getAvailablePurchases","iapGetAvailablePurchases","getProducts","iapGetProducts","getPurchaseHistory","iapGetPurchaseHistory","getSubscriptions","iapGetSubscriptions","requestPurchase","iapRequestPurchase","requestSubscription","iapRequestSubscription","useIAPContext","useIAP","connected","products","promotedProductsIOS","subscriptions","purchaseHistory","availablePurchases","currentPurchase","currentPurchaseError","initConnectionError","setProducts","setSubscriptions","setAvailablePurchases","setPurchaseHistory","setCurrentPurchase","setCurrentPurchaseError","skus","purchase","isConsumable","developerPayloadAndroid","err","productId","undefined"],"sources":["useIAP.ts"],"sourcesContent":["import {useCallback} from 'react';\n\nimport {\n finishTransaction as iapFinishTransaction,\n getAvailablePurchases as iapGetAvailablePurchases,\n getProducts as iapGetProducts,\n getPurchaseHistory as iapGetPurchaseHistory,\n getSubscriptions as iapGetSubscriptions,\n requestPurchase as iapRequestPurchase,\n requestSubscription as iapRequestSubscription,\n} from '../iap';\nimport type {PurchaseError} from '../purchaseError';\nimport type {Product, Purchase, PurchaseResult, Subscription} from '../types';\n\nimport {useIAPContext} from './withIAPContext';\n\ntype IAP_STATUS = {\n connected: boolean;\n products: Product[];\n promotedProductsIOS: Product[];\n subscriptions: Subscription[];\n purchaseHistory: Purchase[];\n availablePurchases: Purchase[];\n currentPurchase?: Purchase;\n currentPurchaseError?: PurchaseError;\n initConnectionError?: Error;\n finishTransaction: ({\n purchase,\n isConsumable,\n developerPayloadAndroid,\n }: {\n purchase: Purchase;\n isConsumable?: boolean;\n developerPayloadAndroid?: string;\n }) => Promise<string | boolean | PurchaseResult | void>;\n getAvailablePurchases: () => Promise<void>;\n getPurchaseHistory: () => Promise<void>;\n getProducts: ({skus}: {skus: string[]}) => Promise<void>;\n getSubscriptions: ({skus}: {skus: string[]}) => Promise<void>;\n requestPurchase: typeof iapRequestPurchase;\n requestSubscription: typeof iapRequestSubscription;\n};\n\nexport const useIAP = (): IAP_STATUS => {\n const {\n connected,\n products,\n promotedProductsIOS,\n subscriptions,\n purchaseHistory,\n availablePurchases,\n currentPurchase,\n currentPurchaseError,\n initConnectionError,\n setProducts,\n setSubscriptions,\n setAvailablePurchases,\n setPurchaseHistory,\n setCurrentPurchase,\n setCurrentPurchaseError,\n } = useIAPContext();\n\n const getProducts = useCallback(\n async ({skus}: {skus: string[]}): Promise<void> => {\n setProducts(await iapGetProducts({skus}));\n },\n [setProducts],\n );\n\n const getSubscriptions = useCallback(\n async ({skus}: {skus: string[]}): Promise<void> => {\n setSubscriptions(await iapGetSubscriptions({skus}));\n },\n [setSubscriptions],\n );\n\n const getAvailablePurchases = useCallback(async (): Promise<void> => {\n setAvailablePurchases(await iapGetAvailablePurchases());\n }, [setAvailablePurchases]);\n\n const getPurchaseHistory = useCallback(async (): Promise<void> => {\n setPurchaseHistory(await iapGetPurchaseHistory());\n }, [setPurchaseHistory]);\n\n const finishTransaction = useCallback(\n async ({\n purchase,\n isConsumable,\n developerPayloadAndroid,\n }: {\n purchase: Purchase;\n isConsumable?: boolean;\n developerPayloadAndroid?: string;\n }): Promise<string | boolean | PurchaseResult | void> => {\n try {\n return await iapFinishTransaction({\n purchase,\n isConsumable,\n developerPayloadAndroid,\n });\n } catch (err) {\n throw err;\n } finally {\n if (purchase.productId === currentPurchase?.productId) {\n setCurrentPurchase(undefined);\n }\n\n if (purchase.productId === currentPurchaseError?.productId) {\n setCurrentPurchaseError(undefined);\n }\n }\n },\n [\n currentPurchase?.productId,\n currentPurchaseError?.productId,\n setCurrentPurchase,\n setCurrentPurchaseError,\n ],\n );\n\n return {\n connected,\n products,\n promotedProductsIOS,\n subscriptions,\n purchaseHistory,\n availablePurchases,\n currentPurchase,\n currentPurchaseError,\n initConnectionError,\n finishTransaction,\n getProducts,\n getSubscriptions,\n getAvailablePurchases,\n getPurchaseHistory,\n requestPurchase: iapRequestPurchase,\n requestSubscription: iapRequestSubscription,\n };\n};\n"],"mappings":"AAAA,SAAQA,WAAR,QAA0B,OAA1B;AAEA,SACEC,iBAAiB,IAAIC,oBADvB,EAEEC,qBAAqB,IAAIC,wBAF3B,EAGEC,WAAW,IAAIC,cAHjB,EAIEC,kBAAkB,IAAIC,qBAJxB,EAKEC,gBAAgB,IAAIC,mBALtB,EAMEC,eAAe,IAAIC,kBANrB,EAOEC,mBAAmB,IAAIC,sBAPzB,QAQO,QARP;AAYA,SAAQC,aAAR,QA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,GAAP,EAAY;MACZ,MAAMA,GAAN;IACD,CARD,SAQU;MACR,IAAIH,QAAQ,CAACI,SAAT,MAAuBd,eAAvB,aAAuBA,eAAvB,uBAAuBA,eAAe,CAAEc,SAAxC,CAAJ,EAAuD;QACrDP,kBAAkB,CAACQ,SAAD,CAAlB;MACD;;MAED,IAAIL,QAAQ,CAACI,SAAT,MAAuBb,oBAAvB,aAAuBA,oBAAvB,uBAAuBA,oBAAoB,CAAEa,SAA7C,CAAJ,EAA4D;QAC1DN,uBAAuB,CAACO,SAAD,CAAvB;MACD;IACF;EACF,CA3BkC,EA4BnC,CACEf,eADF,aACEA,eADF,uBACEA,eAAe,CAAEc,SADnB,EAEEb,oBAFF,aAEEA,oBAFF,uBAEEA,oBAAoB,CAAEa,SAFxB,EAGEP,kBAHF,EAIEC,uBAJF,CA5BmC,CAArC;EAoCA,OAAO;IACLd,SADK;IAELC,QAFK;IAGLC,mBAHK;IAILC,aAJK;IAKLC,eALK;IAMLC,kBANK;IAOLC,eAPK;IAQLC,oBARK;IASLC,mBATK;IAULxB,iBAVK;IAWLI,WAXK;IAYLI,gBAZK;IAaLN,qBAbK;IAcLI,kBAdK;IAeLI,eAAe,EAAEC,kBAfZ;IAgBLC,mBAAmB,EAAEC;EAhBhB,CAAP;AAkBD,CA/FM"}
1
+ {"version":3,"names":["useCallback","finishTransaction","iapFinishTransaction","getAvailablePurchases","iapGetAvailablePurchases","getProducts","iapGetProducts","getPurchaseHistory","iapGetPurchaseHistory","getSubscriptions","iapGetSubscriptions","requestPurchase","iapRequestPurchase","requestSubscription","iapRequestSubscription","useIAPContext","useIAP","connected","products","promotedProductsIOS","subscriptions","purchaseHistory","availablePurchases","currentPurchase","currentPurchaseError","initConnectionError","setProducts","setSubscriptions","setAvailablePurchases","setPurchaseHistory","setCurrentPurchase","setCurrentPurchaseError","skus","purchase","isConsumable","developerPayloadAndroid","err","productId","undefined"],"sourceRoot":"../../../src","sources":["hooks/useIAP.ts"],"mappings":"AAAA,S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qC,EAEnC,CAACqB,kBAAD,CAFmC,CAAtC;EAIA,MAAM5B,iBAAiB,GAAGD,WAAW,CACnC,eAQyD;IAAA,IARlD;MACLiC,QADK;MAELC,YAFK;MAGLC;IAHK,CAQkD;;IACvD,IAAI;MACF,OAAO,MAAMjC,oBAAoB,CAAC;QAChC+B,QADgC;QAEhCC,YAFgC;QAGhCC;MAHgC,CAAD,CAAjC;IAKD,CAND,CAME,OAAOC,GAAP,EAAY;MACZ,MAAMA,GAAN;IACD,CARD,SAQU;MACR,IAAIH,QAAQ,CAACI,SAAT,MAAuBd,eAAvB,aAAuBA,eAAvB,uBAAuBA,eAAe,CAAEc,SAAxC,CAAJ,EAAuD;QACrDP,kBAAkB,CAACQ,SAAD,CAAlB;MACD;;MAED,IAAIL,QAAQ,CAACI,SAAT,MAAuBb,oBAAvB,aAAuBA,oBAAvB,uBAAuBA,oBAAoB,CAAEa,SAA7C,CAAJ,EAA4D;QAC1DN,uBAAuB,CAACO,SAAD,CAAvB;MACD;IACF;EACF,CA3BkC,EA4BnC,CACEf,eADF,aACEA,eADF,uBACEA,eAAe,CAAEc,SADnB,EAEEb,oBAFF,aAEEA,oBAFF,uBAEEA,oBAAoB,CAAEa,SAFxB,EAGEP,kBAHF,EAIEC,uBAJF,CA5BmC,CAArC;EAoCA,OAAO;IACLd,SADK;IAELC,QAFK;IAGLC,mBAHK;IAILC,aAJK;IAKLC,eALK;IAMLC,kBANK;IAOLC,eAPK;IAQLC,oBARK;IASLC,mBATK;IAULxB,iBAVK;IAWLI,WAXK;IAYLI,gBAZK;IAaLN,qBAbK;IAcLI,kBAdK;IAeLI,eAAe,EAAEC,kBAfZ;IAgBLC,mBAAmB,EAAEC;EAhBhB,CAAP;AAkBD,CA/FM"}
@@ -1 +1 @@
1
- {"version":3,"names":["React","useContext","useEffect","useMemo","useState","promotedProductListener","purchaseErrorListener","purchaseUpdatedListener","transactionListener","IapIos","initConnection","IAPContext","createContext","useIAPContext","ctx","Error","withIAPContext","Component","WrapperComponent","props","connected","setConnected","products","setProducts","promotedProductsIOS","setPromotedProductsIOS","subscriptions","setSubscriptions","purchaseHistory","setPurchaseHistory","availablePurchases","setAvailablePurchases","currentPurchase","setCurrentPurchase","currentTransaction","setCurrentTransaction","currentPurchaseError","setCurrentPurchaseError","initConnectionError","setInitConnectionError","context","then","value","undefined","catch","purchaseUpdateSubscription","purchase","transactionUpdateSubscription","transactionOrError","error","transaction","purchaseErrorSubscription","promotedProductSubscription","product","getPromotedProductIOS","prevProducts","remove"],"sources":["withIAPContext.tsx"],"sourcesContent":["import React, {useContext, useEffect, useMemo, useState} from 'react';\n\nimport {\n promotedProductListener,\n purchaseErrorListener,\n purchaseUpdatedListener,\n transactionListener,\n} from '../eventEmitter';\nimport {IapIos, initConnection} from '../iap';\nimport type {PurchaseError} from '../purchaseError';\nimport type {\n Product,\n ProductPurchase,\n Purchase,\n Subscription,\n SubscriptionPurchase,\n} from '../types';\nimport type {TransactionEvent, TransactionSk2} from '../types/appleSk2';\n\ntype IAPContextType = {\n connected: boolean;\n products: Product[];\n promotedProductsIOS: Product[];\n subscriptions: Subscription[];\n purchaseHistory: Purchase[];\n availablePurchases: Purchase[];\n currentPurchase?: Purchase;\n currentTransaction?: TransactionSk2;\n currentPurchaseError?: PurchaseError;\n initConnectionError?: Error;\n setProducts: (products: Product[]) => void;\n setSubscriptions: (subscriptions: Subscription[]) => void;\n setPurchaseHistory: (purchaseHistory: Purchase[]) => void;\n setAvailablePurchases: (availablePurchases: Purchase[]) => void;\n setCurrentPurchase: (currentPurchase: Purchase | undefined) => void;\n setCurrentPurchaseError: (\n currentPurchaseError: PurchaseError | undefined,\n ) => void;\n};\n\n// @ts-ignore\nconst IAPContext = React.createContext<IAPContextType>(null);\n\nexport function useIAPContext(): IAPContextType {\n const ctx = useContext(IAPContext);\n\n if (!ctx) {\n throw new Error('You need wrap your app with withIAPContext HOC');\n }\n\n return ctx;\n}\n\nexport function withIAPContext<T>(Component: React.ComponentType<T>) {\n return function WrapperComponent(props: T) {\n const [connected, setConnected] = useState(false);\n const [products, setProducts] = useState<Product[]>([]);\n\n const [promotedProductsIOS, setPromotedProductsIOS] = useState<Product[]>(\n [],\n );\n const [subscriptions, setSubscriptions] = useState<Subscription[]>([]);\n const [purchaseHistory, setPurchaseHistory] = useState<Purchase[]>([]);\n\n const [availablePurchases, setAvailablePurchases] = useState<Purchase[]>(\n [],\n );\n const [currentPurchase, setCurrentPurchase] = useState<Purchase>();\n const [currentTransaction, setCurrentTransaction] =\n useState<TransactionSk2>();\n\n const [currentPurchaseError, setCurrentPurchaseError] =\n useState<PurchaseError>();\n\n const [initConnectionError, setInitConnectionError] = useState<Error>();\n\n const context = useMemo(\n () => ({\n connected,\n products,\n subscriptions,\n promotedProductsIOS,\n purchaseHistory,\n availablePurchases,\n currentPurchase,\n currentTransaction,\n currentPurchaseError,\n initConnectionError,\n setProducts,\n setSubscriptions,\n setPurchaseHistory,\n setAvailablePurchases,\n setCurrentPurchase,\n setCurrentPurchaseError,\n }),\n [\n connected,\n products,\n subscriptions,\n promotedProductsIOS,\n purchaseHistory,\n availablePurchases,\n currentPurchase,\n currentTransaction,\n currentPurchaseError,\n initConnectionError,\n setProducts,\n setSubscriptions,\n setPurchaseHistory,\n setAvailablePurchases,\n setCurrentPurchase,\n setCurrentPurchaseError,\n ],\n );\n\n useEffect(() => {\n initConnection()\n .then((value) => {\n setInitConnectionError(undefined);\n setConnected(value);\n })\n .catch(setInitConnectionError);\n }, []);\n\n useEffect(() => {\n if (!connected) {\n return;\n }\n\n const purchaseUpdateSubscription = purchaseUpdatedListener(\n async (purchase: ProductPurchase | SubscriptionPurchase) => {\n setCurrentPurchaseError(undefined);\n setCurrentPurchase(purchase);\n },\n );\n\n const transactionUpdateSubscription = transactionListener(\n async (transactionOrError: TransactionEvent) => {\n setCurrentPurchaseError(transactionOrError?.error);\n setCurrentTransaction(transactionOrError?.transaction);\n },\n );\n\n const purchaseErrorSubscription = purchaseErrorListener(\n (error: PurchaseError) => {\n setCurrentPurchase(undefined);\n setCurrentPurchaseError(error);\n },\n );\n\n const promotedProductSubscription = promotedProductListener(async () => {\n const product = await IapIos.getPromotedProductIOS();\n\n setPromotedProductsIOS((prevProducts) => [\n ...prevProducts,\n ...(product ? [product] : []),\n ]);\n });\n\n return () => {\n purchaseUpdateSubscription.remove();\n purchaseErrorSubscription.remove();\n promotedProductSubscription?.remove();\n transactionUpdateSubscription?.remove();\n };\n }, [connected]);\n\n return (\n <IAPContext.Provider value={context}>\n <Component {...props} />\n </IAPContext.Provider>\n );\n };\n}\n"],"mappings":"AAAA,OAAOA,KAAP,IAAeC,UAAf,EAA2BC,SAA3B,EAAsCC,OAAtC,EAA+CC,QAA/C,QAA8D,OAA9D;AAEA,SACEC,uBADF,EAEEC,qBAFF,EAGEC,uBAHF,EAIEC,mBAJF,QAKO,iBALP;AAMA,SAAQC,MAAR,EAAgBC,cAAhB,QAAqC,QAArC;AAgCA;AACA,MAAMC,UAAU,gBAAGX,KAAK,CAACY,aAAN,CAAoC,IAApC,CAAnB;AAEA,OAAO,SAASC,aAAT,GAAyC;EAC9C,MAAMC,GAAG,GAAGb,UAAU,CAACU,UAAD,CAAtB;;EAEA,IAAI,CAACG,GAAL,EAAU;IACR,MAAM,IAAIC,KAAJ,CAAU,gDAAV,CAAN;EACD;;EAED,OAAOD,GAAP;AACD;AAED,OAAO,SAASE,cAAT,CAA2BC,SAA3B,EAA8D;EACnE,OAAO,SAASC,gBAAT,CAA0BC,KAA1B,EAAoC;IACzC,MAAM,CAACC,SAAD,EAAYC,YAAZ,IAA4BjB,QAAQ,CAAC,KAAD,CAA1C;IACA,MAAM,CAACkB,QAAD,EAAWC,WAAX,IAA0BnB,QAAQ,CAAY,EAAZ,CAAxC;IAEA,MAAM,CAACoB,mBAAD,EAAsBC,sBAAtB,IAAgDrB,QAAQ,CAC5D,EAD4D,CAA9D;IAGA,MAAM,CAACsB,aAAD,EAAgBC,gBAAhB,IAAoCvB,QAAQ,CAAiB,EAAj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useContext","useEffect","useMemo","useState","promotedProductListener","purchaseErrorListener","purchaseUpdatedListener","transactionListener","IapIos","initConnection","IAPContext","createContext","useIAPContext","ctx","Error","withIAPContext","Component","WrapperComponent","props","connected","setConnected","products","setProducts","promotedProductsIOS","setPromotedProductsIOS","subscriptions","setSubscriptions","purchaseHistory","setPurchaseHistory","availablePurchases","setAvailablePurchases","currentPurchase","setCurrentPurchase","currentTransaction","setCurrentTransaction","currentPurchaseError","setCurrentPurchaseError","initConnectionError","setInitConnectionError","context","then","value","undefined","catch","purchaseUpdateSubscription","purchase","transactionUpdateSubscription","transactionOrError","error","transaction","purchaseErrorSubscription","promotedProductSubscription","product","getPromotedProductIOS","prevProducts","remove"],"sourceRoot":"../../../src","sources":["hooks/withIAPContext.tsx"],"mappings":"AAAA,OAAOA,KAAP,IAAeC,UAAf,EAA2BC,SAA3B,EAAsCC,OAAtC,EAA+CC,QAA/C,QAA8D,OAA9D;AAEA,SACEC,uBADF,EAEEC,qBAFF,EAGEC,uBAHF,EAIEC,mBAJF,QAKO,iBALP;AAMA,SAAQC,MAAR,EAAgBC,cAAhB,QAAqC,QAArC;AAgCA;AACA,MAAMC,UAAU,gBAAGX,KAAK,CAACY,aAAN,CAAoC,IAApC,CAAnB;AAEA,OAAO,SAASC,aAAT,GAAyC;EAC9C,MAAMC,GAAG,GAAGb,UAAU,CAACU,UAAD,CAAtB;;EAEA,IAAI,CAACG,GAAL,EAAU;IACR,MAAM,IAAIC,KAAJ,CAAU,gDAAV,CAAN;EACD;;EAED,OAAOD,GAAP;AACD;AAED,OAAO,SAASE,cAAT,CAA2BC,SAA3B,EAA8D;EACnE,OAAO,SAASC,gBAAT,CAA0BC,KAA1B,EAAoC;IACzC,MAAM,CAACC,SAAD,EAAYC,YAAZ,IAA4BjB,QAAQ,CAAC,KAAD,CAA1C;IACA,MAAM,CAACkB,QAAD,EAAWC,WAAX,IAA0BnB,QAAQ,CAAY,EAAZ,CAAxC;IAEA,MAAM,CAACoB,mBAAD,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CAAY,QAAZ;MAAqB,KAAK,EAAEoB;IAA5B,gBACE,oBAAC,SAAD,EAAerB,KAAf,CADF,CADF;EAKD,CAtHD;AAuHD"}
@@ -1 +1 @@
1
- {"version":3,"names":["NativeModules","Platform","IapAmazon","IapAndroid","IapIos","IapIosSk2","singleProductAndroidMap","offerToRecord","offerSk2Map","productSk2Map","subscriptionSk2Map","transactionSk2ToPurchaseMap","fillProductsWithAdditionalData","getAndroidModule","getAndroidModuleType","getIosModule","getNativeModule","isAmazon","isIosStorekit2","storekit1Mode","storekit2Mode","storekitHybridMode","ProductType","PurchaseStateAndroid","SubscriptionPlatform","RNIapIos","RNIapIosSk2","RNIapModule","RNIapAmazonModule","ANDROID_ITEM_TYPE_SUBSCRIPTION","subs","ANDROID_ITEM_TYPE_IAP","inapp","setup","storekitMode","initConnection","endConnection","flushFailedPurchasesCachedAsPendingAndroid","flushFailedPurchasesCachedAsPending","getProducts","skus","length","Promise","reject","select","ios","items","getItems","map","filter","item","includes","productId","android","products","getItemsByType","Error","getSubscriptions","addSubscriptionPlatform","androidPlatform","subscriptions","castSubscriptions","amazon","platform","subscription","getPurchaseHistory","alsoPublishToEventListener","automaticallyFinishRestoredTransactions","onlyIncludeActiveItems","resolve","getAvailableItems","getPurchaseHistoryByType","concat","getAvailablePurchases","getAvailableItemsByType","requestPurchase","request","sku","andDangerouslyFinishTransactionAutomaticallyIOS","appAccountToken","quantity","withOffer","console","warn","offer","purchase","buyProduct","buyItemByType","obfuscatedAccountIdAndroid","obfuscatedProfileIdAndroid","isOfferPersonalized","undefined","requestSubscription","subscriptionOffers","purchaseTokenAndroid","prorationModeAndroid","so","offerToken","finishTransaction","isConsumable","developerPayloadAndroid","transactionId","purchaseToken","consumeProduct","userIdAmazon","isAcknowledgedAndroid","purchaseStateAndroid","PURCHASED","acknowledgePurchase","deepLinkToSubscriptions","isAmazonDevice","deepLinkToSubscriptionsIos","deepLinkToSubscriptionsAmazon","deepLinkToSubscriptionsAndroid"],"sources":["iap.ts"],"sourcesContent":["import {NativeModules, Platform} from 'react-native';\n\nimport * as IapAmazon from './modules/amazon';\nimport * as IapAndroid from './modules/android';\nimport * as IapIos from './modules/ios';\nimport * as IapIosSk2 from './modules/iosSk2';\nimport {singleProductAndroidMap} from './types/android';\nimport {offerToRecord} from './types/apple';\nimport {\n offerSk2Map,\n ProductSk2,\n productSk2Map,\n subscriptionSk2Map,\n transactionSk2ToPurchaseMap,\n} from './types/appleSk2';\nimport {\n fillProductsWithAdditionalData,\n getAndroidModule,\n getAndroidModuleType,\n getIosModule,\n getNativeModule,\n isAmazon,\n isIosStorekit2,\n storekit1Mode,\n storekit2Mode,\n storekitHybridMode,\n} from './internal';\nimport {\n Product,\n ProductPurchase,\n ProductType,\n Purchase,\n PurchaseResult,\n PurchaseStateAndroid,\n RequestPurchase,\n RequestSubscription,\n Subscription,\n SubscriptionAmazon,\n SubscriptionAndroid,\n SubscriptionIOS,\n SubscriptionPlatform,\n SubscriptionPurchase,\n} from './types';\n\nexport {IapAndroid, IapAmazon, IapIos, IapIosSk2, isIosStorekit2};\n\nconst {RNIapIos, RNIapIosSk2, RNIapModule, RNIapAmazonModule} = NativeModules;\nconst ANDROID_ITEM_TYPE_SUBSCRIPTION = ProductType.subs;\nconst ANDROID_ITEM_TYPE_IAP = ProductType.inapp;\n\n/**\n * STOREKIT1_MODE: Will not enable Storekit 2 even if the device supports it. Thigs will work as before,\n * minimum changes required in the migration guide (default)\n * HYBRID_MODE: Will enable Storekit 2 for iOS devices > 15.0 but will fallback to Sk1 on older devices\n * There are some edge cases that you need to handle in this case (described in migration guide). This mode\n * is for developers that are migrating to Storekit 2 but want to keep supporting older versions.\n * STOREKIT2_MODE: Will *only* enable Storekit 2. This disables Storekit 1. This is for apps that\n * have already targeted a min version of 15 for their app.\n */\nexport type STOREKIT_OPTIONS =\n | 'STOREKIT1_MODE'\n | 'STOREKIT_HYBRID_MODE'\n | 'STOREKIT2_MODE';\n\nexport const setup = ({\n storekitMode = 'STOREKIT1_MODE',\n}: {\n storekitMode?: STOREKIT_OPTIONS;\n} = {}) => {\n switch (storekitMode) {\n case 'STOREKIT1_MODE':\n storekit1Mode();\n break;\n case 'STOREKIT2_MODE':\n storekit2Mode();\n break;\n case 'STOREKIT_HYBRID_MODE':\n storekitHybridMode();\n break;\n default:\n break;\n }\n};\n\n/**\n * Init module for purchase flow. Required on Android. In ios it will check whether user canMakePayment.\n * ## Usage\n\n```tsx\nimport React, {useEffect} from 'react';\nimport {View} from 'react-native';\nimport {initConnection} from 'react-native-iap';\n\nconst App = () => {\n useEffect(() => {\n void initConnection();\n }, []);\n\n return <View />;\n};\n```\n */\nexport const initConnection = (): Promise<boolean> =>\n getNativeModule().initConnection();\n\n/**\n * Disconnects from native SDK\n * Usage\n * ```tsx\nimport React, {useEffect} from 'react';\nimport {View} from 'react-native';\nimport {endConnection} from 'react-native-iap';\n\nconst App = () => {\n useEffect(() => {\n return () => {\n void endConnection();\n };\n }, []);\n\n return <View />;\n};\n```\n * @returns {Promise<void>}\n */\nexport const endConnection = (): Promise<boolean> =>\n getNativeModule().endConnection();\n\n/**\n * Consume all 'ghost' purchases (that is, pending payment that already failed but is still marked as pending in Play Store cache). Android only.\n * @returns {Promise<boolean>}\n */\nexport const flushFailedPurchasesCachedAsPendingAndroid =\n (): Promise<boolean> =>\n getAndroidModule().flushFailedPurchasesCachedAsPending();\n\n/**\n * Get a list of products (consumable and non-consumable items, but not subscriptions)\n ## Usage\n\n```ts\nimport React, {useState} from 'react';\nimport {Platform} from 'react-native';\nimport {getProducts, Product} from 'react-native-iap';\n\nconst skus = Platform.select({\n ios: ['com.example.consumableIos'],\n android: ['com.example.consumableAndroid'],\n});\n\nconst App = () => {\n const [products, setProducts] = useState<Product[]>([]);\n\n const handleProducts = async () => {\n const items = await getProducts({skus});\n\n setProducts(items);\n };\n\n useEffect(() => {\n void handleProducts();\n }, []);\n\n return (\n <>\n {products.map((product) => (\n <Text key={product.productId}>{product.productId}</Text>\n ))}\n </>\n );\n};\n```\n\nJust a few things to keep in mind:\n\n- You can get your products in `componentDidMount`, `useEffect` or another appropriate area of your app.\n- Since a user may start your app with a bad or no internet connection, preparing/getting the items more than once may be a good idea.\n- If the user has no IAPs available when the app starts first, you may want to check again when the user enters your IAP store.\n\n */\nexport const getProducts = ({\n skus,\n}: {\n skus: string[];\n}): Promise<Array<Product>> => {\n if (!skus?.length) {\n return Promise.reject('\"skus\" is required');\n }\n return (\n Platform.select({\n ios: async () => {\n let items: Product[];\n if (isIosStorekit2()) {\n items = ((await RNIapIosSk2.getItems(skus)) as ProductSk2[]).map(\n productSk2Map,\n );\n } else {\n items = (await RNIapIos.getItems(skus)) as Product[];\n }\n return items.filter((item: Product) => skus.includes(item.productId));\n },\n android: async () => {\n const products = (\n await getAndroidModule().getItemsByType(ANDROID_ITEM_TYPE_IAP, skus)\n ).map(singleProductAndroidMap);\n\n return fillProductsWithAdditionalData(products);\n },\n }) || (() => Promise.reject(new Error('Unsupported Platform')))\n )();\n};\n\n/**\n * Get a list of subscriptions\n * ## Usage\n\n```tsx\nimport React, {useCallback} from 'react';\nimport {View} from 'react-native';\nimport {getSubscriptions} from 'react-native-iap';\n\nconst App = () => {\n const subscriptions = useCallback(\n async () =>\n await getSubscriptions({skus:['com.example.product1', 'com.example.product2']}),\n [],\n );\n\n return <View />;\n};\n```\n\n */\nexport const getSubscriptions = ({\n skus,\n}: {\n skus: string[];\n}): Promise<Subscription[]> => {\n if (!skus?.length) {\n return Promise.reject('\"skus\" is required');\n }\n return (\n Platform.select({\n ios: async (): Promise<SubscriptionIOS[]> => {\n let items: SubscriptionIOS[];\n if (isIosStorekit2()) {\n items = ((await RNIapIosSk2.getItems(skus)) as ProductSk2[]).map(\n subscriptionSk2Map,\n );\n } else {\n items = (await RNIapIos.getItems(skus)) as SubscriptionIOS[];\n }\n\n items = items.filter((item: SubscriptionIOS) =>\n skus.includes(item.productId),\n );\n\n return addSubscriptionPlatform(items, SubscriptionPlatform.ios);\n },\n android: async (): Promise<Subscription[]> => {\n const androidPlatform = getAndroidModuleType();\n\n let subscriptions = (await getAndroidModule().getItemsByType(\n ANDROID_ITEM_TYPE_SUBSCRIPTION,\n skus,\n )) as SubscriptionAndroid[] | SubscriptionAmazon[];\n\n switch (androidPlatform) {\n case 'android': {\n const castSubscriptions = subscriptions as SubscriptionAndroid[];\n return addSubscriptionPlatform(\n castSubscriptions,\n SubscriptionPlatform.android,\n );\n }\n case 'amazon':\n let castSubscriptions = subscriptions as SubscriptionAmazon[];\n castSubscriptions = await fillProductsWithAdditionalData(\n castSubscriptions,\n );\n return addSubscriptionPlatform(\n castSubscriptions,\n SubscriptionPlatform.amazon,\n );\n case null:\n default:\n throw new Error(\n `getSubscriptions received unknown platform ${androidPlatform}. Verify the logic in getAndroidModuleType`,\n );\n }\n },\n }) || (() => Promise.reject(new Error('Unsupported Platform')))\n )();\n};\n\n/**\n * Adds an extra property to subscriptions so we can distinguish the platform\n * we retrieved them on.\n */\nconst addSubscriptionPlatform = <T>(\n subscriptions: T[],\n platform: SubscriptionPlatform,\n): T[] => {\n return subscriptions.map((subscription) => ({...subscription, platform}));\n};\n\n/**\n * Gets an inventory of purchases made by the user regardless of consumption status\n * ## Usage\n\n```tsx\nimport React, {useCallback} from 'react';\nimport {View} from 'react-native';\nimport {getPurchaseHistory} from 'react-native-iap';\n\nconst App = () => {\n const history = useCallback(\n async () =>\n await getPurchaseHistory([\n 'com.example.product1',\n 'com.example.product2',\n ]),\n [],\n );\n\n return <View />;\n};\n```\n@param {alsoPublishToEventListener}:boolean. (IOS Sk2 only) When `true`, every element will also be pushed to the purchaseUpdated listener.\nNote that this is only for backaward compatiblity. It won't publish to transactionUpdated (Storekit2) Defaults to `false`\n@param {automaticallyFinishRestoredTransactions}:boolean. (IOS Sk1 only) When `true`, all the transactions that are returned are automatically\nfinished. This means that if you call this method again you won't get the same result on the same device. On the other hand, if `false` you'd\nhave to manually finish the returned transaction once you have delivered the content to your user.\n@param {onlyIncludeActiveItems}:boolean. (IOS Sk2 only). Defaults to false, meaning that it will return one transaction per item purchased. \n@See https://developer.apple.com/documentation/storekit/transaction/3851204-currententitlements for details\n */\nexport const getPurchaseHistory = ({\n alsoPublishToEventListener = false,\n automaticallyFinishRestoredTransactions = true,\n onlyIncludeActiveItems = false,\n}: {\n alsoPublishToEventListener?: boolean;\n automaticallyFinishRestoredTransactions?: boolean;\n onlyIncludeActiveItems?: boolean;\n} = {}): Promise<Purchase[]> =>\n (\n Platform.select({\n ios: async () => {\n if (isIosStorekit2()) {\n return Promise.resolve(\n (\n await RNIapIosSk2.getAvailableItems(\n alsoPublishToEventListener,\n onlyIncludeActiveItems,\n )\n ).map(transactionSk2ToPurchaseMap),\n );\n } else {\n return RNIapIos.getAvailableItems(\n automaticallyFinishRestoredTransactions,\n );\n }\n },\n android: async () => {\n if (RNIapAmazonModule) {\n return await RNIapAmazonModule.getAvailableItems();\n }\n\n const products = await RNIapModule.getPurchaseHistoryByType(\n ANDROID_ITEM_TYPE_IAP,\n );\n\n const subscriptions = await RNIapModule.getPurchaseHistoryByType(\n ANDROID_ITEM_TYPE_SUBSCRIPTION,\n );\n\n return products.concat(subscriptions);\n },\n }) || (() => Promise.resolve([]))\n )();\n\n/**\n * Get all purchases made by the user (either non-consumable, or haven't been consumed yet)\n * ## Usage\n\n```tsx\nimport React, {useCallback} from 'react';\nimport {View} from 'react-native';\nimport {getAvailablePurchases} from 'react-native-iap';\n\nconst App = () => {\n const availablePurchases = useCallback(\n async () => await getAvailablePurchases(),\n [],\n );\n\n return <View />;\n};\n```\n\n## Restoring purchases\n\nYou can use `getAvailablePurchases()` to do what's commonly understood as \"restoring\" purchases.\n\n:::note\nFor debugging you may want to consume all items, you have then to iterate over the purchases returned by `getAvailablePurchases()`.\n:::\n\n:::warning\nBeware that if you consume an item without having recorded the purchase in your database the user may have paid for something without getting it delivered and you will have no way to recover the receipt to validate and restore their purchase.\n:::\n\n```tsx\nimport React from 'react';\nimport {Button} from 'react-native';\nimport {getAvailablePurchases,finishTransaction} from 'react-native-iap';\n\nconst App = () => {\n handleRestore = async () => {\n try {\n const purchases = await getAvailablePurchases();\n const newState = {premium: false, ads: true};\n let titles = [];\n\n await Promise.all(purchases.map(async purchase => {\n switch (purchase.productId) {\n case 'com.example.premium':\n newState.premium = true;\n titles.push('Premium Version');\n break;\n\n case 'com.example.no_ads':\n newState.ads = false;\n titles.push('No Ads');\n break;\n\n case 'com.example.coins100':\n await finishTransaction({purchase});\n CoinStore.addCoins(100);\n }\n }));\n\n Alert.alert(\n 'Restore Successful',\n `You successfully restored the following purchases: ${titles.join(', ')}`,\n );\n } catch (error) {\n console.warn(error);\n Alert.alert(error.message);\n }\n };\n\n return (\n <Button title=\"Restore purchases\" onPress={handleRestore} />\n )\n};\n```\n@param {alsoPublishToEventListener}:boolean When `true`, every element will also be pushed to the purchaseUpdated listener.\nNote that this is only for backaward compatiblity. It won't publish to transactionUpdated (Storekit2) Defaults to `false`\n@param {onlyIncludeActiveItems}:boolean. (IOS Sk2 only). Defaults to true, meaning that it will return the transaction if suscription has not expired. \n@See https://developer.apple.com/documentation/storekit/transaction/3851204-currententitlements for details\n *\n */\nexport const getAvailablePurchases = ({\n alsoPublishToEventListener = false,\n automaticallyFinishRestoredTransactions = false,\n onlyIncludeActiveItems = true,\n}: {\n alsoPublishToEventListener?: boolean;\n automaticallyFinishRestoredTransactions?: boolean;\n onlyIncludeActiveItems?: boolean;\n} = {}): Promise<Purchase[]> =>\n (\n Platform.select({\n ios: async () => {\n if (isIosStorekit2()) {\n return Promise.resolve(\n (\n await RNIapIosSk2.getAvailableItems(\n alsoPublishToEventListener,\n onlyIncludeActiveItems,\n )\n ).map(transactionSk2ToPurchaseMap),\n );\n } else {\n return RNIapIos.getAvailableItems(\n automaticallyFinishRestoredTransactions,\n );\n }\n },\n android: async () => {\n if (RNIapAmazonModule) {\n return await RNIapAmazonModule.getAvailableItems();\n }\n\n const products = await RNIapModule.getAvailableItemsByType(\n ANDROID_ITEM_TYPE_IAP,\n );\n\n const subscriptions = await RNIapModule.getAvailableItemsByType(\n ANDROID_ITEM_TYPE_SUBSCRIPTION,\n );\n\n return products.concat(subscriptions);\n },\n }) || (() => Promise.resolve([]))\n )();\n\n/**\n * Request a purchase for product. This will be received in `PurchaseUpdatedListener`.\n * Request a purchase for a product (consumables or non-consumables).\n\nThe response will be received through the `PurchaseUpdatedListener`.\n\n:::note\n`andDangerouslyFinishTransactionAutomatically` defaults to false. We recommend\nalways keeping at false, and verifying the transaction receipts on the server-side.\n:::\n\n## Signature\n\n```ts\nrequestPurchase(\n The product's sku/ID\n sku,\n\n\n * You should set this to false and call finishTransaction manually when you have delivered the purchased goods to the user.\n * @default false\n\n andDangerouslyFinishTransactionAutomaticallyIOS = false,\n\n /** Specifies an optional obfuscated string that is uniquely associated with the user's account in your app.\n obfuscatedAccountIdAndroid,\n\n Specifies an optional obfuscated string that is uniquely associated with the user's profile in your app.\n obfuscatedProfileIdAndroid,\n\n The purchaser's user ID\n applicationUsername,\n): Promise<ProductPurchase>;\n```\n\n## Usage\n\n```tsx\nimport React, {useCallback} from 'react';\nimport {Button} from 'react-native';\nimport {requestPurchase, Product, Sku, getProducts} from 'react-native-iap';\n\nconst App = () => {\n const products = useCallback(\n async () => getProducts({skus:['com.example.product']}),\n [],\n );\n\n const handlePurchase = async (sku: Sku) => {\n await requestPurchase({sku});\n };\n\n return (\n <>\n {products.map((product) => (\n <Button\n key={product.productId}\n title=\"Buy product\"\n onPress={() => handlePurchase(product.productId)}\n />\n ))}\n </>\n );\n};\n```\n\n */\n\nexport const requestPurchase = (\n request: RequestPurchase,\n): Promise<ProductPurchase | void> =>\n (\n Platform.select({\n ios: async () => {\n if (!('sku' in request)) {\n throw new Error('sku is required for iOS purchase');\n }\n\n const {\n sku,\n andDangerouslyFinishTransactionAutomaticallyIOS = false,\n appAccountToken,\n quantity,\n withOffer,\n } = request;\n\n if (andDangerouslyFinishTransactionAutomaticallyIOS) {\n console.warn(\n 'You are dangerously allowing react-native-iap to finish your transaction automatically. You should set andDangerouslyFinishTransactionAutomatically to false when calling requestPurchase and call finishTransaction manually when you have delivered the purchased goods to the user. It defaults to true to provide backwards compatibility. Will default to false in version 4.0.0.',\n );\n }\n if (isIosStorekit2()) {\n const offer = offerSk2Map(withOffer);\n\n const purchase = transactionSk2ToPurchaseMap(\n await RNIapIosSk2.buyProduct(\n sku,\n andDangerouslyFinishTransactionAutomaticallyIOS,\n appAccountToken,\n quantity ?? -1,\n offer,\n ),\n );\n return Promise.resolve(purchase);\n } else {\n return RNIapIos.buyProduct(\n sku,\n andDangerouslyFinishTransactionAutomaticallyIOS,\n appAccountToken,\n quantity ?? -1,\n offerToRecord(withOffer),\n );\n }\n },\n android: async () => {\n if (isAmazon) {\n if (!('sku' in request)) {\n throw new Error('sku is required for Amazon purchase');\n }\n const {sku} = request;\n return RNIapAmazonModule.buyItemByType(sku);\n } else {\n if (!('skus' in request) || !request.skus.length) {\n throw new Error('skus is required for Android purchase');\n }\n\n const {\n skus,\n obfuscatedAccountIdAndroid,\n obfuscatedProfileIdAndroid,\n isOfferPersonalized,\n } = request;\n return getAndroidModule().buyItemByType(\n ANDROID_ITEM_TYPE_IAP,\n skus,\n undefined,\n -1,\n obfuscatedAccountIdAndroid,\n obfuscatedProfileIdAndroid,\n [],\n isOfferPersonalized ?? false,\n );\n }\n },\n }) || Promise.resolve\n )();\n\n/**\n * Request a purchase for product. This will be received in `PurchaseUpdatedListener`.\n * Request a purchase for a subscription.\n\nThe response will be received through the `PurchaseUpdatedListener`.\n\n:::note\n`andDangerouslyFinishTransactionAutomatically` defaults to false. We recommend\nalways keeping at false, and verifying the transaction receipts on the server-side.\n:::\n\n## Signature\n\n```ts\nrequestSubscription(\n The product's sku/ID\n sku,\n\n\n * You should set this to false and call finishTransaction manually when you have delivered the purchased goods to the user.\n * @default false\n\n andDangerouslyFinishTransactionAutomaticallyIOS = false,\n\n purchaseToken that the user is upgrading or downgrading from (Android).\n purchaseTokenAndroid,\n\n UNKNOWN_SUBSCRIPTION_UPGRADE_DOWNGRADE_POLICY, IMMEDIATE_WITH_TIME_PRORATION, IMMEDIATE_AND_CHARGE_PRORATED_PRICE, IMMEDIATE_WITHOUT_PRORATION, DEFERRED\n prorationModeAndroid = -1,\n\n /** Specifies an optional obfuscated string that is uniquely associated with the user's account in your app.\n obfuscatedAccountIdAndroid,\n\n Specifies an optional obfuscated string that is uniquely associated with the user's profile in your app.\n obfuscatedProfileIdAndroid,\n\n The purchaser's user ID\n applicationUsername,\n): Promise<SubscriptionPurchase>\n```\n\n## Usage\n\n```tsx\nimport React, {useCallback} from 'react';\nimport {Button} from 'react-native';\nimport {\n requestSubscription,\n Product,\n Sku,\n getSubscriptions,\n} from 'react-native-iap';\n\nconst App = () => {\n const subscriptions = useCallback(\n async () => getSubscriptions(['com.example.subscription']),\n [],\n );\n\n const handlePurchase = async (sku: Sku) => {\n await requestSubscription({sku});\n };\n\n return (\n <>\n {subscriptions.map((subscription) => (\n <Button\n key={subscription.productId}\n title=\"Buy subscription\"\n onPress={() => handlePurchase(subscription.productId)}\n />\n ))}\n </>\n );\n};\n```\n */\nexport const requestSubscription = (\n request: RequestSubscription,\n): Promise<SubscriptionPurchase | null | void> =>\n (\n Platform.select({\n ios: async () => {\n if (!('sku' in request)) {\n throw new Error('sku is required for iOS subscriptions');\n }\n\n const {\n sku,\n andDangerouslyFinishTransactionAutomaticallyIOS = false,\n appAccountToken,\n quantity,\n withOffer,\n } = request;\n\n if (andDangerouslyFinishTransactionAutomaticallyIOS) {\n console.warn(\n 'You are dangerously allowing react-native-iap to finish your transaction automatically. You should set andDangerouslyFinishTransactionAutomatically to false when calling requestPurchase and call finishTransaction manually when you have delivered the purchased goods to the user. It defaults to true to provide backwards compatibility. Will default to false in version 4.0.0.',\n );\n }\n\n if (isIosStorekit2()) {\n const offer = offerSk2Map(withOffer);\n\n const purchase = transactionSk2ToPurchaseMap(\n await RNIapIosSk2.buyProduct(\n sku,\n andDangerouslyFinishTransactionAutomaticallyIOS,\n appAccountToken,\n quantity ?? -1,\n offer,\n ),\n );\n return Promise.resolve(purchase);\n } else {\n return RNIapIos.buyProduct(\n sku,\n andDangerouslyFinishTransactionAutomaticallyIOS,\n appAccountToken,\n quantity ?? -1,\n offerToRecord(withOffer),\n );\n }\n },\n android: async () => {\n if (isAmazon) {\n if (!('sku' in request)) {\n throw new Error('sku is required for Amazon subscriptions');\n }\n const {sku} = request;\n return RNIapAmazonModule.buyItemByType(sku);\n } else {\n if (\n !('subscriptionOffers' in request) ||\n request.subscriptionOffers.length === 0\n ) {\n throw new Error(\n 'subscriptionOffers are required for Google Play subscriptions',\n );\n }\n\n const {\n subscriptionOffers,\n purchaseTokenAndroid,\n prorationModeAndroid = -1,\n obfuscatedAccountIdAndroid,\n obfuscatedProfileIdAndroid,\n isOfferPersonalized,\n } = request;\n\n return RNIapModule.buyItemByType(\n ANDROID_ITEM_TYPE_SUBSCRIPTION,\n subscriptionOffers?.map((so) => so.sku),\n purchaseTokenAndroid,\n prorationModeAndroid,\n obfuscatedAccountIdAndroid,\n obfuscatedProfileIdAndroid,\n subscriptionOffers?.map((so) => so.offerToken),\n isOfferPersonalized ?? false,\n );\n }\n },\n }) || (() => Promise.resolve(null))\n )();\n\n/**\n * Finish Transaction (both platforms)\n * Abstracts Finish Transaction\n * iOS: Tells StoreKit that you have delivered the purchase to the user and StoreKit can now let go of the transaction.\n * Call this after you have persisted the purchased state to your server or local data in your app.\n * `react-native-iap` will continue to deliver the purchase updated events with the successful purchase until you finish the transaction. **Even after the app has relaunched.**\n * Android: it will consume purchase for consumables and acknowledge purchase for non-consumables.\n *\n```tsx\nimport React from 'react';\nimport {Button} from 'react-native';\nimport {finishTransaction} from 'react-native-iap';\n\nconst App = () => {\n const handlePurchase = async () => {\n // ... handle the purchase request\n\n const result = finishTransaction({purchase});\n };\n\n return <Button title=\"Buy product\" onPress={handlePurchase} />;\n};\n```\n @returns {Promise<PurchaseResult | boolean>} Android: PurchaseResult, iOS: true\n */\nexport const finishTransaction = ({\n purchase,\n isConsumable,\n developerPayloadAndroid,\n}: {\n purchase: Purchase;\n isConsumable?: boolean;\n developerPayloadAndroid?: string;\n}): Promise<PurchaseResult | boolean> => {\n return (\n Platform.select({\n ios: async () => {\n const transactionId = purchase.transactionId;\n\n if (!transactionId) {\n return Promise.reject(\n new Error('transactionId required to finish iOS transaction'),\n );\n }\n await getIosModule().finishTransaction(transactionId);\n return Promise.resolve(true);\n },\n android: async () => {\n if (purchase?.purchaseToken) {\n if (isConsumable) {\n return getAndroidModule().consumeProduct(\n purchase.purchaseToken,\n developerPayloadAndroid,\n );\n } else if (\n purchase.userIdAmazon ||\n (!purchase.isAcknowledgedAndroid &&\n purchase.purchaseStateAndroid === PurchaseStateAndroid.PURCHASED)\n ) {\n return getAndroidModule().acknowledgePurchase(\n purchase.purchaseToken,\n developerPayloadAndroid,\n );\n } else {\n return Promise.reject(\n new Error('purchase is not suitable to be purchased'),\n );\n }\n }\n return Promise.reject(\n new Error('purchase is not suitable to be purchased'),\n );\n },\n }) || (() => Promise.reject(new Error('Unsupported Platform')))\n )();\n};\n\n/**\n * Deeplinks to native interface that allows users to manage their subscriptions\n *\n */\nexport const deepLinkToSubscriptions = ({\n sku,\n isAmazonDevice = true,\n}: {\n sku?: string;\n isAmazonDevice?: boolean;\n}): Promise<void> => {\n return (\n Platform.select({\n ios: async () => {\n IapIos.deepLinkToSubscriptionsIos();\n },\n android: async () => {\n if (isAmazon) {\n IapAmazon.deepLinkToSubscriptionsAmazon({isAmazonDevice});\n } else if (sku) {\n IapAndroid.deepLinkToSubscriptionsAndroid({sku});\n } else {\n Promise.reject(\n new Error(\n 'Sku is required to locate subscription in Android Store',\n ),\n );\n }\n },\n }) || (() => Promise.reject(new Error('Unsupported Platform')))\n )();\n};\n"],"mappings":"AAAA,SAAQA,aAAR,EAAuBC,QAAvB,QAAsC,cAAtC;AAEA,OAAO,KAAKC,SAAZ,MAA2B,kBAA3B;AACA,OAAO,KAAKC,UAAZ,MAA4B,mBAA5B;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D,uBAAuB,GAAG,SAMlB;EAAA,IANmB;IACtChC,GADsC;IAEtCiC,cAAc,GAAG;EAFqB,CAMnB;EACnB,OAAO,CACL7G,QAAQ,CAAC2C,MAAT,CAAgB;IACdC,GAAG,EAAE,YAAY;MACfzC,MAAM,CAAC2G,0BAAP;IACD,CAHa;IAId1D,OAAO,EAAE,YAAY;MACnB,IAAIpC,QAAJ,EAAc;QACZf,SAAS,CAAC8G,6BAAV,CAAwC;UAACF;QAAD,CAAxC;MACD,CAFD,MAEO,IAAIjC,GAAJ,EAAS;QACd1E,UAAU,CAAC8G,8BAAX,CAA0C;UAACpC;QAAD,CAA1C;MACD,CAFM,MAEA;QACLnC,OAAO,CAACC,MAAR,CACE,IAAIa,KAAJ,CACE,yDADF,CADF;MAKD;IACF;EAhBa,CAAhB,MAiBO,MAAMd,OAAO,CAACC,MAAR,CAAe,IAAIa,KAAJ,CAAU,sBAAV,CAAf,CAjBb,CADK,GAAP;AAoBD,CA3BM"}
1
+ {"version":3,"names":["NativeModules","Platform","IapAmazon","IapAndroid","IapIos","IapIosSk2","singleProductAndroidMap","offerToRecord","offerSk2Map","productSk2Map","subscriptionSk2Map","transactionSk2ToPurchaseMap","fillProductsWithAdditionalData","getAndroidModule","getAndroidModuleType","getIosModule","getNativeModule","isAmazon","isIosStorekit2","storekit1Mode","storekit2Mode","storekitHybridMode","ProductType","PurchaseStateAndroid","SubscriptionPlatform","RNIapIos","RNIapIosSk2","RNIapModule","RNIapAmazonModule","ANDROID_ITEM_TYPE_SUBSCRIPTION","subs","ANDROID_ITEM_TYPE_IAP","inapp","setup","storekitMode","initConnection","endConnection","flushFailedPurchasesCachedAsPendingAndroid","flushFailedPurchasesCachedAsPending","getProducts","skus","length","Promise","reject","select","ios","items","getItems","map","filter","item","includes","productId","android","products","getItemsByType","Error","getSubscriptions","addSubscriptionPlatform","androidPlatform","subscriptions","castSubscriptions","amazon","platform","subscription","getPurchaseHistory","alsoPublishToEventListener","automaticallyFinishRestoredTransactions","onlyIncludeActiveItems","resolve","getAvailableItems","getPurchaseHistoryByType","concat","getAvailablePurchases","getAvailableItemsByType","requestPurchase","request","sku","andDangerouslyFinishTransactionAutomaticallyIOS","appAccountToken","quantity","withOffer","console","warn","offer","purchase","buyProduct","buyItemByType","obfuscatedAccountIdAndroid","obfuscatedProfileIdAndroid","isOfferPersonalized","undefined","requestSubscription","subscriptionOffers","purchaseTokenAndroid","prorationModeAndroid","so","offerToken","finishTransaction","isConsumable","developerPayloadAndroid","transactionId","purchaseToken","consumeProduct","userIdAmazon","isAcknowledgedAndroid","purchaseStateAndroid","PURCHASED","acknowledgePurchase","deepLinkToSubscriptions","isAmazonDevice","deepLinkToSubscriptionsIos","deepLinkToSubscriptionsAmazon","deepLinkToSubscriptionsAndroid"],"sourceRoot":"../../src","sources":["iap.ts"],"mappings":"AAAA,SAAQA,aAAR,EAAuBC,QAAvB,QAAsC,cAAtC;AAEA,OAAO,KAAKC,SAAZ,MAA2B,kBAA3B;AACA,OAAO,KAAKC,UAAZ,MAA4B,mBAA5B;AACA,OAAO,KAAKC,MAAZ,MAAwB,eAAxB;AACA,OAAO,KAAKC,SAAZ,MAA2B,kBAA3B;AACA,SAAQC,uBAAR,QAAsC,iBAAtC;AACA,SAAQC,aAAR,QAA4B,eAA5B;AACA,SACEC,WADF,EAGEC,aAHF,EAIEC,kBAJF,EAKEC,2BALF,QAMO,kBANP;AAOA,SACEC,8BADF,EAEEC,gBAFF,EAGEC,oBAHF,EAIEC,YAJF,EAKEC,eALF,EAMEC,QANF,EAOEC,cAPF,EAQEC,aARF,EASEC,aATF,EAUEC,kBAVF,QAWO,YAXP;AAYA,SAGEC,WAHF,EAMEC,oBANF,EAaEC,oBAbF,QAeO,SAfP;AAiBA,SAAQrB,UAAR,EAAoBD,SAApB,EAA+BE,MAA/B,EAAuCC,SAAvC,EAAkDa,cAAlD;AAEA,MAAM;EAACO,QAAD;EAAWC,WAAX;EAAwBC,WAAxB;EAAqCC;AAArC,IAA0D5B,aAAhE;AACA,MAAM6B,8BAA8B,GAAGP,WAAW,CAACQ,IAAnD;AACA,MAAMC,qBAAqB,GAAGT,WAAW,CAACU,KAA1C;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAMA,OAAO,MAAMC,KAAK,GAAG,YAIV;EAAA,IAJW;IACpBC,YAAY,GAAG;EADK,CAIX,uEAAP,EAAO;;EACT,QAAQA,YAAR;IACE,KAAK,gBAAL;MACEf,aAAa;MACb;;IACF,KAAK,gBAAL;MACEC,aAAa;MACb;;IACF,KAAK,sBAAL;MACEC,kBAAkB;MAClB;;IACF;MACE;EAXJ;AAaD,CAlBM;AAoBP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,MAAMc,cAAc,GAAG,MAC5BnB,eAAe,GAAGmB,cAAlB,EADK;AAGP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,MAAMC,aAAa,GAAG,MAC3BpB,eAAe,GAAGoB,aAAlB,EADK;AAGP;AACA;AACA;AACA;;AACA,OAAO,MAAMC,0CAA0C,GACrD,MACExB,gBAAgB,GAAGyB,mCAAnB,EAFG;AAIP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,MAAMC,WAAW,GAAG,QAII;EAAA,IAJH;IAC1BC;EAD0B,CAIG;;EAC7B,IAAI,EAACA,IAAD,aAACA,IAAD,eAACA,IAAI,CAAEC,MAAP,CAAJ,EAAmB;IACjB,OAAOC,OAAO,CAACC,MAAR,CAAe,oBAAf,CAAP;EACD;;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K,GAAP;AAoBD,CA3BM"}
@@ -1 +1 @@
1
- {"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export * from './iap';\nexport * from './types';\nexport * from './eventEmitter';\nexport * from './hooks/useIAP';\nexport * from './hooks/withIAPContext';\nexport * from './purchaseError';\nexport * from './modules';\n"],"mappings":"AAAA,cAAc,OAAd;AACA,cAAc,SAAd;AACA,cAAc,gBAAd;AACA,cAAc,gBAAd;AACA,cAAc,wBAAd;AACA,cAAc,iBAAd;AACA,cAAc,WAAd"}
1
+ {"version":3,"names":[],"sourceRoot":"../../src","sources":["index.ts"],"mappings":"AAAA,cAAc,OAAd;AACA,cAAc,SAAd;AACA,cAAc,gBAAd;AACA,cAAc,gBAAd;AACA,cAAc,wBAAd;AACA,cAAc,iBAAd;AACA,cAAc,WAAd"}
@@ -1 +1 @@
1
- {"version":3,"names":["enhancedFetch","url","init","response","fetch","method","headers","Accept","body","JSON","stringify","ok","Object","assign","Error","statusText","statusCode","status","json"],"sources":["enhancedFetch.ts"],"sourcesContent":["interface OverwrittenRequestInit extends Omit<RequestInit, 'body'> {\n body: Record<string, any>;\n}\n\nexport const enhancedFetch = async <T = any>(\n url: string,\n init?: OverwrittenRequestInit,\n) => {\n const response = await fetch(url, {\n method: init?.method ?? 'GET',\n headers: {\n Accept: 'application/json',\n 'Content-Type': 'application/json',\n },\n ...(init?.body ? {body: JSON.stringify(init.body)} : {}),\n });\n\n if (!response.ok) {\n throw Object.assign(new Error(response.statusText), {\n statusCode: response.status,\n });\n }\n\n return response.json() as Promise<T>;\n};\n"],"mappings":"AAIA,OAAO,MAAMA,aAAa,GAAG,OAC3BC,GAD2B,EAE3BC,IAF2B,KAGxB;EACH,MAAMC,QAAQ,GAAG,MAAMC,KAAK,CAACH,GAAD,EAAM;IAChCI,MAAM,EAAE,CAAAH,IAAI,SAAJ,IAAAA,IAAI,WAAJ,YAAAA,IAAI,CAAEG,MAAN,KAAgB,KADQ;IAEhCC,OAAO,EAAE;MACPC,MAAM,EAAE,kBADD;MAEP,gBAAgB;IAFT,CAFuB;IAMhC,IAAIL,IAAI,SAAJ,IAAAA,IAAI,WAAJ,IAAAA,IAAI,CAAEM,IAAN,GAAa;MAACA,IAAI,EAAEC,IAAI,CAACC,SAAL,CAAeR,IAAI,CAACM,IAApB;IAAP,CAAb,GAAiD,EAArD;EANgC,CAAN,CAA5B;;EASA,IAAI,CAACL,QAAQ,CAACQ,EAAd,EAAkB;IAChB,MAAMC,MAAM,CAACC,MAAP,CAAc,IAAIC,KAAJ,CAAUX,QAAQ,CAACY,UAAnB,CAAd,EAA8C;MAClDC,UAAU,EAAEb,QAAQ,CAACc;IAD6B,CAA9C,CAAN;EAGD;;EAED,OAAOd,QAAQ,CAACe,IAAT,EAAP;AACD,CApBM"}
1
+ {"version":3,"names":["enhancedFetch","url","init","response","fetch","method","headers","Accept","body","JSON","stringify","ok","Object","assign","Error","statusText","statusCode","status","json"],"sourceRoot":"../../../src","sources":["internal/enhancedFetch.ts"],"mappings":"AAIA,OAAO,MAAMA,aAAa,GAAG,OAC3BC,GAD2B,EAE3BC,IAF2B,KAGxB;EACH,MAAMC,QAAQ,GAAG,MAAMC,KAAK,CAACH,GAAD,EAAM;IAChCI,MAAM,EAAE,CAAAH,IAAI,SAAJ,IAAAA,IAAI,WAAJ,YAAAA,IAAI,CAAEG,MAAN,KAAgB,KADQ;IAEhCC,OAAO,EAAE;MACPC,MAAM,EAAE,kBADD;MAEP,gBAAgB;IAFT,CAFuB;IAMhC,IAAIL,IAAI,SAAJ,IAAAA,IAAI,WAAJ,IAAAA,IAAI,CAAEM,IAAN,GAAa;MAACA,IAAI,EAAEC,IAAI,CAACC,SAAL,CAAeR,IAAI,CAACM,IAApB;IAAP,CAAb,GAAiD,EAArD;EANgC,CAAN,CAA5B;;EASA,IAAI,CAACL,QAAQ,CAACQ,EAAd,EAAkB;IAChB,MAAMC,MAAM,CAACC,MAAP,CAAc,IAAIC,KAAJ,CAAUX,QAAQ,CAACY,UAAnB,CAAd,EAA8C;MAClDC,UAAU,EAAEb,QAAQ,CAACc;IAD6B,CAA9C,CAAN;EAGD;;EAED,OAAOd,QAAQ,CAACe,IAAT,EAAP;AACD,CApBM"}
@@ -1 +1 @@
1
- {"version":3,"names":["NativeModules","RNIapAmazonModule","fillProductsWithAdditionalData","items","user","getUser","currencies","CA","ES","AU","DE","IN","US","JP","GB","IT","BR","FR","currency","userMarketplaceAmazon","forEach","item"],"sources":["fillProductsWithAdditionalData.ts"],"sourcesContent":["import {NativeModules} from 'react-native';\n\nimport type {ProductCommon} from '../types';\n\nconst {RNIapAmazonModule} = NativeModules;\n\n/**\n * For Amazon products, we add the currency code from the user's information\n * since it isn't included in the product information.\n */\nexport const fillProductsWithAdditionalData = async <T extends ProductCommon>(\n items: T[],\n): Promise<T[]> => {\n if (RNIapAmazonModule) {\n // On amazon we must get the user marketplace to detect the currency\n const user = await RNIapAmazonModule.getUser();\n\n const currencies = {\n CA: 'CAD',\n ES: 'EUR',\n AU: 'AUD',\n DE: 'EUR',\n IN: 'INR',\n US: 'USD',\n JP: 'JPY',\n GB: 'GBP',\n IT: 'EUR',\n BR: 'BRL',\n FR: 'EUR',\n };\n\n const currency =\n currencies[user.userMarketplaceAmazon as keyof typeof currencies];\n\n // Add currency to items\n items.forEach((item) => {\n if (currency) {\n item.currency = currency;\n }\n });\n }\n\n return items;\n};\n"],"mappings":"AAAA,SAAQA,aAAR,QAA4B,cAA5B;AAIA,MAAM;EAACC;AAAD,IAAsBD,aAA5B;AAEA;AACA;AACA;AACA;;AACA,OAAO,MAAME,8BAA8B,GAAG,MAC5CC,KAD4C,IAE3B;EACjB,IAAIF,iBAAJ,EAAuB;IACrB;IACA,MAAMG,IAAI,GAAG,MAAMH,iBAAiB,CAACI,OAAlB,EAAnB;IAEA,MAAMC,UAAU,GAAG;MACjBC,EAAE,EAAE,KADa;MAEjBC,EAAE,EAAE,KAFa;MAGjBC,EAAE,EAAE,KAHa;MAIjBC,EAAE,EAAE,KAJa;MAKjBC,EAAE,EAAE,KALa;MAMjBC,EAAE,EAAE,KANa;MAOjBC,EAAE,EAAE,KAPa;MAQjBC,EAAE,EAAE,KARa;MASjBC,EAAE,EAAE,KATa;MAUjBC,EAAE,EAAE,KAVa;MAWjBC,EAAE,EAAE;IAXa,CAAnB;IAcA,MAAMC,QAAQ,GACZZ,UAAU,CAACF,IAAI,CAACe,qBAAN,CADZ,CAlBqB,CAqBrB;;IACAhB,KAAK,CAACiB,OAAN,CAAeC,IAAD,IAAU;MACtB,IAAIH,QAAJ,EAAc;QACZG,IAAI,CAACH,QAAL,GAAgBA,QAAhB;MACD;IACF,CAJD;EAKD;;EAED,OAAOf,KAAP;AACD,CAjCM"}
1
+ {"version":3,"names":["NativeModules","RNIapAmazonModule","fillProductsWithAdditionalData","items","user","getUser","currencies","CA","ES","AU","DE","IN","US","JP","GB","IT","BR","FR","currency","userMarketplaceAmazon","forEach","item"],"sourceRoot":"../../../src","sources":["internal/fillProductsWithAdditionalData.ts"],"mappings":"AAAA,SAAQA,aAAR,QAA4B,cAA5B;AAIA,MAAM;EAACC;AAAD,IAAsBD,aAA5B;AAEA;AACA;AACA;AACA;;AACA,OAAO,MAAME,8BAA8B,GAAG,MAC5CC,KAD4C,IAE3B;EACjB,IAAIF,iBAAJ,EAAuB;IACrB;IACA,MAAMG,IAAI,GAAG,MAAMH,iBAAiB,CAACI,OAAlB,EAAnB;IAEA,MAAMC,UAAU,GAAG;MACjBC,EAAE,EAAE,KADa;MAEjBC,EAAE,EAAE,KAFa;MAGjBC,EAAE,EAAE,KAHa;MAIjBC,EAAE,EAAE,KAJa;MAKjBC,EAAE,EAAE,KALa;MAMjBC,EAAE,EAAE,KANa;MAOjBC,EAAE,EAAE,KAPa;MAQjBC,EAAE,EAAE,KARa;MASjBC,EAAE,EAAE,KATa;MAUjBC,EAAE,EAAE,KAVa;MAWjBC,EAAE,EAAE;IAXa,CAAnB;IAcA,MAAMC,QAAQ,GACZZ,UAAU,CAACF,IAAI,CAACe,qBAAN,CADZ,CAlBqB,CAqBrB;;IACAhB,KAAK,CAACiB,OAAN,CAAeC,IAAD,IAAU;MACtB,IAAIH,QAAJ,EAAc;QACZG,IAAI,CAACH,QAAL,GAAgBA,QAAhB;MACD;IACF,CAJD;EAKD;;EAED,OAAOf,KAAP;AACD,CAjCM"}
@@ -1 +1 @@
1
- {"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export * from './enhancedFetch';\nexport * from './fillProductsWithAdditionalData';\nexport * from './platform';\n"],"mappings":"AAAA,cAAc,iBAAd;AACA,cAAc,kCAAd;AACA,cAAc,YAAd"}
1
+ {"version":3,"names":[],"sourceRoot":"../../../src","sources":["internal/index.ts"],"mappings":"AAAA,cAAc,iBAAd;AACA,cAAc,kCAAd;AACA,cAAc,YAAd"}
@@ -1 +1 @@
1
- {"version":3,"names":["NativeModules","Platform","ErrorCode","RNIapIos","RNIapIosSk2","RNIapModule","RNIapAmazonModule","isIos","OS","isAndroid","isAmazon","isPlay","androidNativeModule","setAndroidNativeModule","nativeModule","checkNativeAndroidAvailable","Error","E_IAP_NOT_AVAILABLE","getAndroidModule","getAndroidModuleType","module","getNativeModule","getIosModule","iosNativeModule","isStorekit2Avaiable","isAvailable","isIosStorekit2","setIosNativeModule","storekit2Mode","disable","console","warn","storekit1Mode","storekitHybridMode","info","checkNativeIOSAvailable"],"sources":["platform.ts"],"sourcesContent":["import {NativeModules, Platform} from 'react-native';\n\nimport {ErrorCode} from '../purchaseError';\n\nconst {RNIapIos, RNIapIosSk2, RNIapModule, RNIapAmazonModule} = NativeModules;\n\nexport const isIos = Platform.OS === 'ios';\nexport const isAndroid = Platform.OS === 'android';\nexport const isAmazon = isAndroid && !!RNIapAmazonModule;\nexport const isPlay = isAndroid && !!RNIapModule;\n\n// Android\n\nlet androidNativeModule = RNIapModule;\n\nexport const setAndroidNativeModule = (\n nativeModule: typeof RNIapModule,\n): void => {\n androidNativeModule = nativeModule;\n};\n\nexport const checkNativeAndroidAvailable = (): void => {\n if (!RNIapModule && !RNIapAmazonModule) {\n throw new Error(ErrorCode.E_IAP_NOT_AVAILABLE);\n }\n};\n\n/**\n * If changing the typings of `getAndroidModule` to accommodate extra modules,\n * make sure to update `getAndroidModuleType`.\n */\nexport const getAndroidModule = ():\n | typeof RNIapModule\n | typeof RNIapAmazonModule => {\n checkNativeAndroidAvailable();\n\n return androidNativeModule\n ? androidNativeModule\n : RNIapModule\n ? RNIapModule\n : RNIapAmazonModule;\n};\n\n/**\n * Returns whether the Android in-app-purchase code is using the Android,\n * Amazon, or another store.\n */\nexport const getAndroidModuleType = (): 'android' | 'amazon' | null => {\n const module = getAndroidModule();\n switch (module) {\n case RNIapModule:\n return 'android';\n case RNIapAmazonModule:\n return 'amazon';\n default:\n return null;\n }\n};\n\nexport const getNativeModule = ():\n | typeof RNIapModule\n | typeof RNIapAmazonModule\n | typeof RNIapIos\n | typeof RNIapIosSk2 => {\n return isAndroid ? getAndroidModule() : getIosModule();\n};\n\n// iOS\n\nlet iosNativeModule: typeof RNIapIos | typeof RNIapIosSk2 = RNIapIos;\n\nexport const isStorekit2Avaiable = (): boolean =>\n isIos && RNIapIosSk2?.isAvailable() === 1;\n\nexport const isIosStorekit2 = () =>\n isIos &&\n !!iosNativeModule &&\n iosNativeModule === RNIapIosSk2 &&\n isStorekit2Avaiable();\n\nexport const setIosNativeModule = (\n nativeModule: typeof RNIapIos | typeof RNIapIosSk2,\n): void => {\n iosNativeModule = nativeModule;\n};\n\nexport const storekit2Mode = () => {\n iosNativeModule = RNIapIosSk2;\n if (isStorekit2Avaiable()) {\n RNIapIos.disable();\n return true;\n }\n if (isIos) {\n console.warn('Storekit 2 is not available on this device');\n return false;\n }\n return true;\n};\n\nexport const storekit1Mode = () => {\n iosNativeModule = RNIapIos;\n if (isStorekit2Avaiable()) {\n RNIapIosSk2.disable();\n return true;\n }\n return false;\n};\n\nexport const storekitHybridMode = () => {\n if (isStorekit2Avaiable()) {\n iosNativeModule = RNIapIosSk2;\n console.info('Using Storekit 2');\n return true;\n } else {\n iosNativeModule = RNIapIos;\n console.info('Using Storekit 1');\n return true;\n }\n};\n\nconst checkNativeIOSAvailable = (): void => {\n if (!RNIapIos && !isStorekit2Avaiable()) {\n throw new Error(ErrorCode.E_IAP_NOT_AVAILABLE);\n }\n};\n\nexport const getIosModule = (): typeof RNIapIos | typeof RNIapIosSk2 => {\n checkNativeIOSAvailable();\n\n return iosNativeModule\n ? iosNativeModule\n : RNIapIosSk2\n ? RNIapIosSk2\n : RNIapIos;\n};\n"],"mappings":"AAAA,SAAQA,aAAR,EAAuBC,QAAvB,QAAsC,cAAtC;AAEA,SAAQC,SAAR,QAAwB,kBAAxB;AAEA,MAAM;EAACC,QAAD;EAAWC,WAAX;EAAwBC,WAAxB;EAAqCC;AAArC,IAA0DN,aAAhE;AAEA,OAAO,MAAMO,KAAK,GAAGN,QAAQ,CAACO,EAAT,KAAgB,KAA9B;AACP,OAAO,MAAMC,SAAS,GAAGR,QAAQ,CAACO,EAAT,KAAgB,SAAlC;AACP,OAAO,MAAME,QAAQ,GAAGD,SAAS,IAAI,CAAC,CAACH,iBAAhC;AACP,OAAO,MAAMK,MAAM,GAAGF,SAAS,IAAI,CAAC,CAACJ,WAA9B,C,CAEP;;AAEA,IAAIO,mBAAmB,GAAGP,WAA1B;AAEA,OAAO,MAAMQ,sBAAsB,GACjCC,YADoC,IAE3B;EACTF,mBAAmB,GAAGE,YAAtB;AACD,CAJM;AAMP,OAAO,MAAMC,2BAA2B,GAAG,MAAY;EACrD,IAAI,CAACV,WAAD,IAAgB,CAACC,iBAArB,EAAwC;IACtC,MAAM,IAAIU,KAAJ,CAAUd,SAAS,CAACe,mBAApB,CAAN;EACD;AACF,CAJM;AAMP;AACA;AACA;AACA;;AACA,OAAO,MAAMC,gBAAgB,GAAG,MAEA;EAC9BH,2BAA2B;EAE3B,OAAOH,mBAAmB,GACtBA,mBADsB,GAEtBP,WAAW,GACXA,WADW,GAEXC,iBAJJ;AAKD,CAVM;AAYP;AACA;A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AAmB,EAAvB,EAA2B;IACzBD,eAAe,GAAGnB,WAAlB;IACA0B,OAAO,CAACI,IAAR,CAAa,kBAAb;IACA,OAAO,IAAP;EACD,CAJD,MAIO;IACLX,eAAe,GAAGpB,QAAlB;IACA2B,OAAO,CAACI,IAAR,CAAa,kBAAb;IACA,OAAO,IAAP;EACD;AACF,CAVM;;AAYP,MAAMC,uBAAuB,GAAG,MAAY;EAC1C,IAAI,CAAChC,QAAD,IAAa,CAACqB,mBAAmB,EAArC,EAAyC;IACvC,MAAM,IAAIR,KAAJ,CAAUd,SAAS,CAACe,mBAApB,CAAN;EACD;AACF,CAJD;;AAMA,OAAO,MAAMK,YAAY,GAAG,MAA4C;EACtEa,uBAAuB;EAEvB,OAAOZ,eAAe,GAClBA,eADkB,GAElBnB,WAAW,GACXA,WADW,GAEXD,QAJJ;AAKD,CARM"}
1
+ {"version":3,"names":["NativeModules","Platform","ErrorCode","RNIapIos","RNIapIosSk2","RNIapModule","RNIapAmazonModule","isIos","OS","isAndroid","isAmazon","isPlay","androidNativeModule","setAndroidNativeModule","nativeModule","checkNativeAndroidAvailable","Error","E_IAP_NOT_AVAILABLE","getAndroidModule","getAndroidModuleType","module","getNativeModule","getIosModule","iosNativeModule","isStorekit2Avaiable","isAvailable","isIosStorekit2","setIosNativeModule","storekit2Mode","disable","console","warn","storekit1Mode","storekitHybridMode","info","checkNativeIOSAvailable"],"sourceRoot":"../../../src","sources":["internal/platform.ts"],"mappings":"AAAA,SAAQA,aAAR,EAAuBC,QAAvB,QAAsC,cAAtC;AAEA,SAAQC,SAAR,QAAwB,kBAAxB;AAEA,MAAM;EAACC,QAAD;EAAWC,WAAX;EAAwBC,WAAxB;EAAqCC;AAArC,IAA0DN,aAAhE;AAEA,OAAO,MAAMO,KAAK,GAAGN,QAAQ,CAACO,EAAT,KAAgB,KAA9B;AACP,OAAO,MAAMC,SAAS,GAAGR,QAAQ,CAACO,EAAT,KAAgB,SAAlC;AACP,OAAO,MAAME,QAAQ,GA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AMG,kBAAkB,GAC7Bb,YADgC,IAEvB;EACTS,eAAe,GAAGT,YAAlB;AACD,CAJM;AAMP,OAAO,MAAMc,aAAa,GAAG,MAAM;EACjCL,eAAe,GAAGnB,WAAlB;;EACA,IAAIoB,mBAAmB,EAAvB,EAA2B;IACzBrB,QAAQ,CAAC0B,OAAT;IACA,OAAO,IAAP;EACD;;EACD,IAAItB,KAAJ,EAAW;IACTuB,OAAO,CAACC,IAAR,CAAa,4CAAb;IACA,OAAO,KAAP;EACD;;EACD,OAAO,IAAP;AACD,CAXM;AAaP,OAAO,MAAMC,aAAa,GAAG,MAAM;EACjCT,eAAe,GAAGpB,QAAlB;;EACA,IAAIqB,mBAAmB,EAAvB,EAA2B;IACzBpB,WAAW,CAACyB,OAAZ;IACA,OAAO,IAAP;EACD;;EACD,OAAO,KAAP;AACD,CAPM;AASP,OAAO,MAAMI,kBAAkB,GAAG,MAAM;EACtC,IAAIT,mBAAmB,EAAvB,EAA2B;IACzBD,eAAe,GAAGnB,WAAlB;IACA0B,OAAO,CAACI,IAAR,CAAa,kBAAb;IACA,OAAO,IAAP;EACD,CAJD,MAIO;IACLX,eAAe,GAAGpB,QAAlB;IACA2B,OAAO,CAACI,IAAR,CAAa,kBAAb;IACA,OAAO,IAAP;EACD;AACF,CAVM;;AAYP,MAAMC,uBAAuB,GAAG,MAAY;EAC1C,IAAI,CAAChC,QAAD,IAAa,CAACqB,mBAAmB,EAArC,EAAyC;IACvC,MAAM,IAAIR,KAAJ,CAAUd,SAAS,CAACe,mBAApB,CAAN;EACD;AACF,CAJD;;AAMA,OAAO,MAAMK,YAAY,GAAG,MAA4C;EACtEa,uBAAuB;EAEvB,OAAOZ,eAAe,GAClBA,eADkB,GAElBnB,WAAW,GACXA,WADW,GAEXD,QAJJ;AAKD,CARM"}
@@ -1 +1 @@
1
- {"version":3,"names":["NativeModules","enhancedFetch","AmazonModule","RNIapAmazonModule","validateReceiptAmazon","developerSecret","userId","receiptId","useSandbox","sandBoxUrl","url","verifyLicense","deepLinkToSubscriptionsAmazon","isAmazonDevice","deepLinkToSubscriptions"],"sources":["amazon.ts"],"sourcesContent":["import {NativeModules} from 'react-native';\n\nimport {enhancedFetch} from '../internal';\nimport type {Product, Purchase, Sku} from '../types';\nimport type {\n AmazonLicensingStatus,\n ReceiptType,\n UserDataAmazon,\n} from '../types/amazon';\n\nimport type {NativeModuleProps} from './common';\n// ----------\n\ntype GetUser = () => Promise<UserDataAmazon>;\ntype FlushFailedPurchasesCachedAsPending = () => Promise<boolean>;\ntype GetItemsByType = (type: string, skus: Sku[]) => Promise<Product[]>;\ntype GetAvailableItems = () => Promise<Purchase[]>;\ntype BuyItemByType = (sku: Sku) => Promise<Purchase>;\n\ntype AcknowledgePurchase = (\n purchaseToken: string,\n developerPayloadAndroid?: string,\n) => Promise<boolean>;\n\ntype ConsumeProduct = (\n purchaseToken: string,\n developerPayloadAndroid?: string,\n) => Promise<boolean>;\n\ntype StartListening = () => Promise<void>;\n\nexport interface AmazonModuleProps extends NativeModuleProps {\n getUser: GetUser;\n flushFailedPurchasesCachedAsPending: FlushFailedPurchasesCachedAsPending;\n getItemsByType: GetItemsByType;\n getAvailableItems: GetAvailableItems;\n buyItemByType: BuyItemByType;\n acknowledgePurchase: AcknowledgePurchase;\n consumeProduct: ConsumeProduct;\n /** @deprecated to be renamed to sendUnconsumedPurchases if not removed completely */\n startListening: StartListening;\n verifyLicense: () => Promise<AmazonLicensingStatus>;\n deepLinkToSubscriptions: (isAmazonDevice: boolean) => Promise<void>;\n}\n\nexport const AmazonModule =\n NativeModules.RNIapAmazonModule as AmazonModuleProps;\n\n/**\n * Validate receipt for Amazon. NOTE: This method is here for debugging purposes only. Including\n * your developer secret in the binary you ship to users is potentially dangerous.\n * Use server side validation instead for your production builds\n * @param {string} developerSecret: from the Amazon developer console.\n * @param {string} userId who purchased the item.\n * @param {string} receiptId long obfuscated string returned when purchasing the item\n * @param {boolean} useSandbox Defaults to true, use sandbox environment or production.\n * @returns {Promise<object>}\n */\nexport const validateReceiptAmazon = async ({\n developerSecret,\n userId,\n receiptId,\n useSandbox = true,\n}: {\n developerSecret: string;\n userId: string;\n receiptId: string;\n useSandbox: boolean;\n}): Promise<ReceiptType> => {\n const sandBoxUrl = useSandbox ? 'sandbox/' : '';\n const url = `https://appstore-sdk.amazon.com/${sandBoxUrl}version/1.0/verifyReceiptId/developer/${developerSecret}/user/${userId}/receiptId/${receiptId}`;\n\n return await enhancedFetch<ReceiptType>(url);\n};\n\n/**\n * Returns the status of verifying app's license @see AmazonLicensingStatus\n */\nexport const verifyLicense = async (): Promise<AmazonLicensingStatus> =>\n AmazonModule.verifyLicense();\n\n/**\n * Deep link to subscriptions screen on Android.\n * @param {string} sku The product's SKU (on Android)\n * @returns {Promise<void>}\n */\nexport const deepLinkToSubscriptionsAmazon = async ({\n isAmazonDevice,\n}: {\n isAmazonDevice: boolean;\n}): Promise<void> => AmazonModule.deepLinkToSubscriptions(isAmazonDevice);\n"],"mappings":"AAAA,SAAQA,aAAR,QAA4B,cAA5B;AAEA,SAAQC,aAAR,QAA4B,aAA5B;AA2CA,OAAO,MAAMC,YAAY,GACvBF,aAAa,CAACG,iBADT;AAGP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,MAAMC,qBAAqB,GAAG,cAUT;EAAA,IAVgB;IAC1CC,eAD0C;IAE1CC,MAF0C;IAG1CC,SAH0C;IAI1CC,UAAU,GAAG;EAJ6B,CAUhB;EAC1B,MAAMC,UAAU,GAAGD,UAAU,GAAG,UAAH,GAAgB,EAA7C;EACA,MAAME,GAAG,GAAI,mCAAkCD,UAAW,yCAAwCJ,eAAgB,SAAQC,MAAO,cAAaC,SAAU,EAAxJ;EAEA,OAAO,MAAMN,aAAa,CAAcS,GAAd,CAA1B;AACD,CAfM;AAiBP;AACA;AACA;;AACA,OAAO,MAAMC,aAAa,GAAG,YAC3BT,YAAY,CAACS,aAAb,EADK;AAGP;AACA;AACA;AACA;AACA;;AACA,OAAO,MAAMC,6BAA6B,GAAG;EAAA,IAAO;IAClDC;EADkD,CAAP;EAAA,OAIxBX,YAAY,CAACY,uBAAb,CAAqCD,cAArC,CAJwB;AAAA,CAAtC"}
1
+ {"version":3,"names":["NativeModules","enhancedFetch","AmazonModule","RNIapAmazonModule","validateReceiptAmazon","developerSecret","userId","receiptId","useSandbox","sandBoxUrl","url","verifyLicense","deepLinkToSubscriptionsAmazon","isAmazonDevice","deepLinkToSubscriptions"],"sourceRoot":"../../../src","sources":["modules/amazon.ts"],"mappings":"AAAA,SAAQA,aAAR,QAA4B,cAA5B;AAEA,SAAQC,aAAR,QAA4B,aAA5B;AA2CA,OAAO,MAAMC,YAAY,GACvBF,aAAa,CAACG,iBADT;AAGP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,MAAMC,qBAAqB,GAAG,cAUT;EAAA,IAVgB;IAC1CC,eAD0C;IAE1CC,MAF0C;IAG1CC,SAH0C;IAI1CC,UAAU,GAAG;EAJ6B,CAUhB;EAC1B,MAAMC,UAAU,GAAGD,UAAU,GAAG,UAAH,GAAgB,EAA7C;EACA,MAAME,GAAG,GAAI,mCAAkCD,UAAW,yCAAwCJ,eAAgB,SAAQC,MAAO,cAAaC,SAAU,EAAxJ;EAEA,OAAO,MAAMN,aAAa,CAAcS,GAAd,CAA1B;AACD,CAfM;AAiBP;AACA;AACA;;AACA,OAAO,MAAMC,aAAa,GAAG,YAC3BT,YAAY,CAACS,aAAb,EADK;AAGP;AACA;AACA;AACA;AACA;;AACA,OAAO,MAAMC,6BAA6B,GAAG;EAAA,IAAO;IAClDC;EADkD,CAAP;EAAA,OAIxBX,YAAY,CAACY,uBAAb,CAAqCD,cAArC,CAJwB;AAAA,CAAtC"}
@@ -1 +1 @@
1
- {"version":3,"names":["Linking","NativeModules","checkNativeAndroidAvailable","getAndroidModule","InstallSourceAndroid","RNIapModule","AndroidModule","getInstallSourceAndroid","GOOGLE_PLAY","AMAZON","deepLinkToSubscriptionsAndroid","sku","openURL","getPackageName","validateReceiptAndroid","packageName","productId","productToken","accessToken","isSub","type","url","response","fetch","method","headers","ok","Object","assign","Error","statusText","statusCode","status","json","acknowledgePurchaseAndroid","token","developerPayload","acknowledgePurchase"],"sources":["android.ts"],"sourcesContent":["import {Linking, NativeModules} from 'react-native';\n\nimport {checkNativeAndroidAvailable, getAndroidModule} from '../internal';\nimport {\n InstallSourceAndroid,\n Product,\n ProductType,\n ProrationModesAndroid,\n Purchase,\n PurchaseResult,\n Sku,\n} from '../types';\nimport type * as Android from '../types/android';\n\nimport type {NativeModuleProps} from './common';\n\nconst {RNIapModule} = NativeModules;\n\ntype FlushFailedPurchasesCachedAsPending = () => Promise<boolean>;\n\ntype GetItemsByType = <T = Product>(\n type: ProductType,\n skus: Sku[],\n) => Promise<T[]>;\n\ntype GetAvailableItemsByType = <T = Purchase>(\n type: ProductType,\n) => Promise<T[]>;\n\ntype GetPurchaseHistoryByType = <T = Purchase>(\n type: ProductType,\n) => Promise<T[]>;\n\nexport type BuyItemByType = (\n type: string,\n skus: Sku[],\n purchaseToken: string | undefined,\n prorationMode: ProrationModesAndroid | -1,\n obfuscatedAccountId: string | undefined,\n obfuscatedProfileId: string | undefined,\n subscriptionOffers: string[],\n isOfferPersonalized: boolean,\n) => Promise<Purchase>;\n\ntype AcknowledgePurchase = (\n purchaseToken: string,\n developerPayloadAndroid?: string,\n) => Promise<PurchaseResult | boolean>;\n\ntype ConsumeProduct = (\n purchaseToken: string,\n developerPayloadAndroid?: string,\n) => Promise<PurchaseResult | boolean>;\n\ntype StartListening = () => Promise<void>;\ntype GetPackageName = () => Promise<string>;\n\nexport interface AndroidModuleProps extends NativeModuleProps {\n flushFailedPurchasesCachedAsPending: FlushFailedPurchasesCachedAsPending;\n getItemsByType: GetItemsByType;\n getAvailableItemsByType: GetAvailableItemsByType;\n getPurchaseHistoryByType: GetPurchaseHistoryByType;\n buyItemByType: BuyItemByType;\n acknowledgePurchase: AcknowledgePurchase;\n consumeProduct: ConsumeProduct;\n /** @deprecated to be renamed to sendUnconsumedPurchases if not removed completely */\n startListening: StartListening;\n getPackageName: GetPackageName;\n}\n\nexport const AndroidModule = NativeModules.RNIapModule as AndroidModuleProps;\n\nexport const getInstallSourceAndroid = (): InstallSourceAndroid => {\n return RNIapModule\n ? InstallSourceAndroid.GOOGLE_PLAY\n : InstallSourceAndroid.AMAZON;\n};\n\n/**\n * Deep link to subscriptions screen on Android.\n * @param {string} sku The product's SKU (on Android)\n * @returns {Promise<void>}\n */\nexport const deepLinkToSubscriptionsAndroid = async ({\n sku,\n}: {\n sku: Sku;\n}): Promise<void> => {\n checkNativeAndroidAvailable();\n\n return Linking.openURL(\n `https://play.google.com/store/account/subscriptions?package=${await RNIapModule.getPackageName()}&sku=${sku}`,\n );\n};\n\n/**\n * Validate receipt for Android. NOTE: This method is here for debugging purposes only. Including\n * your access token in the binary you ship to users is potentially dangerous.\n * Use server side validation instead for your production builds\n * @param {string} packageName package name of your app.\n * @param {string} productId product id for your in app product.\n * @param {string} productToken token for your purchase.\n * @param {string} accessToken accessToken from googleApis.\n * @param {boolean} isSub whether this is subscription or inapp. `true` for subscription.\n * @returns {Promise<object>}\n */\nexport const validateReceiptAndroid = async ({\n packageName,\n productId,\n productToken,\n accessToken,\n isSub,\n}: {\n packageName: string;\n productId: string;\n productToken: string;\n accessToken: string;\n isSub?: boolean;\n}): Promise<Android.ReceiptType> => {\n const type = isSub ? 'subscriptions' : 'products';\n\n const url =\n 'https://androidpublisher.googleapis.com/androidpublisher/v3/applications' +\n `/${packageName}/purchases/${type}/${productId}` +\n `/tokens/${productToken}?access_token=${accessToken}`;\n\n const response = await fetch(url, {\n method: 'GET',\n headers: {\n 'Content-Type': 'application/json',\n },\n });\n\n if (!response.ok) {\n throw Object.assign(new Error(response.statusText), {\n statusCode: response.status,\n });\n }\n\n return response.json();\n};\n\n/**\n * Acknowledge a product (on Android.) No-op on iOS.\n * @param {string} token The product's token (on Android)\n * @returns {Promise<PurchaseResult | void>}\n */\nexport const acknowledgePurchaseAndroid = ({\n token,\n developerPayload,\n}: {\n token: string;\n developerPayload?: string;\n}): Promise<PurchaseResult | boolean | void> => {\n return getAndroidModule().acknowledgePurchase(token, developerPayload);\n};\n"],"mappings":"AAAA,SAAQA,OAAR,EAAiBC,aAAjB,QAAqC,cAArC;AAEA,SAAQC,2BAAR,EAAqCC,gBAArC,QAA4D,aAA5D;AACA,SACEC,oBADF,QAQO,UARP;AAaA,MAAM;EAACC;AAAD,IAAgBJ,aAAtB;AAsDA,OAAO,MAAMK,aAAa,GAAGL,aAAa,CAACI,WAApC;AAEP,OAAO,MAAME,uBAAuB,GAAG,MAA4B;EACjE,OAAOF,WAAW,GACdD,oBAAoB,CAACI,WADP,GAEdJ,oBAAoB,CAACK,MAFzB;AAGD,CAJM;AAMP;AACA;AACA;AACA;AACA;;AACA,OAAO,MAAMC,8BAA8B,GAAG,cAIzB;EAAA,IAJgC;IACnDC;EADmD,CAIhC;EACnBT,2BAA2B;EAE3B,OAAOF,OAAO,CAACY,OAAR,CACJ,+DAA8D,MAAMP,WAAW,CAACQ,cAAZ,EAA6B,QAAOF,GAAI,EADxG,CAAP;AAGD,CAVM;AAYP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,MAAMG,sBAAsB,GAAG,eAYF;EAAA,IAZS;IAC3CC,WAD2C;IAE3CC,SAF2C;IAG3CC,YAH2C;IAI3CC,WAJ2C;IAK3CC;EAL2C,CAYT;EAClC,MAAMC,IAAI,GAAGD,KAAK,GAAG,eAAH,GAAqB,UAAvC;EAEA,MAAME,GAAG,GACP,6EACC,IAAGN,WAAY,cAAaK,IAAK,IAAGJ,SAAU,EAD/C,GAEC,WAAUC,YAAa,iBAAgBC,WAAY,EAHtD;EAKA,MAAMI,QAAQ,GAAG,MAAMC,KAAK,CAACF,GAAD,EAAM;IAChCG,MAAM,EAAE,KADwB;IAEhCC,OAAO,EAAE;MACP,gBAAgB;IADT;EAFuB,CAAN,CAA5B;;EAOA,IAAI,CAACH,QAAQ,CAACI,EAAd,EAAkB;IAChB,MAAMC,MAAM,CAACC,MAAP,CAAc,IAAIC,KAAJ,CAAUP,QAAQ,CAACQ,UAAnB,CAAd,EAA8C;MAClDC,UAAU,EAAET,QAAQ,CAACU;IAD6B,CAA9C,CAAN;EAGD;;EAED,OAAOV,QAAQ,CAACW,IAAT,EAAP;AACD,CAlCM;AAoCP;AACA;AACA;AACA;AACA;;AACA,OAAO,MAAMC,0BAA0B,GAAG,SAMM;EAAA,IANL;IACzCC,KADyC;IAEzCC;EAFyC,CAMK;EAC9C,OAAOjC,gBAAgB,GAAGkC,mBAAnB,CAAuCF,KAAvC,EAA8CC,gBAA9C,CAAP;AACD,CARM"}
1
+ {"version":3,"names":["Linking","NativeModules","checkNativeAndroidAvailable","getAndroidModule","InstallSourceAndroid","RNIapModule","AndroidModule","getInstallSourceAndroid","GOOGLE_PLAY","AMAZON","deepLinkToSubscriptionsAndroid","sku","openURL","getPackageName","validateReceiptAndroid","packageName","productId","productToken","accessToken","isSub","type","url","response","fetch","method","headers","ok","Object","assign","Error","statusText","statusCode","status","json","acknowledgePurchaseAndroid","token","developerPayload","acknowledgePurchase"],"sourceRoot":"../../../src","sources":["modules/android.ts"],"mappings":"AAAA,SAAQA,OAAR,EAAiBC,aAAjB,QAAqC,cAArC;AAEA,SAAQC,2BAAR,EAAqCC,gBAArC,QAA4D,aAA5D;AACA,SACEC,oBADF,QAQO,UARP;AAaA,MAAM;EAACC;AAAD,IAAgBJ,aAAtB;AAsDA,OAAO,MAAMK,aAAa,GAAGL,aAAa,CAACI,WAApC;AAEP,OAAO,MAAME,uBAAuB,GAAG,MAA4B;EACjE,OAAOF,WAAW,GACdD,oBAAoB,CAACI,WADP,GAEdJ,oBAAoB,CAACK,MAFzB;AAGD,CAJM;AAMP;AACA;AACA;AACA;AACA;;AACA,OAAO,MAAMC,8BAA8B,GAAG,cAIzB;EAAA,IAJgC;IACnDC;EADmD,CAIhC;EACnBT,2BAA2B;EAE3B,OAAOF,OAAO,CAACY,OAAR,CACJ,+DAA8D,MAAMP,WAAW,CAACQ,cAAZ,EAA6B,QAAOF,GAAI,EADxG,CAAP;AAGD,CAVM;AAYP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,MAAMG,sBAAsB,GAAG,eAYF;EAAA,IAZS;IAC3CC,WAD2C;IAE3CC,SAF2C;IAG3CC,YAH2C;IAI3CC,WAJ2C;IAK3CC;EAL2C,CAYT;EAClC,MAAMC,IAAI,GAAGD,KAAK,GAAG,eAAH,GAAqB,UAAvC;EAEA,MAAME,GAAG,GACP,6EACC,IAAGN,WAAY,cAAaK,IAAK,IAAGJ,SAAU,EAD/C,GAEC,WAAUC,YAAa,iBAAgBC,WAAY,EAHtD;EAKA,MAAMI,QAAQ,GAAG,MAAMC,KAAK,CAACF,GAAD,EAAM;IAChCG,MAAM,EAAE,KADwB;IAEhCC,OAAO,EAAE;MACP,gBAAgB;IADT;EAFuB,CAAN,CAA5B;;EAOA,IAAI,CAACH,QAAQ,CAACI,EAAd,EAAkB;IAChB,MAAMC,MAAM,CAACC,MAAP,CAAc,IAAIC,KAAJ,CAAUP,QAAQ,CAACQ,UAAnB,CAAd,EAA8C;MAClDC,UAAU,EAAET,QAAQ,CAACU;IAD6B,CAA9C,CAAN;EAGD;;EAED,OAAOV,QAAQ,CAACW,IAAT,EAAP;AACD,CAlCM;AAoCP;AACA;AACA;AACA;AACA;;AACA,OAAO,MAAMC,0BAA0B,GAAG,SAMM;EAAA,IANL;IACzCC,KADyC;IAEzCC;EAFyC,CAMK;EAC9C,OAAOjC,gBAAgB,GAAGkC,mBAAnB,CAAuCF,KAAvC,EAA8CC,gBAA9C,CAAP;AACD,CARM"}
@@ -1 +1 @@
1
- {"version":3,"names":[],"sources":["common.ts"],"sourcesContent":["/**\n * Common interface for all native modules (iOS — AppStore, Android — PlayStore and Amazon).\n */\nexport interface NativeModuleProps {\n /** Required method to start a payment provider connection */\n initConnection(): Promise<boolean>;\n\n /** Required method to end the payment provider connection */\n endConnection(): Promise<boolean>;\n\n /** addListener for NativeEventEmitter */\n addListener(eventType: string): void;\n\n /** removeListeners for NativeEventEmitter */\n removeListeners(count: number): void;\n}\n"],"mappings":""}
1
+ {"version":3,"names":[],"sourceRoot":"../../../src","sources":["modules/common.ts"],"mappings":""}
@@ -1 +1 @@
1
- {"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export * from './amazon';\nexport * from './android';\nexport * from './ios';\nexport * from './common';\n"],"mappings":"AAAA,cAAc,UAAd;AACA,cAAc,WAAd;AACA,cAAc,OAAd;AACA,cAAc,UAAd"}
1
+ {"version":3,"names":[],"sourceRoot":"../../../src","sources":["modules/index.ts"],"mappings":"AAAA,cAAc,UAAd;AACA,cAAc,WAAd;AACA,cAAc,OAAd;AACA,cAAc,UAAd"}
@@ -6,25 +6,44 @@ const {
6
6
 
7
7
  /**
8
8
  * Get the current receipt base64 encoded in IOS.
9
- * @param {forceRefresh?:boolean}
10
9
  * @returns {Promise<ProductPurchase[]>}
11
10
  */
12
11
  export const getPendingPurchasesIOS = async () => getIosModule().getPendingTransactions();
13
12
  /**
14
13
  * Get the current receipt base64 encoded in IOS.
14
+ *
15
+ * The sequence should be as follows:
16
+ * Call getReceiptIOS({forceRefresh: false}). That will return the cached receipt that is available on TestFlight and Production.
17
+ * In the case of Sandbox the receipt might not be cached, causing it to return nil.
18
+ * In that case you might want to let the user that they will to be prompted for credentials.
19
+ * If they accept, call it again with `getReceiptIOS({forceRefresh:true}) If it fails or the user declines, assume they haven't purchased any items.
20
+ * Reference: https://developer.apple.com/forums/thread/662350
21
+ *
15
22
  * From: https://apphud.com/blog/app-store-receipt-validation#what-is-app-store-receipt
16
- > Does a receipt always exist in the app?
17
- > If a user downloaded the app from the App Store – yes. However, in sandbox if your app was installed via Xcode or Testflight, then there won't be a receipt until you make a purchase or restore.
23
+ > Q: Does a receipt always exist in the app?
24
+ > A: If a user downloaded the app from the App Store – yes. However, in sandbox if your app was installed via Xcode or Testflight, then there won't be a receipt until you make a purchase or restore.
18
25
  *
19
26
  ## Usage
20
27
  ```tsx
21
- import {useCallback} from 'react';
22
28
  import {getReceiptIOS} from 'react-native-iap';
23
-
24
- const receipt = useCallback(async () => await getReceiptIOS({forceRefresh: false}));
29
+ try{
30
+ let receipt = await getReceiptIOS({forceRefresh: false});
31
+ if(!receipt){
32
+ // Let user know that they might get prompted for credentials
33
+ const shouldShowPrompt = // Display UI with details, Did user agree?. this only for Sandbox testing
34
+ if(shouldShowPrompt){
35
+ receipt = await getReceiptIOS({forceRefresh: true});
36
+ }
37
+ }
38
+ }catch(error:Error){
39
+ // error while getting the receipt, it might indicate an invalid receipt of a connection error while trying to get it
40
+ }
41
+ // If !receipt assume user doesn't own the items
25
42
  ```
26
- * @param {forceRefresh?:boolean} Requests the receipt from Bundle.main.appStoreReceiptURL. Based on the note above, looks like forceRefresh only makes sense when testing an app not downloaded from the Appstore.
27
- * @returns {Promise<string>} The receipt data
43
+ * @param {forceRefresh?:boolean} Requests the receipt from Bundle.main.appStoreReceiptURL.
44
+ Based on the note above, looks like forceRefresh only makes sense when testing an app not downloaded from the Appstore.
45
+ And only afer a direct user action.
46
+ * @returns {Promise<string | undefined | null>} The receipt data
28
47
  */
29
48
 
30
49
  export const getReceiptIOS = async _ref => {
@@ -1 +1 @@
1
- {"version":3,"names":["Linking","NativeModules","getIosModule","isIosStorekit2","RNIapIos","getPendingPurchasesIOS","getPendingTransactions","getReceiptIOS","forceRefresh","requestReceipt","Promise","reject","presentCodeRedemptionSheetIOS","presentCodeRedemptionSheet","getPromotedProductIOS","promotedProduct","buyPromotedProductIOS","buyPromotedProduct","fetchJsonOrThrow","url","receiptBody","response","fetch","method","headers","Accept","body","JSON","stringify","ok","Object","assign","Error","statusText","statusCode","status","json","TEST_RECEIPT","requestAgnosticReceiptValidationIos","testResponse","validateReceiptIos","isTest","clearTransactionIOS","clearTransaction","clearProductsIOS","clearProducts","deepLinkToSubscriptionsIos","openURL"],"sources":["ios.ts"],"sourcesContent":["import {Linking, NativeModules} from 'react-native';\nimport type {ResponseBody as ReceiptValidationResponse} from '@jeremybarbet/apple-api-types';\n\nimport {getIosModule, isIosStorekit2} from '../internal';\nconst {RNIapIos} = NativeModules;\nimport type {\n ProductIOS,\n ProductPurchase,\n Purchase,\n Sku,\n SubscriptionIOS,\n} from '../types';\nimport type {PaymentDiscount} from '../types/apple';\n\nimport type {NativeModuleProps} from './common';\n\ntype getItems = (skus: Sku[]) => Promise<ProductIOS[] | SubscriptionIOS[]>;\n\ntype getAvailableItems = (\n automaticallyFinishRestoredTransactions: boolean,\n) => Promise<Purchase[]>;\n\nexport type BuyProduct = (\n sku: Sku,\n andDangerouslyFinishTransactionAutomaticallyIOS: boolean,\n applicationUsername: string | undefined,\n quantity: number,\n withOffer: Record<keyof PaymentDiscount, string> | undefined,\n) => Promise<Purchase>;\n\ntype clearTransaction = () => Promise<void>;\ntype clearProducts = () => Promise<void>;\ntype promotedProduct = () => Promise<ProductIOS | 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 disable: () => Promise<null>;\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 * From: https://apphud.com/blog/app-store-receipt-validation#what-is-app-store-receipt\n > Does a receipt always exist in the app?\n > If a user downloaded the app from the App Store – yes. However, in sandbox if your app was installed via Xcode or Testflight, then there won't be a receipt until you make a purchase or restore.\n * \n ## Usage \n ```tsx\nimport {useCallback} from 'react';\nimport {getReceiptIOS} from 'react-native-iap';\n\nconst receipt = useCallback(async () => await getReceiptIOS({forceRefresh: false}));\n```\n * @param {forceRefresh?:boolean} Requests the receipt from Bundle.main.appStoreReceiptURL. Based on the note above, looks like forceRefresh only makes sense when testing an app not downloaded from the Appstore.\n * @returns {Promise<string>} The receipt data\n */\nexport const getReceiptIOS = async ({\n forceRefresh,\n}: {\n forceRefresh?: boolean;\n}): Promise<string> => {\n if (!isIosStorekit2()) {\n return RNIapIos.requestReceipt(forceRefresh ?? false);\n } else {\n return Promise.reject('Only available on Sk1');\n }\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<ProductIOS | null> => {\n if (!isIosStorekit2()) {\n return RNIapIos.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 fetchJsonOrThrow = async (\n url: string,\n receiptBody: Record<string, unknown>,\n): Promise<ReceiptValidationResponse | false> => {\n const response = await fetch(url, {\n method: 'POST',\n headers: {\n Accept: 'application/json',\n 'Content-Type': 'application/json',\n },\n body: JSON.stringify(receiptBody),\n });\n\n if (!response.ok) {\n throw Object.assign(new Error(response.statusText), {\n statusCode: response.status,\n });\n }\n\n return response.json();\n};\n\nconst TEST_RECEIPT = 21007;\nconst requestAgnosticReceiptValidationIos = async (\n receiptBody: Record<string, unknown>,\n): Promise<ReceiptValidationResponse | false> => {\n const response = await fetchJsonOrThrow(\n 'https://buy.itunes.apple.com/verifyReceipt',\n receiptBody,\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 fetchJsonOrThrow(\n 'https://sandbox.itunes.apple.com/verifyReceipt',\n receiptBody,\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 const response = await fetchJsonOrThrow(url, receiptBody);\n\n return response;\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\nexport const deepLinkToSubscriptionsIos = (): Promise<void> =>\n Linking.openURL('https://apps.apple.com/account/subscriptions');\n"],"mappings":"AAAA,SAAQA,OAAR,EAAiBC,aAAjB,QAAqC,cAArC;AAGA,SAAQC,YAAR,EAAsBC,cAAtB,QAA2C,aAA3C;AACA,MAAM;EAACC;AAAD,IAAaH,aAAnB;;AAoDA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMI,sBAAsB,GAAG,YACpCH,YAAY,GAAGI,sBAAf,EADK;AAGP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,MAAMC,aAAa,GAAG,cAIN;EAAA,IAJa;IAClCC;EADkC,CAIb;;EACrB,IAAI,CAACL,cAAc,EAAnB,EAAuB;IACrB,OAAOC,QAAQ,CAACK,cAAT,CAAwBD,YAAY,IAAI,KAAxC,CAAP;EACD,CAFD,MAEO;IACL,OAAOE,OAAO,CAACC,MAAR,CAAe,uBAAf,CAAP;EACD;AACF,CAVM;AAWP;AACA;AACA;AACA;;AACA,OAAO,MAAMC,6BAA6B,GAAG,YAC3CV,YAAY,GAAGW,0BAAf,EADK;AAGP;AACA;AACA;AACA;AACA;;AACA,OAAO,MAAMC,qBAAqB,GAAG,MAAkC;EACrE,IAAI,CAACX,cAAc,EAAnB,EAAuB;IACrB,OAAOC,QAAQ,CAACW,eAAT,EAAP;EACD,CAFD,MAEO;IACL,OAAOL,OAAO,CAACC,MAAR,CAAe,uBAAf,CAAP;EACD;AACF,CANM;AAQP;AACA;AACA;AACA;AACA;;AACA,OAAO,MAAMK,qBAAqB,GAAG,MACnCd,YAAY,GAAGe,kBAAf,EADK;;AAGP,MAAMC,gBAAgB,GAAG,OACvBC,GADuB,EAEvBC,WAFuB,KAGwB;EAC/C,MAAMC,QAAQ,GAAG,MAAMC,KAAK,CAACH,GAAD,EAAM;IAChCI,MAAM,EAAE,MADwB;IAEhCC,OAAO,EAAE;MACPC,MAAM,EAAE,kBADD;MAEP,gBAAgB;IAFT,CAFuB;IAMh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gBAAgB,GAAG,MAC9B1C,YAAY,GAAG2C,aAAf,EADK;AAGP,OAAO,MAAMC,0BAA0B,GAAG,MACxC9C,OAAO,CAAC+C,OAAR,CAAgB,8CAAhB,CADK"}
1
+ {"version":3,"names":["Linking","NativeModules","getIosModule","isIosStorekit2","RNIapIos","getPendingPurchasesIOS","getPendingTransactions","getReceiptIOS","forceRefresh","requestReceipt","Promise","reject","presentCodeRedemptionSheetIOS","presentCodeRedemptionSheet","getPromotedProductIOS","promotedProduct","buyPromotedProductIOS","buyPromotedProduct","fetchJsonOrThrow","url","receiptBody","response","fetch","method","headers","Accept","body","JSON","stringify","ok","Object","assign","Error","statusText","statusCode","status","json","TEST_RECEIPT","requestAgnosticReceiptValidationIos","testResponse","validateReceiptIos","isTest","clearTransactionIOS","clearTransaction","clearProductsIOS","clearProducts","deepLinkToSubscriptionsIos","openURL"],"sourceRoot":"../../../src","sources":["modules/ios.ts"],"mappings":"AAAA,SAAQA,OAAR,EAAiBC,aAAjB,QAAqC,cAArC;AAGA,SAAQC,YAAR,EAAsBC,cAAtB,QAA2C,aAA3C;AACA,MAAM;EAACC;AAAD,IAAaH,aAAnB;;AAoDA;AACA;AACA;AACA;AACA,OAAO,MAAMI,sBAAsB,GAAG,YACpCH,YAAY,GAAGI,sBAAf,EADK;AAGP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,MAAMC,aAAa,GAAG,cAIa;EAAA,IAJN;IAClCC;EADkC,CAIM;;EACxC,IAAI,CAACL,cAAc,EAAnB,EAAuB;IACrB,OAAOC,QAAQ,CAACK,cAAT,CAAwBD,YAAY,IAAI,KAAxC,CAAP;EACD,CAFD,MAEO;IACL,OAAOE,OAAO,CAACC,MAAR,CAAe,uBAAf,CAAP;EACD;AACF,CA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gBAAgB,CACzC,gDADyC,EAEzCE,WAFyC,CAA3C;IAKA,OAAOmB,YAAP;EACD;;EAED,OAAOlB,QAAP;AACD,CApBD;AAsBA;AACA;AACA;AACA;AACA;AACA;;;AACA,OAAO,MAAMmB,kBAAkB,GAAG,eAMgB;EAAA,IANT;IACvCpB,WADuC;IAEvCqB;EAFuC,CAMS;;EAChD,IAAIA,MAAM,IAAI,IAAd,EAAoB;IAClB,OAAO,MAAMH,mCAAmC,CAAClB,WAAD,CAAhD;EACD;;EAED,MAAMD,GAAG,GAAGsB,MAAM,GACd,gDADc,GAEd,4CAFJ;EAIA,MAAMpB,QAAQ,GAAG,MAAMH,gBAAgB,CAACC,GAAD,EAAMC,WAAN,CAAvC;EAEA,OAAOC,QAAP;AACD,CAlBM;AAoBP;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,MAAMqB,mBAAmB,GAAG,MACjCxC,YAAY,GAAGyC,gBAAf,EADK;AAGP;AACA;AACA;AACA;AACA;;AACA,OAAO,MAAMC,gBAAgB,GAAG,MAC9B1C,YAAY,GAAG2C,aAAf,EADK;AAGP,OAAO,MAAMC,0BAA0B,GAAG,MACxC9C,OAAO,CAAC+C,OAAR,CAAgB,8CAAhB,CADK"}
@@ -1 +1 @@
1
- {"version":3,"names":["NativeModules","RNIapIosSk2","sync","isEligibleForIntroOffer","groupID","subscriptionStatus","sku","currentEntitlement","latestTransaction","beginRefundRequest"],"sources":["iosSk2.ts"],"sourcesContent":["import {NativeModules} from 'react-native';\n\nimport type {Product, ProductPurchase, Sku} from '../types';\nimport type {\n PaymentDiscountSk2,\n ProductSk2,\n ProductStatus,\n RefundRequestStatus,\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 = (\n alsoPublishToEventListener?: boolean,\n onlyIncludeActiveItems?: boolean,\n) => Promise<TransactionSk2[]>;\n\nexport type BuyProduct = (\n sku: Sku,\n andDangerouslyFinishTransactionAutomaticallyIOS: boolean,\n applicationUsername: string | undefined,\n quantity: number,\n withOffer: Record<keyof PaymentDiscountSk2, string> | undefined,\n) => Promise<TransactionSk2>;\n\ntype clearTransaction = () => Promise<void>;\ntype clearProducts = () => Promise<void>;\ntype promotedProduct = () => Promise<Product | null>;\ntype buyPromotedProduct = () => Promise<void>;\n\ntype finishTransaction = (transactionIdentifier: string) => Promise<boolean>;\n\ntype getPendingTransactions = () => Promise<ProductPurchase[]>;\ntype presentCodeRedemptionSheet = () => Promise<null>;\ntype showManageSubscriptions = () => Promise<null>;\n\nexport interface IosModulePropsSk2 extends NativeModuleProps {\n isAvailable(): number;\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 finishTransaction: finishTransaction;\n getPendingTransactions: getPendingTransactions;\n presentCodeRedemptionSheet: presentCodeRedemptionSheet;\n showManageSubscriptions: showManageSubscriptions;\n disable: () => Promise<null>;\n beginRefundRequest: (sku: string) => Promise<RefundRequestStatus>;\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\n/**\n *\n */\nexport const beginRefundRequest = (sku: string): Promise<RefundRequestStatus> =>\n RNIapIosSk2.beginRefundRequest(sku);\n"],"mappings":"AAAA,SAAQA,aAAR,QAA4B,cAA5B;AAYA,MAAM;EAACC;AAAD,IAAgBD,aAAtB;;AAkDA;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;AAGP;AACA;AACA;;AACA,OAAO,MAAMG,kBAAkB,GAAIH,GAAD,IAChCL,WAAW,CAACQ,kBAAZ,CAA+BH,GAA/B,CADK"}
1
+ {"version":3,"names":["NativeModules","RNIapIosSk2","sync","isEligibleForIntroOffer","groupID","subscriptionStatus","sku","currentEntitlement","latestTransaction","beginRefundRequest"],"sourceRoot":"../../../src","sources":["modules/iosSk2.ts"],"mappings":"AAAA,SAAQA,aAAR,QAA4B,cAA5B;AAYA,MAAM;EAACC;AAAD,IAAgBD,aAAtB;;AAkDA;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;AAGP;AACA;AACA;;AACA,OAAO,MAAMG,kBAAkB,GAAIH,GAAD,IAChCL,WAAW,CAACQ,kBAAZ,CAA+BH,GAA/B,CADK"}
@@ -1 +1 @@
1
- {"version":3,"names":["ErrorCode","PurchaseError","constructor","name","message","responseCode","debugMessage","code","productId"],"sources":["purchaseError.ts"],"sourcesContent":["export enum ErrorCode {\n E_UNKNOWN = 'E_UNKNOWN',\n E_USER_CANCELLED = 'E_USER_CANCELLED',\n E_USER_ERROR = 'E_USER_ERROR',\n E_ITEM_UNAVAILABLE = 'E_ITEM_UNAVAILABLE',\n E_REMOTE_ERROR = 'E_REMOTE_ERROR',\n E_NETWORK_ERROR = 'E_NETWORK_ERROR',\n E_SERVICE_ERROR = 'E_SERVICE_ERROR',\n E_RECEIPT_FAILED = 'E_RECEIPT_FAILED',\n E_RECEIPT_FINISHED_FAILED = 'E_RECEIPT_FINISHED_FAILED',\n E_NOT_PREPARED = 'E_NOT_PREPARED',\n E_NOT_ENDED = 'E_NOT_ENDED',\n E_ALREADY_OWNED = 'E_ALREADY_OWNED',\n E_DEVELOPER_ERROR = 'E_DEVELOPER_ERROR',\n E_BILLING_RESPONSE_JSON_PARSE_ERROR = 'E_BILLING_RESPONSE_JSON_PARSE_ERROR',\n E_DEFERRED_PAYMENT = 'E_DEFERRED_PAYMENT',\n E_INTERRUPTED = 'E_INTERRUPTED',\n E_IAP_NOT_AVAILABLE = 'E_IAP_NOT_AVAILABLE',\n}\n\nexport class PurchaseError implements Error {\n constructor(\n public name: string,\n public message: string,\n public responseCode?: number,\n public debugMessage?: string,\n public code?: ErrorCode,\n public productId?: string,\n ) {\n this.name = '[react-native-iap]: PurchaseError';\n this.message = message;\n this.responseCode = responseCode;\n this.debugMessage = debugMessage;\n this.code = code;\n this.productId = productId;\n }\n}\n"],"mappings":"AAAA,WAAYA,SAAZ;;WAAYA,S;EAAAA,S;EAAAA,S;EAAAA,S;EAAAA,S;EAAAA,S;EAAAA,S;EAAAA,S;EAAAA,S;EAAAA,S;EAAAA,S;EAAAA,S;EAAAA,S;EAAAA,S;EAAAA,S;EAAAA,S;EAAAA,S;EAAAA,S;GAAAA,S,KAAAA,S;;AAoBZ,OAAO,MAAMC,aAAN,CAAqC;EAC1CC,WAAW,CACFC,IADE,EAEFC,OAFE,EAGFC,YAHE,EAIFC,YAJE,EAKFC,IALE,EAMFC,SANE,EAOT;IAAA,KANOL,IAMP,GANOA,IAMP;IAAA,KALOC,OAKP,GALOA,OAKP;IAAA,KAJOC,YAIP,GAJOA,YAIP;IAAA,KAHOC,YAGP,GAHOA,YAGP;IAAA,KAFOC,IAEP,GAFOA,IAEP;IAAA,KADOC,SACP,GADOA,SACP;IACA,KAAKL,IAAL,GAAY,mCAAZ;IACA,KAAKC,OAAL,GAAeA,OAAf;IACA,KAAKC,YAAL,GAAoBA,YAApB;IACA,KAAKC,YAAL,GAAoBA,YAApB;IACA,KAAKC,IAAL,GAAYA,IAAZ;IACA,KAAKC,SAAL,GAAiBA,SAAjB;EACD;;AAfyC"}
1
+ {"version":3,"names":["ErrorCode","PurchaseError","constructor","name","message","responseCode","debugMessage","code","productId"],"sourceRoot":"../../src","sources":["purchaseError.ts"],"mappings":"AAAA,WAAYA,SAAZ;;WAAYA,S;EAAAA,S;EAAAA,S;EAAAA,S;EAAAA,S;EAAAA,S;EAAAA,S;EAAAA,S;EAAAA,S;EAAAA,S;EAAAA,S;EAAAA,S;EAAAA,S;EAAAA,S;EAAAA,S;EAAAA,S;EAAAA,S;EAAAA,S;GAAAA,S,KAAAA,S;;AAoBZ,OAAO,MAAMC,aAAN,CAAqC;EAC1CC,WAAW,CACFC,IADE,EAEFC,OAFE,EAGFC,YAHE,EAIFC,YAJE,EAKFC,IALE,EAMFC,SANE,EAOT;IAAA,KANOL,IAMP,GANOA,IAMP;IAAA,KALOC,OAKP,GALOA,OAKP;IAAA,KAJOC,YAIP,GAJOA,YAIP;IAAA,KAHOC,YAGP,GAHOA,YAGP;IAAA,KAFOC,IAEP,GAFOA,IAEP;IAAA,KADOC,SACP,GADOA,SACP;IACA,KAAKL,IAAL,GAAY,mCAAZ;IACA,KAAKC,OAAL,GAAeA,OAAf;IACA,KAAKC,YAAL,GAAoBA,YAApB;IACA,KAAKC,YAAL,GAAoBA,YAApB;IACA,KAAKC,IAAL,GAAYA,IAAZ;IACA,KAAKC,SAAL,GAAiBA,SAAjB;EACD;;AAfyC"}
@@ -1 +1 @@
1
- {"version":3,"names":[],"sources":["amazon.ts"],"sourcesContent":["export interface UserDataAmazon {\n userIdAmazon?: string;\n userMarketplaceAmazon?: string;\n userJsonAmazon?: string;\n}\n\nexport interface ProductPurchaseAmazon extends UserDataAmazon {\n isCanceledAmazon?: boolean;\n}\n/**\n * From: https://developer.amazon.com/es/docs/in-app-purchasing/iap-rvs-examples.html\n */\nexport type ReceiptType = {\n autoRenewing: boolean;\n betaProduct: boolean;\n cancelDate: number | null;\n cancelReason: string;\n deferredDate: number | null;\n deferredSku: number | null;\n freeTrialEndDate: number;\n gracePeriodEndDate: number;\n parentProductId: string;\n productId: string;\n productType: string;\n purchaseDate: number;\n quantity: number;\n receiptId: string;\n renewalDate: number;\n term: string;\n termSku: string;\n testTransaction: boolean;\n} & Record<string, unknown>;\n\nexport type AmazonLicensingStatus =\n | 'LICENSED'\n | 'NOT_LICENSED'\n | 'EXPIRED'\n | 'ERROR_VERIFICATION'\n | 'ERROR_INVALID_LICENSING_KEYS'\n | 'UNKNOWN_ERROR';\n"],"mappings":""}
1
+ {"version":3,"names":[],"sourceRoot":"../../../src","sources":["types/amazon.ts"],"mappings":""}