diff --git a/Components/Services/OnboardingStatusService.php b/Components/Services/OnboardingStatusService.php index ea073e32..37a95a46 100644 --- a/Components/Services/OnboardingStatusService.php +++ b/Components/Services/OnboardingStatusService.php @@ -109,14 +109,15 @@ public function getIsCapableResult( $this->loggerService->debug(sprintf('%s MERCHANT INTEGRATIONS: %s', __METHOD__, \json_encode($response))); - $capabilities = $response['capabilities']; - if (!\is_array($capabilities)) { - return new IsCapableResult(false); - } - $this->lastResponsePaymentsReceivable = $this->getBoolValueFromResponseArray(IsCapableResult::PAYMENTS_RECEIVABLE, $response); $this->lastResponsePrimaryEmailConfirmed = $this->getBoolValueFromResponseArray(IsCapableResult::PRIMARY_EMAIL_CONFIRMED, $response); + if (!\array_key_exists('capabilities', $response) || !\is_array($response['capabilities'])) { + return new IsCapableResult(false, null, $this->lastResponsePaymentsReceivable, $this->lastResponsePrimaryEmailConfirmed); + } + + $capabilities = $response['capabilities']; + $this->lastResponseCapabilities = $capabilities; $this->expiry = (new DateTime())->add(new DateInterval(self::CACHE_LIFETIME)); } @@ -127,7 +128,7 @@ public function getIsCapableResult( return new IsCapableResult( $isCapable, - $capability['limits'], + \array_key_exists('limits', $capability) ? $capability['limits'] : null, $this->lastResponsePaymentsReceivable, $this->lastResponsePrimaryEmailConfirmed ); diff --git a/Tests/Functional/Components/Services/OnboardingStatusServiceTest.php b/Tests/Functional/Components/Services/OnboardingStatusServiceTest.php index 1e945faa..e375ba9a 100644 --- a/Tests/Functional/Components/Services/OnboardingStatusServiceTest.php +++ b/Tests/Functional/Components/Services/OnboardingStatusServiceTest.php @@ -305,6 +305,53 @@ public function getIsCapableResultShouldReturnValuesForPaymentsReceivableAndPrim ]; } + /** + * @dataProvider getIsCapableResultWithoutCapabilitiesTestDataProvider + * + * @param bool $paymentsReceivable + * @param bool $primaryEmailConfirmed + * @param bool $expectedPaymentsReceivableResult + * @param bool $expectedPrimaryEmailConfirmedResult + * + * @return void + */ + public function testGetIsCapableResultWithoutCapabilities( + $paymentsReceivable, + $primaryEmailConfirmed, + $expectedPaymentsReceivableResult, + $expectedPrimaryEmailConfirmedResult + ) { + $response = [ + 'merchant_id' => 'FOOBAR42', + 'products' => [], + 'payments_receivable' => $paymentsReceivable, + 'primary_email_confirmed' => $primaryEmailConfirmed, + ]; + + $onboardingStatusService = $this->createOnboardingStatusService( + $this->createMerchantIntegrationsResourceMock($response) + ); + + $result = $onboardingStatusService->getIsCapableResult('anyPayerId', 1, false); + + static::assertFalse($result->isCapable()); + static::assertSame($expectedPaymentsReceivableResult, $result->getIsPaymentsReceivable()); + static::assertSame($expectedPrimaryEmailConfirmedResult, $result->getIsPrimaryEmailConfirmed()); + } + + /** + * @return array> + */ + public function getIsCapableResultWithoutCapabilitiesTestDataProvider() + { + return [ + 'PaymentsReceivable is false and EmailConfirmed is false' => [false, false, false, false], + 'PaymentsReceivable is true and EmailConfirmed is false' => [true, false, true, false], + 'PaymentsReceivable is true and EmailConfirmed is true' => [true, true, true, true], + 'PaymentsReceivable is false and EmailConfirmed is true' => [false, true, false, true], + ]; + } + /** * @param array|null $response * diff --git a/Tests/Functional/Components/Services/RiskManagement/Apm/Validator/SofortValidatorHandlerTest.php b/Tests/Functional/Components/Services/RiskManagement/Apm/Validator/SofortValidatorHandlerTest.php index 792e1b95..f4a59d16 100644 --- a/Tests/Functional/Components/Services/RiskManagement/Apm/Validator/SofortValidatorHandlerTest.php +++ b/Tests/Functional/Components/Services/RiskManagement/Apm/Validator/SofortValidatorHandlerTest.php @@ -13,6 +13,7 @@ use SwagPaymentPayPalUnified\PayPalBundle\PaymentType; use SwagPaymentPayPalUnified\Tests\Functional\ContainerTrait; use SwagPaymentPayPalUnified\Tests\Functional\ReflectionHelperTrait; +use Symfony\Component\Validator\ConstraintViolationInterface; use Symfony\Component\Validator\Validator\ValidatorInterface; class SofortValidatorHandlerTest extends TestCase @@ -36,8 +37,12 @@ public function testCreateValidatorShouldNotContainItalyAsCountry() ); static::assertCount(1, $violationList); - static::assertSame('The value you selected is not a valid choice.', $violationList[0]->getMessage()); - static::assertSame('IT', $violationList[0]->getInvalidValue()); + + $violation = $violationList[0]; + static::assertInstanceOf(ConstraintViolationInterface::class, $violation); + + static::assertSame('The value you selected is not a valid choice.', $violation->getMessage()); + static::assertSame('IT', $violation->getInvalidValue()); } /** diff --git a/plugin.xml b/plugin.xml index 26d5d4ec..4d4ffc11 100644 --- a/plugin.xml +++ b/plugin.xml @@ -5,13 +5,22 @@ - 6.1.2 + 6.1.3 (c) by shopware AG MIT http://store.shopware.com shopware AG + + + PT-13146 - Behebt ein Problem bei der Überprüfung der Transaktionsfähigkeit ohne PPCP; + + + PT-13146 - Fixes a problem when checking transaction eligibility without PPCP; + + + PT-13142 - Verbessert die Bearbeitung von Webhooks;