简体   繁体   中英

Braintree - No payment method is available

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

在此处输入图像描述

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

在此处输入图像描述

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?

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.

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