Creating an Invoice with Paypal-Php-SDK fails with "Can not deserialize instance of java..." error -


i'm trying create invoice paypal-php-sdk, everything's okay, when try set billing info goes wrong , error:

{"name":"validation_error","message":"invalid request - see details.","debug_id":"2d34973f0cfef","details":[{"field":"billing_info","issue":"can not deserialize instance of java.util.arraylist out of start_object token @ line:1, column:2"}]}exception 'paypal\exception\paypalconnectionexception' message 'got http response code 400 when accessing https://api.sandbox.paypal.com/v1/invoicing/invoices.' in /var/www/admin/data/www/****/vendor/paypal/rest-api-sdk-php/lib/paypal/core/paypalhttpconnection.php:176 stack trace: #0 /var/www/admin/data/www/****/vendor/paypal/rest-api-sdk-php/lib/paypal/transport/paypalrestcall.php(74): paypal\core\paypalhttpconnection->execute('{"billing_info"...') #1 /var/www/admin/data/www/****/vendor/paypal/rest-api-sdk-php/lib/paypal/common/paypalresourcemodel.php(103): paypal\transport\paypalrestcall->execute(array, '/v1/invoicing/i...', 'post', '{"billing_info"...', null) #2 /var/www/admin/data/www/****/vendor/paypal/rest-api-sdk-php/lib/paypal/api/invoice.php(736): paypal\common\paypalresourcemodel::executecall('/v1/invoicing/i...', 'post', '{"billing_info"...', null, object(paypal\rest\apicontext), null) #3 var/www/admin/data/www/****/application/controllers/store.php(487): paypal\api\invoice->create(object(paypal\rest\apicontext)) #4 [internal function]: store->payment() #5 /var/www/admin/data/www/****/system/core/codeigniter.php(359): call_user_func_array(array, array) #6 /var/www/admin/data/www/****/index.php(202): require_once('/var/www/admin/...') #7 {main} 

here's code use:

$client_id = "****"; $secret = "****";  $apicontext = new apicontext(new oauthtokencredential( $client_id, $secret));  $merchantinfo = new paypal\api\merchantinfo(); $merchantinfo->setemail("****"); $merchantinfo->setwebsite("****");  $billinginfo = new paypal\api\billinginfo(); $billinginfo->setemail("****");  $invoice = new paypal\api\invoice(); $invoice->setmerchantinfo($merchantinfo); $invoice->setbillinginfo($billinginfo);  try {     $invoice->create($apicontext); } catch (paypal\exception\paypalconnectionexception $ex) {     echo $ex->getdata();     die($ex); } catch (exception $ex) {     die($ex); } 

here's i've received paypal support:

change these 2 lines this:

$invoice->setmerchantinfo(array($merchantinfo));  $invoice->setbillinginfo(array($billinginfo)); 

both billing info , merchant info takes in array of objects, not object directly.

it's strange started work when changed billing info, right code me was:

$invoice->setmerchantinfo($merchantinfo); $invoice->setbillinginfo(array($billinginfo)); 

Comments

Popular posts from this blog

How to connect android app to App engine -

gcc - MinGW's ld cannot perform PE operations on non PE output file -

php - display validation error message next to the textbox in codeigniter -