Braintree iOS: fatal error "Braintree_Configuration" not found

I want to integrate Braintree payment in my iOS app. For this, I installed composer after .

The composer folder is created locally and I put it on my server.

But when I run the file payAmountUsingBraintree.php

, I get the following error:

Fatal error: Class 'Braintree_Configuration' not found

Contents payAmountUsingBraintree.php


//include '../config.php';
include 'db_config.php';
require_once 'vendor/autoload.php';
//echo 'Current PHP version: ' . phpversion();

$PartnerId = $_POST["PartnerId"];
$nonce = $_POST["Nonce"];
$amount = $_POST["Amount"];
$fname = $_POST["fname"];
$lname = $_POST["lname"];
$SaveCard = $_POST["SaveCard"];
$number = $_POST["CardNumber"];
$postal_code = $_POST["postal_code"];
$CVV = $_POST["CVV"];
$MerchantAccountId = '';
$IsAvailable = 'no';

Braintree_Configuration::environment('sandbox'); // get error on this line


Where am I going wrong? How to solve this?


source to share

2 answers

I know him a little late. But let me add a solution for future readers who might be looking for a similar solution by integrating PHP technology to get a client token.

First you need to set up the prerequisites.

  • PHP version required> = 5.4.0.

The following PHP extensions are required:

  • curl
  • house
  • hash
  • OpenSSL
  • XmlWriter

Assuming you've installed the dependencies on your server. The BrainTree API expects the following:

1) Sandbox developer account - create here

2) BrainTree Client Framework in your application - Download here

Quick start example


require_once 'PATH_TO_BRAINTREE/lib/Braintree.php';


$result = Braintree_Transaction::sale([
    'amount' => '1000.00',
    'paymentMethodNonce' => 'nonceFromTheClient',
    'options' => [ 'submitForSettlement' => true ]

if ($result->success) {
    print_r("success!: " . $result->transaction->id);
} else if ($result->transaction) {
    print_r("Error processing transaction:");
    print_r("\n  code: " . $result->transaction->processorResponseCode);
    print_r("\n  text: " . $result->transaction->processorResponseText);
} else {
    print_r("Validation errors: \n");


The statement is require_once 'PATH_TO_BRAINTREE/lib/Braintree.php';

missing from the code snippet.

Here are the links for the solution.

1) Integration of Braintree payment gateway with PHP

2) Github link from Braintree PHP



I also had this problem. This error only occurs after successfully enabling Braintree.php. But other file ie Braintree.php / configuration.php is not included autoload.php

This is an error Invalid directory path .

You want to use the exact DIRECTORY_SEPARATOR in $ file_name and change

$fileName = dirname(__DIR__) . '/lib/';


$fileName = dirname(__DIR__) . DIRECTORY_SEPARATOR.'paypal'.DIRECTORY_SEPARATOR;

I used paypal as a directory. so change it however you want. And try printing the full $ filename if you get the same error and fix the directory path.



All Articles