李帅

1.打印paypal token

......@@ -14,6 +14,7 @@ use App\Models\User;
use App\Models\UserProfile;
use Carbon\Carbon;
use GuzzleHttp\Client;
use Illuminate\Support\Facades\Log;
use Illuminate\Support\Facades\Redis;
class PaypalPayment implements PaymentInterface
......@@ -34,6 +35,7 @@ class PaypalPayment implements PaymentInterface
public function __construct()
{
try{
// 初始化时做一些准备工作
$redis = Redis::connection();
$access_token = $redis->get('paypal:access_token');
......@@ -47,7 +49,6 @@ class PaypalPayment implements PaymentInterface
'Accept'=>'application/json',
]
]);
$response = $client->post('/v1/oauth2/token',[
'form_params'=>['grant_type' => 'client_credentials'],
'auth' => [$this->clientId, $this->secret],
......@@ -58,6 +59,9 @@ class PaypalPayment implements PaymentInterface
$redis->setex('paypal:access_token',$content['expires_in'],$content['access_token']);
}
}catch (\Exception $exception){
Log::channel('daily')->error($exception->getMessage());
}
}
/**
......@@ -98,7 +102,7 @@ class PaypalPayment implements PaymentInterface
}
public function prepare(Order $order)
{return $this->accessToken;
{
// 在PayPal上创建一个订单,它会返回一个订单对象,它有一个订单id
$client = new Client([
'base_uri' => $this->baseUrlSandbox,
......