Galaxy Store Purchasing Happy Path#2922
Conversation
| val iapHelper: IapHelper, | ||
| ) : IAPHelperProvider { | ||
|
|
||
| override fun setOperationMode( |
There was a problem hiding this comment.
This function doesn't need to be @GalaxySerialOperation. Since the operation doesn't make a network request, Samsung doesn't take this function into account when restricting which operations can be performed in parallel.
| ), | ||
| ) | ||
| clearInFlightRequest() | ||
| return |
There was a problem hiding this comment.
This return isn't really necessary, but I included it in case we ever add anything beneath this block in the future :)
| } | ||
|
|
||
| // TO DO: Map galaxy errors to PurchaseErrors so we can give better errors | ||
| val purchasesError = PurchasesError(PurchasesErrorCode.StoreProblemError, underlyingErrorMessage) |
There was a problem hiding this comment.
We'll flesh this out and parse specific error codes in a future PR
tonidero
left a comment
There was a problem hiding this comment.
Looking great! Amazing we're already doing purchases 🙌 . Just left some comments
| productIds = listOf(productId), | ||
| type = type, | ||
| purchaseTime = purchaseDate.time, | ||
| purchaseToken = this.orderId, |
There was a problem hiding this comment.
So the orderId is what we need in the backend to validate the purchase, correct?
There was a problem hiding this comment.
I believe so, but will confirm with the backend engineers!
There was a problem hiding this comment.
Checked with the backend engineers, and this value should be the PurchaseVo's purchaseId. Updated this to use purchaseId in b978aa3 👍
|
|
||
| internal fun String.parseDateFromGalaxyDateString(): Date { | ||
| val formatter = SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.ROOT).apply { | ||
| timeZone = TimeZone.getDefault() |
There was a problem hiding this comment.
Hmm is the date sent from the galaxy library timezone aware? Not sure if maybe matching the Samsung account timezone? We should make sure it's correct on different device timezones and with different Samsung account timezones
There was a problem hiding this comment.
Yeah, we should probably get confirmation from Samsung on this. I'll see if I can find it in the SDK's decompiled code, and if not, we can see if we can ask Samsung. In my testing, it came back in my device's timezone (which for some reason is 1 hour ahead of my own timezone 😅)
There was a problem hiding this comment.
@tonidero I think we're good here now.
For future reference in case anyone sees this, it looks like this is how the date string is created:
- Samsung Store server sends down a timestamp in a JSON object
- PurchaseVo gets created from that JSON
- When PurchaseVo is created, it’s using simple DateFormat.format parsing:
String result = "";
String dateFormat = "yyyy-MM-dd HH:mm:ss";
result = DateFormat.format(dateFormat, _timeMills).toString();| } | ||
| val storeProduct = galaxyPurchaseInfo.storeProduct | ||
|
|
||
| if (!shouldFinishTransactions()) { return } |
There was a problem hiding this comment.
Hmm I think the meaning of finishing a transaction is wrong here... In this case, seems we wouldn't be finishing the transaction at all. Whereas it should mean we won't actually "acknowledge" and/or "consume" the purchase. But we would still allow purchasing with our SDK even with finishTransactions set to false.
However, I'm not sure if Galaxy store has a similar "acknowledge" and/or "consume" step to consider this 🤔
There was a problem hiding this comment.
Yeah, the Galaxy Store has a concept of acknowledging purchases, and it's something we'll need to implement in a follow up PR. Here are their docs on it: https://developer.samsung.com/iap/programming-guide/iap-helper-programming.html#Notify-Samsung-IAP-that-the-purchase-was-processed
I think you're right, maybe we shouldn't do this here. I included this because this is what we're doing today on Amazon, not sure if that's a bug or not:
I'll go ahead and remove this check here for now, and then when we implement the logic to acknowledge Galaxy purchases, we can surround that with an if(shouldFinishTransactions()) check
There was a problem hiding this comment.
Hmm that's indeed a good point... we do allow purchasing in Google when not finishing transactions, but seems we don't for Amazon... From a conceptual POV, I think not allowing to purchase when we're not going to finish transactions might make sense (we can discuss it with the team), but in that case, we should return an error, unlike what we have currently in Amazon, where it seems it would be left hanging 😬
There was a problem hiding this comment.
But yeah, allowing to purchase, and just not handle the acknowledge makes sense, since it's what we do for Google
| return if (finishTransactions) { | ||
| true | ||
| } else { | ||
| log(LogIntent.AMAZON_WARNING) { AmazonStrings.WARNING_AMAZON_NOT_FINISHING_TRANSACTIONS } |
There was a problem hiding this comment.
This shouldn't be Amazon :)
There was a problem hiding this comment.
Removed this helper for now since we don't need finishTransactions at the moment 👍
Description
This PR enables support for making purchases through the Galaxy Store. To keep the PR size down, it primarily considers the happy path where the purchase succeeds with no issues.
It:
IapHelper's operation mode when theGalaxyBillingWrapperis initialized.IapHelperthrough thePurchaseHandlerclassPurchaseVoresponses toStoreTransactionsfor successful purchasesTo keep the PR size down, the PR does not:
PurchaseVoobject.We'll tackle these features in future PRs.