lundi 23 décembre 2019

Getting 403 error while getting paypal payment details in Laravel

I want to get payment details by transaction id in the backend. So will get only transaction id from the frontend and I need to check this payment.

My transaction info:

{
    "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"
        }
    }
}

My Controller:

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();
        }
    }

Error is:

Got Http response code 403 when accessing https: //api.sandbox.paypal.com/v1/payments/payment/PAYID-LYAS2CA0MC84362BH057454Y.



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/2sY2KWG
via IFTTT

Aucun commentaire:

Enregistrer un commentaire