3 回答

TA贡献1876条经验 获得超7个赞
请参阅下面的示例以了解 braintree/paypal 的具体示例。这是对我有用的最优雅的解决方案:
app\Providers\AppServiceProvider.php:
/**
* Bootstrap any application services.
*
* @return void
*/
public function boot()
{
// braintree setup
$environment = env('BRAINTREE_ENV');
$braintree = new \Braintree\Gateway([
'environment' => $environment,
'merchantId' => 'merchant_id_example',
'publicKey' => 'public_key_example',
'privateKey' => 'private_key_example'
]);
config(['braintree' => $braintree]);
// braintree setup for specifically for paypal direct integration for those who need it
/*$accessToken = env('PAYPAL_ACCESS_TOKEN');
$braintree = new \Braintree\Gateway([
'accessToken' => $accessToken
]);
config(['braintree' => $braintree]);*/
}
// 示例文件.php:
public function token()
{
$braintree = config('braintree');
$clienttoken = $braintree->clientToken()->generate();
}
public function sale()
{
$braintree = config('braintree');
$result = $braintree->transaction()->sale([
'amount' => $amount,
'paymentMethodNonce' => $nonce
]);
}

TA贡献1830条经验 获得超3个赞
您使用 braintree 的方式似乎遵循一个已弃用的示例(我猜是 Braintre_php 的先前版本),因为当前包中不存在 Braintree_Configuration 类。
在调用自动加载的类之前,您还需要使用“\”,例如:\Braintree。
这应该在你的 app/Providers/AppServiceProvider.php 文件中使用 Braintree 5.x :
/**
* Bootstrap any application services.
*
* @return void
*/
public function boot()
{
//
$gateway = new \Braintree\Gateway([
'environment' => 'sandbox',
'merchantId' => 'use_your_merchant_id',
'publicKey' => 'use_your_public_key',
'privateKey' => 'use_your_private_key'
]);
}
你可以在这里有一个最新的例子来查看一些基本的 sdk 函数来开始: https ://developers.braintreepayments.com/start/hello-server/php

TA贡献1817条经验 获得超14个赞
您是否在 AppServiceProvider 中添加了 use 语句?
use App\Providers\Braintree_Configuration;
- 3 回答
- 0 关注
- 130 浏览
添加回答
举报