Home » Php » php – How to verify android in-app purchase in laravel

php – How to verify android in-app purchase in laravel

Posted by: admin February 25, 2020 Leave a comment

Questions:

How to get android in-app purchase details from backend if I have orderId, productId, purchaseToken and other details.

I think Google Purchases.subscriptions: get API is the way. google doc for that API.

I tried following,

 use Google_Client;

 putenv('GOOGLE_APPLICATION_CREDENTIALS=../public_html/assets/serv-i-6d295-94a5f25150d4.p12');

    $client = new Google_Client();
    $client->useApplicationDefaultCredentials();
    $client->addScope('https://www.googleapis.com/auth/androidpublisher');
    $service = new Google_Service_AndroidPublisher($client);
    $purchase = $service->purchases_products->get($packageName, $skuID, $purchaseToken);
    return $purchase['orderId'];

I’m getting The project id used to call the Google Play Developer API has not been linked in the Google Play Developer Console. issue

Please guide me. Thank you.

How to&Answers: