From 395b049cb2ae01acd0462d952520ca9303705485 Mon Sep 17 00:00:00 2001 From: "alex.ferreira" Date: Thu, 27 Mar 2025 15:13:09 +0000 Subject: [PATCH 1/9] feat: add Tags to DD logs --- src/Traits/HasDDErrorEvent.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/Traits/HasDDErrorEvent.php b/src/Traits/HasDDErrorEvent.php index b227308..c5f7ce9 100644 --- a/src/Traits/HasDDErrorEvent.php +++ b/src/Traits/HasDDErrorEvent.php @@ -29,6 +29,12 @@ private function sendDDErrorEvent( 'purchaseToken' => $androidPublisherModel->subscriptionNotification->purchaseToken ?? '' ], JSON_THROW_ON_ERROR), Event::ALERT_ERROR, + [ + 'packageName' => $androidPublisherModel->packageName ?? '', + 'subscriptionId' => $androidPublisherModel->subscriptionNotification->subscriptionId ?? '', + 'productId' => $androidPublisherModel->getProductId() ?? '', + 'appName' => 'android-services-bundle', + ] ); } catch (Throwable $throwable) { $logger->warning('Failed to send event to Datadog', [ From 506fc46848f13832abb61b8a36907aee7084b224 Mon Sep 17 00:00:00 2001 From: "alex.ferreira" Date: Thu, 27 Mar 2025 15:13:52 +0000 Subject: [PATCH 2/9] feat: add new trait to strip rdn number append to `orderId` when RENEWAL --- src/Traits/HasStripOrderId.php | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 src/Traits/HasStripOrderId.php diff --git a/src/Traits/HasStripOrderId.php b/src/Traits/HasStripOrderId.php new file mode 100644 index 0000000..fbc8a91 --- /dev/null +++ b/src/Traits/HasStripOrderId.php @@ -0,0 +1,25 @@ + Date: Thu, 27 Mar 2025 15:14:14 +0000 Subject: [PATCH 3/9] feat: update README --- README.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/README.md b/README.md index aa0d226..0504bb5 100644 --- a/README.md +++ b/README.md @@ -111,3 +111,11 @@ If you only want a run the tests you can run the following command: ```sh composer run-tests ``` + +--- +> [!IMPORTANT] +> +> The Google API will append `..[random number]` at the end of the `orderId` when a subscriber `RENEW` a subscription. +> +> If you are looking at doing any sort of validation using the `orderId`, the bundle offer a `trait` [HasStripOrderId](src/Traits/HasStripOrderId.php) available to help. + From ec8a3fe04804017d9a0e4f7a3665684915d06fb9 Mon Sep 17 00:00:00 2001 From: "alex.ferreira" Date: Thu, 27 Mar 2025 15:53:23 +0000 Subject: [PATCH 4/9] fix: phpcs flagging @link over the limit char --- src/AndroidServicesApi.php | 5 ++++- src/Traits/HasStripOrderId.php | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/AndroidServicesApi.php b/src/AndroidServicesApi.php index 86947a5..4a11ce4 100644 --- a/src/AndroidServicesApi.php +++ b/src/AndroidServicesApi.php @@ -37,6 +37,7 @@ public function __construct( /** * @throws AndroidServiceException|JsonException + * @phpcs:ignore * @link https://developers.google.com/android-publisher/api-ref/rest/v3/purchases.subscriptionsv2 Purchases.subscriptionsV2 * */ public function getPurchaseSubscriptionV2( @@ -66,6 +67,7 @@ public function getPurchaseSubscriptionV2( /** * @throws AndroidServiceException|JsonException + * @phpcs:ignore * @link https://developers.google.com/android-publisher/api-ref/rest/v3/monetization.subscriptions.basePlans.offers Monetization.subscriptions.basePlans.offers * */ public function getBasePlanOffers( @@ -99,7 +101,8 @@ public function getBasePlanOffers( /** * @throws AndroidServiceException|JsonException - * @link https://developers.google.com/android-publisher/api-ref/rest/v3/monetization.subscriptions Monetization.subscriptions + * @phpcs:ignore + * @link https://developers.google.com/android-publisher/api-ref/rest/v3/monetization.subscriptions Monetization.subscriptions // @phpcs:ignore */ public function getPackageSubscriptions( AndroidPublisherModelInterface $androidPublisherModel diff --git a/src/Traits/HasStripOrderId.php b/src/Traits/HasStripOrderId.php index fbc8a91..7206b26 100644 --- a/src/Traits/HasStripOrderId.php +++ b/src/Traits/HasStripOrderId.php @@ -22,4 +22,4 @@ private function stripOrderId(?string $orderId): ?string return $orderId; } -} \ No newline at end of file +} From c1bdc51550eb77ce3ed4fa81ab6042de18952562 Mon Sep 17 00:00:00 2001 From: "alex.ferreira" Date: Mon, 31 Mar 2025 10:02:09 +0100 Subject: [PATCH 5/9] fix: app version & phpcs --- composer.json | 2 +- src/AndroidServicesApi.php | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/composer.json b/composer.json index f8c2060..cf8aba2 100644 --- a/composer.json +++ b/composer.json @@ -1,6 +1,6 @@ { "name": "immediate/android-services-bundle", - "version": "1.0.0", + "version": "1.1.0", "description": "This bundle allows for interaction with the Android Publisher services specifically", "type": "symfony-bundle", "license": "MIT", diff --git a/src/AndroidServicesApi.php b/src/AndroidServicesApi.php index 4a11ce4..13e7103 100644 --- a/src/AndroidServicesApi.php +++ b/src/AndroidServicesApi.php @@ -39,6 +39,7 @@ public function __construct( * @throws AndroidServiceException|JsonException * @phpcs:ignore * @link https://developers.google.com/android-publisher/api-ref/rest/v3/purchases.subscriptionsv2 Purchases.subscriptionsV2 + * @phpcs:enable * */ public function getPurchaseSubscriptionV2( AndroidPublisherModelInterface $androidPublisherModel @@ -69,6 +70,7 @@ public function getPurchaseSubscriptionV2( * @throws AndroidServiceException|JsonException * @phpcs:ignore * @link https://developers.google.com/android-publisher/api-ref/rest/v3/monetization.subscriptions.basePlans.offers Monetization.subscriptions.basePlans.offers + * @phpcs:enable * */ public function getBasePlanOffers( AndroidPublisherModelInterface $androidPublisherModel @@ -102,7 +104,8 @@ public function getBasePlanOffers( /** * @throws AndroidServiceException|JsonException * @phpcs:ignore - * @link https://developers.google.com/android-publisher/api-ref/rest/v3/monetization.subscriptions Monetization.subscriptions // @phpcs:ignore + * @link https://developers.google.com/android-publisher/api-ref/rest/v3/monetization.subscriptions Monetization.subscriptions + * @phpcs:enable */ public function getPackageSubscriptions( AndroidPublisherModelInterface $androidPublisherModel From 2d3c3bbb58557c6d94550d97d981c1e0822a2f4c Mon Sep 17 00:00:00 2001 From: "alex.ferreira" Date: Mon, 31 Mar 2025 10:08:01 +0100 Subject: [PATCH 6/9] fix: phpcs update --- src/AndroidServicesApi.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/AndroidServicesApi.php b/src/AndroidServicesApi.php index 13e7103..a3e512e 100644 --- a/src/AndroidServicesApi.php +++ b/src/AndroidServicesApi.php @@ -37,7 +37,7 @@ public function __construct( /** * @throws AndroidServiceException|JsonException - * @phpcs:ignore + * @phpcs:disable * @link https://developers.google.com/android-publisher/api-ref/rest/v3/purchases.subscriptionsv2 Purchases.subscriptionsV2 * @phpcs:enable * */ @@ -68,7 +68,7 @@ public function getPurchaseSubscriptionV2( /** * @throws AndroidServiceException|JsonException - * @phpcs:ignore + * @phpcs:disable * @link https://developers.google.com/android-publisher/api-ref/rest/v3/monetization.subscriptions.basePlans.offers Monetization.subscriptions.basePlans.offers * @phpcs:enable * */ @@ -103,7 +103,7 @@ public function getBasePlanOffers( /** * @throws AndroidServiceException|JsonException - * @phpcs:ignore + * @phpcs:disable * @link https://developers.google.com/android-publisher/api-ref/rest/v3/monetization.subscriptions Monetization.subscriptions * @phpcs:enable */ From 1761196426cdf53a9eb6f67859a3551715fa98bb Mon Sep 17 00:00:00 2001 From: "alex.ferreira" Date: Mon, 31 Mar 2025 11:43:09 +0100 Subject: [PATCH 7/9] feat: add test for HasStripOrderId trait --- tests/phpunit/Traits/HasStripOrderIdTest.php | 29 ++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 tests/phpunit/Traits/HasStripOrderIdTest.php diff --git a/tests/phpunit/Traits/HasStripOrderIdTest.php b/tests/phpunit/Traits/HasStripOrderIdTest.php new file mode 100644 index 0000000..c52009d --- /dev/null +++ b/tests/phpunit/Traits/HasStripOrderIdTest.php @@ -0,0 +1,29 @@ +assertSame($this->expected, $this->stripOrderId($this->orderId)); + } + + public function testReturnsNullForNullOrderId(): void + { + $this->assertNull($this->stripOrderId(null)); + } + + public function testReturnsOriginalOrderIdIfNoExtraPart(): void + { + $this->assertSame($this->expected, $this->stripOrderId($this->expected)); + } +} From b7e4822de0e4cdf360ed14a5b3feba8a9a2f252d Mon Sep 17 00:00:00 2001 From: "alex.ferreira" Date: Mon, 31 Mar 2025 11:44:38 +0100 Subject: [PATCH 8/9] fix: strict type --- tests/phpunit/Traits/HasStripOrderIdTest.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/phpunit/Traits/HasStripOrderIdTest.php b/tests/phpunit/Traits/HasStripOrderIdTest.php index c52009d..7bb99a9 100644 --- a/tests/phpunit/Traits/HasStripOrderIdTest.php +++ b/tests/phpunit/Traits/HasStripOrderIdTest.php @@ -1,5 +1,7 @@ Date: Mon, 31 Mar 2025 16:05:53 +0100 Subject: [PATCH 9/9] fix: typo within README.md --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 0504bb5..b1b9876 100644 --- a/README.md +++ b/README.md @@ -115,7 +115,7 @@ composer run-tests --- > [!IMPORTANT] > -> The Google API will append `..[random number]` at the end of the `orderId` when a subscriber `RENEW` a subscription. -> -> If you are looking at doing any sort of validation using the `orderId`, the bundle offer a `trait` [HasStripOrderId](src/Traits/HasStripOrderId.php) available to help. +>The Google API will append `..[random number]` at the end of the orderId when a subscriber renews a subscription. +> +> If you plan doing any sort of validation using the `orderId`, the bundle offers a helper `Trait` [HasStripOrderId](src/Traits/HasStripOrderId.php) which removes the appending data from the Order ID.