Skip to content

Send one payment method update per order at a time - #945

Merged
acasazza merged 1 commit into
mainfrom
fix/944-payment-method-double-patch
Nov 20, 2026
Merged

acasazza merged 1 commit into
mainfrom
fix/944-payment-method-double-patch

Conversation

@malessani

@malessani malessani commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

Closes #944

A click on a payment method label reaches a clickable <PaymentMethod> twice (label click, then the browser's click on the linked radio), and a click can land while the single-method auto-select is still setting the method. Both paths sent the same payment_method order update twice at once.

  • setPaymentMethod (in PaymentMethodReducer) now handles one update per order at a time, next to the existing setPaymentSource request coalescing: a call for the method already being set joins that request; a call for another method waits for it and goes out next, so the order keeps the last selection. Entries are removed once settled.
  • This covers every caller (clickable container, radio button, auto-select, express payments, PaymentMethodsContainer) and survives the component remounting, with no change to <PaymentMethod> itself.
  • Specs: reducer-level (same method joined, another method queued and kept, sequential calls update again, other orders unaffected) and component-level through the real context (label click and click during auto-select each send one update).

@netlify

netlify Bot commented Nov 20, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for commercelayer-react-components ready!

Name Link
🔨 Latest commit 40af761
🔍 Latest deploy log https://app.netlify.com/projects/commercelayer-react-components/deploys/6b0073d60025cb6168b2b58c
😎 Deploy Preview https://deploy-preview-945--commercelayer-react-components.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

A click on a payment method label reaches a clickable <PaymentMethod>
twice, and a click can land while the single-method auto-select is
still setting the method, so the same order update went out twice at
once. setPaymentMethod now joins a call for the method already being
set and queues a call for another method behind the one in flight, so
the order keeps the last selection.
@malessani
malessani force-pushed the fix/944-payment-method-double-patch branch from 602e6e6 to 40af761 Compare November 20, 2026 16:22
@malessani malessani changed the title Set the payment method once per selection Send one payment method update per order at a time Nov 20, 2026
@pkg-pr-new

pkg-pr-new Bot commented Nov 20, 2026

Copy link
Copy Markdown
npm i https://pkg.pr.new/@commercelayer/core-components@945
npm i https://pkg.pr.new/@commercelayer/react-components@945
npm i https://pkg.pr.new/@commercelayer/react-hooks-components@945

commit: 40af761

@acasazza acasazza left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well done

@malessani malessani self-assigned this Nov 20, 2026
@malessani malessani added the bug Something isn't working label Nov 20, 2026
@acasazza
acasazza merged commit 685cac5 into main Nov 20, 2026
8 checks passed
@acasazza
acasazza deleted the fix/944-payment-method-double-patch branch November 20, 2026 17:10
@acasazza acasazza mentioned this pull request Nov 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Clicking a payment method label sends the payment method PATCH twice

2 participants