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

Adds product_ids to post receipt #335

Merged
merged 4 commits into from
Jul 9, 2021
Merged

Adds product_ids to post receipt #335

merged 4 commits into from
Jul 9, 2021

Conversation

vegaro
Copy link
Contributor

@vegaro vegaro commented Jul 7, 2021

With Google's new changes (not live yet) a single Android token can have multiple SKUS. There are still a lot of unknowns. However, we need to adapt the endpoints to make it compatible with the new billing.

The backend starts accepting a new parameter for post receipt product_ids. The way the backend works is: if product_ids is present, use it. If length is > 1, return an error and log it in Sentry. Otherwise, use its only element. It fallbacks to product_id if product_ids not present.

@vegaro vegaro marked this pull request as ready for review July 7, 2021 23:04
@vegaro vegaro requested a review from a team July 7, 2021 23:04
@vegaro vegaro added this to the 4.3.0 milestone Jul 7, 2021
@@ -3,7 +3,7 @@ package com.revenuecat.purchases.common
import com.revenuecat.purchases.models.ProductDetails

class ReceiptInfo(
val productID: String,
val productIDs: List<String>,
Copy link
Contributor

Choose a reason for hiding this comment

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

i might just not be remembering correctly, but how can we have multiple product IDs but only one product details object?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The main reason why we are adding this new parameter to the call is so we can know when this goes live. There are still some questions regarding how this is going to work on the Google side, some of them change our data model in the backend. For now we just want to know if there ever is a transaction with more than one product ID to know when this is live.

There is going to be more future work around this, like adding the price, currency or durations of all products.

Copy link
Contributor

Choose a reason for hiding this comment

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

got it. perhaps we should outline that in the release notes, so people don't expect full functionality right away

@@ -131,7 +131,7 @@ internal class AmazonBilling constructor(
queryAllPurchases(
appUserID,
onReceivePurchaseHistory = {
val record: PurchaseDetails? = it.firstOrNull { record -> sku == record.sku }
val record: PurchaseDetails? = it.firstOrNull { record -> sku == record.skus[0] }
Copy link
Contributor

Choose a reason for hiding this comment

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

would we ever get an empty list? if so, we should use skus.getOrNull(0)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The list will never be empty, it always has one product ID. It will be at least one product ID when multi line subscriptions are available.

Copy link
Member

Choose a reason for hiding this comment

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

perhaps we can add a comment so future devs know about this particular detail.
I mean, hopefully we'll have real multi-line subscription support soon, but in the meantime, folks reading through the code might be left wondering

postToBackend(
purchase = purchase,
productDetails = skuDetailsList.firstOrNull { it.sku == purchase.sku },
productDetails = productDetailsList.takeUnless { it.isEmpty() }?.get(0),
Copy link
Contributor

@beylmk beylmk Jul 8, 2021

Choose a reason for hiding this comment

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

another place where i'm kinda confused on the behavior here... is this defined somewhere by google? that we care about all the skus but only the first productdetails?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is just a patch to mimic the current behavior where there is always just one product ID. This makes sure it works, although incorrectly because we would only post the details of one of the products being purchased if someone purchases more than one at the same time.

"productID='$productID', " +
"productIDs='$productIDs', " +
Copy link
Member

Choose a reason for hiding this comment

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

will this get nicely translated from list to string?

@vegaro vegaro merged commit afa4870 into develop Jul 9, 2021
@vegaro vegaro deleted the multiline-subs branch July 9, 2021 21:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants