Braintree unvalid Token

26 views Asked by At

I am trying to implement a payments system using Braintree functionality. So, I tested all functionality in Postman using as a token a fake-valid-nonce, and payments appear in my sandbox account with no problem. But if I use a token generated by this

class BrainTreeController extends Controller
{
    public function generate(Request $request)
    {
        $gateway = new Gateway([
            'environment' => env('BRAINTREE_ENVIRONMENT'),
            'merchantId' => env('BRAINTREE_MERCHANT_ID'),
            'publicKey' => env('BRAINTREE_PUBLIC_KEY'),
            'privateKey' => env('BRAINTREE_PRIVATE_KEY')
        ]);
        $token = $gateway->clientToken()->generate();
        $data = [
            'success' => true,
            'token' => $token
        ];
        return response()->json($data, 200);
    }

I get an error from the payment request that says that the request is unauthorized.

Checked all env variables already Tried the payment with token : "fake-valid-nonce" and it works Tried to check if the token I generate is different every time I call the function ChatGBT says that the token must be divided in 3 parts, separeted with a . but I can't see any

0

There are 0 answers