【问题标题】:Braintree iOS: fatal error 'Braintree_Configuration' not foundBraintree iOS:找不到致命错误“Braintree_Configuration”
【发布时间】:2015-04-30 06:16:46
【问题描述】:

我想在我的 iOS 应用中集成 Braintree 支付。为此,我在https://getcomposer.org/doc/01-basic-usage.md 之后安装了作曲家。

composer 文件夹是在本地创建的,我已经把它放在我的服务器上。

但是当我运行payAmountUsingBraintree.php 文件时,我得到以下错误:

Fatal error: Class 'Braintree_Configuration' not found

payAmountUsingBraintree.php的内容:

    <?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
Braintree_Configuration::merchantId('2qyx6qtd9bvy82r');
Braintree_Configuration::publicKey('c9qvxk3nvhmd68b');
Braintree_Configuration::privateKey('6f8ca01bd95cc0c753e936148303de4');

我哪里错了?我该如何解决?

【问题讨论】:

  • 我在布伦特里工作。抱歉,我们错过了您的问题。如果你已经解决了,你能发布一个答案让我知道吗?否则,我建议你email our support team;他们将能够提供帮助。

标签: php ios braintree


【解决方案1】:

我知道有点晚了。但是,让我为将来可能正在寻找类似解决方案同时集成 PHP 技术以获取客户端令牌的读者添加解决方案。

您需要先设置先决条件。

  • 需要 PHP 版本 >= 5.4.0。

需要以下 PHP 扩展:

  • 卷曲
  • dom
  • 散列
  • openssl
  • xmlwriter

假设您已经在服务器上安装了依赖项。 BrainTree API 期望如下:

1) 开发者沙盒帐户 – 创建一个 here

2) 应用程序中的 BrainTree 客户端框架 - 从 here 下载

快速入门示例

<?php

require_once 'PATH_TO_BRAINTREE/lib/Braintree.php';

Braintree_Configuration::environment('sandbox');
Braintree_Configuration::merchantId('your_merchant_id');
Braintree_Configuration::publicKey('your_public_key');
Braintree_Configuration::privateKey('your_private_key');

$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");
    print_r($result->errors->deepAll());
}

您的代码 sn-p 中缺少语句 require_once 'PATH_TO_BRAINTREE/lib/Braintree.php';

这里是解决方案的参考链接。

1) Integrating Braintree Payment Gateway with PHP

2)Github link of Braintree PHP

【讨论】:

    【解决方案2】:

    我也有这个问题。只有在成功包含 Braintree.php 后才会出现此错误。但是 autoload.php

    不包含另一个文件,即 Braintree.php/configuration.php

    这是一个无效的目录路径错误。

    您想在 $file_name 中使用准确的 DIRECTORY_SEPARATOR 并更改

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

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

    我使用paypal 作为目录。所以随心所欲地改变它。如果遇到同样的错误并更正目录路径,请尝试打印完整的 $filename

    【讨论】:

      猜你喜欢
      • 2021-06-03
      • 2021-01-29
      • 1970-01-01
      • 2013-01-21
      • 2014-10-03
      • 1970-01-01
      • 1970-01-01
      • 2011-09-08
      • 2011-12-17
      相关资源
      最近更新 更多