Closed Orkin closed 4 years ago
@Orkin thanks for PR. It would be nice to have strategy for this behavior. At first someone already store the acknowledgement value. At second, get-request took time and do additional request to Google API, which has limits.
Who knows what kind of error Google will return in the future, right? So it might be useful to be able handle such error by youself. So, better to add two strategies:
// Do acknowledge only in case if it have not done
const ACKNOWLEDGE_STRATEGY_IMPLICIT ='strategy_implicit';
// Try to do acknowledge directly (exception will be returned in case when acknowledge already was done)
const ACKNOWLEDGE_STRATEGY_EXPLICIT ='strategy_explicit';
And public method to setStrategy(string $strategy);
ACKNOWLEDGE_STRATEGY_EXPLICIT
should be default.
Hello, yes of course it's a good idea. I'll try to find some time to do this. I'd just need a quick fix due to production error and share my solution 😉
There is a BC break because without this it was not possible to catch AlreadyAcknowledgeException
Hello @Stafox any new on validating this PR ?
Hello @Stafox any new on validating this PR ?
Hi. Could you make the fixes from our latest discussion? After that it can be merged. Thanks.
@Stafox I have resolved conflict. I can do modification but it's become impossible to test the case when acknowledge failed because we don't know which exception is thrown. It's ok for you ?
IE => I have to remove some tests
And of course it's become impossible to catch on our code if it's a generic error on payment or just an acknowledge error 😢
but it's become impossible to test the case when acknowledge failed because we don't know which exception is thrown. It's ok for you ?
Yes, it will work like it worked before. The main thing that it become possible to catch Exception to handle that (it provides transparency).
@Stafox done ;)
Reviewed. Looks fine.
Thanks
How to acknowledge for google play? any example?
Thanks
How to acknowledge for google play? any example?
Thanks
$strategy = Acknowledger::ACKNOWLEDGE_STRATEGY_EXPLICIT;
$acknowledger = new Acknowledger(
$googleServiceAndroidPublisher,
$packageName,
$productId,
$purchaseToken,
$strategy
);
$purchaseType = Acknowledger::SUBSCRIPTION; // or Acknowledger::PRODUCT
$developerPayload = 'dev_payload_here';
$acknowledger->acknowledge($purchaseType, $developerPayload);
Also purchase can be acknowledged on client in that case no needs to do that on backend.
On acknowledgement of purchase already acknowledge the google play api send message not really explicit :
The product purchase not is owned by the user.
After many researches I found this and try and it fix the issue for me and it's a small optimisation because we don't have to acknowledge a purchase when it's already done
https://stackoverflow.com/questions/57971231/unable-to-use-purchase-subscriptionacknowledge-to-acknowledge-a-subscription