mollie / magento2

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

GraphQL: cannot restore cart after payment failed / cancelled: The cart isn't active. #487

Closed joggienl closed 2 years ago

joggienl commented 2 years ago

Describe the bug In followup of #484 I am creating this bug report. At least, at this point it seems a bug. After a not successful payment (cancelled, failed, back button in the browser) we can't reactive the cart with the mollieRestoreCart mutation. The GraphQL api then returns an error with "The cart isn't active." which is obviously true, but the whole reason for using mollieRestoreCart was to re-active the cart.

Please let me know if there is something wrong in the way I am trying to accomplish my expected behaviour. Thanks!

Used versions

To Reproduce I've included some graphql queries / mutations that show what happens. Everything is executed from the perspective of a guest customer.

1. Create cart

mutation {
  createEmptyCart
}

# take note of the cart_id in the result!

2. Add a product to cart

Make sure to substitute XXX with the correct values of your own environment:

mutation {
  addProductsToCart(
    cartId: "XXX"
    cartItems: [
      {
        quantity: 1
        sku: "XXX"
        }
    ]
  ) {
    cart {
      total_quantity
    }
  }
}

3. Set some details on cart

Make sure to substitute XXX with the correct values of your own environment:

mutation {  
  # Guest email
  setGuestEmailOnCart(
    input: {
      cart_id: "XXX",
      email: "XXX"
    }
  ) {
    cart {
      total_quantity
    }
  }

  # Shipping and billing address
  setBillingAddressOnCart(
    input: {
      cart_id: "XXX"
      billing_address: {
        use_for_shipping: true
        address: {
          firstname: "XXX"
          lastname: "XXX"
          telephone: "XXX"
          street: ["XXX", "XXX", "XXX"]
           city: "XXX"
           country_code: "XXX"
           postcode: "XXX"
        }
      }
    }
  ) {
    cart {
      total_quantity
    }
  }
}

4. Set shipment and payment option to cart

Make sure to substitute XXX with the correct values of your own environment:

  # Set some shipment method on cart
  setShippingMethodsOnCart(
    input: {
      cart_id: "XXX"
      shipping_methods: [
        {
          carrier_code: "XXX"
          method_code: "XXX"
        }
      ]
    }
  ) {
    cart {
      total_quantity
    }
  }

  # Set mollie payment method on cart
  setPaymentMethodOnCart(
    input: {
      cart_id: "XXX"
      payment_method: {
        code: "mollie_methods_ideal"
        mollie_selected_issuer: "ideal_ABNANL2A"
      }
    }
  ) {
    cart {
      total_quantity
    }
  }

5. Place order and cancel payment

Make sure to substitute XXX with the correct values of your own environment:

mutation {
  # Place order
  placeOrder (
    input: {
      cart_id: "XXX"
    }
  ) {
    order {
      order_number
      mollie_redirect_url
      mollie_payment_token
    }
  }
}

At this point we should have successfully placed an order. Use the redirect url from the resulting JSON and from the mollie screen cancel the order.

6. Restore cart

Make sure to substitute XXX with the correct values of your own environment:

mutation {
  mollieRestoreCart(
    input: {
      cart_id: "XXX"
    }
  ) {
    cart {
      total_quantity
    }
  }
}

At this point you will get the error:

{
  "errors": [
    {
      "message": "The cart isn't active.",
      "extensions": {
        "category": "graphql-no-such-entity"
      },
      "locations": [
        {
          "line": 18,
          "column": 3
        }
      ],
      "path": [
        "mollieRestoreCart"
      ]
    }
  ],
  "data": {
    "mollieRestoreCart": null
  }
}

Expected behavior When using the mollieRestoreCart on a cart_id that was previously inactivated (due to failed/canceled payment) the cart_id should be "active" again with all the previous details on there.

Actual behavior When calling mollieRestoreCart the following error gets back from magento:

{
  "errors": [
    {
      "message": "The cart isn't active.",
      "extensions": {
        "category": "graphql-no-such-entity"
      },
      "locations": [
        {
          "line": 2,
          "column": 3
        }
      ],
      "path": [
        "mollieRestoreCart"
      ]
    }
  ],
  "data": {
    "mollieRestoreCart": null
  }
}

Screenshots No screenshots.

Additional context This is a follow up from issue #484

Frank-Magmodules commented 2 years ago

HI @joggienl ,

Thank you for opening this issue, we are happy to share that we've just released the new 2.6.0 version where we have covered this. Thank you for the detailed issue report. 

We are closing this issue now but please feel free to reopen the issue if this still occurs.

joggienl commented 2 years ago

Thanks for the update @Frank-Magmodules!

We are going to check the new version!