braintree 支付与 zf2(zend 框架 2)集成

braintree payments integration with zf2( zend framework 2 )

我是 zf2 的新手,想将 braintree 支付整合到我的 zf2 项目中。

我在 vendor/autoload.php

中添加了以下代码行
require_once __DIR__ . '/braintree/lib' . '/autoload.php';

当我将配置代码添加到我的操作时,它停止工作并显示空白屏幕(根据我的应用程序设置错误视图已删除,因此它显示空白屏幕。错误是 class 未找到)

Braintree_Configuration::environment('sandbox');

请帮助我在 zf2 中设置 braintree 库。

通过使用下面的博客文章,我能够在 May 服务器上手动配置 braintree 支付网关库。

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

1) 这里我需要在 autoload_classmap.php 中添加 lib 引用,如下所示。

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

2) 在 Module.php 文件的函数 getAutoloaderConfig 中添加 ClassMapAutoloader 部分(如果它不存在)以便从 autoload_classmap.php 文件加载配置。该函数应如下所示:

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

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

}

3) 更改后我可以在你的控制器中使用 Braintree 库:

$Braintree = new \Braintree\Configuration();
$Braintree::merchantId('your_merchant_id');
$Braintree::publicKey('your_public_key');
$Braintree::privateKey('your_private_key');