From 0d8d36ad9f3c8f7de48bbe2e717af324eaca52fb Mon Sep 17 00:00:00 2001 From: Michiel Gerritsen Date: Mon, 10 May 2021 15:22:53 +0200 Subject: [PATCH 1/6] Feature: Retrieve customer connection by Mollie Customer ID --- Api/MollieCustomerRepositoryInterface.php | 7 +++++++ Model/MollieCustomerRepository.php | 15 +++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/Api/MollieCustomerRepositoryInterface.php b/Api/MollieCustomerRepositoryInterface.php index 665eddf0d36..2974f72d36b 100644 --- a/Api/MollieCustomerRepositoryInterface.php +++ b/Api/MollieCustomerRepositoryInterface.php @@ -28,6 +28,13 @@ public function save( */ public function get($id); + /** + * Retrieve Mollie Customer connection by Mollie Customer ID + * @param string $customerId + * @return \Mollie\Payment\Api\Data\MollieCustomerInterface + */ + public function getByMollieCustomerId(string $customerId); + /** * Retrieve Mollie Customer by Magento customer * @param \Magento\Customer\Api\Data\CustomerInterface $customer diff --git a/Model/MollieCustomerRepository.php b/Model/MollieCustomerRepository.php index 8c125090b1f..bb3ec57566d 100644 --- a/Model/MollieCustomerRepository.php +++ b/Model/MollieCustomerRepository.php @@ -156,6 +156,21 @@ public function get($customerId) return $customer->getDataModel(); } + /** + * {@inheritDoc} + */ + public function getByMollieCustomerId(string $customerId) + { + $mollieCustomer = $this->mollieCustomerFactory->create(); + $this->resource->load($mollieCustomer, $customerId, 'mollie_customer_id'); + + if (!$mollieCustomer->getId()) { + return null; + } + + return $mollieCustomer->getDataModel(); + } + /** * {@inheritDoc} */ From 55a9f62b607f0aefb7f3818d6945231f36162177 Mon Sep 17 00:00:00 2001 From: Michiel Gerritsen Date: Thu, 20 May 2021 13:45:18 +0200 Subject: [PATCH 2/6] Feature: Direct implementation for the GraphQL `placeOrder` endpoint --- GraphQL/DataProvider.php | 19 +++++ .../PlaceOrderAndReturnRedirectUrl.php | 75 +++++++++++++++++++ etc/graphql/di.xml | 28 +++++++ etc/schema.graphqls | 8 +- 4 files changed, 129 insertions(+), 1 deletion(-) create mode 100644 GraphQL/DataProvider.php create mode 100644 GraphQL/Resolver/Checkout/PlaceOrderAndReturnRedirectUrl.php create mode 100644 etc/graphql/di.xml diff --git a/GraphQL/DataProvider.php b/GraphQL/DataProvider.php new file mode 100644 index 00000000000..7cb34727403 --- /dev/null +++ b/GraphQL/DataProvider.php @@ -0,0 +1,19 @@ + $data['mollie_selected_issuer'] ?? null, + 'card_token' => $data['mollie_card_token'] ?? null, + ]; + } +} diff --git a/GraphQL/Resolver/Checkout/PlaceOrderAndReturnRedirectUrl.php b/GraphQL/Resolver/Checkout/PlaceOrderAndReturnRedirectUrl.php new file mode 100644 index 00000000000..cf2b7eeee63 --- /dev/null +++ b/GraphQL/Resolver/Checkout/PlaceOrderAndReturnRedirectUrl.php @@ -0,0 +1,75 @@ +orderRepository = $orderRepository; + $this->searchCriteriaBuilder = $searchCriteriaBuilder; + $this->mollie = $mollie; + } + + public function resolve(Field $field, $context, ResolveInfo $info, array $value = null, array $args = null) + { + $order = $this->getOrderByIncrementId($value['order_id']); + if (!$order) { + return null; + } + + if ($order->getPayment()->getAdditionalInformation('checkout_url')) { + return $order->getPayment()->getAdditionalInformation('checkout_url'); + } + + $this->mollie->startTransaction($order); + + return $order->getPayment()->getAdditionalInformation('checkout_url'); + } + + /** + * @param string $incrementId + * @return \Magento\Sales\Api\Data\OrderInterface|null + */ + private function getOrderByIncrementId($incrementId) + { + $this->searchCriteriaBuilder->addFilter('increment_id', $incrementId); + + $items = $this->orderRepository->getList($this->searchCriteriaBuilder->create())->getItems(); + + return array_shift($items); + } +} diff --git a/etc/graphql/di.xml b/etc/graphql/di.xml new file mode 100644 index 00000000000..a770d17078d --- /dev/null +++ b/etc/graphql/di.xml @@ -0,0 +1,28 @@ + + + + + + Mollie\Payment\GraphQL\DataProvider + Mollie\Payment\GraphQL\DataProvider + Mollie\Payment\GraphQL\DataProvider + Mollie\Payment\GraphQL\DataProvider + Mollie\Payment\GraphQL\DataProvider + Mollie\Payment\GraphQL\DataProvider + Mollie\Payment\GraphQL\DataProvider + Mollie\Payment\GraphQL\DataProvider + Mollie\Payment\GraphQL\DataProvider + Mollie\Payment\GraphQL\DataProvider + Mollie\Payment\GraphQL\DataProvider + Mollie\Payment\GraphQL\DataProvider + Mollie\Payment\GraphQL\DataProvider + Mollie\Payment\GraphQL\DataProvider + Mollie\Payment\GraphQL\DataProvider + Mollie\Payment\GraphQL\DataProvider + Mollie\Payment\GraphQL\DataProvider + Mollie\Payment\GraphQL\DataProvider + Mollie\Payment\GraphQL\DataProvider + + + + diff --git a/etc/schema.graphqls b/etc/schema.graphqls index ca3f6bb2839..976b693db11 100644 --- a/etc/schema.graphqls +++ b/etc/schema.graphqls @@ -1,8 +1,9 @@ type Mutation { - createMollieTransaction(input: MollieTransactionInput): MollieTransactionOutput @resolver(class: "\\Mollie\\Payment\\GraphQL\\Resolver\\Checkout\\CreateMollieTransaction") + createMollieTransaction(input: MollieTransactionInput): MollieTransactionOutput @resolver(class: "\\Mollie\\Payment\\GraphQL\\Resolver\\Checkout\\CreateMollieTransaction") @deprecated(reason: "Using the Order.mollie_redirect_url attribuut") } type Order { + mollie_redirect_url: String @resolver(class: "\\Mollie\\Payment\\GraphQL\\Resolver\\Checkout\\PlaceOrderAndReturnRedirectUrl") mollie_payment_token: String @resolver(class: "\\Mollie\\Payment\\GraphQL\\Resolver\\Checkout\\PaymentToken") } @@ -23,6 +24,11 @@ type SelectedPaymentMethod { mollie_meta: MolliePaymentMethodMeta! @resolver(class: "Mollie\\Payment\\GraphQL\\Resolver\\Cart\\PaymentMethodMeta") @doc(description: "Retrieve meta information for this payment method (image)") } +input PaymentMethodInput { + mollie_selected_issuer: String @doc(description: "Provided the issuer chosen by the end-user") + mollie_card_token: String @doc(description: "The card token provided by Mollie Components") +} + type MollieIssuer { name: String code: String From 54949047bdaa26f83b7d56fa1173f3d28e7e65b3 Mon Sep 17 00:00:00 2001 From: Michiel Gerritsen Date: Mon, 31 May 2021 14:16:52 +0200 Subject: [PATCH 3/6] Moved required Magento version from 2.2 to 2.3.3 --- .github/workflows/integration-test.yml | 4 +- .github/workflows/phpstan.yml | 4 +- .github/workflows/setup-di-compile.yml | 4 +- .github/workflows/unit-test.yml | 10 +- LegacySupport/GraphQl/Field.php | 196 -------------------- LegacySupport/GraphQl/ResolveInfo.php | 23 --- LegacySupport/GraphQl/ResolverInterface.php | 45 ----- composer.json | 9 +- 8 files changed, 9 insertions(+), 286 deletions(-) delete mode 100644 LegacySupport/GraphQl/Field.php delete mode 100644 LegacySupport/GraphQl/ResolveInfo.php delete mode 100644 LegacySupport/GraphQl/ResolverInterface.php diff --git a/.github/workflows/integration-test.yml b/.github/workflows/integration-test.yml index 78748403fc0..5d5d1e6cfc0 100644 --- a/.github/workflows/integration-test.yml +++ b/.github/workflows/integration-test.yml @@ -7,10 +7,8 @@ jobs: strategy: matrix: include: - - PHP_VERSION: php7-fpm - MAGENTO_VERSION: 2.2.11 - PHP_VERSION: php71-fpm - MAGENTO_VERSION: 2.2.11 + MAGENTO_VERSION: 2.3.1 - PHP_VERSION: php73-fpm MAGENTO_VERSION: 2.3.6-p1 - PHP_VERSION: php73-fpm diff --git a/.github/workflows/phpstan.yml b/.github/workflows/phpstan.yml index 5400fc6d800..cb1689ed1e8 100644 --- a/.github/workflows/phpstan.yml +++ b/.github/workflows/phpstan.yml @@ -8,9 +8,9 @@ jobs: matrix: include: - PHP_VERSION: php71-fpm - MAGENTO_VERSION: 2.3.5-p1 + MAGENTO_VERSION: 2.3.1 - PHP_VERSION: php72-fpm - MAGENTO_VERSION: 2.3.5-p1 + MAGENTO_VERSION: 2.3.6-p1 - PHP_VERSION: php74-fpm MAGENTO_VERSION: 2.4.2 runs-on: ubuntu-latest diff --git a/.github/workflows/setup-di-compile.yml b/.github/workflows/setup-di-compile.yml index 9118b1c28df..f6cb321ce58 100644 --- a/.github/workflows/setup-di-compile.yml +++ b/.github/workflows/setup-di-compile.yml @@ -7,8 +7,8 @@ jobs: strategy: matrix: include: - - PHP_VERSION: php7-fpm - MAGENTO_VERSION: 2.2.11 + - PHP_VERSION: php71-fpm + MAGENTO_VERSION: 2.3.3 - PHP_VERSION: php72-fpm MAGENTO_VERSION: 2.3.6-p1 - PHP_VERSION: php74-fpm diff --git a/.github/workflows/unit-test.yml b/.github/workflows/unit-test.yml index 4be90f8e546..88c206cc4f5 100644 --- a/.github/workflows/unit-test.yml +++ b/.github/workflows/unit-test.yml @@ -6,18 +6,10 @@ jobs: strategy: matrix: include: - - PHP_VERSION: php7-fpm - MAGENTO_VERSION: 2.2.11 - PHP_VERSION: php71-fpm - MAGENTO_VERSION: 2.2.11 - - PHP_VERSION: php71-fpm - MAGENTO_VERSION: 2.3.6-p1 + MAGENTO_VERSION: 2.3.3 - PHP_VERSION: php72-fpm MAGENTO_VERSION: 2.3.6-p1 - - PHP_VERSION: php73-fpm - MAGENTO_VERSION: 2.3.6-p1 - - PHP_VERSION: php73-fpm - MAGENTO_VERSION: 2.4.2 - PHP_VERSION: php74-fpm MAGENTO_VERSION: 2.4.2 runs-on: ubuntu-latest diff --git a/LegacySupport/GraphQl/Field.php b/LegacySupport/GraphQl/Field.php deleted file mode 100644 index 74c13019386..00000000000 --- a/LegacySupport/GraphQl/Field.php +++ /dev/null @@ -1,196 +0,0 @@ -name = $name; - $this->type = $isList ? $itemType : $type; - $this->required = $required; - $this->isList = $isList; - $this->resolver = $resolver; - $this->description = $description; - $this->arguments = $arguments; - $this->cache = $cache; - $this->deprecated = $deprecated; - } - - /** - * Get the field name. - * - * @return string - */ - public function getName(): string - { - return $this->name; - } - - /** - * Get the type's configured name. - * - * @return string - */ - public function getTypeName(): string - { - return $this->type; - } - - /** - * Return true if field is a list of items. False otherwise. - * - * @return bool - */ - public function isList(): bool - { - return $this->isList; - } - - /** - * Return true if the field is required by an input type to be populated. False otherwise. - * - * @return bool - */ - public function isRequired(): bool - { - return $this->required; - } - - /** - * Get the resolver for a given field. If no resolver is specified, return an empty string. - * - * @return string - */ - public function getResolver(): string - { - return $this->resolver; - } - - /** - * Get the list of arguments configured for the field. Return an empty array if no arguments are configured. - * - * @return Argument[] - */ - public function getArguments(): array - { - return $this->arguments; - } - - /** - * Return the human-readable description of the field. - * - * @return string|null - */ - public function getDescription(): string - { - return $this->description; - } - - /** - * Return the cache tag for the field. - * - * @return array|null - */ - public function getCache(): array - { - return $this->cache; - } - - /** - * Return the deprecated annotation for the field - * - * @return array - */ - public function getDeprecated(): array - { - return $this->deprecated; - } - } -} \ No newline at end of file diff --git a/LegacySupport/GraphQl/ResolveInfo.php b/LegacySupport/GraphQl/ResolveInfo.php deleted file mode 100644 index a0b917ec3e2..00000000000 --- a/LegacySupport/GraphQl/ResolveInfo.php +++ /dev/null @@ -1,23 +0,0 @@ -=101.0.0", - "php": ">=7.0", + "magento/framework": ">=102.0.3", + "php": ">=7.1", "ext-json": "*" }, "type": "magento2-module", @@ -56,10 +56,7 @@ ], "autoload": { "files": [ - "registration.php", - "LegacySupport/GraphQl/Field.php", - "LegacySupport/GraphQl/ResolveInfo.php", - "LegacySupport/GraphQl/ResolverInterface.php" + "registration.php" ], "psr-4": { "Mollie\\Payment\\": "" From 038d5f5041a02d62775eaea713e0f9e86ee4154b Mon Sep 17 00:00:00 2001 From: Michiel Gerritsen Date: Mon, 31 May 2021 15:10:15 +0200 Subject: [PATCH 4/6] Require the current version --- .github/workflows/integration-test.yml | 4 ++-- .github/workflows/phpstan.yml | 6 +++--- .github/workflows/setup-di-compile.yml | 2 +- .github/workflows/unit-test.yml | 6 +++--- .../GraphQL/Resolver/Checkout/PaymentTokenTest.php | 1 + 5 files changed, 10 insertions(+), 9 deletions(-) diff --git a/.github/workflows/integration-test.yml b/.github/workflows/integration-test.yml index 5d5d1e6cfc0..c7b919c83a7 100644 --- a/.github/workflows/integration-test.yml +++ b/.github/workflows/integration-test.yml @@ -8,7 +8,7 @@ jobs: matrix: include: - PHP_VERSION: php71-fpm - MAGENTO_VERSION: 2.3.1 + MAGENTO_VERSION: 2.3.3 - PHP_VERSION: php73-fpm MAGENTO_VERSION: 2.3.6-p1 - PHP_VERSION: php73-fpm @@ -23,7 +23,7 @@ jobs: run: PHP_VERSION=${{ matrix.PHP_VERSION }} MAGENTO_VERSION=magento${{ matrix.MAGENTO_VERSION }} docker-compose -f .github/workflows/templates/docker-compose.yml up -d - name: Upload the code into the docker container - run: docker cp $(pwd)/. magento-project-community-edition:/data/extensions && docker exec magento-project-community-edition composer require mollie/magento2:@dev && docker exec magento-project-community-edition bash -c "rm -rf /data/vendor/mollie/magento2 && ln -s /data/extensions /data/vendor/mollie/magento2" + run: docker cp $(pwd) magento-project-community-edition:/data/extensions/ && docker exec magento-project-community-edition composer require mollie/magento2 @dev - name: Enable developer mode run: docker exec magento-project-community-edition php bin/magento deploy:mode:set developer diff --git a/.github/workflows/phpstan.yml b/.github/workflows/phpstan.yml index cb1689ed1e8..59a459b7002 100644 --- a/.github/workflows/phpstan.yml +++ b/.github/workflows/phpstan.yml @@ -7,9 +7,9 @@ jobs: strategy: matrix: include: - - PHP_VERSION: php71-fpm - MAGENTO_VERSION: 2.3.1 - PHP_VERSION: php72-fpm + MAGENTO_VERSION: 2.3.3 + - PHP_VERSION: php73-fpm MAGENTO_VERSION: 2.3.6-p1 - PHP_VERSION: php74-fpm MAGENTO_VERSION: 2.4.2 @@ -24,7 +24,7 @@ jobs: run: docker cp $(pwd) magento-project-community-edition:/data/extensions/ - name: Install the extensions in Magento - run: docker exec magento-project-community-edition composer require mollie/magento2:@dev fooman/phpstan-magento2-magic-methods:0.7.1 + run: docker exec magento-project-community-edition composer require mollie/magento2:@dev fooman/phpstan-magento2-magic-methods:^0.7 - name: Run PHPStan run: docker exec magento-project-community-edition /bin/bash -c "./vendor/bin/phpstan analyse -c /data/extensions/*/phpstan.neon /data/extensions" diff --git a/.github/workflows/setup-di-compile.yml b/.github/workflows/setup-di-compile.yml index f6cb321ce58..e46126bfa45 100644 --- a/.github/workflows/setup-di-compile.yml +++ b/.github/workflows/setup-di-compile.yml @@ -9,7 +9,7 @@ jobs: include: - PHP_VERSION: php71-fpm MAGENTO_VERSION: 2.3.3 - - PHP_VERSION: php72-fpm + - PHP_VERSION: php73-fpm MAGENTO_VERSION: 2.3.6-p1 - PHP_VERSION: php74-fpm MAGENTO_VERSION: 2.4.2 diff --git a/.github/workflows/unit-test.yml b/.github/workflows/unit-test.yml index 88c206cc4f5..b51da8988c2 100644 --- a/.github/workflows/unit-test.yml +++ b/.github/workflows/unit-test.yml @@ -8,7 +8,7 @@ jobs: include: - PHP_VERSION: php71-fpm MAGENTO_VERSION: 2.3.3 - - PHP_VERSION: php72-fpm + - PHP_VERSION: php73-fpm MAGENTO_VERSION: 2.3.6-p1 - PHP_VERSION: php74-fpm MAGENTO_VERSION: 2.4.2 @@ -20,7 +20,7 @@ jobs: run: PHP_VERSION=${{ matrix.PHP_VERSION }} MAGENTO_VERSION=magento${{ matrix.MAGENTO_VERSION }} docker-compose -f .github/workflows/templates/docker-compose.yml up -d - name: Upload the code into the docker container - run: docker cp $(pwd)/. magento-project-community-edition:/data/extensions && docker exec magento-project-community-edition composer require mollie/magento2:@dev && docker exec magento-project-community-edition bash -c "rm -rf /data/vendor/mollie/magento2 && ln -s /data/extensions /data/vendor/mollie/magento2" + run: docker cp $(pwd) magento-project-community-edition:/data/extensions/ && docker exec magento-project-community-edition composer require mollie/magento2 @dev - name: Run tests - run: docker exec magento-project-community-edition bash -c "vendor/bin/phpunit extensions/Test/Unit" + run: docker exec magento-project-community-edition bash -c "vendor/bin/phpunit extensions/mollie-magento2/Test/Unit" diff --git a/Test/Integration/GraphQL/Resolver/Checkout/PaymentTokenTest.php b/Test/Integration/GraphQL/Resolver/Checkout/PaymentTokenTest.php index 93cb26c1ef5..ab558db20a1 100644 --- a/Test/Integration/GraphQL/Resolver/Checkout/PaymentTokenTest.php +++ b/Test/Integration/GraphQL/Resolver/Checkout/PaymentTokenTest.php @@ -81,6 +81,7 @@ public function callResolve(PaymentToken $instance, $value = null, $args = null) 'rootValue' => '', 'operation' => null, 'variableValues' => [], + 'values' => [], ]), $value, $args From dd234e84f1209f20c33293cdb4a75f8300343076 Mon Sep 17 00:00:00 2001 From: Marvin-Magmodules Date: Tue, 1 Jun 2021 11:41:32 +0200 Subject: [PATCH 5/6] Version bump --- composer.json | 2 +- etc/config.xml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/composer.json b/composer.json index d2a018a7fbc..2020314c012 100644 --- a/composer.json +++ b/composer.json @@ -1,7 +1,7 @@ { "name": "mollie/magento2", "description": "Mollie Payment Module for Magento 2", - "version": "1.25.2", + "version": "1.26.0", "keywords": [ "mollie", "payment", diff --git a/etc/config.xml b/etc/config.xml index 20abce72a05..4ccc03cb48a 100644 --- a/etc/config.xml +++ b/etc/config.xml @@ -3,7 +3,7 @@ - v1.25.2 + v1.26.0 0 0 test From d6388077793989ed251edb4db73201865f97e736 Mon Sep 17 00:00:00 2001 From: Michiel Gerritsen Date: Tue, 1 Jun 2021 11:58:32 +0200 Subject: [PATCH 6/6] Use wildcard for the extension directory --- .github/workflows/unit-test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/unit-test.yml b/.github/workflows/unit-test.yml index b51da8988c2..9acc234d4c7 100644 --- a/.github/workflows/unit-test.yml +++ b/.github/workflows/unit-test.yml @@ -23,4 +23,4 @@ jobs: run: docker cp $(pwd) magento-project-community-edition:/data/extensions/ && docker exec magento-project-community-edition composer require mollie/magento2 @dev - name: Run tests - run: docker exec magento-project-community-edition bash -c "vendor/bin/phpunit extensions/mollie-magento2/Test/Unit" + run: docker exec magento-project-community-edition bash -c "vendor/bin/phpunit extensions/*/Test/Unit"