Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot place order at checkout with Braintree and 3DS enabled using billing addresses without region set #34204

Closed
4 tasks
dphilipps opened this issue Sep 30, 2021 · 20 comments
Labels
Area: Payments Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed Priority: P1 Once P0 defects have been fixed, a defect having this priority is the next candidate for fixing. Progress: done Reported on 2.4.3 Indicates original Magento version for the Issue report. Reproduced on 2.4.x The issue has been reproduced on latest 2.4-develop branch

Comments

@dphilipps
Copy link

dphilipps commented Sep 30, 2021

Preconditions (*)

  1. Magento 2.4.3
  2. Braintree enabled
  3. Card Payments enabled
  4. 3D Secure enabled
  5. Use billing address without state/region set

Steps to reproduce (*)

  1. Enable Braintree in Sandbox mode.
  2. Sandbox credentials:
    PUBLIC: hpbfzdqypph3njjq
    PRIVATE: 4de9983821adb24738636e502c557248
    MERCHANTID: vq82jrtv65hsgjbk
  3. Enable Braintree Card Payments
  4. Enable Braintree 3D Secure
  5. Sign in to front end as demo user
  6. Under account edit default address and ensure set as default shipping and billing
  7. Country: United Kingdom
  8. Street address: 123 Somewhere
  9. City: London
  10. State/Province: [MUST BE LEFT EMPTY]
  11. Postcode: SE3 9SZ
  12. Make up any other address details
  13. Save address
  14. Add a product to basket and proceed to payment step
  15. Select credit card
  16. Enter card details:
    4242 4242 4242 4242
    12/23
    123
  17. Click 'Place Order'

Expected result (*)

  1. Order confirmation is displayed

Actual result (*)

  1. Cannot proceed past payment screen and cannot place order. Button is non responsive and no errors are displayed on screen. Console messages below:

image

Note: If 3DS is disabled, then the same address (above) will complete OK. Likewise, if a state/region is set it will too.


Please provide Severity assessment for the Issue as Reporter. This information will help during Confirmation and Issue triage processes.

  • [ X] Severity: S0 - Affects critical data or functionality and leaves users without workaround.
  • Severity: S1 - Affects critical data or functionality and forces users to employ a workaround.
  • Severity: S2 - Affects non-critical data or functionality and forces users to employ a workaround.
  • Severity: S3 - Affects non-critical data or functionality and does not force users to employ a workaround.
  • Severity: S4 - Affects aesthetics, professional look and feel, “quality” or “usability”.

3DS is vital for processing credit card payments as is a regulatory requirement in some jurisdictions and some processors do not approve payments without, therefore disabling it is not a work around. UK addresses which typically do not have state or region set will not be able to place orders with 3DS enabled.

@m2-assistant
Copy link

m2-assistant bot commented Sep 30, 2021

Hi @dphilipps. Thank you for your report.
To help us process this issue please make sure that you provided the following information:

  • Summary of the issue
  • Information on your environment
  • Steps to reproduce
  • Expected and actual results

Please make sure that the issue is reproducible on the vanilla Magento instance following Steps to reproduce. To deploy vanilla Magento instance on our environment, please, add a comment to the issue:

@magento give me 2.4-develop instance - upcoming 2.4.x release

For more details, please, review the Magento Contributor Assistant documentation.

Please, add a comment to assign the issue: @magento I am working on this


⚠️ According to the Magento Contribution requirements, all issues must go through the Community Contributions Triage process. Community Contributions Triage is a public meeting.

🕙 You can find the schedule on the Magento Community Calendar page.

📞 The triage of issues happens in the queue order. If you want to speed up the delivery of your contribution, please join the Community Contributions Triage session to discuss the appropriate ticket.

🎥 You can find the recording of the previous Community Contributions Triage on the Magento Youtube Channel

✏️ Feel free to post questions/proposals/feedback related to the Community Contributions Triage process to the corresponding Slack Channel

@dphilipps
Copy link
Author

@magento give me 2.4-develop instance

@magento-deployment-service
Copy link

Hi @dphilipps. Thank you for your request. I'm working on Magento instance for you.

@dphilipps dphilipps changed the title Checkout cannot place order with Braintree and 3DS enabled using billing addresses without region set Cannot place order at checkout with Braintree and 3DS enabled using billing addresses without region set Sep 30, 2021
@dphilipps
Copy link
Author

Hi @engcom-November
How do i get an instance deployed with Braintree included in the build? Even with country set in payment methods config, it does not appear.

Many thanks
Dave

@dphilipps
Copy link
Author

I have verified these steps on a fresh composer install of M2.4.3

@dphilipps
Copy link
Author

What do I need to add to this ticket to get it to be triaged @magento/engcom-team-members? This is a serious checkout issue in the latest version of Magento using a mainstream payment gateway?

@nicholasscottfish
Copy link

nicholasscottfish commented Oct 22, 2021

Is there any update on this, we are also experiencing the same issue. This is a critical bug and needs addressing, happy to assist with a fix if required.

@dphilipps did you happen to find a workaround? Disabling 3DS is a no-go for legal reasons, yet making the state field required is a UX problem.

@nicholasscottfish
Copy link

nicholasscottfish commented Oct 22, 2021

@dphilipps For all those who come across this issue, I have created a patch file, attached.

ISSUE-34204__PayPal-Braintree-Validation.patch.zip

diff --git a/view/frontend/web/js/view/payment/3d-secure.js b/view/frontend/web/js/view/payment/3d-secure.js
index 864d5e53..ef832923 100644
--- a/view/frontend/web/js/view/payment/3d-secure.js
+++ b/view/frontend/web/js/view/payment/3d-secure.js
@@ -55,7 +55,7 @@ define([
                 totalAmount = parseFloat(quote.totals()['base_grand_total']).toFixed(2),
                 billingAddress = quote.billingAddress();

-            if (billingAddress.regionCode !== undefined && billingAddress.regionCode.length > 2) {
+            if (billingAddress.regionCode != null && billingAddress.regionCode.length > 2) {
                 billingAddress.regionCode = undefined;
             }

This patch file updates the validation to check for null, which naturally covers both 'undefined and null', thus bypassing the 'cannot read properties of null' error when reading the length in the case a region is not set.

I have created a PR on the Braintree repo, is this the correct place for it? If I need to raise a PR on a different repo please may somebody assign the issue to me and point me in the right direction.

genecommerce/module-braintree-magento2#182

I would question the original code as it seems a bit of a hack having to set regionCode to undefined, a possible workaround for a bug in the system at Braintree's end?

@dphilipps
Copy link
Author

Hi @nicholasscottfish
Agree this is a nasty one - checkout just freezes. In the end I contacted Gene directly through their Braintree Magento support channel. They got back to me with a patch yesterday but I haven't had a chance to test it yet. I'll post it here. Thanks for your patch BTW.

@dphilipps
Copy link
Author

dphilipps commented Oct 22, 2021

Patch supplied by Gene support directly in response to this issue, however I have not tested it yet.

when region-code is not mandatory(for Magento 2.4.3).zip

@nicholasscottfish
Copy link

nicholasscottfish commented Oct 22, 2021

Hi @dphilipps, the patch I posted has been tested and fixes the issue, however, looking at the patch they supplied it is fixing the same lines of code but is slightly different in that they still set regionCode as undefined if it was null, possibly what needs to happen.

I will get in touch to find out why that is necessary.

Thanks for sharing!

@IanFiretoys
Copy link

worth noting that while this seems to only occur using saved addresses for logged in users with a blank region, freshly entered ones work fine. (it was mentioned to save the address in the reproduction steps, but not explicitly anywhere else in the body)

also someone should include the JS error in this issue as text somewhere so it's not so hard for anyone else with the same issue to find. screenshots aren't searchable

hosted-fields.min.js:1 Error in callback function
hosted-fields.min.js:1 TypeError: Cannot read properties of null (reading 'length')
    at Object.validate (3d-secure.js:1)
    at validator-handler.js:1
    at Function.map (jquery.js:2)
    at Object.validate (validator-handler.js:1)
    at UiClass.handleNonce (cc-form.js:1)
    at UiClass.onPaymentMethodReceived (cc-form.js:1)
    at Object.<anonymous> (adapter.js:1)
    at hosted-fields.min.js:1

you're welcome, frantic googlers

anyway, thanks to @dphilipps for logging this, and @nicholasscottfish for the fix, this has been a particularly nasty one to root out.

@nicholasscottfish
Copy link

Patch supplied by Gene support directly in response to this issue, however I have not tested it yet.

when region-code is not mandatory(for Magento 2.4.3).zip

I have updated my patch as it had a strict type check on null when it needed to be !=, to be safe I would use the official patch provided by @dphilipps as I have tested and this fixes the bug.

@engcom-Hotel engcom-Hotel self-assigned this Nov 22, 2021
@m2-assistant
Copy link

m2-assistant bot commented Nov 22, 2021

Hi @engcom-Hotel. Thank you for working on this issue.
In order to make sure that issue has enough information and ready for development, please read and check the following instruction: 👇

  • 1. Verify that issue has all the required information. (Preconditions, Steps to reproduce, Expected result, Actual result).

    DetailsIf the issue has a valid description, the label Issue: Format is valid will be added to the issue automatically. Please, edit issue description if needed, until label Issue: Format is valid appears.

  • 2. Verify that issue has a meaningful description and provides enough information to reproduce the issue. If the report is valid, add Issue: Clear Description label to the issue by yourself.

  • 3. Add Component: XXXXX label(s) to the ticket, indicating the components it may be related to.

  • 4. Verify that the issue is reproducible on 2.4-develop branch

    Details- Add the comment @magento give me 2.4-develop instance to deploy test instance on Magento infrastructure.
    - If the issue is reproducible on 2.4-develop branch, please, add the label Reproduced on 2.4.x.
    - If the issue is not reproducible, add your comment that issue is not reproducible and close the issue and stop verification process here!

  • 5. Add label Issue: Confirmed once verification is complete.

  • 6. Make sure that automatic system confirms that report has been added to the backlog.

@engcom-Hotel
Copy link
Contributor

engcom-Hotel commented Nov 23, 2021

Hi @dphilipps,

Thank you for reporting the issue.

We followed your steps and were able to reproduce it on Magento 2.4-develop/2.4.3/2.4.3-p1. Hence confirming the issue.

Thank you

@engcom-Hotel engcom-Hotel added Area: Payments Reported on 2.4.3 Indicates original Magento version for the Issue report. Reproduced on 2.4.x The issue has been reproduced on latest 2.4-develop branch Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed labels Nov 23, 2021
@github-jira-sync-bot
Copy link

✅ Jira issue https://jira.corp.magento.com/browse/AC-1830 is successfully created for this GitHub issue.

@m2-assistant
Copy link

m2-assistant bot commented Nov 23, 2021

✅ Confirmed by @engcom-Hotel. Thank you for verifying the issue.
Issue Available: @engcom-Hotel, You will be automatically unassigned. Contributors/Maintainers can claim this issue to continue. To reclaim and continue work, reassign the ticket to yourself.

@engcom-Alfa engcom-Alfa added the Priority: P1 Once P0 defects have been fixed, a defect having this priority is the next candidate for fixing. label Nov 23, 2021
@engcom-Hotel
Copy link
Contributor

Hello @dphilipps,

Fix for the issue is added to the 2.4.4-release of Braintree package.

With 'paypal/module-braintree' version 4.3.0 issue will be fixed.

Below is the patch which is added to 4.3.0 of 'paypal/module-braintree'

if (billingAddress.regionCode == null)

{ billingAddress.regionCode = undefined; }

We are closing this issue.

Thanks

@dphilipps
Copy link
Author

Thank you @engcom-Hotel

engcom-Hotel

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: Payments Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed Priority: P1 Once P0 defects have been fixed, a defect having this priority is the next candidate for fixing. Progress: done Reported on 2.4.3 Indicates original Magento version for the Issue report. Reproduced on 2.4.x The issue has been reproduced on latest 2.4-develop branch
Projects
Archived in project
Development

No branches or pull requests

6 participants