aporat / store-receipt-validator

PHP receipt validator for Apple iTunes, Google Play and Amazon App Store
Apache License 2.0
633 stars 153 forks source link

Getting information about the order #152

Closed Mongoj closed 2 years ago

Mongoj commented 3 years ago

Hello, When I query about a valid order, I can't see any information for Google Play orders. How can I get order information? I need information such as purchase date, renewal date, renewal status, expiry date. I am using test_play_receipt.php file. I would be glad if you give an example on this. Regards.

use ReceiptValidator\GooglePlay\Validator as PlayValidator;

// google authentication $applicationName = 'xxxxxx'; $scope = ['https://www.googleapis.com/auth/androidpublisher']; $configLocation = 'googleapi.json';

// receipt data $packageName = 'xxxxx'; $productId = 'xxxxx'; $purchaseToken = 'xxxxx';

$client = new \Google_Client(); $client->setApplicationName($applicationName); $client->setAuthConfig($configLocation); $client->setScopes($scope);

$validator = new PlayValidator(new \Google_Service_AndroidPublisher($client));

try { $response = $validator->setPackageName($packageName)->setProductId($productId)->setPurchaseToken($purchaseToken)->validatePurchase(); } catch (Exception $e) { echo 'got error = '.$e->getMessage().PHP_EOL;

Stafox commented 3 years ago

Are you sure that you do not set subscription (not purchase) token? The code provide is used for onetime purchase, not subscription. use validateSubscription() instead.

Mongoj commented 3 years ago

Are you sure that you do not set subscription (not purchase) token? The code provide is used for onetime purchase, not subscription. use validateSubscription() instead.

Hello, Yes thank you. I managed to get some information with the codes below. But how can I tell if a subscription is renewed or pending payment? Is it possible to do this with this library? Thanks.

echo 'getAutoRenewing = '.$response->getAutoRenewing().PHP_EOL; echo 'getCancelReason = '.$response->getCancelReason().PHP_EOL; echo 'getPriceAmountMicros = '.$response->getPriceAmountMicros().PHP_EOL; echo 'getPriceCurrencyCode = '.$response->getPriceCurrencyCode().PHP_EOL; echo 'getStartTimeMillis = '.$response->getStartTimeMillis().PHP_EOL; echo 'getExpiryTimeMillis = '.$response->getExpiryTimeMillis().PHP_EOL; echo 'getUserCancellationTimeMillis = '.$response->getUserCancellationTimeMillis().PHP_EOL; echo 'getPaymentState = '.$response->getPaymentState().PHP_EOL; echo 'getAcknowledgementState = '.$response->getAcknowledgementState().PHP_EOL; echo 'isAcknowledged = '.$response->isAcknowledged().PHP_EOL; echo 'getKind = '.$response->getKind().PHP_EOL; echo 'introductoryPriceInfo = '.$response->priceAmountMicros().PHP_EOL;

Stafox commented 3 years ago

Yes, it is possible.

All needed information you can find here: https://developers.google.com/android-publisher/api-ref/rest/v3/purchases.subscriptions

On Fri, Jul 23, 2021 at 8:20 PM Mongoj @.***> wrote:

Are you sure that you do not set subscription (not purchase) token? The code provide is used for onetime purchase, not subscription. use validateSubscription() instead.

Hello, Yes thank you. I managed to get some information with the codes below. But how can I tell if a subscription is renewed or pending payment? Is it possible to do this with this library? Thanks.

echo 'getAutoRenewing = '.$response->getAutoRenewing().PHP_EOL; echo 'getCancelReason = '.$response->getCancelReason().PHP_EOL; echo 'getPriceAmountMicros = '.$response->getPriceAmountMicros().PHP_EOL; echo 'getPriceCurrencyCode = '.$response->getPriceCurrencyCode().PHP_EOL; echo 'getStartTimeMillis = '.$response->getStartTimeMillis().PHP_EOL; echo 'getExpiryTimeMillis = '.$response->getExpiryTimeMillis().PHP_EOL; echo 'getUserCancellationTimeMillis = '.$response->getUserCancellationTimeMillis().PHP_EOL; echo 'getPaymentState = '.$response->getPaymentState().PHP_EOL; echo 'getAcknowledgementState = '.$response->getAcknowledgementState().PHP_EOL; echo 'isAcknowledged = '.$response->isAcknowledged().PHP_EOL; echo 'getKind = '.$response->getKind().PHP_EOL; echo 'introductoryPriceInfo = '.$response->priceAmountMicros().PHP_EOL;

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/aporat/store-receipt-validator/issues/152#issuecomment-885785288, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAIM6TWN4L6RC5OC3ZGMMS3TZGQF3ANCNFSM5A2MADIQ .