diff --git a/.github/workflows/integration-test.yml b/.github/workflows/integration-test.yml index 78748403fc0..c7b919c83a7 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.3 - PHP_VERSION: php73-fpm MAGENTO_VERSION: 2.3.6-p1 - PHP_VERSION: php73-fpm @@ -25,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 5400fc6d800..59a459b7002 100644 --- a/.github/workflows/phpstan.yml +++ b/.github/workflows/phpstan.yml @@ -7,10 +7,10 @@ jobs: strategy: matrix: include: - - PHP_VERSION: php71-fpm - MAGENTO_VERSION: 2.3.5-p1 - PHP_VERSION: php72-fpm - MAGENTO_VERSION: 2.3.5-p1 + MAGENTO_VERSION: 2.3.3 + - PHP_VERSION: php73-fpm + MAGENTO_VERSION: 2.3.6-p1 - PHP_VERSION: php74-fpm MAGENTO_VERSION: 2.4.2 runs-on: ubuntu-latest @@ -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 9118b1c28df..e46126bfa45 100644 --- a/.github/workflows/setup-di-compile.yml +++ b/.github/workflows/setup-di-compile.yml @@ -7,9 +7,9 @@ jobs: strategy: matrix: include: - - PHP_VERSION: php7-fpm - MAGENTO_VERSION: 2.2.11 - - PHP_VERSION: php72-fpm + - PHP_VERSION: php71-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 diff --git a/.github/workflows/unit-test.yml b/.github/workflows/unit-test.yml index 4be90f8e546..9acc234d4c7 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 - - PHP_VERSION: php72-fpm - MAGENTO_VERSION: 2.3.6-p1 + MAGENTO_VERSION: 2.3.3 - 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 @@ -28,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/*/Test/Unit" 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/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/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 @@ -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} */ 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 diff --git a/composer.json b/composer.json index d6617240fcb..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", @@ -45,8 +45,8 @@ ], "require": { "mollie/mollie-api-php": "^2.1", - "magento/framework": ">=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\\": "" 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 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