react-native-iap 10.0.2 → 10.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,23 +1,18 @@
1
- # ![image](https://user-images.githubusercontent.com/27461460/75094417-20321b00-55ce-11ea-8de7-a1df42a4b7df.png)
1
+ ![image](https://user-images.githubusercontent.com/27461460/75094417-20321b00-55ce-11ea-8de7-a1df42a4b7df.png)
2
+
3
+ ---
2
4
 
3
5
  [![Version](http://img.shields.io/npm/v/react-native-iap.svg?style=flat-square)](https://npmjs.org/package/react-native-iap)
4
6
  [![Next Version](https://img.shields.io/npm/v/react-native-iap/next)](https://npmjs.org/package/react-native-iap)
5
-
6
7
  [![Download](http://img.shields.io/npm/dm/react-native-iap.svg?style=flat-square)](https://npmjs.org/package/react-native-iap)
7
- [![CI](https://github.com/dooboolab/react-native-iap/actions/workflows/ci.yml/badge.svg)](https://github.com/dooboolab/react-native-iap/actions/workflows/ci.yml)
8
- [![document](https://github.com/dooboolab/react-native-iap/actions/workflows/deploy-documentation.yml/badge.svg)](https://github.com/dooboolab/react-native-iap/actions/workflows/deploy-documentation.yml)
9
- [![License](https://img.shields.io/npm/l/react-native-iap.svg)](https://npmjs.org/package/react-native-iap)
10
- [![Vulnerabilities](https://img.shields.io/snyk/vulnerabilities/github/dooboolab/react-native-iap.svg)](https://github.com/dooboolab/react-native-iap)
11
- [![Issue Opened](https://img.shields.io/opencollective/all/react-native-iap.svg)](https://opencollective.com/react-native-iap#backers)
12
- [![Issue Opened](https://img.shields.io/github/issues/dooboolab/react-native-iap.svg)](https://github.com/dooboolab/react-native-iap/issues)
13
- [![Issue Closed](https://img.shields.io/github/issues-closed/dooboolab/react-native-iap.svg)](https://github.com/dooboolab/react-native-iap/issues?q=is%3Aissue+is%3Aclosed)
14
- [![PR Opened](https://img.shields.io/github/issues-pr/dooboolab/react-native-iap.svg)](https://github.com/dooboolab/react-native-iap/pulls)
15
- [![PR Closed](https://img.shields.io/github/issues-pr-closed/dooboolab/react-native-iap.svg)](https://github.com/dooboolab/react-native-iap/pulls?q=is%3Apr+is%3Aclosed)
8
+ [![Backers and Sponsors](https://img.shields.io/opencollective/all/react-native-iap.svg)](https://opencollective.com/react-native-iap)
16
9
  [![FOSSA Status](https://app.fossa.com/api/projects/git%2Bgithub.com%2Fdooboolab%2Freact-native-iap.svg?type=shield)](https://app.fossa.com/projects/git%2Bgithub.com%2Fdooboolab%2Freact-native-iap?ref=badge_shield)
17
10
 
11
+ ---
12
+
18
13
  ## Documentation
19
14
 
20
- Published in [website](https://react-native-iap.dooboolab.com).
15
+ Read the [documentation](https://react-native-iap.dooboolab.com). See the [troubleshooting](https://react-native-iap.dooboolab.com/docs/guides/troubleshooting#common-issues) for the common issues to avoid.
21
16
 
22
17
  ## Our maintainers
23
18
 
@@ -34,129 +29,46 @@ Please [fund the project](https://opencollective.com/react-native-iap) if you ar
34
29
 
35
30
  ## Announcement
36
31
 
37
- - Version `9.0.0` is currently in release candidate. The module migrates android sdk to [play billing library v5](https://qonversion.io/blog/google-play-billing-library-5-0) and iOS sdk to [storekit2](https://developer.apple.com/videos/play/wwdc2021/10114). Our core maintainers [andresesfm](https://github.com/andresesfm) and [jeremybarbet](https://github.com/jeremybarbet) are working hard on this.
32
+ - Version `11.0.0` is currently in alpha candidate. The module migrates OS sdk to [storekit2](https://developer.apple.com/videos/play/wwdc2021/10114). [andresesfm](https://github.com/andresesfm) is working hard on this.
38
33
 
39
34
  ```
40
35
  yarn add react-native-iap@next
41
36
  ```
42
37
 
38
+ - Version `10.0.0` is a maitenance build. Many internal refactorings and clean up of the code. Special thanks to [jeremybarbet](https://github.com/jeremybarbet) for his contributions. Most notably all methods now take an object parameter instead of separate parameters. Please help us test
39
+
40
+ - Version `9.0.0` The module migrates android sdk to [play billing library v5](https://qonversion.io/blog/google-play-billing-library-5-0). Our core maintainers [andresesfm](https://github.com/andresesfm) and [jeremybarbet](https://github.com/jeremybarbet) worked hard on this.
41
+
43
42
  - Version `8.0.0` has finally landed in Jan 28th. Since this is early release, please use it with caution 🚧. We recommend user to use `>=8.0.0` with react-native `>=0.65.1`. The `next` package is no longer updated until we organize the roadmap for `9.0.0`.
44
43
 
45
44
  - Version `8.0.0` is currently in release candidate. The module is completely rewritten with `Kotlin` and `Swift` for maintenenance issue by [andresesfm](https://github.com/andresesfm) 🔆. You may install this for early preview.
46
45
 
47
- ```
48
- yarn add react-native-iap@next
49
- ```
50
-
51
46
  - React Native IAP hook is out. You can see [medium post](https://medium.com/dooboolab/announcing-react-native-iap-hooks-96c7ffd3f19a) on how to use it.
52
47
 
53
48
  - The `react-native-iap` module hasn't been maintained well recently. We are thinking of participating again and make the module healthier. Please refer to [2021 Maintenance plan](https://github.com/dooboolab/react-native-iap/issues/1241) and share with us how you or your organization is using it. Happy new year 🎉
54
49
 
55
50
  - The sample code is out in [Sponsor page](https://github.com/hyochan/dooboolab.com/blob/main/src/components/pages/Sponsor.tsx) in [dooboolab.com](https://github.com/hyochan/dooboolab.com) repository which sadly is rejected by Apple because of lacking product features. I will work on another example project to support this module. More information in [#1241 commment](https://github.com/dooboolab/react-native-iap/issues/1241#issuecomment-798540785).
56
51
 
57
- ## Introduction
58
-
59
- This react-native module will help you access the In-app purchases capabilities of your phone on the `Android`, `iOS` platforms and the `Amazon` platform (Beta).
60
-
61
- **Keep in mind** `react-native-iap` will provide the basic features you need but is not a turnkey solution, implementing In-app purchases in your app will still require quite some work.<br/>
62
- Also, implementing the client side is only one side of the coin, you'll have to implement the server side to validate your receipts (which is probably the most time consuming part to do it correctly).
63
-
64
- If you're looking for a module going further than react-native-iap, we recommend using [react-native-iaphub](https://github.com/iaphub/react-native-iaphub) which is taking care of everything from the client side to the server side.
65
-
66
- ⚠️ Most of users experiencing issues are caused by:
67
-
68
- - A device simulator, use a real device for testing!
69
- - The sandbox environment of the project not being configured properly ([Configure android sandbox](https://www.iaphub.com/docs/set-up-android/configure-sandbox-testing), [Configure ios sandbox](https://www.iaphub.com/docs/set-up-ios/configure-sandbox-testing/))
70
- - An incorrect usage of the library
71
-
72
- ## Demo
73
-
74
- > ![demo.gif](https://user-images.githubusercontent.com/27461460/52619625-87aa8a80-2ee5-11e9-9aee-6691c34408f3.gif)
75
-
76
- <!-- Inline anchors -->
77
-
78
- [a-acknowledge-purchase-android]: #finishing-a-purchase
79
- [a-migration-guide]: #migration-guide
80
- [a-purchase-flow]: #new-purchase-flow
81
-
82
- <!-- Official Blog -->
83
-
84
- [blog-config-steps]: https://medium.com/p/121622d26b67
85
- [blog-v3-note]: https://medium.com/p/1259e0b0c017
86
-
87
- <!-- Internals -->
88
-
89
- [contribute]: https://github.com/dooboolab/react-native-iap/blob/main/CONTRIBUTING.md
90
- [example]: https://github.com/dooboolab/react-native-iap/tree/main/IapExample
91
- [issue-126-c1]: https://github.com/dooboolab/react-native-iap/issues/126#issuecomment-439084872
92
- [issue-174]: https://github.com/dooboolab/react-native-iap/issues/174
93
- [issue-203]: https://github.com/dooboolab/react-native-iap/issues/203
94
- [issue-237]: https://github.com/dooboolab/react-native-iap/issues/237
95
- [issue-256]: https://github.com/dooboolab/react-native-iap/issues/256
96
- [issue-263]: https://github.com/dooboolab/react-native-iap/issues/263
97
- [issue-283]: https://github.com/dooboolab/react-native-iap/issues/283
98
- [issue-307-c1]: https://github.com/dooboolab/react-native-iap/issues/307#issuecomment-447745027
99
- [issue-307]: https://github.com/dooboolab/react-native-iap/issues/307
100
- [open-collective-backer]: https://opencollective.com/react-native-iap#backer
101
- [open-collective-sponsor]: https://opencollective.com/react-native-iap#sponsor
102
- [open-collective]: https://opencollective.com/react-native-iap
103
- [readme-deprecated]: https://github.com/dooboolab/react-native-iap/blob/main/README_DEPRECATED.md
52
+ ## Configuration of Play Store & App Store Connect
104
53
 
105
- <!-- Externals -->
54
+ - Please refer to this [Blog post](https://medium.com/p/121622d26b67).
106
55
 
107
- [android-acknowledge-purchase]: https://developer.android.com/reference/com/android/billingclient/api/BillingClient.html#acknowledgePurchase(com.android.billingclient.api.AcknowledgePurchaseParams,%20com.android.billingclient.api.AcknowledgePurchaseResponseListener) 'BillingClient#acknowledgePurchase()'
108
- [android-end-connection]: https://developer.android.com/reference/com/android/billingclient/api/BillingClient.html#endConnection() 'BillingClient#endConnection()'
109
- [android-iap-validation-guide]: https://developer.android.com/google/play/billing/billing_library_overview
110
- [android-migrate-androidx]: https://developer.android.com/jetpack/androidx/migrate
111
- [android-sku-details]: https://developer.android.com/reference/com/android/billingclient/api/SkuDetails
112
- [apple-iap-promoting]: https://developer.apple.com/app-store/promoting-in-app-purchases/
113
- [apple-iap-validation-guide]: https://developer.apple.com/library/content/releasenotes/General/ValidateAppStoreReceipt/Chapters/ValidateRemotely.html
114
- [apple-store-kit-flow]: https://forums.developer.apple.com/thread/6431#14831
115
- [google-api-nodejs-client]: https://github.com/googleapis/google-api-nodejs-client/
116
- [google-play-console]: https://play.google.com/apps/publish/
117
- [stackoverflow-android-iap-validation]: https://stackoverflow.com/questions/35127086
118
- [android-access-token-example-repo]: https://github.com/Bang9/android-get-access-token-example
119
-
120
- ## Quick News
121
-
122
- - We had hard time supporting `react-native-iap` issues that did not provide working codes or any other examples. Therefore, we've decided to make an `example` app called [DoobooIAP](https://github.com/hyochan/DoobooIAP), which will contain all the features of `IAP`'s and willing to continuously improve to support real-life examples. [@Bang9](http://github.com/bang9) who had been helping many others for `react-native-iap`, is willing to support this repo so he will grant $300 of our income in `opencollective` as described in [#855](https://github.com/dooboolab/react-native-iap/issues/855) :tada:.
123
- - `react-native-iap@4.0.8` ~ `react-native-iap@4.1.0` is incompatible with `react-native <0.61`. This is fixed in `react-native-iap@4.1.1` and above.
124
- - `react-native-iap@4.0.0` has been released. You can see [#716](https://github.com/dooboolab/react-native-iap/pull/716) for updates.
125
- - In the past, `react-native-iap@^3.*` has been updated very promptly for migration issues.
126
- Don't get surprised too much on why it is bumping up version so quickly these days.
127
- 1. Migrated to new `AndroidX` APIs.
128
- 2. Migrated to new `Android` billing client which is `> 2.0.0`.
129
- - [`acknowledgePurchase()`][android-acknowledge-purchase] has been added since `3.2.0` which is very important.
130
- 3. New [Purchase Flow][a-purchase-flow]
131
- 4. More is coming in `iOS 13`.
132
-
133
- ## Breaking Changes
134
-
135
- [7.4.0]
136
-
137
- - Now using React's Context to manage IAP state
138
- - Introduce `withIAPContext` HOC ([how to use](docs/docs/usage_instructions/using_hooks.md))
139
-
140
- [7.1.0]
56
+ ## Example
141
57
 
142
- - `androidOldSku` is no longer required [#1438](https://github.com/dooboolab/react-native-iap/pull/1438).
58
+ Follow [this guide](./IapExample/README.md) to get the example running.
143
59
 
144
- [6.1.0]
60
+ ## Our maintainers
145
61
 
146
- - Creates two variants: `play` and `amazon` and only uses the required code.
147
- ```
148
- NOTE: This would be a breaking change with a very simple fix described in the documentation. To add: `missingDimensionStrategy 'store', 'play'` `in build.gradle`
149
- ```
150
- [3.0.0+]
151
- [react-native-iap V3 note][blog-v3-note]
62
+ Please [fund the project](https://opencollective.com/react-native-iap) if you are willing the maintainers to make the repository sustainable.
152
63
 
153
- ## Configuration of Google Play & iTunes Connect
64
+ - [andresesfm](https://github.com/andresesfm)
65
+ - [jeremybarbet](https://github.com/jeremybarbet)
154
66
 
155
- - Please refer to [Blog][blog-config-steps].
67
+ > The fund goes to maintainers.
156
68
 
157
- ## Example
69
+ ## Acknowledgements
158
70
 
159
- Follow [this guide](./IapExample/README.md) to get the example running.
71
+ If you're looking for a module going further than `react-native-iap`, we recommend using [react-native-iaphub](https://github.com/iaphub/react-native-iaphub) which is taking care of everything from the client-side to the server-side.
160
72
 
161
73
  ## Sponsoring
162
74
 
@@ -164,24 +76,28 @@ Since `IAP` itself is not perfect on each platform, we desperately need
164
76
  this project to be maintained. If you'd like to help us, please consider being
165
77
  with us in [Open Collective](https://opencollective.com/react-native-iap).
166
78
 
79
+ ### Supporter
80
+
81
+ - [hyochan](https://github.com/hyochan)
82
+
167
83
  ### Sponsors
168
84
 
169
85
  Support this project by becoming a sponsor. Your logo will show up here with
170
- a link to your website. [Become a sponsor][open-collective-sponsor].
171
- <a href="https://opencollective.com/react-native-iap#sponsors" target="_blank"><img src="https://opencollective.com/react-native-iap/sponsors.svg?width=890"></a>
86
+ a link to your website. [Become a sponsor](https://opencollective.com/react-native-iap#sponsor).
87
+ <a href="https://opencollective.com/react-native-iap#sponsors" target="_blank"><img src="https://opencollective.com/react-native-iap/sponsors.svg?width=890" /></a>
172
88
 
173
89
  ### Backers
174
90
 
175
- Please be our [Backers][open-collective-backer].
176
- <a href="https://opencollective.com/react-native-iap#backers" target="_blank"><img src="https://opencollective.com/react-native-iap/backers.svg?width=890"></a>
91
+ Please be our [Backers](https://opencollective.com/react-native-iap#backer).
92
+ <a href="https://opencollective.com/react-native-iap#backers" target="_blank"><img src="https://opencollective.com/react-native-iap/backers.svg?width=890" /></a>
177
93
 
178
94
  ### Contributing
179
95
 
180
- Please make sure to read the [Contributing Guide][contribute] before making a pull request.
96
+ Please make sure to read the [Contributing Guide](https://github.com/dooboolab/react-native-iap/blob/main/CONTRIBUTING.md) before making a pull request.
181
97
  Thank you to all the people who helped to maintain and upgrade this project!
182
98
 
183
99
  <a href="graphs/contributors"><img src="https://opencollective.com/react-native-iap/contributors.svg?width=890" /></a>
184
100
 
185
- <hr>
101
+ ---
186
102
 
187
103
  [![FOSSA Status](https://app.fossa.com/api/projects/git%2Bgithub.com%2Fdooboolab%2Freact-native-iap.svg?type=large)](https://app.fossa.com/projects/git%2Bgithub.com%2Fdooboolab%2Freact-native-iap?ref=badge_large)
@@ -333,6 +333,10 @@ class RNIapAmazonListener(private val reactContext: ReactContext) : PurchasingLi
333
333
  )
334
334
  }
335
335
  }
336
+ fun clear(){
337
+ skus.clear()
338
+
339
+ }
336
340
 
337
341
  private fun sendEvent(
338
342
  reactContext: ReactContext,
@@ -15,6 +15,7 @@ import java.util.HashSet
15
15
  class RNIapAmazonModule(reactContext: ReactApplicationContext) :
16
16
  ReactContextBaseJavaModule(reactContext) {
17
17
  var hasListener = false
18
+ private var amazonListener: RNIapAmazonListener? = null
18
19
  override fun getName(): String {
19
20
  return TAG
20
21
  }
@@ -22,7 +23,9 @@ class RNIapAmazonModule(reactContext: ReactApplicationContext) :
22
23
  @ReactMethod
23
24
  fun initConnection(promise: Promise) {
24
25
  val context = reactApplicationContext
25
- PurchasingService.registerListener(context, RNIapAmazonListener(context))
26
+ val amazonListener = RNIapAmazonListener(context)
27
+ this.amazonListener = amazonListener
28
+ PurchasingService.registerListener(context, amazonListener)
26
29
  hasListener = true
27
30
  // Prefetch user and purchases as per Amazon SDK documentation:
28
31
  PurchasingService.getUserData()
@@ -32,6 +35,9 @@ class RNIapAmazonModule(reactContext: ReactApplicationContext) :
32
35
 
33
36
  @ReactMethod
34
37
  fun endConnection(promise: Promise) {
38
+ DoobooUtils.instance.rejectAllPendingPromises()
39
+ amazonListener?.clear()
40
+ hasListener = false
35
41
  promise.resolve(true)
36
42
  }
37
43
 
@@ -49,6 +49,13 @@ class DoobooUtils {
49
49
  }
50
50
  }
51
51
 
52
+ fun rejectAllPendingPromises() {
53
+ promises.flatMap { it.value }.forEach { promise ->
54
+ promise.safeReject(E_CONNECTION_CLOSED, "Connection has been closed", null)
55
+ }
56
+ promises.clear()
57
+ }
58
+
52
59
  fun rejectPromisesForKey(
53
60
  key: String,
54
61
  code: String?,
@@ -175,6 +182,7 @@ class DoobooUtils {
175
182
  const val E_USER_ERROR = "E_USER_ERROR"
176
183
  const val E_DEVELOPER_ERROR = "E_DEVELOPER_ERROR"
177
184
  const val E_BILLING_RESPONSE_JSON_PARSE_ERROR = "E_BILLING_RESPONSE_JSON_PARSE_ERROR"
185
+ const val E_CONNECTION_CLOSED = "E_CONNECTION_CLOSED"
178
186
  val instance = DoobooUtils()
179
187
  }
180
188
  }
@@ -9,11 +9,13 @@ import com.facebook.react.bridge.Promise
9
9
  * want to crash in the case of it being resolved/rejected more than once
10
10
  */
11
11
 
12
+ const val TAG = "IapPromises"
13
+
12
14
  fun Promise.safeResolve(value: Any) {
13
15
  try {
14
16
  this.resolve(value)
15
17
  } catch (oce: ObjectAlreadyConsumedException) {
16
- Log.d(RNIapModule.TAG, "Already consumed ${oce.message}")
18
+ Log.d(TAG, "Already consumed ${oce.message}")
17
19
  }
18
20
  }
19
21
 
@@ -28,6 +30,6 @@ fun Promise.safeReject(code: String?, message: String?, throwable: Throwable?) {
28
30
  try {
29
31
  this.reject(code, message, throwable)
30
32
  } catch (oce: ObjectAlreadyConsumedException) {
31
- Log.d(RNIapModule.TAG, "Already consumed ${oce.message}")
33
+ Log.d(TAG, "Already consumed ${oce.message}")
32
34
  }
33
35
  }
@@ -127,6 +127,8 @@ class RNIapModule(
127
127
  fun endConnection(promise: Promise) {
128
128
  billingClientCache?.endConnection()
129
129
  billingClientCache = null
130
+ skus.clear()
131
+ DoobooUtils.instance.rejectAllPendingPromises()
130
132
  promise.safeResolve(true)
131
133
  }
132
134
 
@@ -133,6 +133,14 @@ class RNIapIos: RCTEventEmitter, SKRequestDelegate, SKPaymentTransactionObserver
133
133
  }
134
134
  }
135
135
 
136
+ func rejectAllPendingPromises() {
137
+ promisesByKey.values.reduce([], +).forEach({tuple in
138
+ let reject = tuple.1
139
+ reject("E_CONNECTION_CLOSED", "Connection has been closed", nil)
140
+ })
141
+ promisesByKey.removeAll()
142
+ }
143
+
136
144
  func paymentQueue(_ queue: SKPaymentQueue, shouldAddStorePayment payment: SKPayment, for product: SKProduct) -> Bool {
137
145
  promotedProduct = product
138
146
  promotedPayment = payment
@@ -160,6 +168,14 @@ class RNIapIos: RCTEventEmitter, SKRequestDelegate, SKPaymentTransactionObserver
160
168
  reject: @escaping RCTPromiseRejectBlock = { _, _, _ in }
161
169
  ) {
162
170
  removeTransactionObserver()
171
+ stopObserving()
172
+ rejectAllPendingPromises()
173
+ receiptBlock = nil
174
+ validProducts.removeAll()
175
+ promotedPayment = nil
176
+ promotedProduct = nil
177
+ productsRequest = nil
178
+ countPendingTransaction = 0
163
179
  resolve(nil)
164
180
  }
165
181
  @objc public func getItems(
@@ -544,7 +560,13 @@ class RNIapIos: RCTEventEmitter, SKRequestDelegate, SKPaymentTransactionObserver
544
560
  SKPaymentQueue.default().finishTransaction(transaction)
545
561
 
546
562
  myQueue.sync(execute: { [self] in
547
- let nsError = transaction.error as NSError?
563
+ var nsError = transaction.error as? NSError
564
+ // From https://developer.apple.com/forums/thread/674081
565
+ if let underlyingError = nsError?.userInfo["NSUnderlyingError"] as? NSError,
566
+ underlyingError.code == 3038 {
567
+ // General conditions have changed, don't display an error for the interrupted transaction
568
+ nsError = underlyingError
569
+ }
548
570
 
549
571
  if hasListeners {
550
572
  let code = nsError?.code
@@ -647,6 +669,9 @@ class RNIapIos: RCTEventEmitter, SKRequestDelegate, SKPaymentTransactionObserver
647
669
  guard let code = code else {
648
670
  return descriptions[0]
649
671
  }
672
+ if code == 3038 { // Purchase interrupted so user can accept terms and conditions
673
+ return "E_INTERRUPTED"
674
+ }
650
675
 
651
676
  if code > descriptions.count - 1 || code < 0 { // Fix crash app without internet connection
652
677
  return descriptions[0]
@@ -708,15 +733,15 @@ class RNIapIos: RCTEventEmitter, SKRequestDelegate, SKPaymentTransactionObserver
708
733
  switch product.introductoryPrice?.paymentMode {
709
734
  case .freeTrial:
710
735
  introductoryPricePaymentMode = "FREETRIAL"
711
- introductoryPriceNumberOfPeriods = NSNumber(value: product.introductoryPrice?.subscriptionPeriod.numberOfUnits ?? 0).stringValue
736
+ introductoryPriceNumberOfPeriods = String( product.introductoryPrice?.subscriptionPeriod.numberOfUnits ?? 0)
712
737
 
713
738
  case .payAsYouGo:
714
739
  introductoryPricePaymentMode = "PAYASYOUGO"
715
- introductoryPriceNumberOfPeriods = NSNumber(value: product.introductoryPrice?.numberOfPeriods ?? 0).stringValue
740
+ introductoryPriceNumberOfPeriods = String( product.introductoryPrice?.numberOfPeriods ?? 0)
716
741
 
717
742
  case .payUpFront:
718
743
  introductoryPricePaymentMode = "PAYUPFRONT"
719
- introductoryPriceNumberOfPeriods = NSNumber(value: product.introductoryPrice?.subscriptionPeriod.numberOfUnits ?? 0).stringValue
744
+ introductoryPriceNumberOfPeriods = String( product.introductoryPrice?.subscriptionPeriod.numberOfUnits ?? 0)
720
745
 
721
746
  default:
722
747
  introductoryPricePaymentMode = ""
@@ -793,8 +818,8 @@ class RNIapIos: RCTEventEmitter, SKRequestDelegate, SKPaymentTransactionObserver
793
818
  let formatter = NumberFormatter()
794
819
  formatter.numberStyle = .currency
795
820
  let priceLocale: Locale? = discount.priceLocale
796
- if let pLocale = priceLocale {
797
- formatter.locale = pLocale
821
+ if let priceLocale = priceLocale {
822
+ formatter.locale = priceLocale
798
823
  }
799
824
  localizedPrice = formatter.string(from: discount.price)
800
825
  var numberOfPeriods: String?
@@ -802,17 +827,17 @@ class RNIapIos: RCTEventEmitter, SKRequestDelegate, SKPaymentTransactionObserver
802
827
  switch discount.paymentMode {
803
828
  case .freeTrial:
804
829
  paymendMode = "FREETRIAL"
805
- numberOfPeriods = NSNumber(value: discount.subscriptionPeriod.numberOfUnits ).stringValue
830
+ numberOfPeriods = String(discount.subscriptionPeriod.numberOfUnits)
806
831
  break
807
832
 
808
833
  case .payAsYouGo:
809
834
  paymendMode = "PAYASYOUGO"
810
- numberOfPeriods = NSNumber(value: discount.numberOfPeriods).stringValue
835
+ numberOfPeriods = String(discount.numberOfPeriods)
811
836
  break
812
837
 
813
838
  case .payUpFront:
814
839
  paymendMode = "PAYUPFRONT"
815
- numberOfPeriods = NSNumber(value: discount.subscriptionPeriod.numberOfUnits ).stringValue
840
+ numberOfPeriods = String(discount.subscriptionPeriod.numberOfUnits )
816
841
  break
817
842
 
818
843
  default:
@@ -265,8 +265,7 @@ const requestSubscription = _ref4 => {
265
265
  return RNIapAmazonModule.buyItemByType(sku);
266
266
  } else {
267
267
  if (!(subscriptionOffers !== null && subscriptionOffers !== void 0 && subscriptionOffers.length)) {
268
- Promise.reject('subscriptionOffers are required for Google Play Subscriptions');
269
- return;
268
+ return Promise.reject('subscriptionOffers are required for Google Play Subscriptions');
270
269
  }
271
270
 
272
271
  return RNIapModule.buyItemByType(ANDROID_ITEM_TYPE_SUBSCRIPTION, subscriptionOffers === null || subscriptionOffers === void 0 ? void 0 : subscriptionOffers.map(so => so.sku), purchaseTokenAndroid, prorationModeAndroid, obfuscatedAccountIdAndroid, obfuscatedProfileIdAndroid, subscriptionOffers === null || subscriptionOffers === void 0 ? void 0 : subscriptionOffers.map(so => so.offerToken), isOfferPersonalized ?? false);
@@ -1 +1 @@
1
- {"version":3,"names":["RNIapIos","RNIapModule","RNIapAmazonModule","NativeModules","ANDROID_ITEM_TYPE_SUBSCRIPTION","ANDROID_ITEM_TYPE_IAP","getInstallSourceAndroid","InstallSourceAndroid","GOOGLE_PLAY","AMAZON","androidNativeModule","setAndroidNativeModule","nativeModule","checkNativeAndroidAvailable","Error","getAndroidModule","checkNativeIOSAvailable","getIosModule","getNativeModule","isAndroid","initConnection","endConnection","flushFailedPurchasesCachedAsPendingAndroid","flushFailedPurchasesCachedAsPending","getProducts","skus","Platform","select","ios","items","getItems","filter","item","includes","productId","type","android","products","getItemsByType","fillProductsWithAdditionalData","Promise","resolve","getSubscriptions","subscriptions","getPurchaseHistory","getAvailableItems","getPurchaseHistoryByType","concat","getAvailablePurchases","getAvailableItemsByType","requestPurchase","sku","andDangerouslyFinishTransactionAutomaticallyIOS","applicationUsername","obfuscatedAccountIdAndroid","obfuscatedProfileIdAndroid","isOfferPersonalized","console","warn","buyProduct","isAmazon","buyItemByType","length","requestSubscription","purchaseTokenAndroid","prorationModeAndroid","subscriptionOffers","undefined","reject","map","so","offerToken","requestPurchaseWithQuantityIOS","quantity","buyProductWithQuantityIOS","finishTransaction","purchase","isConsumable","developerPayloadAndroid","transactionId","consumeProduct","purchaseToken","userIdAmazon","isAcknowledgedAndroid","purchaseStateAndroid","PurchaseStateAndroid","PURCHASED","acknowledgePurchase","clearTransactionIOS","clearTransaction","clearProductsIOS","clearProducts","acknowledgePurchaseAndroid","token","developerPayload","deepLinkToSubscriptionsAndroid","Linking","openURL","getPackageName","getPromotedProductIOS","promotedProduct","buyPromotedProductIOS","buyPromotedProduct","requestAgnosticReceiptValidationIos","receiptBody","response","enhancedFetch","method","body","status","ReceiptValidationStatus","TEST_RECEIPT","testResponse","requestPurchaseWithOfferIOS","forUser","withOffer","buyProductWithOffer","validateReceiptIos","isTest","url","validateReceiptAndroid","packageName","productToken","accessToken","isSub","validateReceiptAmazon","developerSecret","userId","receiptId","useSandbox","sandBoxUrl","getPendingPurchasesIOS","getPendingTransactions","getReceiptIOS","forceRefresh","requestReceipt","presentCodeRedemptionSheetIOS","presentCodeRedemptionSheet"],"sources":["iap.ts"],"sourcesContent":["import {Linking, NativeModules, Platform} from 'react-native';\n\nimport type * as Amazon from './types/amazon';\nimport type * as Android from './types/android';\nimport type * as Apple from './types/apple';\nimport {ReceiptValidationStatus} from './types/apple';\nimport {\n enhancedFetch,\n fillProductsWithAdditionalData,\n isAmazon,\n isAndroid,\n} from './internal';\nimport type {\n Product,\n ProductPurchase,\n ProrationModesAndroid,\n PurchaseResult,\n Sku,\n Subscription,\n SubscriptionOffer,\n SubscriptionPurchase,\n} from './types';\nimport {InstallSourceAndroid, PurchaseStateAndroid} from './types';\n\nconst {RNIapIos, RNIapModule, RNIapAmazonModule} = NativeModules;\nconst ANDROID_ITEM_TYPE_SUBSCRIPTION = 'subs';\nconst ANDROID_ITEM_TYPE_IAP = 'inapp';\n\nexport const getInstallSourceAndroid = (): InstallSourceAndroid => {\n return RNIapModule\n ? InstallSourceAndroid.GOOGLE_PLAY\n : InstallSourceAndroid.AMAZON;\n};\n\nlet androidNativeModule = RNIapModule;\n\nexport const setAndroidNativeModule = (\n nativeModule: typeof RNIapModule,\n): void => {\n androidNativeModule = nativeModule;\n};\n\nconst checkNativeAndroidAvailable = (): void => {\n if (!RNIapModule && !RNIapAmazonModule) {\n throw new Error('IAP_NOT_AVAILABLE');\n }\n};\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\nconst checkNativeIOSAvailable = (): void => {\n if (!RNIapIos) {\n throw new Error('IAP_NOT_AVAILABLE');\n }\n};\n\nexport const getIosModule = (): typeof RNIapIos => {\n checkNativeIOSAvailable();\n\n return RNIapIos;\n};\n\nexport const getNativeModule = ():\n | typeof RNIapModule\n | typeof RNIapAmazonModule\n | typeof RNIapIos => {\n return isAndroid ? getAndroidModule() : getIosModule();\n};\n\n/**\n * Init module for purchase flow. Required on Android. In ios it will check whether user canMakePayment.\n * @returns {Promise<boolean>}\n */\nexport const initConnection = (): Promise<boolean> =>\n getNativeModule().initConnection();\n\n/**\n * End module for purchase flow.\n * @returns {Promise<void>}\n */\nexport const endConnection = (): Promise<void> =>\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 = (): Promise<\n string[]\n> => getAndroidModule().flushFailedPurchasesCachedAsPending();\n\n/**\n * Get a list of products (consumable and non-consumable items, but not subscriptions)\n * @param {string[]} skus The item skus\n * @returns {Promise<Product[]>}\n */\nexport const getProducts = ({\n skus,\n}: {\n skus: string[];\n}): Promise<Array<Product>> =>\n (\n Platform.select({\n ios: async () => {\n const items = await getIosModule().getItems(skus);\n\n return items.filter(\n (item: Product) =>\n skus.includes(item.productId) && item.type === 'iap',\n );\n },\n android: async () => {\n const products = await getAndroidModule().getItemsByType(\n ANDROID_ITEM_TYPE_IAP,\n skus,\n );\n\n return fillProductsWithAdditionalData(products);\n },\n }) || Promise.resolve\n )();\n\n/**\n * Get a list of subscriptions\n * @param {string[]} skus The item skus\n * @returns {Promise<Subscription[]>}\n */\nexport const getSubscriptions = ({\n skus,\n}: {\n skus: string[];\n}): Promise<Subscription[]> =>\n (\n Platform.select({\n ios: async () => {\n const items = await getIosModule().getItems(skus);\n\n return items.filter(\n (item: Subscription) =>\n skus.includes(item.productId) && item.type === 'subs',\n );\n },\n android: async () => {\n const subscriptions = await getAndroidModule().getItemsByType(\n ANDROID_ITEM_TYPE_SUBSCRIPTION,\n skus,\n );\n\n return fillProductsWithAdditionalData(subscriptions);\n },\n }) || Promise.resolve\n )();\n\n/**\n * Gets an inventory of purchases made by the user regardless of consumption status\n * @returns {Promise<(ProductPurchase | SubscriptionPurchase)[]>}\n */\nexport const getPurchaseHistory = (): Promise<\n (ProductPurchase | SubscriptionPurchase)[]\n> =>\n (\n Platform.select({\n ios: async () => {\n return getIosModule().getAvailableItems();\n },\n android: async () => {\n if (RNIapAmazonModule) {\n return await RNIapAmazonModule.getAvailableItems();\n }\n\n const products = await getAndroidModule().getPurchaseHistoryByType(\n ANDROID_ITEM_TYPE_IAP,\n );\n\n const subscriptions = await getAndroidModule().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 * @returns {Promise<(ProductPurchase | SubscriptionPurchase)[]>}\n */\nexport const getAvailablePurchases = (): Promise<\n (ProductPurchase | SubscriptionPurchase)[]\n> =>\n (\n Platform.select({\n ios: async () => {\n return getIosModule().getAvailableItems();\n },\n android: async () => {\n if (RNIapAmazonModule) {\n return await RNIapAmazonModule.getAvailableItems();\n }\n\n const products = await getAndroidModule().getAvailableItemsByType(\n ANDROID_ITEM_TYPE_IAP,\n );\n\n const subscriptions = await getAndroidModule().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 * @param {string} sku The product's sku/ID\n * @param {string} [applicationUsername] The purchaser's user ID\n * @param {boolean} [andDangerouslyFinishTransactionAutomaticallyIOS] You should set this to false 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 * @param {string} [obfuscatedAccountIdAndroid] Specifies an optional obfuscated string that is uniquely associated with the user's account in your app.\n * @param {string} [obfuscatedProfileIdAndroid] Specifies an optional obfuscated string that is uniquely associated with the user's profile in your app.\n * @param {string[]} [skus] Product Ids to purchase. Note that this is only for Android. iOS only uses a single SKU. If not provided, it'll default to using [sku] for backward-compatibility\n * @param {boolean} [isOfferPersonalized] Defaults to false, Only for Android V5\n * @returns {Promise<ProductPurchase>}\n */\n\nexport const requestPurchase = ({\n sku,\n andDangerouslyFinishTransactionAutomaticallyIOS = false,\n applicationUsername,\n obfuscatedAccountIdAndroid,\n obfuscatedProfileIdAndroid,\n skus,\n isOfferPersonalized,\n}: {\n sku?: Sku;\n andDangerouslyFinishTransactionAutomaticallyIOS?: boolean;\n applicationUsername?: string;\n obfuscatedAccountIdAndroid?: string;\n obfuscatedProfileIdAndroid?: string;\n /** For Google Play Billing Library 5 https://developer.android.com/google/play/billing/integrate#personalized-price */\n skus?: Sku[];\n isOfferPersonalized?: boolean;\n}): Promise<ProductPurchase> =>\n (\n Platform.select({\n ios: async () => {\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 return getIosModule().buyProduct(\n sku,\n andDangerouslyFinishTransactionAutomaticallyIOS,\n applicationUsername,\n );\n },\n android: async () => {\n if (isAmazon) {\n return RNIapAmazonModule.buyItemByType(sku);\n } else {\n return getAndroidModule().buyItemByType(\n ANDROID_ITEM_TYPE_IAP,\n skus?.length ? skus : [sku],\n null,\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 * @param {string} [sku] The product's sku/ID\n * @param {string} [applicationUsername] The purchaser's user ID\n * @param {boolean} [andDangerouslyFinishTransactionAutomaticallyIOS] You should set this to false 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 * @param {string} [purchaseTokenAndroid] purchaseToken that the user is upgrading or downgrading from (Android).\n * @param {ProrationModesAndroid} [prorationModeAndroid] UNKNOWN_SUBSCRIPTION_UPGRADE_DOWNGRADE_POLICY, IMMEDIATE_WITH_TIME_PRORATION, IMMEDIATE_AND_CHARGE_PRORATED_PRICE, IMMEDIATE_WITHOUT_PRORATION, DEFERRED\n * @param {string} [obfuscatedAccountIdAndroid] Specifies an optional obfuscated string that is uniquely associated with the user's account in your app.\n * @param {string} [obfuscatedProfileIdAndroid] Specifies an optional obfuscated string that is uniquely associated with the user's profile in your app.\n * @param {SubscriptionOffers[]} [subscriptionOffers] Array of SubscriptionOffers. Every sku must be paired with a corresponding offerToken\n * @returns {Promise<SubscriptionPurchase | null>} Promise resolves to null when using proratioModesAndroid=DEFERRED, and to a SubscriptionPurchase otherwise\n */\nexport const requestSubscription = ({\n sku,\n andDangerouslyFinishTransactionAutomaticallyIOS = false,\n applicationUsername,\n purchaseTokenAndroid,\n prorationModeAndroid = -1,\n subscriptionOffers,\n obfuscatedAccountIdAndroid,\n obfuscatedProfileIdAndroid,\n isOfferPersonalized = undefined,\n}: {\n sku?: Sku;\n andDangerouslyFinishTransactionAutomaticallyIOS?: boolean;\n applicationUsername?: string;\n purchaseTokenAndroid?: string;\n prorationModeAndroid?: ProrationModesAndroid;\n /** For Google Play Billing Library 5 */\n subscriptionOffers?: SubscriptionOffer[];\n obfuscatedAccountIdAndroid?: string;\n obfuscatedProfileIdAndroid?: string;\n /** For Google Play Billing Library 5 https://developer.android.com/google/play/billing/integrate#personalized-price */\n isOfferPersonalized?: boolean;\n}): Promise<SubscriptionPurchase | null> =>\n (\n Platform.select({\n ios: async () => {\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 return getIosModule().buyProduct(\n sku,\n andDangerouslyFinishTransactionAutomaticallyIOS,\n applicationUsername,\n );\n },\n android: async () => {\n if (isAmazon) {\n return RNIapAmazonModule.buyItemByType(sku);\n } else {\n if (!subscriptionOffers?.length) {\n Promise.reject(\n 'subscriptionOffers are required for Google Play Subscriptions',\n );\n return;\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\n )();\n\n/**\n * Request a purchase for product. This will be received in `PurchaseUpdatedListener`.\n * @param {string} sku The product's sku/ID\n * @returns {Promise<void>}\n */\nexport const requestPurchaseWithQuantityIOS = ({\n sku,\n quantity,\n}: {\n sku: Sku;\n quantity: number;\n}): Promise<ProductPurchase> =>\n getIosModule().buyProductWithQuantityIOS(sku, quantity);\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 * @param {object} purchase The purchase that you would like to finish.\n * @param {boolean} isConsumable Checks if purchase is consumable. Has effect on `android`.\n * @param {string} developerPayloadAndroid Android developerPayload.\n * @returns {Promise<string | void> }\n */\nexport const finishTransaction = ({\n purchase,\n isConsumable,\n developerPayloadAndroid,\n}: {\n purchase: ProductPurchase | ProductPurchase;\n isConsumable?: boolean;\n developerPayloadAndroid?: string;\n}): Promise<string | void> => {\n return (\n Platform.select({\n ios: async () => {\n return getIosModule().finishTransaction(purchase.transactionId);\n },\n android: async () => {\n if (purchase) {\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 throw new Error('purchase is not suitable to be purchased');\n }\n } else {\n throw new Error('purchase is not assigned');\n }\n },\n }) || Promise.resolve\n )();\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\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 | void> => {\n return getAndroidModule().acknowledgePurchase(token, developerPayload);\n};\n\n/**\n * Deep link to subscriptions screen on Android. No-op on iOS.\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 * Should Add Store Payment (iOS only)\n * Indicates the the App Store purchase should continue from the app instead of the App Store.\n * @returns {Promise<Product | null>} promoted product\n */\nexport const getPromotedProductIOS = (): Promise<Product | null> =>\n getIosModule().promotedProduct();\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 requestAgnosticReceiptValidationIos = async (\n receiptBody: Record<string, unknown>,\n): Promise<Apple.ReceiptValidationResponse | false> => {\n const response = await enhancedFetch<Apple.ReceiptValidationResponse>(\n 'https://buy.itunes.apple.com/verifyReceipt',\n {\n method: 'POST',\n body: receiptBody,\n },\n );\n\n // Best practice is to check for test receipt and check sandbox instead\n // https://developer.apple.com/documentation/appstorereceipts/verifyreceipt\n if (response && response.status === ReceiptValidationStatus.TEST_RECEIPT) {\n const testResponse = await enhancedFetch<Apple.ReceiptValidationResponse>(\n 'https://sandbox.itunes.apple.com/verifyReceipt',\n {\n method: 'POST',\n body: receiptBody,\n },\n );\n\n return testResponse;\n }\n\n return response;\n};\n\n/**\n * Buy products or subscriptions with offers (iOS only)\n *\n * Runs the payment process with some info you must fetch\n * from your server.\n * @param {string} sku The product identifier\n * @param {string} forUser An user identifier on you system\n * @param {Apple.PaymentDiscount} withOffer The offer information\n * @param {string} withOffer.identifier The offer identifier\n * @param {string} withOffer.keyIdentifier Key identifier that it uses to generate the signature\n * @param {string} withOffer.nonce An UUID returned from the server\n * @param {string} withOffer.signature The actual signature returned from the server\n * @param {number} withOffer.timestamp The timestamp of the signature\n * @returns {Promise<void>}\n */\nexport const requestPurchaseWithOfferIOS = ({\n sku,\n forUser,\n withOffer,\n}: {\n sku: Sku;\n forUser: string;\n withOffer: Apple.PaymentDiscount;\n}): Promise<void> =>\n getIosModule().buyProductWithOffer(sku, forUser, withOffer);\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<Apple.ReceiptValidationResponse | false> => {\n if (isTest == null) {\n return await requestAgnosticReceiptValidationIos(receiptBody);\n }\n\n const url = isTest\n ? 'https://sandbox.itunes.apple.com/verifyReceipt'\n : 'https://buy.itunes.apple.com/verifyReceipt';\n\n return await enhancedFetch<Apple.ReceiptValidationResponse>(url);\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 return await enhancedFetch<Android.ReceiptType>(url);\n};\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<Amazon.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<Amazon.ReceiptType>(url);\n};\n\n/**\n * Get the current receipt base64 encoded in IOS.\n * @param {forceRefresh?:boolean}\n * @returns {Promise<ProductPurchase[]>}\n */\nexport const getPendingPurchasesIOS = async (): Promise<ProductPurchase[]> =>\n getIosModule().getPendingTransactions();\n\n/**\n * Get the current receipt base64 encoded in IOS.\n * @param {forceRefresh?:boolean}\n * @returns {Promise<string>}\n */\nexport const getReceiptIOS = async ({\n forceRefresh,\n}: {\n forceRefresh?: boolean;\n}): Promise<string> => getIosModule().requestReceipt(forceRefresh ?? false);\n\n/**\n * Launches a modal to register the redeem offer code in IOS.\n * @returns {Promise<null>}\n */\nexport const presentCodeRedemptionSheetIOS = async (): Promise<null> =>\n getIosModule().presentCodeRedemptionSheet();\n"],"mappings":";;;;;;;AAAA;;AAKA;;AACA;;AAgBA;;AAEA,MAAM;EAACA,QAAD;EAAWC,WAAX;EAAwBC;AAAxB,IAA6CC,0BAAnD;AACA,MAAMC,8BAA8B,GAAG,MAAvC;AACA,MAAMC,qBAAqB,GAAG,OAA9B;;AAEO,MAAMC,uBAAuB,GAAG,MAA4B;EACjE,OAAOL,WAAW,GACdM,2BAAA,CAAqBC,WADP,GAEdD,2BAAA,CAAqBE,MAFzB;AAGD,CAJM;;;AAMP,IAAIC,mBAAmB,GAAGT,WAA1B;;AAEO,MAAMU,sBAAsB,GACjCC,YADoC,IAE3B;EACTF,mBAAmB,GAAG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F,KAAK,GAAG,eAAH,GAAqB,UAAvC;EAEA,MAAML,GAAG,GACP,6EACC,IAAGE,WAAY,cAAatF,IAAK,IAAGD,SAAU,EAD/C,GAEC,WAAUwF,YAAa,iBAAgBC,WAAY,EAHtD;EAKA,OAAO,MAAM,IAAAjB,uBAAA,EAAmCa,GAAnC,CAAb;AACD,CArBM;AAuBP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;AACO,MAAMM,qBAAqB,GAAG,gBAUF;EAAA,IAVS;IAC1CC,eAD0C;IAE1CC,MAF0C;IAG1CC,SAH0C;IAI1CC,UAAU,GAAG;EAJ6B,CAUT;EACjC,MAAMC,UAAU,GAAGD,UAAU,GAAG,UAAH,GAAgB,EAA7C;EACA,MAAMV,GAAG,GAAI,mCAAkCW,UAAW,yCAAwCJ,eAAgB,SAAQC,MAAO,cAAaC,SAAU,EAAxJ;EAEA,OAAO,MAAM,IAAAtB,uBAAA,EAAkCa,GAAlC,CAAb;AACD,CAfM;AAiBP;AACA;AACA;AACA;AACA;;;;;AACO,MAAMY,sBAAsB,GAAG,YACpClH,YAAY,GAAGmH,sBAAf,EADK;AAGP;AACA;AACA;AACA;AACA;;;;;AACO,MAAMC,aAAa,GAAG;EAAA,IAAO;IAClCC;EADkC,CAAP;EAAA,OAINrH,YAAY,GAAGsH,cAAf,CAA8BD,YAAY,IAAI,KAA9C,CAJM;AAAA,CAAtB;AAMP;AACA;AACA;AACA;;;;;AACO,MAAME,6BAA6B,GAAG,YAC3CvH,YAAY,GAAGwH,0BAAf,EADK"}
1
+ {"version":3,"names":["RNIapIos","RNIapModule","RNIapAmazonModule","NativeModules","ANDROID_ITEM_TYPE_SUBSCRIPTION","ANDROID_ITEM_TYPE_IAP","getInstallSourceAndroid","InstallSourceAndroid","GOOGLE_PLAY","AMAZON","androidNativeModule","setAndroidNativeModule","nativeModule","checkNativeAndroidAvailable","Error","getAndroidModule","checkNativeIOSAvailable","getIosModule","getNativeModule","isAndroid","initConnection","endConnection","flushFailedPurchasesCachedAsPendingAndroid","flushFailedPurchasesCachedAsPending","getProducts","skus","Platform","select","ios","items","getItems","filter","item","includes","productId","type","android","products","getItemsByType","fillProductsWithAdditionalData","Promise","resolve","getSubscriptions","subscriptions","getPurchaseHistory","getAvailableItems","getPurchaseHistoryByType","concat","getAvailablePurchases","getAvailableItemsByType","requestPurchase","sku","andDangerouslyFinishTransactionAutomaticallyIOS","applicationUsername","obfuscatedAccountIdAndroid","obfuscatedProfileIdAndroid","isOfferPersonalized","console","warn","buyProduct","isAmazon","buyItemByType","length","requestSubscription","purchaseTokenAndroid","prorationModeAndroid","subscriptionOffers","undefined","reject","map","so","offerToken","requestPurchaseWithQuantityIOS","quantity","buyProductWithQuantityIOS","finishTransaction","purchase","isConsumable","developerPayloadAndroid","transactionId","consumeProduct","purchaseToken","userIdAmazon","isAcknowledgedAndroid","purchaseStateAndroid","PurchaseStateAndroid","PURCHASED","acknowledgePurchase","clearTransactionIOS","clearTransaction","clearProductsIOS","clearProducts","acknowledgePurchaseAndroid","token","developerPayload","deepLinkToSubscriptionsAndroid","Linking","openURL","getPackageName","getPromotedProductIOS","promotedProduct","buyPromotedProductIOS","buyPromotedProduct","requestAgnosticReceiptValidationIos","receiptBody","response","enhancedFetch","method","body","status","ReceiptValidationStatus","TEST_RECEIPT","testResponse","requestPurchaseWithOfferIOS","forUser","withOffer","buyProductWithOffer","validateReceiptIos","isTest","url","validateReceiptAndroid","packageName","productToken","accessToken","isSub","validateReceiptAmazon","developerSecret","userId","receiptId","useSandbox","sandBoxUrl","getPendingPurchasesIOS","getPendingTransactions","getReceiptIOS","forceRefresh","requestReceipt","presentCodeRedemptionSheetIOS","presentCodeRedemptionSheet"],"sources":["iap.ts"],"sourcesContent":["import {Linking, NativeModules, Platform} from 'react-native';\n\nimport type * as Amazon from './types/amazon';\nimport type * as Android from './types/android';\nimport type * as Apple from './types/apple';\nimport {ReceiptValidationStatus} from './types/apple';\nimport {\n enhancedFetch,\n fillProductsWithAdditionalData,\n isAmazon,\n isAndroid,\n} from './internal';\nimport type {\n Product,\n ProductPurchase,\n ProrationModesAndroid,\n PurchaseResult,\n Sku,\n Subscription,\n SubscriptionOffer,\n SubscriptionPurchase,\n} from './types';\nimport {InstallSourceAndroid, PurchaseStateAndroid} from './types';\n\nconst {RNIapIos, RNIapModule, RNIapAmazonModule} = NativeModules;\nconst ANDROID_ITEM_TYPE_SUBSCRIPTION = 'subs';\nconst ANDROID_ITEM_TYPE_IAP = 'inapp';\n\nexport const getInstallSourceAndroid = (): InstallSourceAndroid => {\n return RNIapModule\n ? InstallSourceAndroid.GOOGLE_PLAY\n : InstallSourceAndroid.AMAZON;\n};\n\nlet androidNativeModule = RNIapModule;\n\nexport const setAndroidNativeModule = (\n nativeModule: typeof RNIapModule,\n): void => {\n androidNativeModule = nativeModule;\n};\n\nconst checkNativeAndroidAvailable = (): void => {\n if (!RNIapModule && !RNIapAmazonModule) {\n throw new Error('IAP_NOT_AVAILABLE');\n }\n};\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\nconst checkNativeIOSAvailable = (): void => {\n if (!RNIapIos) {\n throw new Error('IAP_NOT_AVAILABLE');\n }\n};\n\nexport const getIosModule = (): typeof RNIapIos => {\n checkNativeIOSAvailable();\n\n return RNIapIos;\n};\n\nexport const getNativeModule = ():\n | typeof RNIapModule\n | typeof RNIapAmazonModule\n | typeof RNIapIos => {\n return isAndroid ? getAndroidModule() : getIosModule();\n};\n\n/**\n * Init module for purchase flow. Required on Android. In ios it will check whether user canMakePayment.\n * @returns {Promise<boolean>}\n */\nexport const initConnection = (): Promise<boolean> =>\n getNativeModule().initConnection();\n\n/**\n * End module for purchase flow.\n * @returns {Promise<void>}\n */\nexport const endConnection = (): Promise<void> =>\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 = (): Promise<\n string[]\n> => getAndroidModule().flushFailedPurchasesCachedAsPending();\n\n/**\n * Get a list of products (consumable and non-consumable items, but not subscriptions)\n * @param {string[]} skus The item skus\n * @returns {Promise<Product[]>}\n */\nexport const getProducts = ({\n skus,\n}: {\n skus: string[];\n}): Promise<Array<Product>> =>\n (\n Platform.select({\n ios: async () => {\n const items = await getIosModule().getItems(skus);\n\n return items.filter(\n (item: Product) =>\n skus.includes(item.productId) && item.type === 'iap',\n );\n },\n android: async () => {\n const products = await getAndroidModule().getItemsByType(\n ANDROID_ITEM_TYPE_IAP,\n skus,\n );\n\n return fillProductsWithAdditionalData(products);\n },\n }) || Promise.resolve\n )();\n\n/**\n * Get a list of subscriptions\n * @param {string[]} skus The item skus\n * @returns {Promise<Subscription[]>}\n */\nexport const getSubscriptions = ({\n skus,\n}: {\n skus: string[];\n}): Promise<Subscription[]> =>\n (\n Platform.select({\n ios: async () => {\n const items = await getIosModule().getItems(skus);\n\n return items.filter(\n (item: Subscription) =>\n skus.includes(item.productId) && item.type === 'subs',\n );\n },\n android: async () => {\n const subscriptions = await getAndroidModule().getItemsByType(\n ANDROID_ITEM_TYPE_SUBSCRIPTION,\n skus,\n );\n\n return fillProductsWithAdditionalData(subscriptions);\n },\n }) || Promise.resolve\n )();\n\n/**\n * Gets an inventory of purchases made by the user regardless of consumption status\n * @returns {Promise<(ProductPurchase | SubscriptionPurchase)[]>}\n */\nexport const getPurchaseHistory = (): Promise<\n (ProductPurchase | SubscriptionPurchase)[]\n> =>\n (\n Platform.select({\n ios: async () => {\n return getIosModule().getAvailableItems();\n },\n android: async () => {\n if (RNIapAmazonModule) {\n return await RNIapAmazonModule.getAvailableItems();\n }\n\n const products = await getAndroidModule().getPurchaseHistoryByType(\n ANDROID_ITEM_TYPE_IAP,\n );\n\n const subscriptions = await getAndroidModule().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 * @returns {Promise<(ProductPurchase | SubscriptionPurchase)[]>}\n */\nexport const getAvailablePurchases = (): Promise<\n (ProductPurchase | SubscriptionPurchase)[]\n> =>\n (\n Platform.select({\n ios: async () => {\n return getIosModule().getAvailableItems();\n },\n android: async () => {\n if (RNIapAmazonModule) {\n return await RNIapAmazonModule.getAvailableItems();\n }\n\n const products = await getAndroidModule().getAvailableItemsByType(\n ANDROID_ITEM_TYPE_IAP,\n );\n\n const subscriptions = await getAndroidModule().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 * @param {string} sku The product's sku/ID\n * @param {string} [applicationUsername] The purchaser's user ID\n * @param {boolean} [andDangerouslyFinishTransactionAutomaticallyIOS] You should set this to false 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 * @param {string} [obfuscatedAccountIdAndroid] Specifies an optional obfuscated string that is uniquely associated with the user's account in your app.\n * @param {string} [obfuscatedProfileIdAndroid] Specifies an optional obfuscated string that is uniquely associated with the user's profile in your app.\n * @param {string[]} [skus] Product Ids to purchase. Note that this is only for Android. iOS only uses a single SKU. If not provided, it'll default to using [sku] for backward-compatibility\n * @param {boolean} [isOfferPersonalized] Defaults to false, Only for Android V5\n * @returns {Promise<ProductPurchase>}\n */\n\nexport const requestPurchase = ({\n sku,\n andDangerouslyFinishTransactionAutomaticallyIOS = false,\n applicationUsername,\n obfuscatedAccountIdAndroid,\n obfuscatedProfileIdAndroid,\n skus,\n isOfferPersonalized,\n}: {\n sku?: Sku;\n andDangerouslyFinishTransactionAutomaticallyIOS?: boolean;\n applicationUsername?: string;\n obfuscatedAccountIdAndroid?: string;\n obfuscatedProfileIdAndroid?: string;\n /** For Google Play Billing Library 5 https://developer.android.com/google/play/billing/integrate#personalized-price */\n skus?: Sku[];\n isOfferPersonalized?: boolean;\n}): Promise<ProductPurchase> =>\n (\n Platform.select({\n ios: async () => {\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 return getIosModule().buyProduct(\n sku,\n andDangerouslyFinishTransactionAutomaticallyIOS,\n applicationUsername,\n );\n },\n android: async () => {\n if (isAmazon) {\n return RNIapAmazonModule.buyItemByType(sku);\n } else {\n return getAndroidModule().buyItemByType(\n ANDROID_ITEM_TYPE_IAP,\n skus?.length ? skus : [sku],\n null,\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 * @param {string} [sku] The product's sku/ID\n * @param {string} [applicationUsername] The purchaser's user ID\n * @param {boolean} [andDangerouslyFinishTransactionAutomaticallyIOS] You should set this to false 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 * @param {string} [purchaseTokenAndroid] purchaseToken that the user is upgrading or downgrading from (Android).\n * @param {ProrationModesAndroid} [prorationModeAndroid] UNKNOWN_SUBSCRIPTION_UPGRADE_DOWNGRADE_POLICY, IMMEDIATE_WITH_TIME_PRORATION, IMMEDIATE_AND_CHARGE_PRORATED_PRICE, IMMEDIATE_WITHOUT_PRORATION, DEFERRED\n * @param {string} [obfuscatedAccountIdAndroid] Specifies an optional obfuscated string that is uniquely associated with the user's account in your app.\n * @param {string} [obfuscatedProfileIdAndroid] Specifies an optional obfuscated string that is uniquely associated with the user's profile in your app.\n * @param {SubscriptionOffers[]} [subscriptionOffers] Array of SubscriptionOffers. Every sku must be paired with a corresponding offerToken\n * @returns {Promise<SubscriptionPurchase | null>} Promise resolves to null when using proratioModesAndroid=DEFERRED, and to a SubscriptionPurchase otherwise\n */\nexport const requestSubscription = ({\n sku,\n andDangerouslyFinishTransactionAutomaticallyIOS = false,\n applicationUsername,\n purchaseTokenAndroid,\n prorationModeAndroid = -1,\n subscriptionOffers,\n obfuscatedAccountIdAndroid,\n obfuscatedProfileIdAndroid,\n isOfferPersonalized = undefined,\n}: {\n sku?: Sku;\n andDangerouslyFinishTransactionAutomaticallyIOS?: boolean;\n applicationUsername?: string;\n purchaseTokenAndroid?: string;\n prorationModeAndroid?: ProrationModesAndroid;\n /** For Google Play Billing Library 5 */\n subscriptionOffers?: SubscriptionOffer[];\n obfuscatedAccountIdAndroid?: string;\n obfuscatedProfileIdAndroid?: string;\n /** For Google Play Billing Library 5 https://developer.android.com/google/play/billing/integrate#personalized-price */\n isOfferPersonalized?: boolean;\n}): Promise<SubscriptionPurchase | null> =>\n (\n Platform.select({\n ios: async () => {\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 return getIosModule().buyProduct(\n sku,\n andDangerouslyFinishTransactionAutomaticallyIOS,\n applicationUsername,\n );\n },\n android: async () => {\n if (isAmazon) {\n return RNIapAmazonModule.buyItemByType(sku);\n } else {\n if (!subscriptionOffers?.length) {\n return Promise.reject(\n 'subscriptionOffers are required for Google Play Subscriptions',\n );\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\n )();\n\n/**\n * Request a purchase for product. This will be received in `PurchaseUpdatedListener`.\n * @param {string} sku The product's sku/ID\n * @returns {Promise<void>}\n */\nexport const requestPurchaseWithQuantityIOS = ({\n sku,\n quantity,\n}: {\n sku: Sku;\n quantity: number;\n}): Promise<ProductPurchase> =>\n getIosModule().buyProductWithQuantityIOS(sku, quantity);\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 * @param {object} purchase The purchase that you would like to finish.\n * @param {boolean} isConsumable Checks if purchase is consumable. Has effect on `android`.\n * @param {string} developerPayloadAndroid Android developerPayload.\n * @returns {Promise<string | void> }\n */\nexport const finishTransaction = ({\n purchase,\n isConsumable,\n developerPayloadAndroid,\n}: {\n purchase: ProductPurchase | ProductPurchase;\n isConsumable?: boolean;\n developerPayloadAndroid?: string;\n}): Promise<string | void> => {\n return (\n Platform.select({\n ios: async () => {\n return getIosModule().finishTransaction(purchase.transactionId);\n },\n android: async () => {\n if (purchase) {\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 throw new Error('purchase is not suitable to be purchased');\n }\n } else {\n throw new Error('purchase is not assigned');\n }\n },\n }) || Promise.resolve\n )();\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\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 | void> => {\n return getAndroidModule().acknowledgePurchase(token, developerPayload);\n};\n\n/**\n * Deep link to subscriptions screen on Android. No-op on iOS.\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 * Should Add Store Payment (iOS only)\n * Indicates the the App Store purchase should continue from the app instead of the App Store.\n * @returns {Promise<Product | null>} promoted product\n */\nexport const getPromotedProductIOS = (): Promise<Product | null> =>\n getIosModule().promotedProduct();\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 requestAgnosticReceiptValidationIos = async (\n receiptBody: Record<string, unknown>,\n): Promise<Apple.ReceiptValidationResponse | false> => {\n const response = await enhancedFetch<Apple.ReceiptValidationResponse>(\n 'https://buy.itunes.apple.com/verifyReceipt',\n {\n method: 'POST',\n body: receiptBody,\n },\n );\n\n // Best practice is to check for test receipt and check sandbox instead\n // https://developer.apple.com/documentation/appstorereceipts/verifyreceipt\n if (response && response.status === ReceiptValidationStatus.TEST_RECEIPT) {\n const testResponse = await enhancedFetch<Apple.ReceiptValidationResponse>(\n 'https://sandbox.itunes.apple.com/verifyReceipt',\n {\n method: 'POST',\n body: receiptBody,\n },\n );\n\n return testResponse;\n }\n\n return response;\n};\n\n/**\n * Buy products or subscriptions with offers (iOS only)\n *\n * Runs the payment process with some info you must fetch\n * from your server.\n * @param {string} sku The product identifier\n * @param {string} forUser An user identifier on you system\n * @param {Apple.PaymentDiscount} withOffer The offer information\n * @param {string} withOffer.identifier The offer identifier\n * @param {string} withOffer.keyIdentifier Key identifier that it uses to generate the signature\n * @param {string} withOffer.nonce An UUID returned from the server\n * @param {string} withOffer.signature The actual signature returned from the server\n * @param {number} withOffer.timestamp The timestamp of the signature\n * @returns {Promise<void>}\n */\nexport const requestPurchaseWithOfferIOS = ({\n sku,\n forUser,\n withOffer,\n}: {\n sku: Sku;\n forUser: string;\n withOffer: Apple.PaymentDiscount;\n}): Promise<void> =>\n getIosModule().buyProductWithOffer(sku, forUser, withOffer);\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<Apple.ReceiptValidationResponse | false> => {\n if (isTest == null) {\n return await requestAgnosticReceiptValidationIos(receiptBody);\n }\n\n const url = isTest\n ? 'https://sandbox.itunes.apple.com/verifyReceipt'\n : 'https://buy.itunes.apple.com/verifyReceipt';\n\n return await enhancedFetch<Apple.ReceiptValidationResponse>(url);\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 return await enhancedFetch<Android.ReceiptType>(url);\n};\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<Amazon.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<Amazon.ReceiptType>(url);\n};\n\n/**\n * Get the current receipt base64 encoded in IOS.\n * @param {forceRefresh?:boolean}\n * @returns {Promise<ProductPurchase[]>}\n */\nexport const getPendingPurchasesIOS = async (): Promise<ProductPurchase[]> =>\n getIosModule().getPendingTransactions();\n\n/**\n * Get the current receipt base64 encoded in IOS.\n * @param {forceRefresh?:boolean}\n * @returns {Promise<string>}\n */\nexport const getReceiptIOS = async ({\n forceRefresh,\n}: {\n forceRefresh?: boolean;\n}): Promise<string> => getIosModule().requestReceipt(forceRefresh ?? false);\n\n/**\n * Launches a modal to register the redeem offer code in IOS.\n * @returns {Promise<null>}\n */\nexport const presentCodeRedemptionSheetIOS = async (): Promise<null> =>\n getIosModule().presentCodeRedemptionSheet();\n"],"mappings":";;;;;;;AAAA;;AAKA;;AACA;;AAgBA;;AAEA,MAAM;EAACA,QAAD;EAAWC,WAAX;EAAwBC;AAAxB,IAA6CC,0BAAnD;AACA,MAAMC,8BAA8B,GAAG,MAAvC;AACA,MAAMC,qBAAqB,GAAG,OAA9B;;AAEO,MAAMC,uBAAuB,GAAG,MAA4B;EACjE,OAAOL,WAAW,GACdM,2BAAA,CAAqBC,WADP,GAEdD,2BAAA,CAAqBE,MAFzB;AAGD,CAJM;;;AAMP,IAAIC,mBAAmB,GAAGT,WAA1B;;AAEO,MAAMU,sBAAsB,GACjCC,YADoC,IAE3B;EACTF,mBAAmB,GAAGE,YAAtB;AACD,CAJM;;;;AAMP,MAAMC,2BAA2B,GAAG,MAAY;EAC9C,IAAI,CAACZ,WAAD,IAAgB,CAACC,iBAArB,EAAwC;IACtC,MAAM,IAAIY,KAAJ,CAAU,mBAAV,CAAN;EACD;AACF,CAJD;;AAMO,MAAMC,gBAAgB,GAAG,MAEA;EAC9BF,2BAA2B;EAE3B,OAAOH,mBAAmB,GACtBA,mBADsB,GAEtBT,WAAW,GACXA,WADW,GAEXC,iBAJJ;AAKD,CAVM;;;;AAYP,MAAMc,uBAAuB,GAAG,MAAY;EAC1C,IAAI,CAAChB,QAAL,EAAe;IACb,MAAM,IAAIc,KAAJ,CAAU,mBAAV,CAAN;EACD;AACF,CAJD;;AAMO,MAAMG,YAAY,GAAG,MAAuB;EACjDD,uBAAuB;EAEvB,OAAOhB,QAAP;AACD,CAJM;;;;AAMA,MAAMkB,eAAe,GAAG,MA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;EAEA,OAAO,MAAM,IAAAtB,uBAAA,EAAkCa,GAAlC,CAAb;AACD,CAfM;AAiBP;AACA;AACA;AACA;AACA;;;;;AACO,MAAMY,sBAAsB,GAAG,YACpClH,YAAY,GAAGmH,sBAAf,EADK;AAGP;AACA;AACA;AACA;AACA;;;;;AACO,MAAMC,aAAa,GAAG;EAAA,IAAO;IAClCC;EADkC,CAAP;EAAA,OAINrH,YAAY,GAAGsH,cAAf,CAA8BD,YAAY,IAAI,KAA9C,CAJM;AAAA,CAAtB;AAMP;AACA;AACA;AACA;;;;;AACO,MAAME,6BAA6B,GAAG,YAC3CvH,YAAY,GAAGwH,0BAAf,EADK"}
@@ -23,6 +23,7 @@ exports.ErrorCode = ErrorCode;
23
23
  ErrorCode["E_DEVELOPER_ERROR"] = "E_DEVELOPER_ERROR";
24
24
  ErrorCode["E_BILLING_RESPONSE_JSON_PARSE_ERROR"] = "E_BILLING_RESPONSE_JSON_PARSE_ERROR";
25
25
  ErrorCode["E_DEFERRED_PAYMENT"] = "E_DEFERRED_PAYMENT";
26
+ ErrorCode["E_INTERRUPTED"] = "E_INTERRUPTED";
26
27
  })(ErrorCode || (exports.ErrorCode = ErrorCode = {}));
27
28
 
28
29
  class PurchaseError {
@@ -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}\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;GAAAA,S,yBAAAA,S;;AAkBL,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"],"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}\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;GAAAA,S,yBAAAA,S;;AAmBL,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"}
package/lib/module/iap.js CHANGED
@@ -216,8 +216,7 @@ export const requestSubscription = _ref4 => {
216
216
  return RNIapAmazonModule.buyItemByType(sku);
217
217
  } else {
218
218
  if (!(subscriptionOffers !== null && subscriptionOffers !== void 0 && subscriptionOffers.length)) {
219
- Promise.reject('subscriptionOffers are required for Google Play Subscriptions');
220
- return;
219
+ return Promise.reject('subscriptionOffers are required for Google Play Subscriptions');
221
220
  }
222
221
 
223
222
  return RNIapModule.buyItemByType(ANDROID_ITEM_TYPE_SUBSCRIPTION, subscriptionOffers === null || subscriptionOffers === void 0 ? void 0 : subscriptionOffers.map(so => so.sku), purchaseTokenAndroid, prorationModeAndroid, obfuscatedAccountIdAndroid, obfuscatedProfileIdAndroid, subscriptionOffers === null || subscriptionOffers === void 0 ? void 0 : subscriptionOffers.map(so => so.offerToken), isOfferPersonalized ?? false);
@@ -1 +1 @@
1
- {"version":3,"names":["Linking","NativeModules","Platform","ReceiptValidationStatus","enhancedFetch","fillProductsWithAdditionalData","isAmazon","isAndroid","InstallSourceAndroid","PurchaseStateAndroid","RNIapIos","RNIapModule","RNIapAmazonModule","ANDROID_ITEM_TYPE_SUBSCRIPTION","ANDROID_ITEM_TYPE_IAP","getInstallSourceAndroid","GOOGLE_PLAY","AMAZON","androidNativeModule","setAndroidNativeModule","nativeModule","checkNativeAndroidAvailable","Error","getAndroidModule","checkNativeIOSAvailable","getIosModule","getNativeModule","initConnection","endConnection","flushFailedPurchasesCachedAsPendingAndroid","flushFailedPurchasesCachedAsPending","getProducts","skus","select","ios","items","getItems","filter","item","includes","productId","type","android","products","getItemsByType","Promise","resolve","getSubscriptions","subscriptions","getPurchaseHistory","getAvailableItems","getPurchaseHistoryByType","concat","getAvailablePurchases","getAvailableItemsByType","requestPurchase","sku","andDangerouslyFinishTransactionAutomaticallyIOS","applicationUsername","obfuscatedAccountIdAndroid","obfuscatedProfileIdAndroid","isOfferPersonalized","console","warn","buyProduct","buyItemByType","length","requestSubscription","purchaseTokenAndroid","prorationModeAndroid","subscriptionOffers","undefined","reject","map","so","offerToken","requestPurchaseWithQuantityIOS","quantity","buyProductWithQuantityIOS","finishTransaction","purchase","isConsumable","developerPayloadAndroid","transactionId","consumeProduct","purchaseToken","userIdAmazon","isAcknowledgedAndroid","purchaseStateAndroid","PURCHASED","acknowledgePurchase","clearTransactionIOS","clearTransaction","clearProductsIOS","clearProducts","acknowledgePurchaseAndroid","token","developerPayload","deepLinkToSubscriptionsAndroid","openURL","getPackageName","getPromotedProductIOS","promotedProduct","buyPromotedProductIOS","buyPromotedProduct","requestAgnosticReceiptValidationIos","receiptBody","response","method","body","status","TEST_RECEIPT","testResponse","requestPurchaseWithOfferIOS","forUser","withOffer","buyProductWithOffer","validateReceiptIos","isTest","url","validateReceiptAndroid","packageName","productToken","accessToken","isSub","validateReceiptAmazon","developerSecret","userId","receiptId","useSandbox","sandBoxUrl","getPendingPurchasesIOS","getPendingTransactions","getReceiptIOS","forceRefresh","requestReceipt","presentCodeRedemptionSheetIOS","presentCodeRedemptionSheet"],"sources":["iap.ts"],"sourcesContent":["import {Linking, NativeModules, Platform} from 'react-native';\n\nimport type * as Amazon from './types/amazon';\nimport type * as Android from './types/android';\nimport type * as Apple from './types/apple';\nimport {ReceiptValidationStatus} from './types/apple';\nimport {\n enhancedFetch,\n fillProductsWithAdditionalData,\n isAmazon,\n isAndroid,\n} from './internal';\nimport type {\n Product,\n ProductPurchase,\n ProrationModesAndroid,\n PurchaseResult,\n Sku,\n Subscription,\n SubscriptionOffer,\n SubscriptionPurchase,\n} from './types';\nimport {InstallSourceAndroid, PurchaseStateAndroid} from './types';\n\nconst {RNIapIos, RNIapModule, RNIapAmazonModule} = NativeModules;\nconst ANDROID_ITEM_TYPE_SUBSCRIPTION = 'subs';\nconst ANDROID_ITEM_TYPE_IAP = 'inapp';\n\nexport const getInstallSourceAndroid = (): InstallSourceAndroid => {\n return RNIapModule\n ? InstallSourceAndroid.GOOGLE_PLAY\n : InstallSourceAndroid.AMAZON;\n};\n\nlet androidNativeModule = RNIapModule;\n\nexport const setAndroidNativeModule = (\n nativeModule: typeof RNIapModule,\n): void => {\n androidNativeModule = nativeModule;\n};\n\nconst checkNativeAndroidAvailable = (): void => {\n if (!RNIapModule && !RNIapAmazonModule) {\n throw new Error('IAP_NOT_AVAILABLE');\n }\n};\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\nconst checkNativeIOSAvailable = (): void => {\n if (!RNIapIos) {\n throw new Error('IAP_NOT_AVAILABLE');\n }\n};\n\nexport const getIosModule = (): typeof RNIapIos => {\n checkNativeIOSAvailable();\n\n return RNIapIos;\n};\n\nexport const getNativeModule = ():\n | typeof RNIapModule\n | typeof RNIapAmazonModule\n | typeof RNIapIos => {\n return isAndroid ? getAndroidModule() : getIosModule();\n};\n\n/**\n * Init module for purchase flow. Required on Android. In ios it will check whether user canMakePayment.\n * @returns {Promise<boolean>}\n */\nexport const initConnection = (): Promise<boolean> =>\n getNativeModule().initConnection();\n\n/**\n * End module for purchase flow.\n * @returns {Promise<void>}\n */\nexport const endConnection = (): Promise<void> =>\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 = (): Promise<\n string[]\n> => getAndroidModule().flushFailedPurchasesCachedAsPending();\n\n/**\n * Get a list of products (consumable and non-consumable items, but not subscriptions)\n * @param {string[]} skus The item skus\n * @returns {Promise<Product[]>}\n */\nexport const getProducts = ({\n skus,\n}: {\n skus: string[];\n}): Promise<Array<Product>> =>\n (\n Platform.select({\n ios: async () => {\n const items = await getIosModule().getItems(skus);\n\n return items.filter(\n (item: Product) =>\n skus.includes(item.productId) && item.type === 'iap',\n );\n },\n android: async () => {\n const products = await getAndroidModule().getItemsByType(\n ANDROID_ITEM_TYPE_IAP,\n skus,\n );\n\n return fillProductsWithAdditionalData(products);\n },\n }) || Promise.resolve\n )();\n\n/**\n * Get a list of subscriptions\n * @param {string[]} skus The item skus\n * @returns {Promise<Subscription[]>}\n */\nexport const getSubscriptions = ({\n skus,\n}: {\n skus: string[];\n}): Promise<Subscription[]> =>\n (\n Platform.select({\n ios: async () => {\n const items = await getIosModule().getItems(skus);\n\n return items.filter(\n (item: Subscription) =>\n skus.includes(item.productId) && item.type === 'subs',\n );\n },\n android: async () => {\n const subscriptions = await getAndroidModule().getItemsByType(\n ANDROID_ITEM_TYPE_SUBSCRIPTION,\n skus,\n );\n\n return fillProductsWithAdditionalData(subscriptions);\n },\n }) || Promise.resolve\n )();\n\n/**\n * Gets an inventory of purchases made by the user regardless of consumption status\n * @returns {Promise<(ProductPurchase | SubscriptionPurchase)[]>}\n */\nexport const getPurchaseHistory = (): Promise<\n (ProductPurchase | SubscriptionPurchase)[]\n> =>\n (\n Platform.select({\n ios: async () => {\n return getIosModule().getAvailableItems();\n },\n android: async () => {\n if (RNIapAmazonModule) {\n return await RNIapAmazonModule.getAvailableItems();\n }\n\n const products = await getAndroidModule().getPurchaseHistoryByType(\n ANDROID_ITEM_TYPE_IAP,\n );\n\n const subscriptions = await getAndroidModule().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 * @returns {Promise<(ProductPurchase | SubscriptionPurchase)[]>}\n */\nexport const getAvailablePurchases = (): Promise<\n (ProductPurchase | SubscriptionPurchase)[]\n> =>\n (\n Platform.select({\n ios: async () => {\n return getIosModule().getAvailableItems();\n },\n android: async () => {\n if (RNIapAmazonModule) {\n return await RNIapAmazonModule.getAvailableItems();\n }\n\n const products = await getAndroidModule().getAvailableItemsByType(\n ANDROID_ITEM_TYPE_IAP,\n );\n\n const subscriptions = await getAndroidModule().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 * @param {string} sku The product's sku/ID\n * @param {string} [applicationUsername] The purchaser's user ID\n * @param {boolean} [andDangerouslyFinishTransactionAutomaticallyIOS] You should set this to false 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 * @param {string} [obfuscatedAccountIdAndroid] Specifies an optional obfuscated string that is uniquely associated with the user's account in your app.\n * @param {string} [obfuscatedProfileIdAndroid] Specifies an optional obfuscated string that is uniquely associated with the user's profile in your app.\n * @param {string[]} [skus] Product Ids to purchase. Note that this is only for Android. iOS only uses a single SKU. If not provided, it'll default to using [sku] for backward-compatibility\n * @param {boolean} [isOfferPersonalized] Defaults to false, Only for Android V5\n * @returns {Promise<ProductPurchase>}\n */\n\nexport const requestPurchase = ({\n sku,\n andDangerouslyFinishTransactionAutomaticallyIOS = false,\n applicationUsername,\n obfuscatedAccountIdAndroid,\n obfuscatedProfileIdAndroid,\n skus,\n isOfferPersonalized,\n}: {\n sku?: Sku;\n andDangerouslyFinishTransactionAutomaticallyIOS?: boolean;\n applicationUsername?: string;\n obfuscatedAccountIdAndroid?: string;\n obfuscatedProfileIdAndroid?: string;\n /** For Google Play Billing Library 5 https://developer.android.com/google/play/billing/integrate#personalized-price */\n skus?: Sku[];\n isOfferPersonalized?: boolean;\n}): Promise<ProductPurchase> =>\n (\n Platform.select({\n ios: async () => {\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 return getIosModule().buyProduct(\n sku,\n andDangerouslyFinishTransactionAutomaticallyIOS,\n applicationUsername,\n );\n },\n android: async () => {\n if (isAmazon) {\n return RNIapAmazonModule.buyItemByType(sku);\n } else {\n return getAndroidModule().buyItemByType(\n ANDROID_ITEM_TYPE_IAP,\n skus?.length ? skus : [sku],\n null,\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 * @param {string} [sku] The product's sku/ID\n * @param {string} [applicationUsername] The purchaser's user ID\n * @param {boolean} [andDangerouslyFinishTransactionAutomaticallyIOS] You should set this to false 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 * @param {string} [purchaseTokenAndroid] purchaseToken that the user is upgrading or downgrading from (Android).\n * @param {ProrationModesAndroid} [prorationModeAndroid] UNKNOWN_SUBSCRIPTION_UPGRADE_DOWNGRADE_POLICY, IMMEDIATE_WITH_TIME_PRORATION, IMMEDIATE_AND_CHARGE_PRORATED_PRICE, IMMEDIATE_WITHOUT_PRORATION, DEFERRED\n * @param {string} [obfuscatedAccountIdAndroid] Specifies an optional obfuscated string that is uniquely associated with the user's account in your app.\n * @param {string} [obfuscatedProfileIdAndroid] Specifies an optional obfuscated string that is uniquely associated with the user's profile in your app.\n * @param {SubscriptionOffers[]} [subscriptionOffers] Array of SubscriptionOffers. Every sku must be paired with a corresponding offerToken\n * @returns {Promise<SubscriptionPurchase | null>} Promise resolves to null when using proratioModesAndroid=DEFERRED, and to a SubscriptionPurchase otherwise\n */\nexport const requestSubscription = ({\n sku,\n andDangerouslyFinishTransactionAutomaticallyIOS = false,\n applicationUsername,\n purchaseTokenAndroid,\n prorationModeAndroid = -1,\n subscriptionOffers,\n obfuscatedAccountIdAndroid,\n obfuscatedProfileIdAndroid,\n isOfferPersonalized = undefined,\n}: {\n sku?: Sku;\n andDangerouslyFinishTransactionAutomaticallyIOS?: boolean;\n applicationUsername?: string;\n purchaseTokenAndroid?: string;\n prorationModeAndroid?: ProrationModesAndroid;\n /** For Google Play Billing Library 5 */\n subscriptionOffers?: SubscriptionOffer[];\n obfuscatedAccountIdAndroid?: string;\n obfuscatedProfileIdAndroid?: string;\n /** For Google Play Billing Library 5 https://developer.android.com/google/play/billing/integrate#personalized-price */\n isOfferPersonalized?: boolean;\n}): Promise<SubscriptionPurchase | null> =>\n (\n Platform.select({\n ios: async () => {\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 return getIosModule().buyProduct(\n sku,\n andDangerouslyFinishTransactionAutomaticallyIOS,\n applicationUsername,\n );\n },\n android: async () => {\n if (isAmazon) {\n return RNIapAmazonModule.buyItemByType(sku);\n } else {\n if (!subscriptionOffers?.length) {\n Promise.reject(\n 'subscriptionOffers are required for Google Play Subscriptions',\n );\n return;\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\n )();\n\n/**\n * Request a purchase for product. This will be received in `PurchaseUpdatedListener`.\n * @param {string} sku The product's sku/ID\n * @returns {Promise<void>}\n */\nexport const requestPurchaseWithQuantityIOS = ({\n sku,\n quantity,\n}: {\n sku: Sku;\n quantity: number;\n}): Promise<ProductPurchase> =>\n getIosModule().buyProductWithQuantityIOS(sku, quantity);\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 * @param {object} purchase The purchase that you would like to finish.\n * @param {boolean} isConsumable Checks if purchase is consumable. Has effect on `android`.\n * @param {string} developerPayloadAndroid Android developerPayload.\n * @returns {Promise<string | void> }\n */\nexport const finishTransaction = ({\n purchase,\n isConsumable,\n developerPayloadAndroid,\n}: {\n purchase: ProductPurchase | ProductPurchase;\n isConsumable?: boolean;\n developerPayloadAndroid?: string;\n}): Promise<string | void> => {\n return (\n Platform.select({\n ios: async () => {\n return getIosModule().finishTransaction(purchase.transactionId);\n },\n android: async () => {\n if (purchase) {\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 throw new Error('purchase is not suitable to be purchased');\n }\n } else {\n throw new Error('purchase is not assigned');\n }\n },\n }) || Promise.resolve\n )();\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\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 | void> => {\n return getAndroidModule().acknowledgePurchase(token, developerPayload);\n};\n\n/**\n * Deep link to subscriptions screen on Android. No-op on iOS.\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 * Should Add Store Payment (iOS only)\n * Indicates the the App Store purchase should continue from the app instead of the App Store.\n * @returns {Promise<Product | null>} promoted product\n */\nexport const getPromotedProductIOS = (): Promise<Product | null> =>\n getIosModule().promotedProduct();\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 requestAgnosticReceiptValidationIos = async (\n receiptBody: Record<string, unknown>,\n): Promise<Apple.ReceiptValidationResponse | false> => {\n const response = await enhancedFetch<Apple.ReceiptValidationResponse>(\n 'https://buy.itunes.apple.com/verifyReceipt',\n {\n method: 'POST',\n body: receiptBody,\n },\n );\n\n // Best practice is to check for test receipt and check sandbox instead\n // https://developer.apple.com/documentation/appstorereceipts/verifyreceipt\n if (response && response.status === ReceiptValidationStatus.TEST_RECEIPT) {\n const testResponse = await enhancedFetch<Apple.ReceiptValidationResponse>(\n 'https://sandbox.itunes.apple.com/verifyReceipt',\n {\n method: 'POST',\n body: receiptBody,\n },\n );\n\n return testResponse;\n }\n\n return response;\n};\n\n/**\n * Buy products or subscriptions with offers (iOS only)\n *\n * Runs the payment process with some info you must fetch\n * from your server.\n * @param {string} sku The product identifier\n * @param {string} forUser An user identifier on you system\n * @param {Apple.PaymentDiscount} withOffer The offer information\n * @param {string} withOffer.identifier The offer identifier\n * @param {string} withOffer.keyIdentifier Key identifier that it uses to generate the signature\n * @param {string} withOffer.nonce An UUID returned from the server\n * @param {string} withOffer.signature The actual signature returned from the server\n * @param {number} withOffer.timestamp The timestamp of the signature\n * @returns {Promise<void>}\n */\nexport const requestPurchaseWithOfferIOS = ({\n sku,\n forUser,\n withOffer,\n}: {\n sku: Sku;\n forUser: string;\n withOffer: Apple.PaymentDiscount;\n}): Promise<void> =>\n getIosModule().buyProductWithOffer(sku, forUser, withOffer);\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<Apple.ReceiptValidationResponse | false> => {\n if (isTest == null) {\n return await requestAgnosticReceiptValidationIos(receiptBody);\n }\n\n const url = isTest\n ? 'https://sandbox.itunes.apple.com/verifyReceipt'\n : 'https://buy.itunes.apple.com/verifyReceipt';\n\n return await enhancedFetch<Apple.ReceiptValidationResponse>(url);\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 return await enhancedFetch<Android.ReceiptType>(url);\n};\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<Amazon.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<Amazon.ReceiptType>(url);\n};\n\n/**\n * Get the current receipt base64 encoded in IOS.\n * @param {forceRefresh?:boolean}\n * @returns {Promise<ProductPurchase[]>}\n */\nexport const getPendingPurchasesIOS = async (): Promise<ProductPurchase[]> =>\n getIosModule().getPendingTransactions();\n\n/**\n * Get the current receipt base64 encoded in IOS.\n * @param {forceRefresh?:boolean}\n * @returns {Promise<string>}\n */\nexport const getReceiptIOS = async ({\n forceRefresh,\n}: {\n forceRefresh?: boolean;\n}): Promise<string> => getIosModule().requestReceipt(forceRefresh ?? false);\n\n/**\n * Launches a modal to register the redeem offer code in IOS.\n * @returns {Promise<null>}\n */\nexport const presentCodeRedemptionSheetIOS = async (): Promise<null> =>\n getIosModule().presentCodeRedemptionSheet();\n"],"mappings":"AAAA,SAAQA,OAAR,EAAiBC,aAAjB,EAAgCC,QAAhC,QAA+C,cAA/C;AAKA,SAAQC,uBAAR,QAAsC,eAAtC;AACA,SACEC,aADF,EAEEC,8BAFF,EAGEC,QAHF,EAIEC,SAJF,QAKO,YALP;AAgBA,SAAQC,oBAAR,EAA8BC,oBAA9B,QAAyD,SAAzD;AAEA,MAAM;EAACC,QAAD;EAAWC,WAAX;EAAwBC;AAAxB,IAA6CX,aAAnD;AACA,MAAMY,8BAA8B,GAAG,MAAvC;AACA,MAAMC,qBAAqB,GAAG,OAA9B;AAEA,OAAO,MAAMC,uBAAuB,GAAG,MAA4B;EACjE,OAAOJ,WAAW,GACdH,oBAAoB,CAACQ,WADP,GAEdR,oBAAoB,CAACS,MAFzB;AAGD,CAJM;AAMP,IAAIC,mBAAmB,GAAGP,WAA1B;AAEA,OAAO,MAAMQ,sBAAsB,GACjCC,YADoC,IAE3B;EACTF,mBAAmB,GAAGE,YAAtB;AACD,CAJM;;AAMP,MAAMC,2BAA2B,GAAG,MAAY;EAC9C,IAAI,CAACV,WAAD,IAAgB,CAACC,iBAArB,EAAwC;IACtC,MAAM,IAAIU,KAAJ,CAAU,mBAAV,CAAN;EACD;AACF,CAJD;;AAMA,OAAO,MAAMC,gBAAgB,GAAG,MAEA;EAC9BF,2BAA2B;EAE3B,OAAOH,mBAAmB,GACtBA,mBADsB,GAEtBP,WAAW,GACXA,WADW,GAEXC,iBAJJ;AAKD,CAVM;;AAYP,MAAMY,uBAAuB,GAAG,MAAY;EAC1C,IAAI,CAACd,QAAL,EAAe;IACb,MAAM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I1CC,UAAU,GAAG;EAJ6B,CAUT;EACjC,MAAMC,UAAU,GAAGD,UAAU,GAAG,UAAH,GAAgB,EAA7C;EACA,MAAMV,GAAG,GAAI,mCAAkCW,UAAW,yCAAwCJ,eAAgB,SAAQC,MAAO,cAAaC,SAAU,EAAxJ;EAEA,OAAO,MAAM5H,aAAa,CAAqBmH,GAArB,CAA1B;AACD,CAfM;AAiBP;AACA;AACA;AACA;AACA;;AACA,OAAO,MAAMY,sBAAsB,GAAG,YACpC1G,YAAY,GAAG2G,sBAAf,EADK;AAGP;AACA;AACA;AACA;AACA;;AACA,OAAO,MAAMC,aAAa,GAAG;EAAA,IAAO;IAClCC;EADkC,CAAP;EAAA,OAIN7G,YAAY,GAAG8G,cAAf,CAA8BD,YAAY,IAAI,KAA9C,CAJM;AAAA,CAAtB;AAMP;AACA;AACA;AACA;;AACA,OAAO,MAAME,6BAA6B,GAAG,YAC3C/G,YAAY,GAAGgH,0BAAf,EADK"}
1
+ {"version":3,"names":["Linking","NativeModules","Platform","ReceiptValidationStatus","enhancedFetch","fillProductsWithAdditionalData","isAmazon","isAndroid","InstallSourceAndroid","PurchaseStateAndroid","RNIapIos","RNIapModule","RNIapAmazonModule","ANDROID_ITEM_TYPE_SUBSCRIPTION","ANDROID_ITEM_TYPE_IAP","getInstallSourceAndroid","GOOGLE_PLAY","AMAZON","androidNativeModule","setAndroidNativeModule","nativeModule","checkNativeAndroidAvailable","Error","getAndroidModule","checkNativeIOSAvailable","getIosModule","getNativeModule","initConnection","endConnection","flushFailedPurchasesCachedAsPendingAndroid","flushFailedPurchasesCachedAsPending","getProducts","skus","select","ios","items","getItems","filter","item","includes","productId","type","android","products","getItemsByType","Promise","resolve","getSubscriptions","subscriptions","getPurchaseHistory","getAvailableItems","getPurchaseHistoryByType","concat","getAvailablePurchases","getAvailableItemsByType","requestPurchase","sku","andDangerouslyFinishTransactionAutomaticallyIOS","applicationUsername","obfuscatedAccountIdAndroid","obfuscatedProfileIdAndroid","isOfferPersonalized","console","warn","buyProduct","buyItemByType","length","requestSubscription","purchaseTokenAndroid","prorationModeAndroid","subscriptionOffers","undefined","reject","map","so","offerToken","requestPurchaseWithQuantityIOS","quantity","buyProductWithQuantityIOS","finishTransaction","purchase","isConsumable","developerPayloadAndroid","transactionId","consumeProduct","purchaseToken","userIdAmazon","isAcknowledgedAndroid","purchaseStateAndroid","PURCHASED","acknowledgePurchase","clearTransactionIOS","clearTransaction","clearProductsIOS","clearProducts","acknowledgePurchaseAndroid","token","developerPayload","deepLinkToSubscriptionsAndroid","openURL","getPackageName","getPromotedProductIOS","promotedProduct","buyPromotedProductIOS","buyPromotedProduct","requestAgnosticReceiptValidationIos","receiptBody","response","method","body","status","TEST_RECEIPT","testResponse","requestPurchaseWithOfferIOS","forUser","withOffer","buyProductWithOffer","validateReceiptIos","isTest","url","validateReceiptAndroid","packageName","productToken","accessToken","isSub","validateReceiptAmazon","developerSecret","userId","receiptId","useSandbox","sandBoxUrl","getPendingPurchasesIOS","getPendingTransactions","getReceiptIOS","forceRefresh","requestReceipt","presentCodeRedemptionSheetIOS","presentCodeRedemptionSheet"],"sources":["iap.ts"],"sourcesContent":["import {Linking, NativeModules, Platform} from 'react-native';\n\nimport type * as Amazon from './types/amazon';\nimport type * as Android from './types/android';\nimport type * as Apple from './types/apple';\nimport {ReceiptValidationStatus} from './types/apple';\nimport {\n enhancedFetch,\n fillProductsWithAdditionalData,\n isAmazon,\n isAndroid,\n} from './internal';\nimport type {\n Product,\n ProductPurchase,\n ProrationModesAndroid,\n PurchaseResult,\n Sku,\n Subscription,\n SubscriptionOffer,\n SubscriptionPurchase,\n} from './types';\nimport {InstallSourceAndroid, PurchaseStateAndroid} from './types';\n\nconst {RNIapIos, RNIapModule, RNIapAmazonModule} = NativeModules;\nconst ANDROID_ITEM_TYPE_SUBSCRIPTION = 'subs';\nconst ANDROID_ITEM_TYPE_IAP = 'inapp';\n\nexport const getInstallSourceAndroid = (): InstallSourceAndroid => {\n return RNIapModule\n ? InstallSourceAndroid.GOOGLE_PLAY\n : InstallSourceAndroid.AMAZON;\n};\n\nlet androidNativeModule = RNIapModule;\n\nexport const setAndroidNativeModule = (\n nativeModule: typeof RNIapModule,\n): void => {\n androidNativeModule = nativeModule;\n};\n\nconst checkNativeAndroidAvailable = (): void => {\n if (!RNIapModule && !RNIapAmazonModule) {\n throw new Error('IAP_NOT_AVAILABLE');\n }\n};\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\nconst checkNativeIOSAvailable = (): void => {\n if (!RNIapIos) {\n throw new Error('IAP_NOT_AVAILABLE');\n }\n};\n\nexport const getIosModule = (): typeof RNIapIos => {\n checkNativeIOSAvailable();\n\n return RNIapIos;\n};\n\nexport const getNativeModule = ():\n | typeof RNIapModule\n | typeof RNIapAmazonModule\n | typeof RNIapIos => {\n return isAndroid ? getAndroidModule() : getIosModule();\n};\n\n/**\n * Init module for purchase flow. Required on Android. In ios it will check whether user canMakePayment.\n * @returns {Promise<boolean>}\n */\nexport const initConnection = (): Promise<boolean> =>\n getNativeModule().initConnection();\n\n/**\n * End module for purchase flow.\n * @returns {Promise<void>}\n */\nexport const endConnection = (): Promise<void> =>\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 = (): Promise<\n string[]\n> => getAndroidModule().flushFailedPurchasesCachedAsPending();\n\n/**\n * Get a list of products (consumable and non-consumable items, but not subscriptions)\n * @param {string[]} skus The item skus\n * @returns {Promise<Product[]>}\n */\nexport const getProducts = ({\n skus,\n}: {\n skus: string[];\n}): Promise<Array<Product>> =>\n (\n Platform.select({\n ios: async () => {\n const items = await getIosModule().getItems(skus);\n\n return items.filter(\n (item: Product) =>\n skus.includes(item.productId) && item.type === 'iap',\n );\n },\n android: async () => {\n const products = await getAndroidModule().getItemsByType(\n ANDROID_ITEM_TYPE_IAP,\n skus,\n );\n\n return fillProductsWithAdditionalData(products);\n },\n }) || Promise.resolve\n )();\n\n/**\n * Get a list of subscriptions\n * @param {string[]} skus The item skus\n * @returns {Promise<Subscription[]>}\n */\nexport const getSubscriptions = ({\n skus,\n}: {\n skus: string[];\n}): Promise<Subscription[]> =>\n (\n Platform.select({\n ios: async () => {\n const items = await getIosModule().getItems(skus);\n\n return items.filter(\n (item: Subscription) =>\n skus.includes(item.productId) && item.type === 'subs',\n );\n },\n android: async () => {\n const subscriptions = await getAndroidModule().getItemsByType(\n ANDROID_ITEM_TYPE_SUBSCRIPTION,\n skus,\n );\n\n return fillProductsWithAdditionalData(subscriptions);\n },\n }) || Promise.resolve\n )();\n\n/**\n * Gets an inventory of purchases made by the user regardless of consumption status\n * @returns {Promise<(ProductPurchase | SubscriptionPurchase)[]>}\n */\nexport const getPurchaseHistory = (): Promise<\n (ProductPurchase | SubscriptionPurchase)[]\n> =>\n (\n Platform.select({\n ios: async () => {\n return getIosModule().getAvailableItems();\n },\n android: async () => {\n if (RNIapAmazonModule) {\n return await RNIapAmazonModule.getAvailableItems();\n }\n\n const products = await getAndroidModule().getPurchaseHistoryByType(\n ANDROID_ITEM_TYPE_IAP,\n );\n\n const subscriptions = await getAndroidModule().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 * @returns {Promise<(ProductPurchase | SubscriptionPurchase)[]>}\n */\nexport const getAvailablePurchases = (): Promise<\n (ProductPurchase | SubscriptionPurchase)[]\n> =>\n (\n Platform.select({\n ios: async () => {\n return getIosModule().getAvailableItems();\n },\n android: async () => {\n if (RNIapAmazonModule) {\n return await RNIapAmazonModule.getAvailableItems();\n }\n\n const products = await getAndroidModule().getAvailableItemsByType(\n ANDROID_ITEM_TYPE_IAP,\n );\n\n const subscriptions = await getAndroidModule().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 * @param {string} sku The product's sku/ID\n * @param {string} [applicationUsername] The purchaser's user ID\n * @param {boolean} [andDangerouslyFinishTransactionAutomaticallyIOS] You should set this to false 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 * @param {string} [obfuscatedAccountIdAndroid] Specifies an optional obfuscated string that is uniquely associated with the user's account in your app.\n * @param {string} [obfuscatedProfileIdAndroid] Specifies an optional obfuscated string that is uniquely associated with the user's profile in your app.\n * @param {string[]} [skus] Product Ids to purchase. Note that this is only for Android. iOS only uses a single SKU. If not provided, it'll default to using [sku] for backward-compatibility\n * @param {boolean} [isOfferPersonalized] Defaults to false, Only for Android V5\n * @returns {Promise<ProductPurchase>}\n */\n\nexport const requestPurchase = ({\n sku,\n andDangerouslyFinishTransactionAutomaticallyIOS = false,\n applicationUsername,\n obfuscatedAccountIdAndroid,\n obfuscatedProfileIdAndroid,\n skus,\n isOfferPersonalized,\n}: {\n sku?: Sku;\n andDangerouslyFinishTransactionAutomaticallyIOS?: boolean;\n applicationUsername?: string;\n obfuscatedAccountIdAndroid?: string;\n obfuscatedProfileIdAndroid?: string;\n /** For Google Play Billing Library 5 https://developer.android.com/google/play/billing/integrate#personalized-price */\n skus?: Sku[];\n isOfferPersonalized?: boolean;\n}): Promise<ProductPurchase> =>\n (\n Platform.select({\n ios: async () => {\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 return getIosModule().buyProduct(\n sku,\n andDangerouslyFinishTransactionAutomaticallyIOS,\n applicationUsername,\n );\n },\n android: async () => {\n if (isAmazon) {\n return RNIapAmazonModule.buyItemByType(sku);\n } else {\n return getAndroidModule().buyItemByType(\n ANDROID_ITEM_TYPE_IAP,\n skus?.length ? skus : [sku],\n null,\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 * @param {string} [sku] The product's sku/ID\n * @param {string} [applicationUsername] The purchaser's user ID\n * @param {boolean} [andDangerouslyFinishTransactionAutomaticallyIOS] You should set this to false 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 * @param {string} [purchaseTokenAndroid] purchaseToken that the user is upgrading or downgrading from (Android).\n * @param {ProrationModesAndroid} [prorationModeAndroid] UNKNOWN_SUBSCRIPTION_UPGRADE_DOWNGRADE_POLICY, IMMEDIATE_WITH_TIME_PRORATION, IMMEDIATE_AND_CHARGE_PRORATED_PRICE, IMMEDIATE_WITHOUT_PRORATION, DEFERRED\n * @param {string} [obfuscatedAccountIdAndroid] Specifies an optional obfuscated string that is uniquely associated with the user's account in your app.\n * @param {string} [obfuscatedProfileIdAndroid] Specifies an optional obfuscated string that is uniquely associated with the user's profile in your app.\n * @param {SubscriptionOffers[]} [subscriptionOffers] Array of SubscriptionOffers. Every sku must be paired with a corresponding offerToken\n * @returns {Promise<SubscriptionPurchase | null>} Promise resolves to null when using proratioModesAndroid=DEFERRED, and to a SubscriptionPurchase otherwise\n */\nexport const requestSubscription = ({\n sku,\n andDangerouslyFinishTransactionAutomaticallyIOS = false,\n applicationUsername,\n purchaseTokenAndroid,\n prorationModeAndroid = -1,\n subscriptionOffers,\n obfuscatedAccountIdAndroid,\n obfuscatedProfileIdAndroid,\n isOfferPersonalized = undefined,\n}: {\n sku?: Sku;\n andDangerouslyFinishTransactionAutomaticallyIOS?: boolean;\n applicationUsername?: string;\n purchaseTokenAndroid?: string;\n prorationModeAndroid?: ProrationModesAndroid;\n /** For Google Play Billing Library 5 */\n subscriptionOffers?: SubscriptionOffer[];\n obfuscatedAccountIdAndroid?: string;\n obfuscatedProfileIdAndroid?: string;\n /** For Google Play Billing Library 5 https://developer.android.com/google/play/billing/integrate#personalized-price */\n isOfferPersonalized?: boolean;\n}): Promise<SubscriptionPurchase | null> =>\n (\n Platform.select({\n ios: async () => {\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 return getIosModule().buyProduct(\n sku,\n andDangerouslyFinishTransactionAutomaticallyIOS,\n applicationUsername,\n );\n },\n android: async () => {\n if (isAmazon) {\n return RNIapAmazonModule.buyItemByType(sku);\n } else {\n if (!subscriptionOffers?.length) {\n return Promise.reject(\n 'subscriptionOffers are required for Google Play Subscriptions',\n );\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\n )();\n\n/**\n * Request a purchase for product. This will be received in `PurchaseUpdatedListener`.\n * @param {string} sku The product's sku/ID\n * @returns {Promise<void>}\n */\nexport const requestPurchaseWithQuantityIOS = ({\n sku,\n quantity,\n}: {\n sku: Sku;\n quantity: number;\n}): Promise<ProductPurchase> =>\n getIosModule().buyProductWithQuantityIOS(sku, quantity);\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 * @param {object} purchase The purchase that you would like to finish.\n * @param {boolean} isConsumable Checks if purchase is consumable. Has effect on `android`.\n * @param {string} developerPayloadAndroid Android developerPayload.\n * @returns {Promise<string | void> }\n */\nexport const finishTransaction = ({\n purchase,\n isConsumable,\n developerPayloadAndroid,\n}: {\n purchase: ProductPurchase | ProductPurchase;\n isConsumable?: boolean;\n developerPayloadAndroid?: string;\n}): Promise<string | void> => {\n return (\n Platform.select({\n ios: async () => {\n return getIosModule().finishTransaction(purchase.transactionId);\n },\n android: async () => {\n if (purchase) {\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 throw new Error('purchase is not suitable to be purchased');\n }\n } else {\n throw new Error('purchase is not assigned');\n }\n },\n }) || Promise.resolve\n )();\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\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 | void> => {\n return getAndroidModule().acknowledgePurchase(token, developerPayload);\n};\n\n/**\n * Deep link to subscriptions screen on Android. No-op on iOS.\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 * Should Add Store Payment (iOS only)\n * Indicates the the App Store purchase should continue from the app instead of the App Store.\n * @returns {Promise<Product | null>} promoted product\n */\nexport const getPromotedProductIOS = (): Promise<Product | null> =>\n getIosModule().promotedProduct();\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 requestAgnosticReceiptValidationIos = async (\n receiptBody: Record<string, unknown>,\n): Promise<Apple.ReceiptValidationResponse | false> => {\n const response = await enhancedFetch<Apple.ReceiptValidationResponse>(\n 'https://buy.itunes.apple.com/verifyReceipt',\n {\n method: 'POST',\n body: receiptBody,\n },\n );\n\n // Best practice is to check for test receipt and check sandbox instead\n // https://developer.apple.com/documentation/appstorereceipts/verifyreceipt\n if (response && response.status === ReceiptValidationStatus.TEST_RECEIPT) {\n const testResponse = await enhancedFetch<Apple.ReceiptValidationResponse>(\n 'https://sandbox.itunes.apple.com/verifyReceipt',\n {\n method: 'POST',\n body: receiptBody,\n },\n );\n\n return testResponse;\n }\n\n return response;\n};\n\n/**\n * Buy products or subscriptions with offers (iOS only)\n *\n * Runs the payment process with some info you must fetch\n * from your server.\n * @param {string} sku The product identifier\n * @param {string} forUser An user identifier on you system\n * @param {Apple.PaymentDiscount} withOffer The offer information\n * @param {string} withOffer.identifier The offer identifier\n * @param {string} withOffer.keyIdentifier Key identifier that it uses to generate the signature\n * @param {string} withOffer.nonce An UUID returned from the server\n * @param {string} withOffer.signature The actual signature returned from the server\n * @param {number} withOffer.timestamp The timestamp of the signature\n * @returns {Promise<void>}\n */\nexport const requestPurchaseWithOfferIOS = ({\n sku,\n forUser,\n withOffer,\n}: {\n sku: Sku;\n forUser: string;\n withOffer: Apple.PaymentDiscount;\n}): Promise<void> =>\n getIosModule().buyProductWithOffer(sku, forUser, withOffer);\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<Apple.ReceiptValidationResponse | false> => {\n if (isTest == null) {\n return await requestAgnosticReceiptValidationIos(receiptBody);\n }\n\n const url = isTest\n ? 'https://sandbox.itunes.apple.com/verifyReceipt'\n : 'https://buy.itunes.apple.com/verifyReceipt';\n\n return await enhancedFetch<Apple.ReceiptValidationResponse>(url);\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 return await enhancedFetch<Android.ReceiptType>(url);\n};\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<Amazon.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<Amazon.ReceiptType>(url);\n};\n\n/**\n * Get the current receipt base64 encoded in IOS.\n * @param {forceRefresh?:boolean}\n * @returns {Promise<ProductPurchase[]>}\n */\nexport const getPendingPurchasesIOS = async (): Promise<ProductPurchase[]> =>\n getIosModule().getPendingTransactions();\n\n/**\n * Get the current receipt base64 encoded in IOS.\n * @param {forceRefresh?:boolean}\n * @returns {Promise<string>}\n */\nexport const getReceiptIOS = async ({\n forceRefresh,\n}: {\n forceRefresh?: boolean;\n}): Promise<string> => getIosModule().requestReceipt(forceRefresh ?? false);\n\n/**\n * Launches a modal to register the redeem offer code in IOS.\n * @returns {Promise<null>}\n */\nexport const presentCodeRedemptionSheetIOS = async (): Promise<null> =>\n getIosModule().presentCodeRedemptionSheet();\n"],"mappings":"AAAA,SAAQA,OAAR,EAAiBC,aAAjB,EAAgCC,QAAhC,QAA+C,cAA/C;AAKA,SAAQC,uBAAR,QAAsC,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EADK;AAGP;AACA;AACA;AACA;AACA;;AACA,OAAO,MAAMC,aAAa,GAAG;EAAA,IAAO;IAClCC;EADkC,CAAP;EAAA,OAIN7G,YAAY,GAAG8G,cAAf,CAA8BD,YAAY,IAAI,KAA9C,CAJM;AAAA,CAAtB;AAMP;AACA;AACA;AACA;;AACA,OAAO,MAAME,6BAA6B,GAAG,YAC3C/G,YAAY,GAAGgH,0BAAf,EADK"}
@@ -16,6 +16,7 @@ export let ErrorCode;
16
16
  ErrorCode["E_DEVELOPER_ERROR"] = "E_DEVELOPER_ERROR";
17
17
  ErrorCode["E_BILLING_RESPONSE_JSON_PARSE_ERROR"] = "E_BILLING_RESPONSE_JSON_PARSE_ERROR";
18
18
  ErrorCode["E_DEFERRED_PAYMENT"] = "E_DEFERRED_PAYMENT";
19
+ ErrorCode["E_INTERRUPTED"] = "E_INTERRUPTED";
19
20
  })(ErrorCode || (ErrorCode = {}));
20
21
 
21
22
  export class PurchaseError {
@@ -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}\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;GAAAA,S,KAAAA,S;;AAkBZ,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"],"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}\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;GAAAA,S,KAAAA,S;;AAmBZ,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"}
@@ -13,7 +13,8 @@ export declare enum ErrorCode {
13
13
  E_ALREADY_OWNED = "E_ALREADY_OWNED",
14
14
  E_DEVELOPER_ERROR = "E_DEVELOPER_ERROR",
15
15
  E_BILLING_RESPONSE_JSON_PARSE_ERROR = "E_BILLING_RESPONSE_JSON_PARSE_ERROR",
16
- E_DEFERRED_PAYMENT = "E_DEFERRED_PAYMENT"
16
+ E_DEFERRED_PAYMENT = "E_DEFERRED_PAYMENT",
17
+ E_INTERRUPTED = "E_INTERRUPTED"
17
18
  }
18
19
  export declare class PurchaseError implements Error {
19
20
  name: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-iap",
3
- "version": "10.0.2",
3
+ "version": "10.0.6",
4
4
  "description": "React Native In App Purchase Module.",
5
5
  "repository": "https://github.com/dooboolab/react-native-iap",
6
6
  "author": "dooboolab <support@dooboolab.com> (https://github.com/dooboolab)",
package/src/iap.ts CHANGED
@@ -340,10 +340,9 @@ export const requestSubscription = ({
340
340
  return RNIapAmazonModule.buyItemByType(sku);
341
341
  } else {
342
342
  if (!subscriptionOffers?.length) {
343
- Promise.reject(
343
+ return Promise.reject(
344
344
  'subscriptionOffers are required for Google Play Subscriptions',
345
345
  );
346
- return;
347
346
  }
348
347
  return RNIapModule.buyItemByType(
349
348
  ANDROID_ITEM_TYPE_SUBSCRIPTION,
@@ -14,6 +14,7 @@ export enum ErrorCode {
14
14
  E_DEVELOPER_ERROR = 'E_DEVELOPER_ERROR',
15
15
  E_BILLING_RESPONSE_JSON_PARSE_ERROR = 'E_BILLING_RESPONSE_JSON_PARSE_ERROR',
16
16
  E_DEFERRED_PAYMENT = 'E_DEFERRED_PAYMENT',
17
+ E_INTERRUPTED = 'E_INTERRUPTED',
17
18
  }
18
19
 
19
20
  export class PurchaseError implements Error {