首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Braintree iOS:找不到致命错误“Braintree_Configuration”

Braintree iOS:找不到致命错误“Braintree_Configuration”
EN

Stack Overflow用户
提问于 2015-04-30 06:16:46
回答 2查看 3K关注 0票数 3

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

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

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

Fatal error: Class 'Braintree_Configuration' not found

payAmountUsingBraintree.php含量

代码语言:javascript
复制
    <?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');

我哪里搞错了?我该怎么解决这个问题?

EN

回答 2

Stack Overflow用户

发布于 2016-05-05 12:34:31

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

您需要首先设置先决条件。

  • PHP >= 5.4.0是必需的。

需要以下PHP扩展:

  • 卷曲
  • dom
  • 哈希
  • openssl
  • xmlwriter

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

1)开发人员Sandbox帐户-创建一个这里

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

快速启动示例

代码语言:javascript
复制
<?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());
}

您的代码片段中缺少了require_once 'PATH_TO_BRAINTREE/lib/Braintree.php';语句。

以下是解决方案的参考链接。

1) 将Braintree支付网关与PHP集成

2) Braintree PHP的Github链接

票数 2
EN

Stack Overflow用户

发布于 2016-07-13 08:15:53

我也有过这个问题。只有在成功地包含Braintree.php之后,此错误才会上升。但是autoload.php没有包含另一个文件,即Braintree.php/ file . the

这是无效目录路径错误。

您希望在$file_name中使用精确的$file_name,并更改

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

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

我使用paypal作为目录。所以你想怎么改就怎么改。如果得到相同的错误并更正目录路径,请尝试打印完整的$filename

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/29960332

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档