Recoverable fatal error: Object of class stdClass could not be converted to string

desaczm
New Community Member

Hey Family i want your help i started my project to integrate customer checkout PayPal to my streaming website initially i have started with the Rest API which i am partially successfull i am able to generate the access token pass it to the creation of the Product Id and pass these two to the generating of the plan ID now i am getting this error Recoverable fatal error: Object of class stdClass could not be converted to string... the following is the code <?php $ProductID = $_GET['ProductID']; $tokens = $_GET['access_token']; $unique_id = md5(uniqid()); ?> <?php // Generated by curl-to-PHP: http://incarnate.github.io/curl-to-php/ $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, 'https://api-m.sandbox.paypal.com/v1/billing/plans'); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, "{\n \"name\": \"Video streaming service\",\n \"description\": \"Video streaming service\",\n \"product_id\": \"$ProductID\",\n \"billing_cycles\": [{\n \"frequency\": {\n \"interval_unit\": \"MONTH\",\n \"interval_count\": 1\n },\n \"tenure_type\": \"REGULAR\",\n \"sequence\": 1,\n \"total_cycles\": 0,\n \"pricing_scheme\": {\n \"fixed_price\": {\n \"value\": \"10\",\n \"currency_code\": \"USD\"\n }\n }\n }],\n \"payment_preferences\": {\n \"auto_bill_outstanding\": true,\n \"payment_failure_threshold\": 1\n }\n }"); $headers = array(); $headers[] = 'Accept: application/json'; $headers[] = 'Authorization: Bearer '.rawurlencode($tokens); $headers[] = 'Content-Type: application/json'; $headers[] = 'Paypal-Request-Id: '.rawurlencode($unique_id); curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); $result = curl_exec($ch); $err = curl_error($ch); curl_close($ch); if ($err) { // code... echo 'Error:'.err; }else{ $response = json_encode($result); echo $response; $PlanID = $response->id; var_dump($PlanID); } ?>

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.