From 923bda93f4daff0507583863481ee0df5e93e924 Mon Sep 17 00:00:00 2001 From: Oleg Iskusnyh Date: Mon, 17 Apr 2023 11:07:23 +0600 Subject: [PATCH] Checkout v3 --- Changelog.txt | 7 ++ composer.json | 2 +- .../Data/PaymentorderPayerInterface.php | 49 +++++++++++++ .../Resource/PaymentorderPayer.php | 69 +++++++++++++++++++ .../Request/Data/PaymentorderInterface.php | 18 +++++ .../Resource/Request/Paymentorder.php | 21 ++++++ .../Request/TransactionCancelV3.php | 18 +++++ .../Request/TransactionCaptureV3.php | 18 +++++ .../Request/TransactionReversalV3.php | 18 +++++ .../Resource/PaymentorderPayerTest.php | 12 ++++ .../Resource/Request/PaymenorderTest.php | 6 ++ 11 files changed, 237 insertions(+), 1 deletion(-) create mode 100644 src/SwedbankPay/Api/Service/Paymentorder/Transaction/Request/TransactionCancelV3.php create mode 100644 src/SwedbankPay/Api/Service/Paymentorder/Transaction/Request/TransactionCaptureV3.php create mode 100644 src/SwedbankPay/Api/Service/Paymentorder/Transaction/Request/TransactionReversalV3.php diff --git a/Changelog.txt b/Changelog.txt index 57bc35d4..256bbc65 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -1,4 +1,11 @@ Changelog +6.0.0 - 2023-04-17 +Added +- Checkout v3 classes and methods +- Add `setImplementation()` and `getImplementation()` for Paymentorder +- Add classes `TransactionCancelV3`, `TransactionCaptureV3`, `TransactionReversalV3` +- Add methods `getFirstName()`, `setFirstName()`, `getLastName()`, `setLastName()`, `getDigitalProducts()`, `setDigitalProducts()`, `getShippingAddressRestrictedToCountryCodes()`, `setShippingAddressRestrictedToCountryCodes()` in `PaymentorderPayer` + 5.6.0 - 2023-04-07 Added - Add `setProductName()` and `getProductName()` for Paymentorder diff --git a/composer.json b/composer.json index 60e1e31c..272650ed 100644 --- a/composer.json +++ b/composer.json @@ -2,7 +2,7 @@ "name": "swedbank-pay/swedbank-pay-sdk-php", "type": "library", "description": "The Swedbank Pay SDK for PHP simplifies integrations against Swedbank Pay's API Platform by providing native PHP interface towards the REST API.", - "version": "5.6.0", + "version": "6.0.0", "authors": [ { "name": "Sammy Nordstr\u00f6m", diff --git a/src/SwedbankPay/Api/Service/Paymentorder/Resource/Data/PaymentorderPayerInterface.php b/src/SwedbankPay/Api/Service/Paymentorder/Resource/Data/PaymentorderPayerInterface.php index 79c44e61..2e8e0f7e 100644 --- a/src/SwedbankPay/Api/Service/Paymentorder/Resource/Data/PaymentorderPayerInterface.php +++ b/src/SwedbankPay/Api/Service/Paymentorder/Resource/Data/PaymentorderPayerInterface.php @@ -16,9 +16,13 @@ interface PaymentorderPayerInterface extends ResourceInterface const PAYER_REFERENCE = 'payer_reference'; const EMAIL = 'email'; const MSISDN = 'msisdn'; + const FIRST_NAME = 'first_name'; + const LAST_NAME = 'last_name'; const WORK_PHONE_NUMBER = 'work_phone_number'; const HOME_PHONE_NUMBER = 'home_phone_number'; const SHIPPING_ADDRESS = 'shipping_address'; + const DIGITAL_PRODUCTS = 'digital_products'; + const SHIPPING_ADDRESS_RESTRICTED_COUNTRIES = 'shipping_address_restricted_to_country_codes'; /** * Get Payer Reference. @@ -68,6 +72,28 @@ public function getMsisdn(); */ public function setMsisdn($msisdn); + /** + * @return string|null + */ + public function getFirstName(); + + /** + * @param string $firstName + * @return $this + */ + public function setFirstName($firstName); + + /** + * @return string|null + */ + public function getLastName(); + + /** + * @param string $lastName + * @return $this + */ + public function setLastName($lastName); + /** * @return string */ @@ -100,4 +126,27 @@ public function getShippingAddress(); * @return mixed */ public function setShippingAddress($shippingAddress); + + /** + * @return bool|null + */ + public function getDigitalProducts(); + + /** + * @param bool $flag + * @return $this + */ + public function setDigitalProducts($flag); + + /** + * @return array|null + */ + public function getShippingAddressRestrictedToCountryCodes(); + + /** + * @param array $countries + * + * @return $this + */ + public function setShippingAddressRestrictedToCountryCodes($countries); } diff --git a/src/SwedbankPay/Api/Service/Paymentorder/Resource/PaymentorderPayer.php b/src/SwedbankPay/Api/Service/Paymentorder/Resource/PaymentorderPayer.php index 49972f55..371548d2 100644 --- a/src/SwedbankPay/Api/Service/Paymentorder/Resource/PaymentorderPayer.php +++ b/src/SwedbankPay/Api/Service/Paymentorder/Resource/PaymentorderPayer.php @@ -84,6 +84,40 @@ public function setMsisdn($msisdn) return $this->offsetSet(self::MSISDN, $msisdn); } + /** + * @return string|null + */ + public function getFirstName() + { + return $this->offsetGet(self::FIRST_NAME); + } + + /** + * @param string $firstName + * @return $this + */ + public function setFirstName($firstName) + { + return $this->offsetSet(self::FIRST_NAME, $firstName); + } + + /** + * @return string|null + */ + public function getLastName() + { + return $this->offsetGet(self::FIRST_NAME); + } + + /** + * @param string $lastName + * @return $this + */ + public function setLastName($lastName) + { + return $this->offsetSet(self::LAST_NAME, $lastName); + } + /** * @return string */ @@ -134,4 +168,39 @@ public function setShippingAddress($shippingAddress) { return $this->offsetSet(self::SHIPPING_ADDRESS, $shippingAddress); } + + /** + * @return bool|null + */ + public function getDigitalProducts() + { + return $this->offsetGet(self::DIGITAL_PRODUCTS); + } + + /** + * @param bool $flag + * @return $this + */ + public function setDigitalProducts($flag) + { + return $this->offsetSet(self::DIGITAL_PRODUCTS, $flag); + } + + /** + * @return array|null + */ + public function getShippingAddressRestrictedToCountryCodes() + { + return $this->offsetGet(self::SHIPPING_ADDRESS_RESTRICTED_COUNTRIES); + } + + /** + * @param array $countries + * + * @return $this + */ + public function setShippingAddressRestrictedToCountryCodes($countries) + { + return $this->offsetSet(self::SHIPPING_ADDRESS_RESTRICTED_COUNTRIES, $countries); + } } diff --git a/src/SwedbankPay/Api/Service/Paymentorder/Resource/Request/Data/PaymentorderInterface.php b/src/SwedbankPay/Api/Service/Paymentorder/Resource/Request/Data/PaymentorderInterface.php index 5fbf250f..a9cd6229 100644 --- a/src/SwedbankPay/Api/Service/Paymentorder/Resource/Request/Data/PaymentorderInterface.php +++ b/src/SwedbankPay/Api/Service/Paymentorder/Resource/Request/Data/PaymentorderInterface.php @@ -9,6 +9,7 @@ use SwedbankPay\Api\Service\Paymentorder\Resource\Data\PaymentorderPayerInterface; use SwedbankPay\Api\Service\Paymentorder\Resource\Data\PaymentorderRiskIndicatorInterface; use SwedbankPay\Api\Service\Paymentorder\Resource\Data\PaymentorderUrlInterface; +use SwedbankPay\Api\Service\Paymentorder\Resource\Request\Paymentorder; use SwedbankPay\Api\Service\Resource\Data\RequestInterface; /** @@ -48,6 +49,8 @@ interface PaymentorderInterface extends RequestInterface const INITIATING_SYSTEM_AGENT = 'initiatingSystemUserAgent'; const PRODUCT_NAME = 'product_name'; + const IMPLEMENTATION = 'implementation'; + /** * Get Initiating System User Agent. * @@ -309,4 +312,19 @@ public function setProductName($productName); * @return string|null */ public function getProductName(); + + /** + * Set Implementation. + * + * @param $implementation + * @return Paymentorder + */ + public function setImplementation($implementation); + + /** + * Get Implementation name. + * + * @return string|null + */ + public function getImplementation(); } diff --git a/src/SwedbankPay/Api/Service/Paymentorder/Resource/Request/Paymentorder.php b/src/SwedbankPay/Api/Service/Paymentorder/Resource/Request/Paymentorder.php index 35c077d3..6649e04d 100644 --- a/src/SwedbankPay/Api/Service/Paymentorder/Resource/Request/Paymentorder.php +++ b/src/SwedbankPay/Api/Service/Paymentorder/Resource/Request/Paymentorder.php @@ -454,4 +454,25 @@ public function getProductName() { return $this->offsetGet(self::PRODUCT_NAME); } + + /** + * Set Implementation. + * + * @param $implementation + * @return Paymentorder + */ + public function setImplementation($implementation) + { + return $this->offsetSet(self::IMPLEMENTATION, $implementation); + } + + /** + * Get Implementation name. + * + * @return string|null + */ + public function getImplementation() + { + return $this->offsetGet(self::IMPLEMENTATION); + } } diff --git a/src/SwedbankPay/Api/Service/Paymentorder/Transaction/Request/TransactionCancelV3.php b/src/SwedbankPay/Api/Service/Paymentorder/Transaction/Request/TransactionCancelV3.php new file mode 100644 index 00000000..0a8f3a57 --- /dev/null +++ b/src/SwedbankPay/Api/Service/Paymentorder/Transaction/Request/TransactionCancelV3.php @@ -0,0 +1,18 @@ +setOperationRel('cancel'); + $this->setResponseResourceFQCN(TransactionCancelResponse::class); + } +} diff --git a/src/SwedbankPay/Api/Service/Paymentorder/Transaction/Request/TransactionCaptureV3.php b/src/SwedbankPay/Api/Service/Paymentorder/Transaction/Request/TransactionCaptureV3.php new file mode 100644 index 00000000..2d663c5c --- /dev/null +++ b/src/SwedbankPay/Api/Service/Paymentorder/Transaction/Request/TransactionCaptureV3.php @@ -0,0 +1,18 @@ +setOperationRel('capture'); + $this->setResponseResourceFQCN(TransactionCaptureResponse::class); + } +} diff --git a/src/SwedbankPay/Api/Service/Paymentorder/Transaction/Request/TransactionReversalV3.php b/src/SwedbankPay/Api/Service/Paymentorder/Transaction/Request/TransactionReversalV3.php new file mode 100644 index 00000000..280b8774 --- /dev/null +++ b/src/SwedbankPay/Api/Service/Paymentorder/Transaction/Request/TransactionReversalV3.php @@ -0,0 +1,18 @@ +setOperationRel('reversal'); + $this->setResponseResourceFQCN(TransactionRevResponse::class); + } +} diff --git a/tests/Unit/SwedbankPayTest/Api/Service/Paymentorder/Resource/PaymentorderPayerTest.php b/tests/Unit/SwedbankPayTest/Api/Service/Paymentorder/Resource/PaymentorderPayerTest.php index eb540a25..16bb76ed 100644 --- a/tests/Unit/SwedbankPayTest/Api/Service/Paymentorder/Resource/PaymentorderPayerTest.php +++ b/tests/Unit/SwedbankPayTest/Api/Service/Paymentorder/Resource/PaymentorderPayerTest.php @@ -55,6 +55,18 @@ public function testData() $object->setShippingAddress($address) ); $this->assertInstanceOf(ConsumerAddress::class, $object->getShippingAddress()); + + $this->assertInstanceOf( + PaymentorderPayer::class, + $object->setDigitalProducts(true) + ); + $this->assertEquals(true, $object->getDigitalProducts()); + + $this->assertInstanceOf( + PaymentorderPayer::class, + $object->setShippingAddressRestrictedToCountryCodes(['NO', 'US']) + ); + $this->assertIsArray($object->getShippingAddressRestrictedToCountryCodes()); } public function testMethods() diff --git a/tests/Unit/SwedbankPayTest/Api/Service/Paymentorder/Resource/Request/PaymenorderTest.php b/tests/Unit/SwedbankPayTest/Api/Service/Paymentorder/Resource/Request/PaymenorderTest.php index 796490d6..d6329a54 100644 --- a/tests/Unit/SwedbankPayTest/Api/Service/Paymentorder/Resource/Request/PaymenorderTest.php +++ b/tests/Unit/SwedbankPayTest/Api/Service/Paymentorder/Resource/Request/PaymenorderTest.php @@ -169,6 +169,12 @@ public function testData() $object->setProductName('Checkout3') ); $this->assertEquals('Checkout3', $object->getProductName()); + + $this->assertInstanceOf( + Paymentorder::class, + $object->setImplementation('Starter') + ); + $this->assertEquals('Starter', $object->getImplementation()); } public function testInitiatingSystemUserAgent()