php - What is issue in my code Sandbox paypal future payment -


i have alredy enable future payments permission in app , using developer dashboard.but not working yet please find error http://developer.paypal.com/ , log in https://developer.paypal.com/developer/accountstatus there can see permits have.

 $data = array(                 "intent" => "authorize",                 "payer" => array(                     "payment_method" => "paypal"                 ),                 "transactions" => array(                     array("amount" => array(                         "currency" => "usd",                         "total" => "1.88"                     ),                         "description" => "future of sauces")                 ));          $data_string = json_encode($data);         $ch = curl_init();         curl_setopt($ch, curlopt_url, "https://api.sandbox.paypal.com/v1/payments/payment");         $headers = array(             'content-type: application/json',             'paypal-client-metadata-id: d6743cbb53ea4470a53bfe458f0cb885',             'authorization: bearer a103.b7d5318jds6na1zgh02avjcx16oxnbpaduat5z9slgvgeiohoaemuqyz0angsics.fakzecypts1ixfemhcpva5yyrgu',         );         curl_setopt($ch, curlopt_httpheader, $headers);         //curl_setopt($ch, curlinfo_header_out, true);         curl_setopt($ch, curlopt_post, true);         curl_setopt($ch, curlopt_postfields, $data_string);         $result = curl_exec($ch);         $information = curl_getinfo($ch);         curl_close($ch);         print_r($information);         die; 

out put here

{"name":"permission_denied","message":"no permission requested operation","information_link":"https://developer.paypal.com/docs/api/#permission_denied","debug_id":"5b39efd4cf370"}array (     [url] => https://api.sandbox.paypal.com/v1/payments/payment     [content_type] => application/json     [http_code] => 403     [header_size] => 592 

i made paypal module, hope code you.

$result_json = json_decode($result);  /* check if authentication valid */ if (isset($result_json->access_token)) {     $enc_data = json_encode($data);      $ch = curl_init();     curl_setopt($ch, curlopt_url, 'https://api.sandbox.paypal.com/v1/payments/payment');     curl_setopt($ch, curlopt_ssl_verifypeer, !in_array($_server['remote_addr'], array('127.0.0.1', '::1')));     curl_setopt($ch, curlopt_ssl_verifyhost, 2);     curl_setopt($ch, curlopt_returntransfer, true);     curl_setopt($ch, curlopt_verbose, true);     curl_setopt($ch, curlopt_post, true);     curl_setopt($ch, curlopt_postfields, $enc_data);     curl_setopt($ch, curlopt_httpheader, array(         'content-type: application/json',         'authorization: bearer '.$result_json->access_token,         'paypal-client-metadata-id: ************'     ));      $result = curl_exec($ch);     $json_result = json_decode($result);     curl_close($ch); } 

json_encode($data) there additional information may not useful transaction might trying example.

{     "intent": "sale",     "payer": {         "payment_method": "credit_card",         "payer_info": {             "email": "...",             "shipping_address": {                 [...]             }         },         "funding_instruments": [             {                 "credit_card": {                     [...]                     }                 }             }         ]     },     "transactions": [         {             "amount": {                 "total": 32.91,                 "currency": "usd"             },             "item_list": {                 "items": [                     {                         "quantity": 1,                         "name": "product name",                         "price": 16.51,                         "currency": "usd"                     },                     {                         "quantity": 1,                         "name": "product name 2",                         "price": "16.40",                         "currency": "usd"                     },                     {                         "quantity": 1,                         "name": "shipping",                         "price": 0,                         "currency": "usd"                     }                 ],                 "shipping_address": {                     [...]                 }             }         }     ] } 

Comments

Popular posts from this blog

java - Run spring boot application error: Cannot instantiate interface org.springframework.context.ApplicationListener -

reactjs - React router and this.props.children - how to pass state to this.props.children -

Excel VBA "Microsoft Windows Common Controls 6.0 (SP6)" Location Changes -