简体   繁体   中英

Sudden Failure Requests on Braintree Sandbox API: 'Billing state format is invalid'

We're running a UK Magento store hooked up to Braintree. All has been running smoothly for months, then suddenly, we are no longer able to complete an order on any of our staging or local test environments which are hooked up to Braintree Sandbox.

At checkout, a request is made to the 3d secure endpoint, and if we have entered a UK based county, we get the following response:

Endpoint: https://api.sandbox.braintreegateway.com/merchants/xxx/client_api/v1/payment_methods/xxx/three_d_secure/lookup

Request billing part:

"additionalInfo": {
        "billingCity": "Leeds",
        "billingCountryCode": "GB",
        "billingGivenName": "John",
        "billingLine1": "50 Upton Road",
        "billingPhoneNumber": "07733222111",
        "billingPostalCode": "LE6 7TH",
        "billingState": "Yorkshire",
        "billingSurname": "Smith"
    },

Response:

{
    "error": {
        "message": "Billing state format is invalid."
    },
    "threeDSecureInfo": {
        "liabilityShiftPossible": false,
        "liabilityShifted": false
    }
}

If we remove the county field from the checkout (and ultimately the 'billingSate from the request), the response is valid and we are able to checkout fine.

  • This has only started happening recently
  • The same codebase works fine on production Braintree
  • I simulated the a request with exact same params on production and it worked OK
  • Raised ticket with Braintree but no response
  • I am able to checkout if I use a two digit US state code in the county field

Anyone have any ideas?

I did finally get an answer from Braintree regarding this. Apparently 3ds2 is now enforced on the Sandbox, and this requires the state or county to be sent as a two digit code.

On production, if the full name is sent, it will (currently) gracefully degrade to 3ds1 and complete.

In an attempt to push people to using 3ds2, the Sandbox does not switch to 3ds1 and returns the error.

Today I encountered same problem with 3DSecure in Braintree. First of all, I made sure that I use the latest version of drop-in, client and data-collector scripts which (at the time of writing this response) are:

<script src="https://js.braintreegateway.com/web/3.71.0/js/client.min.js"></script>
<script src="https://js.braintreegateway.com/web/3.71.0/js/data-collector.min.js"></script>
<script src="https://js.braintreegateway.com/web/dropin/1.25.0/js/dropin.min.js"></script>

Then I modified/renamed two of "threeDSecure" properties "locality"->"city" and "region"->"state"

dropin.requestPaymentMethod({
            threeDSecure: {
                amount: '10.01',
                email: 'me@mydomain.com',
                billingAddress: {
                    givenName: 'John',
                    surname: 'Smith',
                    streetAddress: '51 East Street,
                    extendedAddress: 'na',
                    city: 'Colchester',
                    state: 'Essex',
                    postalCode: 'CO1 2QY',
                    countryCodeAlpha2: 'GB'
                }
            }
        }, function (err, payload) {
            if (err) {
                console.log('tokenization error:');
                dropin.clearSelectedPaymentMethod();     
                return;
            }

            if (!payload.liabilityShifted) {
                console.log('Liability did not shift');
                return;
            }

                console.log('verification success');
                console.log(payload.nonce);
        });

I hope this will help you as it works fine for me in the Sandbox environment.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM