php - curl_exec return an XMLFault from Paypal REST Api -
i'm using paypal rest api mobile app. here's code :
$paymentdatas = array( "intent" => "sale", "redirect_urls" => array( "return_url" => "http://example.com/your_redirect_url/", "cancel_url" => "http://example.com/your_cancel_url/" ), "payer" => array("payment_method" => "paypal"), "transactions" => array( "transactions" => array( "total" => ".99", "currency" => "usd" ) ) ); $paymenturl = 'https://api.sandbox.paypal.com/v1/payments/payment'; $initcurl = curl_init(); curl_setopt_array( $initcurl, array( curlopt_url => $paymenturl, curlopt_timeout => $timeout, curlopt_returntransfer => true, curlopt_ssl_verifypeer => false, //todo: testing purpose, need tp removed curlopt_post =>true, curlopt_httpheader => array( 'accept-language: en_us', 'accept: application/json', 'authorization: bearer '.$data['access_token'] ), curlopt_postfields => json_encode($paymentdatas), ) ); $initret = curl_exec($initcurl); dd($initret); curl_close($initcurl);
and dd gives me :
string '<ns1:xmlfault xmlns:ns1="http://cxf.apache.org/bindings/xformat"><ns1:faultstring xmlns:ns1="http://cxf.apache.org/bindings/xformat">java.lang.nullpointerexception</ns1:faultstring></ns1:xmlfault>' (length=196)
i've made others functions authentication i'm pretty new rest , paypal api.
i had same problem.
when changing post request worked fine. hope you.
Comments
Post a Comment