mollie / magento2

Mollie Payments for Magento 2
https://www.mollie.com
Other
98 stars 50 forks source link

GraphQL orders missing redirect URL in placeOrder response #686

Closed DuckThom closed 9 months ago

DuckThom commented 10 months ago

Describe the bug After updating from 2.27.0 to 2.30.1 we noticed that we're no longer receiving the mollie_redirect_url in the placeOrder mutation.

Used versions

To Reproduce Steps to reproduce the behavior:

  1. Place an order via the placeOrder mutation in GraphQL, requesting the mollie_redirect_url field
  2. The field will be null

Expected behavior The redirect url should be filled

Actual behavior Field stays null

Additional context It looks like this is caused by the addition of the OrderLockService in https://github.com/mollie/magento2/blob/master/Model/Mollie.php#L259

When using GraphQL, the resolver for the mollie_redirect_url field will call $this->mollie->startTransaction($order); here:

https://github.com/mollie/magento2/blob/53548cf1952d3870e1b89f72c2c40d5a406cc3e2/GraphQL/Resolver/Checkout/PlaceOrderAndReturnRedirectUrl.php#L62

Previously, in version 2.27.0, the passed Order instance $order would be re-used within all the code called by startTransaction, making sure that the payment data was added properly. However, due to the addition of the order lock service, this is no longer the case and the $order instance will never receive the new payment data.

A quick, and somewhat dirty, fix would be to add an additional $order = $this->getOrderByIncrementId($value['order_id']); after calling startTransaction to make sure the latest order data is loaded.

    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 (strstr($order->getPayment()->getMethod(), 'mollie_methods') === false) {
            return null;
        }

        if ($order->getPayment()->getAdditionalInformation('checkout_url')) {
            return $order->getPayment()->getAdditionalInformation('checkout_url');
        }

        $this->mollie->startTransaction($order);

        /** This line fixes the missing redirect url */
        $order = $this->getOrderByIncrementId($value['order_id']);

        return $order->getPayment()->getAdditionalInformation('checkout_url');
    }
Frank-Magmodules commented 10 months ago

Thank you, @DuckThom, for the concise description. Much appreciated. We'll return with more information on this matter shortly.

Swahjak commented 10 months ago

Not a 100% sure if this is related, but I think we're experiencing a similar issues with "regular" payment links on 2.30.1 with Magento 2.4.6-p2. The payment link is never persisted to the payment (sales_order_payment, although being set in Orders.php). Still looking into what is actually happening but it seems like during the transaction it is saved with everything there, but at a later stage a different reference is saved without the data.

Frank-Magmodules commented 10 months ago

Hello @Swahjak, it seems like you referring to another issue, but rest assured that we are aware of this one and a solution will be included in the upcoming release.

Swahjak commented 10 months ago

He @Frank-Magmodules is there an open issue for this? Also what is your timeline for a next release? Not to rush you, but that way I can decide to take action myself or wait.

Frank-Magmodules commented 10 months ago

Hello @Swahjak, the issue is not currently accessible to the public, but it's likely that the upcoming release will be available next week!

Frank-Magmodules commented 9 months ago

Hello @Swahjak, we've recently launched a new version (v2.31.0) in which we have identified and resolved the issue you mentioned. I'm closing this matter for now, but please don't hesitate to reopen it if you have any lingering questions or if the issue hasn't been completely resolved to your satisfaction.