3 回答

TA貢獻1876條經(jīng)驗 獲得超7個贊
請參閱下面的示例以了解 braintree/paypal 的具體示例。這是對我有用的最優(yōu)雅的解決方案:
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條經(jīng)驗 獲得超3個贊
您使用 braintree 的方式似乎遵循一個已棄用的示例(我猜是 Braintre_php 的先前版本),因為當前包中不存在 Braintree_Configuration 類。
在調(diào)用自動加載的類之前,您還需要使用“\”,例如:\Braintree。
這應(yīng)該在你的 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 函數(shù)來開始: https ://developers.braintreepayments.com/start/hello-server/php

TA貢獻1817條經(jīng)驗 獲得超14個贊
您是否在 AppServiceProvider 中添加了 use 語句?
use App\Providers\Braintree_Configuration;
- 3 回答
- 0 關(guān)注
- 126 瀏覽
添加回答
舉報