Friday 13 November 2020

Implementing receipt validations on playstore in-app purchase using purchase token

I have added store receipt validator library to implement validation, but I am not receiving any specific parameter that can denotes that it is valid or not.

Here is my code snippet:

       $googleClient = new \Google_Client();
        $scope = ['https://www.googleapis.com/auth/androidpublisher'];
        $googleClient->setApplicationName('Bullet Force');
        $googleClient->setScopes([\Google_Service_AndroidPublisher::ANDROIDPUBLISHER]);
        $pathToServiceAccountJsonFile = json_decode(Storage::disk('local')->get('keys/privateKey.json'), true);
        $googleClient->setAuthConfig($pathToServiceAccountJsonFile);
        $validator = new PlayValidator(new \Google_Service_AndroidPublisher($googleClient));

        // receipt data
        $packageName = 'xxx.xxxxxxxxxx.xxx';
        $productId = 'xxxx';
        $purchaseToken = 'PURCHASE_TOKEN';

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

Response: response-validator-script

So as we see in the above response, there is no parameter based on which we can decide whether it is a valid transaction or not.

Please help me fixing this issue.

Thanks!!



from Implementing receipt validations on playstore in-app purchase using purchase token

No comments:

Post a Comment