Note that there are some explanatory texts on larger screens.

plurals
  1. POpaypal rest api execute error
    primarykey
    data
    text
    <p>I'm trying to implement a PayPal payment in a Wordpress theme . I get the token, create the payment, redirect the user to approval link , get the aproval from user but for some reason i cannot execute the payment" the curl response is empty.</p> <p>Here is the code (i double checked the execute url and token and they are correct)</p> <pre><code>if (isset($_GET['token']) &amp;&amp; isset($_GET['PayerID']) ){ $received_token = sanitize_text_field ( $_GET['token'] ); $received_payerId = sanitize_text_field ( $_GET['PayerID'] ); $execute_urls = get_option('paypal_processing'); $payment_execute_url= $execute_urls[$current_user-&gt;ID]; $execute_urls[$current_user-&gt;ID] = ''; update_option('paypal_processing',$execute_urls); $payment_execute = array( 'payer_id' =&gt; $received_payerId ); $json = json_encode($payment_execute); $json_resp = make_post_call($payment_execute_url, $json,$received_token); print_r($json_resp); echo "Payment Execute processed " . $json_resp['id'] ." with state '". $json_resp['state']."'"; } function make_post_call($url, $postdata,$token) { $curl = curl_init($url); curl_setopt($curl, CURLOPT_POST, true); curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($curl, CURLOPT_HEADER, false); curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); curl_setopt($curl, CURLOPT_HTTPHEADER, array( 'Authorization: Bearer '.$token, 'Accept: application/json', 'Content-Type: application/json' )); curl_setopt($curl, CURLOPT_POSTFIELDS, $postdata); #curl_setopt($curl, CURLOPT_VERBOSE, TRUE); $response = curl_exec( $curl ); if (empty($response)) { // some kind of an error happened print 'curl error'; curl_close($curl); // close cURL handler } else { $info = curl_getinfo($curl); // echo "Time took: " . $info['total_time']*1000 . "ms\n"; curl_close($curl); // close cURL handler if($info['http_code'] != 200 &amp;&amp; $info['http_code'] != 201 ) { //echo "Received error: " . $info['http_code']. "\n"; //echo "Raw response:".$response."\n"; exit('paypal error'); } } // Convert the result from JSON format to a PHP array $jsonResponse = json_decode($response, TRUE); return $jsonResponse; } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload