Braintree - No payment method is available

Viewed 815

I'm using Braintree Sandbox and whenever I try to pay I receive an error of DropIn, saying:

name: "DropinError", message: "No payment method is available.", _braintreeWebError: undefined

What have I done to certify myself that everything is alright:

  1. Double check the Sandbox Braintree API Credentials
  2. Connected Paypal in the "Payment Methods" as asked/required by Braintree Sandbox with the credentials of my App SandBox in Paypal

enter image description here

The end result in my page, after choosing the Braintree payment method, is:

enter image description here

It says no payment method is available, yet I can see the "Card" & "Paypal" UI payment methods, but I can't pay with none of them.

I generate the ClientToken in PHP like the following:

$gateway = new \Braintree\Gateway(
[
    'merchantId' => env('BRAINTREE_MERCHANT_ID'),
    'publicKey' => env('BRAINTREE_PUBLIC_KEY'),
    'privateKey' => env('BRAINTREE_PRIVATE_KEY'),
    'environment' => env('BRAINTREE_ENVIRONMENT')
]);

$token = $gateway->clientToken()->generate();

And then in Javascript all I do is:

// Double checked, its ok!
var token = $('#braintree_token').val();

braintree.dropin.create(
{
    authorization: token,
    container: '#braintree-container',
    paypal:
    {
        flow: 'vault',
    }
}, function(err, instance)
{
    // Error starts after this call
    instance.requestPaymentMethod(function(err, payload)
    {
        // Never reaches here!
        console.log(payload);
    }, 'json');
});

What am I missing?

1 Answers

So with my co-worker who was responsible for the FE part ( i was doing BE part ), we encountered the same issue. We struggled a little bit with account configuration but in the end, my friend identified that problem was on the FE part, particularly in requestPaymentMethod. His explanation:

requestPaymentMethod should be called after the user has selected a payment option, or when he filled in correct credit card details if it’s the only payment option. From what I see in your post I see that maybe it is the same mistake.

Related