Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for product_plan_identifier for offline customer info #959

Merged
merged 18 commits into from
May 4, 2023

Conversation

vegaro
Copy link
Contributor

@vegaro vegaro commented Apr 10, 2023

The response for the offline entitlement->product mapping has changed to add support for product_plan_identifier.

This PR modifies the response and add the product_plan_identifier to the CustomerInfo entitlements

@vegaro vegaro added the fix A bug fix label Apr 10, 2023
@vegaro vegaro force-pushed the cesar/sdk-3055-android-add-support-for branch from 5e3670c to a85488f Compare April 12, 2023 13:17
@vegaro vegaro marked this pull request as ready for review April 12, 2023 15:05
@vegaro vegaro changed the title [WIP] Add support for product_plan_identifier for offline customer info Add support for product_plan_identifier for offline customer info Apr 12, 2023
@vegaro vegaro force-pushed the cesar/sdk-3055-android-add-support-for branch 2 times, most recently from bfc3880 to b9abdde Compare April 18, 2023 14:09
@vegaro vegaro requested a review from tonidero April 18, 2023 14:46
@@ -92,6 +93,8 @@ class OfflineCustomerInfoCalculator(
put(ProductResponseJsonKeys.PURCHASE_DATE, Iso8601Utils.format(purchaseDate))
put(ProductResponseJsonKeys.STORE, appConfig.store.name.lowercase())
put(ProductResponseJsonKeys.UNSUBSCRIBE_DETECTED_AT, JSONObject.NULL)
// TODO: in post receipt we might be able to have the subscription option id
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It will be tricky to have this, since currently we are getting the products from Google directly... But yeah, it might be possible.

@@ -62,7 +62,9 @@ class PurchasedProductsFetcher(
purchaseAssociatedToProduct,
isActive,
productEntitlementMapping?.toMap()?.get(productIdentifier) ?: emptyList(),
expirationDate
expirationDate,
productEntitlementMapping?.mappings?.firstOrNull { it.identifier == productIdentifier }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm guessing you wanted to use getMappings here?

"com.revenuecat.foo_1:not_bw" to "not_bw",
"com.revenuecat.foo_1" to "p1m",
"com.revenuecat.foo_2" to "p1m",
"com.revenuecat.foo_3" to "p1m"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should add tests for some without a base plan, since we will have some like consumables + fallback options.

@vegaro vegaro force-pushed the cesar/sdk-3055-android-add-support-for branch from b9abdde to bfc3880 Compare April 18, 2023 16:50
@vegaro vegaro changed the base branch from main to original-purchase-date-issue April 18, 2023 16:50
@vegaro vegaro force-pushed the cesar/sdk-3055-android-add-support-for branch from bfc3880 to 83193f1 Compare April 18, 2023 16:53
@vegaro vegaro mentioned this pull request Apr 28, 2023
5 tasks
@vegaro vegaro changed the base branch from original-purchase-date-issue to main April 28, 2023 21:17
# Conflicts:
#	common/src/main/java/com/revenuecat/purchases/common/offlineentitlements/ProductEntitlementMapping.kt
#	common/src/main/java/com/revenuecat/purchases/common/offlineentitlements/PurchasedProductsFetcher.kt
#	common/src/test/java/com/revenuecat/purchases/common/BackendTest.kt
#	common/src/test/java/com/revenuecat/purchases/common/DeviceCacheTest.kt
#	common/src/test/java/com/revenuecat/purchases/common/offlineentitlements/ProductEntitlementMappingTest.kt
#	common/src/test/java/com/revenuecat/purchases/common/offlineentitlements/PurchasedProductsFetcherTest.kt
#	common/src/test/java/com/revenuecat/purchases/common/offlineentitlements/productEntitlementMappingFactory.kt
@vegaro vegaro requested a review from tonidero May 1, 2023 23:12
@Test
fun `product with different entitlement per base plan`() {
// Due to an issue with the way the backend returns the data, we are going to be using the wrong
// the wrong original_purchase_date for the first entitlement
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the wrong is duplicated in the previous line.

@vegaro vegaro enabled auto-merge (squash) May 4, 2023 02:43
@vegaro vegaro merged commit 34f043d into main May 4, 2023
4 checks passed
@vegaro vegaro deleted the cesar/sdk-3055-android-add-support-for branch May 4, 2023 02:58
pablo-guardiola added a commit to pablo-guardiola/purchases-android that referenced this pull request May 4, 2023
pablo-guardiola added a commit to pablo-guardiola/purchases-android that referenced this pull request May 4, 2023
tonidero added a commit that referenced this pull request May 18, 2023
**This is an automatic release.**

### New Features
* CAT-859 Expose whether or not a SubscriptionOption is Prepaid in the
SDK (#1005) via Deema AlShamaa (@dalshamaa)
### Bugfixes
* [CF-1324] Fix personalizedPrice defaulting to false (#952) via beylmk
(@beylmk)
### Performance Improvements
* Store and return ETag last refresh time header (#978) via Toni Rico
(@tonidero)
### Dependency Updates
* Bump fastlane-plugin-revenuecat_internal from `3b03efa` to `fe45299`
(#991) via dependabot[bot] (@dependabot[bot])
* Bump danger from 9.2.0 to 9.3.0 (#981) via dependabot[bot]
(@dependabot[bot])
* Bump fastlane-plugin-revenuecat_internal from `8482a43` to `3b03efa`
(#974) via dependabot[bot] (@dependabot[bot])
* Bump fastlane from 2.212.1 to 2.212.2 (#973) via dependabot[bot]
(@dependabot[bot])
* Bump fastlane-plugin-revenuecat_internal from `9255366` to `8482a43`
(#961) via dependabot[bot] (@dependabot[bot])
### Other Changes
* Add proration modes to post to backend (#977) via swehner (@swehner)
* Added ENTITLEMENTS_COMPUTED_ON_DEVICE (#939) via Cesar de la Vega
(@vegaro)
* Fix flaky test in OfflineCustomerInfoCalculatorTest (#997) via Cesar
de la Vega (@vegaro)
* Fix `OfflineCustomerInfoCalculatorTest` `Unresolved reference:
ProducType` (#995) via Cesar de la Vega (@vegaro)
* Add support for product_plan_identifier for offline customer info
(#959) via Cesar de la Vega (@vegaro)
* Add non-subscriptions support to offline customer info (#958) via
Cesar de la Vega (@vegaro)
* Query only active purchases when generating offline entitlements
customer info (#1003) via Toni Rico (@tonidero)
* Fix `PurchasesIntegrationTest` building issue (#996 into main) (#998)
via Cesar de la Vega (@vegaro)
* Fail offline entitlements computation if product entitlement mapping
not available (#999) via Toni Rico (@tonidero)
* Fix  build_magic_weather lane (#993) via Cesar de la Vega (@vegaro)
* Add backend integration tests and test product entitlement mapping
endpoint (#988) via Toni Rico (@tonidero)
* Fix purchases integration tests (#980) via Toni Rico (@tonidero)
* Disable offline entitlements if active inapp purchases exist (#983)
via Toni Rico (@tonidero)
* Clear cached customer info upon entering offline entitlements mode
(#989) via Toni Rico (@tonidero)
* Update product entitlement mapping request to new format (#976) via
Toni Rico (@tonidero)
* Support enabling/disabling offline entitlements (#964) via Toni Rico
(@tonidero)
* Add back integration tests automation (#972) via Toni Rico (@tonidero)
* Upgrade to AGP 8.0 (#975) via Toni Rico (@tonidero)
* Extract post receipt logic to PostReceiptHelper (#967) via Toni Rico
(@tonidero)
* Add isServerDown to error callback for postReceipt and getCustomerInfo
requests (#963) via Toni Rico (@tonidero)
* Add back integration test flavors (#962) via Toni Rico (@tonidero)
* Fix storing test results (#966) via Cesar de la Vega (@vegaro)
* Extract detekt job from test job (#965) via Cesar de la Vega (@vegaro)


[CF-1324]:
https://revenuecats.atlassian.net/browse/CF-1324?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ

---------

Co-authored-by: revenuecat-ops <ops@revenuecat.com>
Co-authored-by: Toni Rico <antonio.rico.diez@revenuecat.com>
tonidero added a commit that referenced this pull request May 23, 2023
### Description
This removes the flag that was disabling offline entitlements, so we
actually start using offline entitlements

#### TODO
- [x] Hold until making sure it all works correctly
- [x] Hold until #983 is merged
- [x] Hold until #959 is merged
- [x] Hold until
#999 is merged
- [x] Hold until #1003 is merged
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
fix A bug fix
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants