From 4a0abfc08932aa42211d0148c9cd950b0cce6d46 Mon Sep 17 00:00:00 2001 From: sixer1182 Date: Tue, 27 Aug 2019 08:40:02 +0200 Subject: [PATCH 1/3] [change] (PHPLIB-231) PayPal: Add email address to payment type. --- CHANGELOG.md | 1 + src/Resources/PaymentTypes/Paypal.php | 26 ++++++++++ test/integration/PaymentTypes/PaypalTest.php | 24 ++++++++++ .../Resources/PaymentTypes/PayPalTest.php | 47 +++++++++++++++++++ 4 files changed, 98 insertions(+) create mode 100644 test/unit/Resources/PaymentTypes/PayPalTest.php diff --git a/CHANGELOG.md b/CHANGELOG.md index 53a9a5f4..01f164a8 100755 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) a * Parameters `paymentReference` and `invoiceId` to `Authorization` and `Payout`. * The SDK now supports the webhook event `payout`. * Example for Flexipay direct. +* Email parameter to `Paypal` payment type. ### Changed * The webhook tests now cover all supported events. diff --git a/src/Resources/PaymentTypes/Paypal.php b/src/Resources/PaymentTypes/Paypal.php index 469acdb8..59a64a53 100755 --- a/src/Resources/PaymentTypes/Paypal.php +++ b/src/Resources/PaymentTypes/Paypal.php @@ -33,4 +33,30 @@ class Paypal extends BasePaymentType use CanAuthorize; use CanDirectCharge; use CanRecur; + + /** @var string|null $email */ + protected $email; + + // + + /** + * @return string|null + */ + public function getEmail() + { + return $this->email; + } + + /** + * @param string|null $email + * + * @return Paypal + */ + public function setEmail(string $email): Paypal + { + $this->email = $email; + return $this; + } + + // } diff --git a/test/integration/PaymentTypes/PaypalTest.php b/test/integration/PaymentTypes/PaypalTest.php index 8dad176a..4d83cc5f 100755 --- a/test/integration/PaymentTypes/PaypalTest.php +++ b/test/integration/PaymentTypes/PaypalTest.php @@ -56,6 +56,30 @@ public function paypalShouldBeCreatableAndFetchable(): BasePaymentType return $fetchedPaypal; } + /** + * Verify PayPal payment type can be created and fetched with email. + * + * @test + * + * @return BasePaymentType + * + * @throws RuntimeException + * @throws HeidelpayApiException + */ + public function paypalShouldBeCreatableAndFetchableWithEmail(): BasePaymentType + { + $paypal = (new Paypal())->setEmail('max@mustermann.de'); + $this->heidelpay->createPaymentType($paypal); + $this->assertNotEmpty($paypal->getId()); + + $fetchedPaypal = $this->heidelpay->fetchPaymentType($paypal->getId()); + $this->assertInstanceOf(Paypal::class, $fetchedPaypal); + $this->assertNotSame($paypal, $fetchedPaypal); + $this->assertEquals($paypal->expose(), $fetchedPaypal->expose()); + + return $fetchedPaypal; + } + /** * Verify paypal can authorize. * diff --git a/test/unit/Resources/PaymentTypes/PayPalTest.php b/test/unit/Resources/PaymentTypes/PayPalTest.php new file mode 100644 index 00000000..beedc303 --- /dev/null +++ b/test/unit/Resources/PaymentTypes/PayPalTest.php @@ -0,0 +1,47 @@ + + * + * @package heidelpayPHP/test/unit + */ +namespace heidelpayPHP\test\unit\Resources\PaymentTypes; + +use heidelpayPHP\Resources\PaymentTypes\Paypal; +use heidelpayPHP\test\BaseUnitTest; +use PHPUnit\Framework\Exception; + +class PayPalTest extends BaseUnitTest +{ + /** + * Verify the bic can be set and read. + * + * @test + * + * @throws Exception + */ + public function bicShouldBeRW() + { + $paypal = new Paypal(); + $this->assertNull($paypal->getEmail()); + $paypal->setEmail('test mail'); + $this->assertEquals('test mail', $paypal->getEmail()); + } +} From 5c01c09beb88de17c322f21c8fcd6c8a6902c90d Mon Sep 17 00:00:00 2001 From: sixer1182 Date: Tue, 27 Aug 2019 09:00:13 +0200 Subject: [PATCH 2/3] [change] Remove skipped test. --- CHANGELOG.md | 3 +++ test/BasePaymentTest.php | 8 +++----- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 01f164a8..950a3383 100755 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,9 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) a ### Changed * The webhook tests now cover all supported events. +### Removed +* SAQ-A test due to lack of a corresponding key. + ## [1.2.0.0][1.2.0.0] ### Changed diff --git a/test/BasePaymentTest.php b/test/BasePaymentTest.php index 5ec0833f..cc618612 100755 --- a/test/BasePaymentTest.php +++ b/test/BasePaymentTest.php @@ -56,10 +56,8 @@ class BasePaymentTest extends TestCase // thus can create a CreditCard via this SDK. // If the merchant is not certified to handle the CreditCard data SAQ-A applies // in which case the merchant has to embed our iFrame via JS (UIComponents). - const PRIVATE_KEY_SAQ_D = 's-priv-2a102ZMq3gV4I3zJ888J7RR6u75oqK3n'; - const PUBLIC_KEY_SAQ_D = 's-pub-2a10ifVINFAjpQJ9qW8jBe5OJPBx6Gxa'; - const PRIVATE_KEY_SAQ_A = 's-priv-2a1095rIVXy4IrNFXG6yQiguSAqNjciC'; - const PUBLIC_KEY_SAQ_A = 's-pub-2a10xITCUtmO2FlTP8RKB3OhdnKI4RmU'; + const PRIVATE_KEY = 's-priv-2a102ZMq3gV4I3zJ888J7RR6u75oqK3n'; + const PUBLIC_KEY = 's-pub-2a10ifVINFAjpQJ9qW8jBe5OJPBx6Gxa'; /** * {@inheritDoc} @@ -68,7 +66,7 @@ class BasePaymentTest extends TestCase */ protected function setUp() { - $this->heidelpay = (new Heidelpay(self::PRIVATE_KEY_SAQ_D)) + $this->heidelpay = (new Heidelpay(self::PRIVATE_KEY)) ->setDebugHandler(new TestDebugHandler())->setDebugMode(true); } From 6eba7c1952afb9c07276adb66606d534a32f9cab Mon Sep 17 00:00:00 2001 From: sixer1182 Date: Tue, 27 Aug 2019 13:17:29 +0200 Subject: [PATCH 3/3] [change] Remove skipped test #2. --- test/integration/PaymentTypes/CardTest.php | 21 --------------------- 1 file changed, 21 deletions(-) diff --git a/test/integration/PaymentTypes/CardTest.php b/test/integration/PaymentTypes/CardTest.php index bdc4c259..22ed20b3 100755 --- a/test/integration/PaymentTypes/CardTest.php +++ b/test/integration/PaymentTypes/CardTest.php @@ -38,27 +38,6 @@ class CardTest extends BasePaymentTest { // - /** - * Verify that direct card creation is not possible if the merchant is not PCI DSS compliant. - * In this case he needs to use the iFrame or needs to be marked PCI DSS compliant in the payment backend. - * - * @test - * - * @throws HeidelpayApiException - * @throws RuntimeException - * - * @group skip - */ - public function createCardWithMerchantNotPCIDSSCompliantShouldThrowException() - { - $this->heidelpay->setKey(self::PRIVATE_KEY_SAQ_A); - - $this->expectException(HeidelpayApiException::class); - $this->expectExceptionCode(ApiResponseCodes::API_ERROR_INSUFFICIENT_PERMISSION); - $card = $this->createCardObject(); - $this->heidelpay->createPaymentType($card); - } - /** * Verify that card payment type resource can be created. *