-
Notifications
You must be signed in to change notification settings - Fork 50
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
Conversation
@@ -3,7 +3,7 @@ package com.revenuecat.purchases.common | |||
import com.revenuecat.purchases.models.ProductDetails | |||
|
|||
class ReceiptInfo( | |||
val productID: String, | |||
val productIDs: List<String>, |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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] } |
There was a problem hiding this comment.
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)
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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), |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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', " + |
There was a problem hiding this comment.
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?
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.