Skip to content

BrainTree: remove the card data from the session once the payment uses it - #1090

Merged
KrzysztofPajak merged 1 commit into
developfrom
fix/braintree-card-session
Nov 23, 2026
Merged

KrzysztofPajak merged 1 commit into
developfrom
fix/braintree-card-session

Conversation

@KrzysztofPajak

Copy link
Copy Markdown
Member

Without 3D Secure the BrainTree payment form posts the card number, expiry date and security code to the store. The plugin kept them in the session between the payment info step and placing the order, and nothing removed them afterwards, so they stayed for the rest of the session.

Changes

  • BrainTreePaymentProvider.ProcessPayment: removes the card keys and the 3D Secure nonce from the session right after reading them, before the gateway is called, so they go whether the payment succeeds or fails.

Notes

  • A customer whose payment fails enters the card again on the payment info step instead of retrying with the stored one.
  • A checkout abandoned after the payment info step still leaves the card in the session until it expires. With 3D Secure on, the card fields are BrainTree hosted fields and only a nonce reaches the store; making the plain form use hosted fields as well would remove the card from the store entirely, and is left for a separate change.

Tests

  • BrainTreePaymentProviderTests.ProcessPayment_RemovesCardDataFromSession_EvenWhenPaymentFails (new, fails without the change).
  • Grand.Modules.Tests (462) pass.

…s it

Without 3D Secure the payment form posts the card number, expiry date and security code, and the plugin keeps them in the session until the order is placed. Nothing removed them afterwards, so they stayed for the rest of the session.

ProcessPayment now removes the card keys (and the 3D Secure nonce) as soon as it has read them, before the gateway is called, so they go whether the payment succeeds or fails.
Copilot AI balanced review requested due to automatic review settings November 22, 2026 19:13

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

@KrzysztofPajak
KrzysztofPajak merged commit 7af05f1 into develop Nov 23, 2026
9 checks passed
@KrzysztofPajak
KrzysztofPajak deleted the fix/braintree-card-session branch November 25, 2026 09:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants