-1

i am new to zf2 and want to integration of braintree payments in to my zf2 project .

i have added below lines of code in vendor/autoload.php

require_once __DIR__ . '/braintree/lib' . '/autoload.php';

when i add Configuration code to my action it stop working and gives blank screen ( as per my app settting error view is removed so it gives blank screen . error is class not found )

Braintree_Configuration::environment('sandbox');

Please help me to set up braintree lib in zf2.

Nishit Maheta
  • 6,021
  • 3
  • 17
  • 32

1 Answers1

0

with the use of below blog article a am able to configure braintree payment gateway lib on may server manually .

http://www.loneshooter.com/zend-framework-2-how-to-use-facebook-php-sdk/

1) Here i need to add lib reference in autoload_classmap.php like below.

 <?php
  return array(
    'Braintree' => 'vendor/< path to Braintree >/Braintree.php',
  );

2) In function getAutoloaderConfig of Module.php file add ClassMapAutoloader section if it doesn’t exist in order to load configurations from autoload_classmap.php file. The function should look as it follows:

public function getAutoloaderConfig()
{
    return array(
        'Zend\Loader\ClassMapAutoloader' => array(
            __DIR__ . '/autoload_classmap.php',
        ),

        'Zend\Loader\StandardAutoloader' => array(
            'namespaces' => array(
                __NAMESPACE__ => __DIR__ . '/src/' . __NAMESPACE__,
            ),
        ),
    );

}

3) After the changes i can use the Braintree library in your controller:

$Braintree = new \Braintree\Configuration();
$Braintree::merchantId('your_merchant_id');
$Braintree::publicKey('your_public_key');
$Braintree::privateKey('your_private_key');
Nishit Maheta
  • 6,021
  • 3
  • 17
  • 32