diff --git a/README.md b/README.md index aa0d226..b1b9876 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 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. + 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 86947a5..a3e512e 100644 --- a/src/AndroidServicesApi.php +++ b/src/AndroidServicesApi.php @@ -37,7 +37,9 @@ public function __construct( /** * @throws AndroidServiceException|JsonException + * @phpcs:disable * @link https://developers.google.com/android-publisher/api-ref/rest/v3/purchases.subscriptionsv2 Purchases.subscriptionsV2 + * @phpcs:enable * */ public function getPurchaseSubscriptionV2( AndroidPublisherModelInterface $androidPublisherModel @@ -66,7 +68,9 @@ public function getPurchaseSubscriptionV2( /** * @throws AndroidServiceException|JsonException + * @phpcs:disable * @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 @@ -99,7 +103,9 @@ public function getBasePlanOffers( /** * @throws AndroidServiceException|JsonException + * @phpcs:disable * @link https://developers.google.com/android-publisher/api-ref/rest/v3/monetization.subscriptions Monetization.subscriptions + * @phpcs:enable */ public function getPackageSubscriptions( AndroidPublisherModelInterface $androidPublisherModel 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', [ diff --git a/src/Traits/HasStripOrderId.php b/src/Traits/HasStripOrderId.php new file mode 100644 index 0000000..7206b26 --- /dev/null +++ b/src/Traits/HasStripOrderId.php @@ -0,0 +1,25 @@ +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)); + } +}