php - getting http 400 when trying to send data to paypal api -


i have tried can possibly think of, , nothing helps. have gone far download sample "pizza store" application have on github. every time, when replace "endpoint" in sdk-config.ini "live" , put in clientid , clientsecret, , update bootstrap.php file information, "my apps" section error "got http response code 400 when accessing https://api.paypal.com/v1/vault/credit-cards." using sample application provide, , error. have been searching , searching, , slike there 40 different end points, no documentation on how use them, how set them, or it. thing can gather sample app can set "mode" live in "setconfig" call, results in 400 error. desperate, need here. have emailed support, , haven't gotten response. trying friend out , website people can buy things, 400 error driving me insane. here direct copy of code using try out...

$config = config::getitem('merchant_settings', 'paypal'); $config = $config['production']; $sdkconfig = array('mode' => 'live'); $apicontext = new apicontext(new oauthtokencredential($config['client_id'], $config['client_secret'])); $apicontext->setconfig($sdkconfig); $card = new creditcard(); $card->settype('visa'); $card->setnumber('4446283280247004'); $card->setexpiremonth('11'); $card->setexpireyear('2018'); $card->setfirstname('joe'); $card->setlastname('shopper'); $funding_instrument = new fundinginstrument(); $funding_instrument->setcreditcard($card); $payer = new payer(); $payer->setpaymentmethod('credit_card'); $payer->setfundinginstruments($funding_instrument); $amount = new amount(); $amount->setcurrency('usd'); $amount->settotal('15.85'); $transaction = new transaction(); $transaction->setamount($amount); $transaction->setdescription('a test purchase'); $payment = new payment(); $payment->setintent('sale'); $payment->setpayer($payer); $payment->settransactions(array($transaction)); try {   $res = $payment->create($apicontext);   $this->set('data' , $res); } catch(paypalconnectionexception $ex) {   $this->set('data', $ex); } catch(exception $e) {   $this->set('data', $e); }  echo '<pre>'; print_r($data); echo '</pre>'; 

and error getting is...

{"name":"malformed_request","message":"incoming json request not map api request","information_link":"https://developer.paypal.com/webapps/developer/docs/api/#malformed_request","debug_id":"2c61b8ecedfc6"} 

i don't understand, using exact same code sample application. why getting error. have gone link, no ever. please, begging please help. yes, realize card information fake, should getting credit card declined error, not malformed request error. please.

i don't know php think funding instrument supposed array:

"payer":{ "payment_method":"credit_card", "funding_instruments":[   {     "credit_card":{ 

if create funding instrument array ($fiarray) of length one, , set first element $funding_instrument, , pass array $payer->setfundinginstruments(fiarray).


Comments

Popular posts from this blog

javascript - Chart.js (Radar Chart) different scaleLineColor for each scaleLine -

apache - Error with PHP mail(): Multiple or malformed newlines found in additional_header -

java - Android – MapFragment overlay button shadow, just like MyLocation button -