PERMISSION_DENIED. You do not have permission to access or perform operations on this resource.

bon23
Contributor
Contributor

I have successfully initiated a payment via sandbox.

Login and paid. I got the results from PayPal

Then request the checkout/orders/orderId via my php backend

I get You do not have permission to access or perform operations on this resource

 

 

// use the orders api to capture payment data
    private function validatePaypalOrder($payment)
    {
        try {
            $accessToken = $this->getAccessToken($payment);
            if (!empty($accessToken)) {
                $ch = curl_init();
                curl_setopt($ch, CURLOPT_URL, $payment['orderApiUrl'] . '/' . $this->orderId);
                curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
                curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
                curl_setopt($ch, CURLOPT_SSLVERSION, 6); //NEW ADDITION
                curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json', 'Authorization: Bearer ' . $accessToken));
                curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'GET');
                //$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
                $result = json_decode(curl_exec($ch), true);
                //if ($httpCode !== 200) {
                //    throw new Exception('Error: ' . $result);
                //}
                Yii::error($result, 'payOrderResulsts');
                if (empty($result))
                    throw new BadRequestHttpException('No paypal order data userId [' . Yii::$app->user->identity->userNumber . ']');
                else {
                    $jsonDecode = json_decode($result);
                    Yii::error($jsonDecode, 'OrderData');
                    $this->completeTransaction($payment, $jsonDecode);
                }
                curl_close($ch);
            }
        } catch (\Exception $ex) {
            return $ex->getMessage();
        }
    }

 

 

Again I successfully get the token using my api credentials but getting orders details fails. 

Login to Me Too
0 REPLIES 0

Haven't Found your Answer?

It happens. Hit the "Login to Ask the community" button to create a question for the PayPal community.