diff --git a/src/Entities/DTO/MerchantBusinessEvent/OrderConfirmedBusinessEvent.php b/src/Entities/DTO/MerchantBusinessEvent/OrderConfirmedBusinessEvent.php index 6c81229..9b96485 100644 --- a/src/Entities/DTO/MerchantBusinessEvent/OrderConfirmedBusinessEvent.php +++ b/src/Entities/DTO/MerchantBusinessEvent/OrderConfirmedBusinessEvent.php @@ -128,8 +128,8 @@ protected function validateData() !is_bool($this->almaP1XStatus) || !is_bool($this->almaBNPLStatus) || !is_bool($this->wasBNPLEligible) || - !is_string($this->orderId) || - !is_string($this->cartId) || + (!is_string($this->orderId) || empty($this->orderId)) || + (!is_string($this->cartId) || empty($this->cartId)) || // Alma payment id should be absent for non Alma payments (!$this->isAlmaPayment() && !is_null($this->almaPaymentId)) ) @@ -140,7 +140,7 @@ protected function validateData() //Alma payment id for Alma payment, Must be a string if( $this->isAlmaPayment() && - !is_string($this->almaPaymentId) + (!is_string($this->almaPaymentId) || empty($this->almaPaymentId)) ) { throw new ParametersException('Alma payment id is mandatory for Alma payment'); diff --git a/tests/Unit/Entities/DTO/MerchantBusinessEvent/OrderConfirmedBusinessEventTest.php b/tests/Unit/Entities/DTO/MerchantBusinessEvent/OrderConfirmedBusinessEventTest.php index 935b34d..2728d2e 100644 --- a/tests/Unit/Entities/DTO/MerchantBusinessEvent/OrderConfirmedBusinessEventTest.php +++ b/tests/Unit/Entities/DTO/MerchantBusinessEvent/OrderConfirmedBusinessEventTest.php @@ -52,6 +52,11 @@ public function testAlmaPaymentIdIsMandatoryForBnplAlmaPayment() $this->expectException(ParametersException::class); new OrderConfirmedBusinessEvent(false, true, true, "42", "54"); } + public function testAlmaPaymentIdCanNotBeAnEmptyStringForAnAlmaPayment() + { + $this->expectException(ParametersException::class); + new OrderConfirmedBusinessEvent(false, true, true, "42", "54", ""); + } public function testAlmaPaymentIdShouldBeAbsentForNonAlmaPayments() { @@ -201,6 +206,13 @@ public static function invalidDataForBusinessEventDataProvider() 'orderId' => "1", 'cartId' => "1" ], + "Order id is empty string" => [ + 'isP1X' => false, + 'isBNPL' => false, + 'wasEligible' => true, + 'orderId' => "", + 'cartId' => "14" + ], "Order id is an int" => [ 'isP1X' => false, 'isBNPL' => false, @@ -271,6 +283,13 @@ public static function invalidDataForBusinessEventDataProvider() 'orderId' => '1', 'cartId' => new \stdClass() ], + "Cart id is empty string" => [ + 'isP1X' => false, + 'isBNPL' => false, + 'wasEligible' => true, + 'orderId' => "1", + 'cartId' => "" + ], ]; } }