在Laravel中获取Paypal付款详细信息时出现403错误

时间:2019-12-23 22:17:10

标签: laravel api laravel-5 paypal

我想通过后端的交易ID获取付款明细。因此,只会从前端获得交易ID,我需要检查这笔付款。

我的交易信息:

{
    "id":"8BE39713UM4013017",
    "state":"completed",
    "payment_mode":"INSTANT_TRANSFER",
    "protection_eligibility":"ELIGIBLE",
    "parent_payment":"PAYID-LYAS2CA0MC84362BH057454Y",
    "create_time":"2019-12-23T21:10:26Z",
    "update_time":"2019-12-23T21:10:26Z",
    "amount": {
        "total":"100.00",
        "currency":"USD",
        "details": {
            "subtotal":"100.00",
            "shipping":"0.00",
            "handling_fee":"0.00",
            "insurance":"0.00",
            "shipping_discount":"0.00"
        }
    }
}

我的控制器:

public function paypal(){

        $payment_token = 'PAYID-LYAS2CA0MC84362BH057454Y';

        try {
            $paypal_key = config('services.paypal.client_id');
            $paypal_secret = config('services.paypal.secret');
            $paypal_mode = config('services.paypal.mode');
            $apiContext = new ApiContext(new OAuthTokenCredential($paypal_key, $paypal_secret));
            $apiContext->setConfig([
                'mode' => $paypal_mode
            ]);
            $payment = Payment::get($payment_token, $apiContext);
            return $payment;
        }
        catch (\Exception $exception){
            return $exception->getMessage();
        }
    }

错误是:

  

访问https时获得Http响应代码403:   //api.sandbox.paypal.com/v1/payments/payment/PAYID-LYAS2CA0MC84362BH057454Y。

1 个答案:

答案 0 :(得分:0)

403是拒绝访问的HTTP响应代码。

以某种方式您无权提出请求,我不熟悉您的用例,但请仔细检查您的详细信息并重新阅读有关该主题的文档。

祝你好运