Skip to content

Commit

Permalink
Merge pull request #153 from yyeltsyn/fix-google-classes
Browse files Browse the repository at this point in the history
  • Loading branch information
Stafox authored Oct 13, 2021
2 parents 032a4e1 + 314ca5a commit d347d8f
Show file tree
Hide file tree
Showing 12 changed files with 80 additions and 68 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ $client->setApplicationName('...');
$client->setAuthConfig('...');
$client->setScopes('...');

$validator = new PlayValidator(new \Google_Service_AndroidPublisher($client));
$validator = new PlayValidator(new \Google\Service\AndroidPublisher($client));

try {
$response = $validator->setPackageName('PACKAGE_NAME')
Expand All @@ -89,11 +89,11 @@ Create service account [Service Account flow](https://developers.google.com/iden

```php
$googleClient = new \Google_Client();
$googleClient->setScopes([\Google_Service_AndroidPublisher::ANDROIDPUBLISHER]);
$googleClient->setScopes([\Google\Service\AndroidPublisher::ANDROIDPUBLISHER]);
$googleClient->setApplicationName('Your_Purchase_Validator_Name');
$googleClient->setAuthConfig($pathToServiceAccountJsonFile);

$googleAndroidPublisher = new \Google_Service_AndroidPublisher($googleClient);
$googleAndroidPublisher = new \Google\Service\AndroidPublisher($googleClient);
$validator = new \ReceiptValidator\GooglePlay\Validator($googleAndroidPublisher);

try {
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"ext-json": "*",
"guzzlehttp/guzzle": "^6.3|^7.0",
"nesbot/carbon": "^1.0|^2.0",
"google/apiclient": "^2.0",
"google/apiclient": "^2.10",
"robrichards/xmlseclibs": "^3.0.4"
},
"require-dev": {
Expand Down
2 changes: 1 addition & 1 deletion examples/test_play_receipt.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
$client->setAuthConfig($configLocation);
$client->setScopes($scope);

$validator = new PlayValidator(new \Google_Service_AndroidPublisher($client));
$validator = new PlayValidator(new \Google\Service\AndroidPublisher($client));

try {
$response = $validator->setPackageName($packageName)->setProductId($productId)->setPurchaseToken($purchaseToken)->validatePurchase();
Expand Down
9 changes: 6 additions & 3 deletions src/GooglePlay/AbstractResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

namespace ReceiptValidator\GooglePlay;

use Google\Service\AndroidPublisher\ProductPurchase;
use Google\Service\AndroidPublisher\SubscriptionPurchase;

/**
* Class AbstractResponse.
*/
Expand All @@ -15,14 +18,14 @@ abstract class AbstractResponse
const ACKNOWLEDGEMENT_STATE_DONE = 1;

/**
* @var \Google_Service_AndroidPublisher_ProductPurchase|\Google_Service_AndroidPublisher_SubscriptionPurchase
* @var ProductPurchase|SubscriptionPurchase
*/
protected $response;

/**
* Constructor.
*
* @param \Google_Service_AndroidPublisher_ProductPurchase|\Google_Service_AndroidPublisher_SubscriptionPurchase $response
* @param ProductPurchase|SubscriptionPurchase $response
*/
public function __construct($response)
{
Expand Down Expand Up @@ -62,7 +65,7 @@ public function getKind()
}

/**
* @return \Google_Service_AndroidPublisher_ProductPurchase|\Google_Service_AndroidPublisher_SubscriptionPurchase
* @return ProductPurchase|SubscriptionPurchase
*/
public function getRawResponse()
{
Expand Down
26 changes: 14 additions & 12 deletions src/GooglePlay/Acknowledger.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
namespace ReceiptValidator\GooglePlay;

use Exception;
use Google_Service_AndroidPublisher;
use Google\Service\AndroidPublisher;
use Google\Service\AndroidPublisher\ProductPurchasesAcknowledgeRequest;
use Google\Service\AndroidPublisher\SubscriptionPurchasesAcknowledgeRequest;
use ReceiptValidator\RunTimeException;

/**
Expand All @@ -20,7 +22,7 @@ class Acknowledger
const PRODUCT = 'PRODUCT';

/**
* @var Google_Service_AndroidPublisher
* @var AndroidPublisher
*/
protected $androidPublisherService;
/**
Expand All @@ -43,16 +45,16 @@ class Acknowledger
/**
* Acknowledger constructor.
*
* @param Google_Service_AndroidPublisher $googleServiceAndroidPublisher
* @param string $packageName
* @param string $purchaseToken
* @param string $productId
* @param string $strategy
* @param AndroidPublisher $googleServiceAndroidPublisher
* @param string $packageName
* @param string $purchaseToken
* @param string $productId
* @param string $strategy
*
* @throws RunTimeException
*/
public function __construct(
Google_Service_AndroidPublisher $googleServiceAndroidPublisher,
AndroidPublisher $googleServiceAndroidPublisher,
$packageName,
$productId,
$purchaseToken,
Expand Down Expand Up @@ -86,7 +88,7 @@ public function acknowledge(string $type = self::SUBSCRIPTION, string $developer
$this->packageName,
$this->productId,
$this->purchaseToken,
new \Google_Service_AndroidPublisher_SubscriptionPurchasesAcknowledgeRequest(
new SubscriptionPurchasesAcknowledgeRequest(
['developerPayload' => $developerPayload]
)
);
Expand All @@ -102,7 +104,7 @@ public function acknowledge(string $type = self::SUBSCRIPTION, string $developer
$this->packageName,
$this->productId,
$this->purchaseToken,
new \Google_Service_AndroidPublisher_SubscriptionPurchasesAcknowledgeRequest(
new SubscriptionPurchasesAcknowledgeRequest(
['developerPayload' => $developerPayload]
)
);
Expand All @@ -116,7 +118,7 @@ public function acknowledge(string $type = self::SUBSCRIPTION, string $developer
$this->packageName,
$this->productId,
$this->purchaseToken,
new \Google_Service_AndroidPublisher_ProductPurchasesAcknowledgeRequest(
new ProductPurchasesAcknowledgeRequest(
['developerPayload' => $developerPayload]
)
);
Expand All @@ -132,7 +134,7 @@ public function acknowledge(string $type = self::SUBSCRIPTION, string $developer
$this->packageName,
$this->productId,
$this->purchaseToken,
new \Google_Service_AndroidPublisher_ProductPurchasesAcknowledgeRequest(
new ProductPurchasesAcknowledgeRequest(
['developerPayload' => $developerPayload]
)
);
Expand Down
4 changes: 3 additions & 1 deletion src/GooglePlay/PurchaseResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@

namespace ReceiptValidator\GooglePlay;

use Google\Service\AndroidPublisher\ProductPurchase;

/**
* Class PurchaseResponse.
*/
class PurchaseResponse extends AbstractResponse
{
/**
* @var \Google_Service_AndroidPublisher_ProductPurchase
* @var ProductPurchase
*/
protected $response;

Expand Down
4 changes: 3 additions & 1 deletion src/GooglePlay/SubscriptionResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@

namespace ReceiptValidator\GooglePlay;

use Google\Service\AndroidPublisher\SubscriptionPurchase;

/**
* Class SubscriptionResponse.
*/
class SubscriptionResponse extends AbstractResponse
{
/**
* @var \Google_Service_AndroidPublisher_SubscriptionPurchase
* @var SubscriptionPurchase
*/
protected $response;

Expand Down
12 changes: 7 additions & 5 deletions src/GooglePlay/Validator.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@

namespace ReceiptValidator\GooglePlay;

use Google\Service\AndroidPublisher;

/**
* Class Validator.
*/
class Validator
{
/**
* @var \Google_Service_AndroidPublisher
* @var AndroidPublisher
*/
protected $_androidPublisherService = null;
/**
Expand All @@ -31,11 +33,11 @@ class Validator
/**
* Validator constructor.
*
* @param \Google_Service_AndroidPublisher $googleServiceAndroidPublisher
* @param bool $validationModePurchase
* @param AndroidPublisher $googleServiceAndroidPublisher
* @param bool $validationModePurchase
*/
public function __construct(
\Google_Service_AndroidPublisher $googleServiceAndroidPublisher,
AndroidPublisher $googleServiceAndroidPublisher,
$validationModePurchase = true
) {
$this->_androidPublisherService = $googleServiceAndroidPublisher;
Expand Down Expand Up @@ -127,7 +129,7 @@ public function validateSubscription()
}

/**
* @return \Google_Service_AndroidPublisher
* @return AndroidPublisher
*/
public function getPublisherService()
{
Expand Down
Loading

0 comments on commit d347d8f

Please sign in to comment.