编程语言
首页 > 编程语言> > PHP-Braintree iOS:找不到致命错误“ Braintree_Configuration”

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

作者:互联网

我想将Braintree付款集成到我的iOS应用中.为此,我已经在https://getcomposer.org/doc/01-basic-usage.md之后安装了composer.

composer文件夹是在本地创建的,并且已将其放在服务器上.

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

致命错误:找不到类“ Braintree_Configuration”

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');

我哪里出问题了?我该如何解决?

解决方法:

我知道有点晚了.但是,让我为将来的读者添加解决方案,他们可能会在集成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());
}

语句require_once’PATH_TO_BRAINTREE / lib / Braintree.php’;在您的代码段中丢失了.

这是该解决方案的参考链接.

1)Integrating Braintree Payment Gateway with PHP

2)Github link of Braintree PHP

标签:braintree,ios,php
来源: https://codeday.me/bug/20191028/1952110.html