Skip to content
This repository has been archived by the owner on Feb 23, 2024. It is now read-only.

Can't place an order with Cash of Delivery if it's conditional #9074

Closed
senadir opened this issue Apr 17, 2023 · 5 comments · Fixed by #9375
Closed

Can't place an order with Cash of Delivery if it's conditional #9074

senadir opened this issue Apr 17, 2023 · 5 comments · Fixed by #9375
Assignees
Labels
block: checkout Issues related to the checkout block. type: bug The issue/PR concerns a confirmed bug. type: cooldown Things that are queued for a cooldown period (assists with planning).

Comments

@senadir
Copy link
Member

senadir commented Apr 17, 2023

Recent PR #8441 changed how we define Checkout payment_method schema for enabled payment methods to available ones to checkout with.

This caused an issue with conditional payment methods like Cash on Delivery which aren't available unless certain conditions are met like selected shipping method, which is only available with a session, but schema generation and validation is sessionless.

Steps to reproduce

  • Enable COD and limit it to certain shipping methods.
  • Enable another payment method.
  • Go to Checkout, try checking out with COD.
  • You will get an error with payment_method isn't $other_payment_methods
@senadir senadir added type: bug The issue/PR concerns a confirmed bug. block: checkout Issues related to the checkout block. labels Apr 17, 2023
@senadir
Copy link
Member Author

senadir commented Apr 17, 2023

This issue only seems to happen if you have more than 1 payment method active, if COD is the only one enabled, enum is an empty array and that skips checking all together?

cc @mikejolley

@mikejolley
Copy link
Member

cc @ralucaStan I've marked this as cooldown so it can be picked up.

@mikejolley mikejolley added the type: cooldown Things that are queued for a cooldown period (assists with planning). label Apr 18, 2023
@mikejolley mikejolley self-assigned this Apr 20, 2023
@mikejolley
Copy link
Member

@senadir Gonna need you to come back and help replicate this one. I tested a few combinations here; multiple gateways active, various rules (require flat rate, require pickup). When COD was available on checkout my orders went through ok.

You're incorrect about it being stateless afaik. The enum uses get_available_payment_gateways and this will refer to the current session to determine which gateways are available. So if you have a valid cart, and your session is up to date, the request to the server will succeed.

Can you take another look?

@senadir
Copy link
Member Author

senadir commented Apr 24, 2023

It seems the error only surfaces if Accept COD if the order is virtual is off.

You're incorrect about it being stateless afaik. The enum uses get_available_payment_gateways and this will refer to the current session to determine which gateways are available. So if you have a valid cart, and your session is up to date, the request to the server will succeed.

This might not always use a session, hitting OPTIONS endpoint will use session, this is where I found the COD to be missing.

is Schema validation happening before session is loaded?

@mikejolley
Copy link
Member

This came up in zendesk—I'll add it to my list to tackle before next release.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
block: checkout Issues related to the checkout block. type: bug The issue/PR concerns a confirmed bug. type: cooldown Things that are queued for a cooldown period (assists with planning).
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants