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

Auto renew issue #130

Closed parthk-hkis closed 4 years ago

parthk-hkis commented 4 years ago

In case auto renew subscription in android, when we validate receipt it always fails. I tried using below code

$response = $validator->setPackageName($packageName)
                    ->setProductId($productId)
                    ->setPurchaseToken($purchaseToken)
                    ->validateSubscription();
Stafox commented 4 years ago

Nice issue.

Could you add any details?

Make sure service account was properly configured. Make sure you validate subscription purchase using validateSubscription, and not a one-time purchase.

parthk-hkis commented 4 years ago

As displayed in the above code, I'm validating subscription only, it works the first time but when it auto-renews, it is not validating the same purchase token which we've stored on our database. Not sure what I'm missing? I'm pretty sure that the service account is properly configured.

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

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

                $response = $validator->setPackageName($packageName)
                    ->setProductId($productId)
                    ->setPurchaseToken($purchaseToken)
                    ->validateSubscription();
Stafox commented 4 years ago

What kind of error you see? Production/Sandbox? Could you share successful validation response before it starts to fail?

Stafox commented 4 years ago

Close because of no details were provided.