mollie / magento2

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

[PWA Question] Clicking back button browser results in empty cart #730

Closed vacla closed 4 months ago

vacla commented 5 months ago

Describe the bug When clicking the back button of the browser when asked to fill payment details on mollie website, we get an empty cart.

Used versions

To Reproduce Steps to reproduce the behavior:

  1. Add item to cart
  2. Fill all details in Magento
  3. Click to pay with Bancontact
  4. You get redirected with webhook to mollie
  5. Click on back button of the browser

Expected behavior Your cart will be reactivated so you can continue again.

Actual behavior Your cart is emptied, and you need to start over fully.

Screenshots https://gyazo.com/89525e9933c902f6c9f785b35baab989

Additional context Response message from Mollie:

{
  "resource": "payment",
  "id": "tr_mMoxxxxxx",
  "mode": "test",
  "amount": {
    "value": "25.64",
    "currency": "EUR"
  },
  "settlementAmount": {
    "value": "25.64",
    "currency": "EUR"
  },
  "amountRefunded": null,
  "amountRemaining": null,
  "amountChargedBack": null,
  "description": "STG000180298",
  "method": "bancontact",
  "status": "open",
  "createdAt": "2024-01-22T10:39:08+00:00",
  "paidAt": null,
  "canceledAt": null,
  "expiresAt": "2024-01-22T11:39:08+00:00",
  "failedAt": null,
  "dueDate": null,
  "billingEmail": null,
  "profileId": "pfl_xxxxxxxxxx",
  "sequenceType": "oneoff",
  "redirectUrl": "https://www.xxxxxxxxx.xxxxxx.be/xxxxx_checkout/checkout/success?order_hash=MDozOjJqL3RkTmNudTVmcWNLQkhhxxxxxxxxxaVBZODdiRThCMm9Eem9EUEgvcmc9PQ==&payment_token=h2K0RkkNxxxxxxlAF0xxxxxxxxar1?order_id=197890&payment_token=h2K0RkkNsO6sLQflAF0nxxxxxxxxar1&utm_nooverride=1",
  "cancelUrl": null,
  "webhookUrl": "https://www.xxxxxxxxx.xxxxxx.be/nl/mollie/checkout/webhook/?isAjax=1&orderId[]=MDozOjczUmx1bW1MK01VZVpLa2hxb1BaL3xxxxxxxxxVUM3RKKzd6VEllWjNwaUE9PQ==",
  "mandateId": null,
  "subscriptionId": null,
  "orderId": null,
  "settlementId": null,
  "locale": null,
  "metadata": {
    "order_id": "197890",
    "store_id": "1",
    "payment_token": "h2K0RkkNsO6sLQflAF0nxxxxxxxxar1"
  },
  "details": null,
  "restrictPaymentMethodsToCountry": null,
  "_links": {
    "self": {
      "href": "https://api.mollie.com/v2/payments/tr_mMoxxxxxx",
      "type": "application/hal+json"
    },
    "checkout": {
      "href": "https://www.mollie.com/checkout/test-mode?method=mistercash&token=6.qlllwr",
      "type": "text/html"
    },
    "dashboard": {
      "href": "https://my.mollie.com/dashboard/org_12xxxxx8/payments/tr_mMoxxxxxx",
      "type": "text/html"
    },
    "documentation": {
      "href": "https://docs.mollie.com/reference/v2/payments-api/create-payment",
      "type": "text/html"
    }
  },
  "_embedded": null,
  "isCancelable": false,
  "amountCaptured": null,
  "captureMode": null,
  "captureDelay": null,
  "captureBefore": null,
  "applicationFee": null,
  "routing": null,
  "authorizedAt": null,
  "expiredAt": null,
  "customerId": null,
  "countryCode": null
} [] []

After 1 hour the payment got canceled

Frank-Magmodules commented 5 months ago

Hi There @vacla , Thank you for opening this issue. In the standard checkouts, we have an action available that re-actives the quote. As you are using a PWA, you have to trigger this action manually. Luckily we have a GraphQL endpoint available for this:

mutation($cartId: String!) {
  mollieRestoreCart(input: {
      cart_id: $cartId
  }) {
    cart
  }
}

More information can be found here: https://github.com/mollie/magento2/wiki/GraphQL-integration#resetting-the-cart

Let me know if this solves your "issue". Thanks!

Frank-Magmodules commented 5 months ago

Hello @vacla,

Did the previous response assist you with this issue?

vacla commented 5 months ago

Hey @Frank-Magmodules ,

Our frontend dev is looking into it, it can take another week before i might know if it worked out.

vacla commented 4 months ago

I'm able to confirm it worked, thanks a lot.

Frank-Magmodules commented 4 months ago

Great @vacla , thank you for confirming, have a great day!