Problem/Motivation

Unable to submit Braintree payment locally, getting "Missing payment method nonce" in database log and "We encountered an unexpected error processing your payment method. Please try again later." displayed on the frontend of the checkout review page.

Steps to reproduce

  1. Set the Braintree gateway to sandbox/test mode
  2. Enable 3D secure
  3. Purchase a product
  4. Use a test card - 4000000000001091 - 10/23

Debugging steps tried so far

The issue could lie with `commerce_braintree/src/Plugin/Commerce/CheckoutPane/Braintree3DSReview.php`
I can see the nonce being set here and the pane array looks like this. A vardump of that array looks like this.

I cannot see the nonce in the checkout review pane on the frontend.

Array
(
    [#id] => edit-braintree-3ds-review
    [#parents] => Array
        (
            [0] => braintree_3ds_review
        )

    [#theme] => commerce_checkout_pane
    [#type] => container
    [#title] => Drupal\Core\StringTranslation\TranslatableMarkup Object
        (
            [translatedMarkup:protected] => 
            [options:protected] => Array
                (
                )

            [stringTranslation:protected] => 
            [string:protected] => Braintree 3DS review
            [arguments:protected] => Array
                (
                )

        )

    [#attributes] => Array
        (
            [class] => Array
                (
                    [0] => checkout-pane
                    [1] => checkout-pane-braintree-3ds-review
                )

        )

    [#pane_id] => braintree_3ds_review
    [#attached] => Array
        (
            [library] => Array
                (
                    [0] => commerce_braintree/checkout-review
                )

            [drupalSettings] => Array
                (
                    [commerceBraintree] => Array
                        (
                            [clientToken] => token-removed
                            [formId] => commerce-checkout-flow-separate-billing
                            [amount] => 12.95
                            [nonce] => XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXXX
                            [bin] => 400000
                            [email] => test@test.com
                        )

                )

        )

    [payment_errors] => Array
        (
            [#type] => markup
            [#markup] => <div id="payment-errors"></div>
            [#weight] => -200
        )

    [payment_method_nonce] => Array
        (
            [#type] => hidden
            [#attributes] => Array
                (
                    [class] => Array
                        (
                            [0] => braintree-nonce
                        )

                )

        )

    [#cache] => Array
        (
            [contexts] => Array
                (
                )

            [tags] => Array
                (
                    [0] => commerce_order:1234
                )

            [max-age] => 0
        )

)

Has anyone else faced issued with the nonce missing? As the site is on test gateway in Braintree, 3DS should automatically be enabled in the frontend.

Comments

jozzy_a created an issue. See original summary.

jozzy_a’s picture

Issue summary: View changes
jozzy_a’s picture

Closing this ticket, the reason for the bug was commerce_braintree expects the Drupal commerce twig files to use specific HTML IDs to invoke Javascript.
Without the IDs there is no graceful failure of the commerce review file.
The fix was to restore the original IDs so it matches whats provided by default by the Drupal commerce module

jozzy_a’s picture

Status: Active » Closed (works as designed)
nicxvan’s picture

Do you happen to know which IDs? I'm pretty sure we're not overriding those but when we enable 3ds we're getting several of these errors.

zohera’s picture

I am getting this issue as mentioned above ” Missing payment method nonce “ when I use production environment using Braintree payment gateway on my commerce site.
But sandbox environment is working fine though. Can you please help me to resolve this issue ?