<?php

date_default_timezone_set('Asia/Ho_Chi_Minh');
ini_set('display_errors', true);
error_reporting(E_ALL);
define('KEY_FILE', __DIR__ . '/service-account-credentials.json');
require_once __DIR__ . '/../vendor/autoload.php';

/*
10 => 'Chí Tôn Võ Lâm',
18 => 'Võ Lâm Tuyệt Kỹ',
23 => 'Tào Tháo PK',
24 => 'Tam Quốc Phán Xử',
25 => 'Học Viện Thú Cưng',
26 => '3Q VL', // wallet
27 => 'Liên Quân Manga', // wallet
28 => 'Võ Lâm Thiên Hạ'
31 => 'Bá Đao Nhất Kiếm'
36 => 'Chí Tôn 3D'
 */
$game_id = '27';

$client = new Google_Client();
$client->setAuthConfig(KEY_FILE);
$client->setScopes([Google_Service_AndroidPublisher::ANDROIDPUBLISHER]);

$endTime = time() * 1000 - 5 * 60 * 1000;
$startTime = $endTime - 48 * 60 * 60 * 1000;

$service = new Google_Service_AndroidPublisher($client);

$packageName = $_REQUEST['packageName'];
$subscriptionId = $_REQUEST['subscriptionId'];
$token = $_REQUEST['token'];
// https://www.googleapis.com/androidpublisher/v3/applications/[packageName]/purchases/subscriptions/[subscriptionId]/tokens/[token]
$service->purchases_subscriptions->get();