@revenuecat/purchases-capacitor 7.5.4 → 7.5.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 +117 -58
- package/RevenueCatPurchasesCapacitor.podspec +1 -1
- package/android/build.gradle +1 -1
- package/android/src/main/java/com/revenuecat/purchases/capacitor/PurchasesPlugin.kt +66 -7
- package/dist/docs.json +141 -4
- package/dist/esm/definitions.d.ts +18 -1
- package/dist/esm/definitions.js.map +1 -1
- package/dist/esm/web.d.ts +5 -1
- package/dist/esm/web.js +11 -0
- package/dist/esm/web.js.map +1 -1
- package/dist/plugin.cjs.js +11 -0
- package/dist/plugin.cjs.js.map +1 -1
- package/dist/plugin.js +11 -0
- package/dist/plugin.js.map +1 -1
- package/ios/Plugin/PurchasesPlugin.m +2 -0
- package/ios/Plugin/PurchasesPlugin.swift +18 -7
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -60,6 +60,8 @@ This plugin is based on [CapGo's Capacitor plugin](https://www.npmjs.com/package
|
|
|
60
60
|
* [`addCustomerInfoUpdateListener(...)`](#addcustomerinfoupdatelistener)
|
|
61
61
|
* [`removeCustomerInfoUpdateListener(...)`](#removecustomerinfoupdatelistener)
|
|
62
62
|
* [`getOfferings()`](#getofferings)
|
|
63
|
+
* [`getCurrentOfferingForPlacement(...)`](#getcurrentofferingforplacement)
|
|
64
|
+
* [`syncAttributesAndOfferingsIfNeeded()`](#syncattributesandofferingsifneeded)
|
|
63
65
|
* [`getProducts(...)`](#getproducts)
|
|
64
66
|
* [`purchaseStoreProduct(...)`](#purchasestoreproduct)
|
|
65
67
|
* [`purchaseDiscountedProduct(...)`](#purchasediscountedproduct)
|
|
@@ -225,6 +227,39 @@ Gets the map of entitlements -> offerings -> products
|
|
|
225
227
|
--------------------
|
|
226
228
|
|
|
227
229
|
|
|
230
|
+
### getCurrentOfferingForPlacement(...)
|
|
231
|
+
|
|
232
|
+
```typescript
|
|
233
|
+
getCurrentOfferingForPlacement(options: { placementIdentifier: string; }) => Promise<PurchasesOffering | null>
|
|
234
|
+
```
|
|
235
|
+
|
|
236
|
+
Retrieves a current offering for a placement identifier, use this to access offerings defined by targeting
|
|
237
|
+
placements configured in the RevenueCat dashboard.
|
|
238
|
+
|
|
239
|
+
| Param | Type |
|
|
240
|
+
| ------------- | --------------------------------------------- |
|
|
241
|
+
| **`options`** | <code>{ placementIdentifier: string; }</code> |
|
|
242
|
+
|
|
243
|
+
**Returns:** <code>Promise<<a href="#purchasesoffering">PurchasesOffering</a> | null></code>
|
|
244
|
+
|
|
245
|
+
--------------------
|
|
246
|
+
|
|
247
|
+
|
|
248
|
+
### syncAttributesAndOfferingsIfNeeded()
|
|
249
|
+
|
|
250
|
+
```typescript
|
|
251
|
+
syncAttributesAndOfferingsIfNeeded() => Promise<PurchasesOfferings>
|
|
252
|
+
```
|
|
253
|
+
|
|
254
|
+
Syncs subscriber attributes and then fetches the configured offerings for this user. This method is intended to
|
|
255
|
+
be called when using Targeting Rules with Custom Attributes. Any subscriber attributes should be set before
|
|
256
|
+
calling this method to ensure the returned offerings are applied with the latest subscriber attributes.
|
|
257
|
+
|
|
258
|
+
**Returns:** <code>Promise<<a href="#purchasesofferings">PurchasesOfferings</a>></code>
|
|
259
|
+
|
|
260
|
+
--------------------
|
|
261
|
+
|
|
262
|
+
|
|
228
263
|
### getProducts(...)
|
|
229
264
|
|
|
230
265
|
```typescript
|
|
@@ -1062,28 +1097,28 @@ Contains all the entitlements associated to the user.
|
|
|
1062
1097
|
|
|
1063
1098
|
The EntitlementInfo object gives you access to all of the information about the status of a user entitlement.
|
|
1064
1099
|
|
|
1065
|
-
| Prop | Type
|
|
1066
|
-
| ---------------------------------- |
|
|
1067
|
-
| **`identifier`** | <code>string</code>
|
|
1068
|
-
| **`isActive`** | <code>boolean</code>
|
|
1069
|
-
| **`willRenew`** | <code>boolean</code>
|
|
1070
|
-
| **`periodType`** | <code>string</code>
|
|
1071
|
-
| **`latestPurchaseDate`** | <code>string</code>
|
|
1072
|
-
| **`latestPurchaseDateMillis`** | <code>number</code>
|
|
1073
|
-
| **`originalPurchaseDate`** | <code>string</code>
|
|
1074
|
-
| **`originalPurchaseDateMillis`** | <code>number</code>
|
|
1075
|
-
| **`expirationDate`** | <code>string \| null</code>
|
|
1076
|
-
| **`expirationDateMillis`** | <code>number \| null</code>
|
|
1077
|
-
| **`store`** | <code>'PLAY_STORE' \| 'APP_STORE' \| 'STRIPE' \| 'MAC_APP_STORE' \| 'PROMOTIONAL' \| 'AMAZON' \| 'UNKNOWN_STORE'</code> | The store where this entitlement was unlocked from. |
|
|
1078
|
-
| **`productIdentifier`** | <code>string</code>
|
|
1079
|
-
| **`productPlanIdentifier`** | <code>string \| null</code>
|
|
1080
|
-
| **`isSandbox`** | <code>boolean</code>
|
|
1081
|
-
| **`unsubscribeDetectedAt`** | <code>string \| null</code>
|
|
1082
|
-
| **`unsubscribeDetectedAtMillis`** | <code>number \| null</code>
|
|
1083
|
-
| **`billingIssueDetectedAt`** | <code>string \| null</code>
|
|
1084
|
-
| **`billingIssueDetectedAtMillis`** | <code>number \| null</code>
|
|
1085
|
-
| **`ownershipType`** | <code>'FAMILY_SHARED' \| 'PURCHASED' \| 'UNKNOWN'</code>
|
|
1086
|
-
| **`verification`** | <code><a href="#verification_result">VERIFICATION_RESULT</a></code>
|
|
1100
|
+
| Prop | Type | Description |
|
|
1101
|
+
| ---------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
1102
|
+
| **`identifier`** | <code>string</code> | The entitlement identifier configured in the RevenueCat dashboard |
|
|
1103
|
+
| **`isActive`** | <code>boolean</code> | True if the user has access to this entitlement |
|
|
1104
|
+
| **`willRenew`** | <code>boolean</code> | True if the underlying subscription is set to renew at the end of the billing period (expirationDate). |
|
|
1105
|
+
| **`periodType`** | <code>string</code> | The last period type this entitlement was in. Either: NORMAL, INTRO, TRIAL. |
|
|
1106
|
+
| **`latestPurchaseDate`** | <code>string</code> | The latest purchase or renewal date for the entitlement in ISO8601 format. |
|
|
1107
|
+
| **`latestPurchaseDateMillis`** | <code>number</code> | The latest purchase or renewal date for the entitlement in milliseconds. |
|
|
1108
|
+
| **`originalPurchaseDate`** | <code>string</code> | The first date this entitlement was purchased in ISO8601 format. |
|
|
1109
|
+
| **`originalPurchaseDateMillis`** | <code>number</code> | The first date this entitlement was purchased in milliseconds. |
|
|
1110
|
+
| **`expirationDate`** | <code>string \| null</code> | The expiration date for the entitlement in ISO8601, can be `null` for lifetime access. If the `periodType` is `trial`, this is the trial expiration date. |
|
|
1111
|
+
| **`expirationDateMillis`** | <code>number \| null</code> | The expiration date for the entitlement in milliseconds, can be `null` for lifetime access. If the `periodType` is `trial`, this is the trial expiration date. |
|
|
1112
|
+
| **`store`** | <code>'PLAY_STORE' \| 'APP_STORE' \| 'STRIPE' \| 'MAC_APP_STORE' \| 'PROMOTIONAL' \| 'AMAZON' \| 'RC_BILLING' \| 'UNKNOWN_STORE'</code> | The store where this entitlement was unlocked from. |
|
|
1113
|
+
| **`productIdentifier`** | <code>string</code> | The product identifier that unlocked this entitlement |
|
|
1114
|
+
| **`productPlanIdentifier`** | <code>string \| null</code> | The product plan identifier that unlocked this entitlement. Android subscriptions only, null on consumables and iOS. |
|
|
1115
|
+
| **`isSandbox`** | <code>boolean</code> | False if this entitlement is unlocked via a production purchase |
|
|
1116
|
+
| **`unsubscribeDetectedAt`** | <code>string \| null</code> | The date an unsubscribe was detected in ISO8601 format. Can be `null`. |
|
|
1117
|
+
| **`unsubscribeDetectedAtMillis`** | <code>number \| null</code> | The date an unsubscribe was detected in milliseconds. Can be `null`. |
|
|
1118
|
+
| **`billingIssueDetectedAt`** | <code>string \| null</code> | The date a billing issue was detected in ISO8601 format. Can be `null` if there is no billing issue or an issue has been resolved |
|
|
1119
|
+
| **`billingIssueDetectedAtMillis`** | <code>number \| null</code> | The date a billing issue was detected in milliseconds. Can be `null` if there is no billing issue or an issue has been resolved |
|
|
1120
|
+
| **`ownershipType`** | <code>'FAMILY_SHARED' \| 'PURCHASED' \| 'UNKNOWN'</code> | Supported ownership types for an entitlement. PURCHASED if the purchase was made directly by this user. FAMILY_SHARED if the purchase has been shared to this user by a family member. UNKNOWN if the purchase has no or an unknown ownership type. |
|
|
1121
|
+
| **`verification`** | <code><a href="#verification_result">VERIFICATION_RESULT</a></code> | If entitlement verification was enabled, the result of that verification. If not, VerificationResult.NOT_REQUESTED |
|
|
1087
1122
|
|
|
1088
1123
|
|
|
1089
1124
|
#### PurchasesStoreTransaction
|
|
@@ -1134,32 +1169,34 @@ For more info see https://docs.revenuecat.com/docs/entitlements
|
|
|
1134
1169
|
Contains information about the product available for the user to purchase.
|
|
1135
1170
|
For more info see https://docs.revenuecat.com/docs/entitlements
|
|
1136
1171
|
|
|
1137
|
-
| Prop
|
|
1138
|
-
|
|
|
1139
|
-
| **`identifier`**
|
|
1140
|
-
| **`packageType`**
|
|
1141
|
-
| **`product`**
|
|
1142
|
-
| **`offeringIdentifier`**
|
|
1172
|
+
| Prop | Type | Description |
|
|
1173
|
+
| ------------------------------ | ----------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------ |
|
|
1174
|
+
| **`identifier`** | <code>string</code> | Unique identifier for this package. Can be one a predefined package type or a custom one. |
|
|
1175
|
+
| **`packageType`** | <code><a href="#package_type">PACKAGE_TYPE</a></code> | Package type for the product. Will be one of [PACKAGE_TYPE]. |
|
|
1176
|
+
| **`product`** | <code><a href="#purchasesstoreproduct">PurchasesStoreProduct</a></code> | Product assigned to this package. |
|
|
1177
|
+
| **`offeringIdentifier`** | <code>string</code> | Offering this package belongs to. |
|
|
1178
|
+
| **`presentedOfferingContext`** | <code><a href="#presentedofferingcontext">PresentedOfferingContext</a></code> | Offering context this package belongs to. Null if not using offerings or if fetched directly from store via getProducts. |
|
|
1143
1179
|
|
|
1144
1180
|
|
|
1145
1181
|
#### PurchasesStoreProduct
|
|
1146
1182
|
|
|
1147
|
-
| Prop | Type
|
|
1148
|
-
| --------------------------------- |
|
|
1149
|
-
| **`identifier`** | <code>string</code>
|
|
1150
|
-
| **`description`** | <code>string</code>
|
|
1151
|
-
| **`title`** | <code>string</code>
|
|
1152
|
-
| **`price`** | <code>number</code>
|
|
1153
|
-
| **`priceString`** | <code>string</code>
|
|
1154
|
-
| **`currencyCode`** | <code>string</code>
|
|
1155
|
-
| **`introPrice`** | <code><a href="#purchasesintroprice">PurchasesIntroPrice</a> \| null</code>
|
|
1156
|
-
| **`discounts`** | <code>PurchasesStoreProductDiscount[] \| null</code>
|
|
1157
|
-
| **`productCategory`** | <code><a href="#product_category">PRODUCT_CATEGORY</a> \| null</code>
|
|
1158
|
-
| **`productType`** | <code><a href="#product_type">PRODUCT_TYPE</a></code>
|
|
1159
|
-
| **`subscriptionPeriod`** | <code>string \| null</code>
|
|
1160
|
-
| **`defaultOption`** | <code><a href="#subscriptionoption">SubscriptionOption</a> \| null</code>
|
|
1161
|
-
| **`subscriptionOptions`** | <code>SubscriptionOption[] \| null</code>
|
|
1162
|
-
| **`presentedOfferingIdentifier`** | <code>string \| null</code>
|
|
1183
|
+
| Prop | Type | Description |
|
|
1184
|
+
| --------------------------------- | ------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
1185
|
+
| **`identifier`** | <code>string</code> | Product Id. |
|
|
1186
|
+
| **`description`** | <code>string</code> | Description of the product. |
|
|
1187
|
+
| **`title`** | <code>string</code> | Title of the product. |
|
|
1188
|
+
| **`price`** | <code>number</code> | <a href="#price">Price</a> of the product in the local currency. Contains the price value of defaultOption for Google Play. |
|
|
1189
|
+
| **`priceString`** | <code>string</code> | Formatted price of the item, including its currency sign. Contains the formatted price value of defaultOption for Google Play. |
|
|
1190
|
+
| **`currencyCode`** | <code>string</code> | Currency code for price and original price. Contains the currency code value of defaultOption for Google Play. |
|
|
1191
|
+
| **`introPrice`** | <code><a href="#purchasesintroprice">PurchasesIntroPrice</a> \| null</code> | Introductory price. |
|
|
1192
|
+
| **`discounts`** | <code>PurchasesStoreProductDiscount[] \| null</code> | Collection of discount offers for a product. Null for Android. |
|
|
1193
|
+
| **`productCategory`** | <code><a href="#product_category">PRODUCT_CATEGORY</a> \| null</code> | Product category. |
|
|
1194
|
+
| **`productType`** | <code><a href="#product_type">PRODUCT_TYPE</a></code> | The specific type of subscription or one time purchase this product represents. Important: In iOS, if using StoreKit 1, we cannot determine the type. |
|
|
1195
|
+
| **`subscriptionPeriod`** | <code>string \| null</code> | Subscription period, specified in ISO 8601 format. For example, P1W equates to one week, P1M equates to one month, P3M equates to three months, P6M equates to six months, and P1Y equates to one year. Note: Not available for Amazon. |
|
|
1196
|
+
| **`defaultOption`** | <code><a href="#subscriptionoption">SubscriptionOption</a> \| null</code> | Default subscription option for a product. Google Play only. |
|
|
1197
|
+
| **`subscriptionOptions`** | <code>SubscriptionOption[] \| null</code> | Collection of subscription options for a product. Google Play only. |
|
|
1198
|
+
| **`presentedOfferingIdentifier`** | <code>string \| null</code> | Offering identifier the store product was presented from. Null if not using offerings or if fetched directly from store via getProducts. |
|
|
1199
|
+
| **`presentedOfferingContext`** | <code><a href="#presentedofferingcontext">PresentedOfferingContext</a> \| null</code> | Offering context this package belongs to. Null if not using offerings or if fetched directly from store via getProducts. |
|
|
1163
1200
|
|
|
1164
1201
|
|
|
1165
1202
|
#### PurchasesIntroPrice
|
|
@@ -1192,20 +1229,21 @@ For more info see https://docs.revenuecat.com/docs/entitlements
|
|
|
1192
1229
|
Contains all details associated with a SubscriptionOption
|
|
1193
1230
|
Used only for Google
|
|
1194
1231
|
|
|
1195
|
-
| Prop | Type
|
|
1196
|
-
| --------------------------------- |
|
|
1197
|
-
| **`id`** | <code>string</code>
|
|
1198
|
-
| **`storeProductId`** | <code>string</code>
|
|
1199
|
-
| **`productId`** | <code>string</code>
|
|
1200
|
-
| **`pricingPhases`** | <code>PricingPhase[]</code>
|
|
1201
|
-
| **`tags`** | <code>string[]</code>
|
|
1202
|
-
| **`isBasePlan`** | <code>boolean</code>
|
|
1203
|
-
| **`billingPeriod`** | <code><a href="#period">Period</a> \| null</code>
|
|
1204
|
-
| **`isPrepaid`** | <code>boolean</code>
|
|
1205
|
-
| **`fullPricePhase`** | <code><a href="#pricingphase">PricingPhase</a> \| null</code>
|
|
1206
|
-
| **`freePhase`** | <code><a href="#pricingphase">PricingPhase</a> \| null</code>
|
|
1207
|
-
| **`introPhase`** | <code><a href="#pricingphase">PricingPhase</a> \| null</code>
|
|
1208
|
-
| **`presentedOfferingIdentifier`** | <code>string \| null</code>
|
|
1232
|
+
| Prop | Type | Description |
|
|
1233
|
+
| --------------------------------- | ------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
|
1234
|
+
| **`id`** | <code>string</code> | Identifier of the subscription option If this <a href="#subscriptionoption">SubscriptionOption</a> represents a base plan, this will be the basePlanId. If it represents an offer, it will be {basePlanId}:{offerId} |
|
|
1235
|
+
| **`storeProductId`** | <code>string</code> | Identifier of the StoreProduct associated with this SubscriptionOption This will be {subId}:{basePlanId} |
|
|
1236
|
+
| **`productId`** | <code>string</code> | Identifer of the subscription associated with this SubscriptionOption This will be {subId} |
|
|
1237
|
+
| **`pricingPhases`** | <code>PricingPhase[]</code> | Pricing phases defining a user's payment plan for the product over time. |
|
|
1238
|
+
| **`tags`** | <code>string[]</code> | Tags defined on the base plan or offer. Empty for Amazon. |
|
|
1239
|
+
| **`isBasePlan`** | <code>boolean</code> | True if this <a href="#subscriptionoption">SubscriptionOption</a> represents a subscription base plan (rather than an offer). |
|
|
1240
|
+
| **`billingPeriod`** | <code><a href="#period">Period</a> \| null</code> | The subscription period of fullPricePhase (after free and intro trials). |
|
|
1241
|
+
| **`isPrepaid`** | <code>boolean</code> | True if the subscription is pre-paid. |
|
|
1242
|
+
| **`fullPricePhase`** | <code><a href="#pricingphase">PricingPhase</a> \| null</code> | The full price <a href="#pricingphase">PricingPhase</a> of the subscription. Looks for the last price phase of the <a href="#subscriptionoption">SubscriptionOption</a>. |
|
|
1243
|
+
| **`freePhase`** | <code><a href="#pricingphase">PricingPhase</a> \| null</code> | The free trial <a href="#pricingphase">PricingPhase</a> of the subscription. Looks for the first pricing phase of the <a href="#subscriptionoption">SubscriptionOption</a> where amountMicros is 0. There can be a freeTrialPhase and an introductoryPhase in the same <a href="#subscriptionoption">SubscriptionOption</a>. |
|
|
1244
|
+
| **`introPhase`** | <code><a href="#pricingphase">PricingPhase</a> \| null</code> | The intro trial <a href="#pricingphase">PricingPhase</a> of the subscription. Looks for the first pricing phase of the <a href="#subscriptionoption">SubscriptionOption</a> where amountMicros is greater than 0. There can be a freeTrialPhase and an introductoryPhase in the same <a href="#subscriptionoption">SubscriptionOption</a>. |
|
|
1245
|
+
| **`presentedOfferingIdentifier`** | <code>string \| null</code> | Offering identifier the subscription option was presented from |
|
|
1246
|
+
| **`presentedOfferingContext`** | <code><a href="#presentedofferingcontext">PresentedOfferingContext</a> \| null</code> | Offering context this package belongs to. Null if not using offerings or if fetched directly from store via getProducts. |
|
|
1209
1247
|
|
|
1210
1248
|
|
|
1211
1249
|
#### PricingPhase
|
|
@@ -1243,6 +1281,27 @@ Contains all the details associated with a <a href="#price">Price</a>
|
|
|
1243
1281
|
| **`currencyCode`** | <code>string</code> | Returns ISO 4217 currency code for price and original price. For example, if price is specified in British pounds sterling, price_currency_code is "GBP". If currency code cannot be determined, currency symbol is returned. |
|
|
1244
1282
|
|
|
1245
1283
|
|
|
1284
|
+
#### PresentedOfferingContext
|
|
1285
|
+
|
|
1286
|
+
Contains data about the context in which an offering was presented.
|
|
1287
|
+
|
|
1288
|
+
| Prop | Type | Description |
|
|
1289
|
+
| ------------------------- | ------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------- |
|
|
1290
|
+
| **`offeringIdentifier`** | <code>string</code> | The identifier of the offering used to obtain this object. |
|
|
1291
|
+
| **`placementIdentifier`** | <code>string \| null</code> | The identifier of the placement used to obtain this object. |
|
|
1292
|
+
| **`targetingContext`** | <code><a href="#presentedofferingtargetingcontext">PresentedOfferingTargetingContext</a> \| null</code> | The revision of the targeting used to obtain this object. |
|
|
1293
|
+
|
|
1294
|
+
|
|
1295
|
+
#### PresentedOfferingTargetingContext
|
|
1296
|
+
|
|
1297
|
+
Contains data about the context in which an offering was presented.
|
|
1298
|
+
|
|
1299
|
+
| Prop | Type | Description |
|
|
1300
|
+
| -------------- | ------------------- | ---------------------------------------------------------- |
|
|
1301
|
+
| **`revision`** | <code>number</code> | The revision of the targeting used to obtain this object. |
|
|
1302
|
+
| **`ruleId`** | <code>string</code> | The rule id from the targeting used to obtain this object. |
|
|
1303
|
+
|
|
1304
|
+
|
|
1246
1305
|
#### GetProductOptions
|
|
1247
1306
|
|
|
1248
1307
|
| Prop | Type | Description |
|
|
@@ -13,6 +13,6 @@ Pod::Spec.new do |s|
|
|
|
13
13
|
s.source_files = 'ios/Plugin/**/*.{swift,h,m,c,cc,mm,cpp}'
|
|
14
14
|
s.ios.deployment_target = '13.0'
|
|
15
15
|
s.dependency 'Capacitor'
|
|
16
|
-
s.dependency 'PurchasesHybridCommon', '
|
|
16
|
+
s.dependency 'PurchasesHybridCommon', '10.3.2'
|
|
17
17
|
s.swift_version = '5.1'
|
|
18
18
|
end
|
package/android/build.gradle
CHANGED
|
@@ -53,7 +53,7 @@ dependencies {
|
|
|
53
53
|
implementation fileTree(dir: 'libs', include: ['*.jar'])
|
|
54
54
|
implementation project(':capacitor-android')
|
|
55
55
|
implementation "androidx.appcompat:appcompat:$androidxAppCompatVersion"
|
|
56
|
-
implementation 'com.revenuecat.purchases:purchases-hybrid-common:
|
|
56
|
+
implementation 'com.revenuecat.purchases:purchases-hybrid-common:10.3.2'
|
|
57
57
|
testImplementation "junit:junit:$junitVersion"
|
|
58
58
|
androidTestImplementation "androidx.test.ext:junit:$androidxJunitVersion"
|
|
59
59
|
androidTestImplementation "androidx.test.espresso:espresso-core:$androidxEspressoCoreVersion"
|
|
@@ -13,6 +13,7 @@ import com.revenuecat.purchases.Purchases
|
|
|
13
13
|
import com.revenuecat.purchases.Store
|
|
14
14
|
import com.revenuecat.purchases.common.PlatformInfo
|
|
15
15
|
import com.revenuecat.purchases.hybridcommon.ErrorContainer
|
|
16
|
+
import com.revenuecat.purchases.hybridcommon.OnNullableResult
|
|
16
17
|
import com.revenuecat.purchases.hybridcommon.OnResult
|
|
17
18
|
import com.revenuecat.purchases.hybridcommon.OnResultAny
|
|
18
19
|
import com.revenuecat.purchases.hybridcommon.OnResultList
|
|
@@ -24,10 +25,12 @@ import com.revenuecat.purchases.hybridcommon.purchaseProduct
|
|
|
24
25
|
import com.revenuecat.purchases.hybridcommon.showInAppMessagesIfNeeded
|
|
25
26
|
import com.revenuecat.purchases.interfaces.UpdatedCustomerInfoListener
|
|
26
27
|
import com.revenuecat.purchases.models.InAppMessageType
|
|
28
|
+
import org.json.JSONObject
|
|
27
29
|
import com.revenuecat.purchases.hybridcommon.canMakePayments as canMakePaymentsCommon
|
|
28
30
|
import com.revenuecat.purchases.hybridcommon.checkTrialOrIntroductoryPriceEligibility as checkTrialOrIntroductoryPriceEligibilityCommon
|
|
29
31
|
import com.revenuecat.purchases.hybridcommon.collectDeviceIdentifiers as collectDeviceIdentifiersCommon
|
|
30
32
|
import com.revenuecat.purchases.hybridcommon.getAppUserID as getAppUserIDCommon
|
|
33
|
+
import com.revenuecat.purchases.hybridcommon.getCurrentOfferingForPlacement as getCurrentOfferingForPlacementCommon
|
|
31
34
|
import com.revenuecat.purchases.hybridcommon.getCustomerInfo as getCustomerInfoCommon
|
|
32
35
|
import com.revenuecat.purchases.hybridcommon.getOfferings as getOfferingsCommon
|
|
33
36
|
import com.revenuecat.purchases.hybridcommon.invalidateCustomerInfoCache as invalidateCustomerInfoCacheCommon
|
|
@@ -61,6 +64,7 @@ import com.revenuecat.purchases.hybridcommon.setOnesignalID as setOnesignalIDCom
|
|
|
61
64
|
import com.revenuecat.purchases.hybridcommon.setPhoneNumber as setPhoneNumberCommon
|
|
62
65
|
import com.revenuecat.purchases.hybridcommon.setProxyURLString as setProxyURLStringCommon
|
|
63
66
|
import com.revenuecat.purchases.hybridcommon.setPushToken as setPushTokenCommon
|
|
67
|
+
import com.revenuecat.purchases.hybridcommon.syncAttributesAndOfferingsIfNeeded as syncAttributesAndOfferingsIfNeededCommon
|
|
64
68
|
import com.revenuecat.purchases.hybridcommon.syncPurchases as syncPurchasesCommon
|
|
65
69
|
|
|
66
70
|
@Suppress("unused")
|
|
@@ -72,7 +76,7 @@ class PurchasesPlugin : Plugin() {
|
|
|
72
76
|
|
|
73
77
|
companion object {
|
|
74
78
|
private const val PLATFORM_NAME = "capacitor"
|
|
75
|
-
private const val PLUGIN_VERSION = "7.5.
|
|
79
|
+
private const val PLUGIN_VERSION = "7.5.6"
|
|
76
80
|
|
|
77
81
|
private const val CUSTOMER_INFO_KEY = "customerInfo"
|
|
78
82
|
}
|
|
@@ -151,6 +155,19 @@ class PurchasesPlugin : Plugin() {
|
|
|
151
155
|
getOfferingsCommon(getOnResult(call))
|
|
152
156
|
}
|
|
153
157
|
|
|
158
|
+
@PluginMethod(returnType = PluginMethod.RETURN_PROMISE)
|
|
159
|
+
fun getCurrentOfferingForPlacement(call: PluginCall) {
|
|
160
|
+
if (rejectIfNotConfigured(call)) return
|
|
161
|
+
val placementIdentifier = call.getStringOrReject("placementIdentifier") ?: return
|
|
162
|
+
getCurrentOfferingForPlacementCommon(placementIdentifier, getOnNullableResult(call))
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
@PluginMethod(returnType = PluginMethod.RETURN_PROMISE)
|
|
166
|
+
fun syncAttributesAndOfferingsIfNeeded(call: PluginCall) {
|
|
167
|
+
if (rejectIfNotConfigured(call)) return
|
|
168
|
+
syncAttributesAndOfferingsIfNeededCommon(getOnResult(call))
|
|
169
|
+
}
|
|
170
|
+
|
|
154
171
|
@PluginMethod(returnType = PluginMethod.RETURN_PROMISE)
|
|
155
172
|
fun getProducts(call: PluginCall) {
|
|
156
173
|
if (rejectIfNotConfigured(call)) return
|
|
@@ -175,7 +192,7 @@ class PurchasesPlugin : Plugin() {
|
|
|
175
192
|
val storeProduct = call.getObjectOrReject("product") ?: return
|
|
176
193
|
val productIdentifier = storeProduct.getStringOrReject(call, "identifier") ?: return
|
|
177
194
|
val type = storeProduct.getStringOrReject(call, "productCategory") ?: return
|
|
178
|
-
val
|
|
195
|
+
val presentedOfferingContext = storeProduct.optJSONObject("presentedOfferingContext")
|
|
179
196
|
val optionalPurchaseParams = PurchaseOptionalInfoParams.fromCall(call)
|
|
180
197
|
purchaseProduct(
|
|
181
198
|
activity,
|
|
@@ -185,7 +202,7 @@ class PurchasesPlugin : Plugin() {
|
|
|
185
202
|
optionalPurchaseParams.oldProductIdentifier,
|
|
186
203
|
optionalPurchaseParams.prorationMode,
|
|
187
204
|
optionalPurchaseParams.isPersonalizedPrice,
|
|
188
|
-
|
|
205
|
+
presentedOfferingContext?.convertToAnyMap(),
|
|
189
206
|
getOnResult(call),
|
|
190
207
|
)
|
|
191
208
|
}
|
|
@@ -205,13 +222,13 @@ class PurchasesPlugin : Plugin() {
|
|
|
205
222
|
if (rejectIfNotConfigured(call)) return
|
|
206
223
|
val packageToPurchase = call.getObjectOrReject("aPackage") ?: return
|
|
207
224
|
val packageIdentifier = packageToPurchase.getStringOrReject(call, "identifier") ?: return
|
|
208
|
-
val
|
|
225
|
+
val presentedOfferingContext = packageToPurchase.getObjectOrReject(call, "presentedOfferingContext") ?: return
|
|
209
226
|
val optionalPurchaseParams = PurchaseOptionalInfoParams.fromCall(call)
|
|
210
227
|
|
|
211
228
|
purchasePackageCommon(
|
|
212
229
|
activity,
|
|
213
230
|
packageIdentifier,
|
|
214
|
-
|
|
231
|
+
presentedOfferingContext.convertToAnyMap(),
|
|
215
232
|
optionalPurchaseParams.oldProductIdentifier,
|
|
216
233
|
optionalPurchaseParams.prorationMode,
|
|
217
234
|
optionalPurchaseParams.isPersonalizedPrice,
|
|
@@ -225,7 +242,7 @@ class PurchasesPlugin : Plugin() {
|
|
|
225
242
|
val subscriptionOption = call.getObjectOrReject("subscriptionOption") ?: return
|
|
226
243
|
val productId = subscriptionOption.getStringOrReject(call, "productId") ?: return
|
|
227
244
|
val subscriptionOptionId = subscriptionOption.getStringOrReject(call, "id") ?: return
|
|
228
|
-
val
|
|
245
|
+
val presentedOfferingContext = subscriptionOption.optJSONObject("presentedOfferingContext")
|
|
229
246
|
val optionalPurchaseParams = PurchaseOptionalInfoParams.fromCall(call)
|
|
230
247
|
|
|
231
248
|
purchaseSubscriptionOptionCommon(
|
|
@@ -235,7 +252,7 @@ class PurchasesPlugin : Plugin() {
|
|
|
235
252
|
optionalPurchaseParams.oldProductIdentifier,
|
|
236
253
|
optionalPurchaseParams.prorationMode,
|
|
237
254
|
optionalPurchaseParams.isPersonalizedPrice,
|
|
238
|
-
|
|
255
|
+
presentedOfferingContext?.convertToAnyMap(),
|
|
239
256
|
getOnResult(call),
|
|
240
257
|
)
|
|
241
258
|
}
|
|
@@ -596,6 +613,23 @@ class PurchasesPlugin : Plugin() {
|
|
|
596
613
|
}
|
|
597
614
|
}
|
|
598
615
|
|
|
616
|
+
private fun getOnNullableResult(call: PluginCall, wrapperKey: String? = null): OnNullableResult {
|
|
617
|
+
return object : OnNullableResult {
|
|
618
|
+
override fun onReceived(map: Map<String, *>?) {
|
|
619
|
+
val mapToConvert = wrapperKey?.let { mapOf(wrapperKey to map) } ?: map
|
|
620
|
+
if (mapToConvert != null) {
|
|
621
|
+
call.resolve(convertMapToJSObject(mapToConvert))
|
|
622
|
+
} else {
|
|
623
|
+
call.resolve(null)
|
|
624
|
+
}
|
|
625
|
+
}
|
|
626
|
+
|
|
627
|
+
override fun onError(errorContainer: ErrorContainer) {
|
|
628
|
+
rejectWithErrorContainer(call, errorContainer)
|
|
629
|
+
}
|
|
630
|
+
}
|
|
631
|
+
}
|
|
632
|
+
|
|
599
633
|
@Suppress("UNCHECKED_CAST")
|
|
600
634
|
private fun convertMapToJSObject(readableMap: Map<String, Any?>): JSObject {
|
|
601
635
|
val jsObject = JSObject()
|
|
@@ -677,6 +711,15 @@ class PurchasesPlugin : Plugin() {
|
|
|
677
711
|
return value
|
|
678
712
|
}
|
|
679
713
|
|
|
714
|
+
private fun JSObject.getObjectOrReject(call: PluginCall, key: String): JSONObject? {
|
|
715
|
+
val value = optJSONObject(key)
|
|
716
|
+
if (value == null) {
|
|
717
|
+
call.reject("Missing $key parameter in $this")
|
|
718
|
+
return null
|
|
719
|
+
}
|
|
720
|
+
return value
|
|
721
|
+
}
|
|
722
|
+
|
|
680
723
|
private fun PluginCall.getArrayOrReject(key: String): JSArray? {
|
|
681
724
|
val value = getArray(key)
|
|
682
725
|
if (value == null) {
|
|
@@ -722,3 +765,19 @@ class PurchasesPlugin : Plugin() {
|
|
|
722
765
|
}
|
|
723
766
|
}
|
|
724
767
|
}
|
|
768
|
+
|
|
769
|
+
private fun JSONObject.convertToAnyMap(): Map<String, Any?> =
|
|
770
|
+
this.keys().asSequence<String>().associate { key ->
|
|
771
|
+
when (val value = this[key]) {
|
|
772
|
+
is JSONObject -> {
|
|
773
|
+
key to value.convertToAnyMap()
|
|
774
|
+
}
|
|
775
|
+
else -> {
|
|
776
|
+
if (this.isNull(key)) {
|
|
777
|
+
key to null
|
|
778
|
+
} else {
|
|
779
|
+
key to value
|
|
780
|
+
}
|
|
781
|
+
}
|
|
782
|
+
}
|
|
783
|
+
}
|