in PayPal Rest API, when create payment, one payment can take multiple transactions?

Lar_ang
Contributor
Contributor

I am working with PHP PayPal Rest API.

I am making code from this link - http://paypal.github.io/PayPal-PHP-SDK/sample/doc/payments/CreatePaymentUsingPayPal.html

It contains this code.

$transaction = new Transaction();$transaction->setAmount($amount)
    ->setItemList($itemList)
    ->setDescription("Payment description");

...$payment = new Payment();$payment->setIntent("sale")
    ->setPayer($payer)
    ->setRedirectUrls($redirectUrls)
    ->setTransactions(array($transaction));

And it works well.

It seems one payment can take multiple transactions as array.

But when take multiple transactions like this:

$transaction1 = new Transaction();$transaction1->setAmount($amount1)
    ->setItemList($itemList1)
    ->setDescription("Payment1 description");$transaction2 = new Transaction();$transaction2->setAmount($amount2)
    ->setItemList($itemList2)
    ->setDescription("Payment2 description");

...$payment = new Payment();$payment->setIntent("sale")
    ->setPayer($payer)
    ->setRedirectUrls($redirectUrls)
    ->setTransactions(array($transaction1, $transaction2));

It doesn't work and it shows error like this.

'Got Http response code 400 when accessing https://api.sandbox.paypal.com/v1/payments/payment.'

Is it impossible to take multiple transactions to one payment?

Or this error is from other reason? what is the reason?

Thanks much for help!

Login to Me Too
0 REPLIES 0

Haven't Found your Answer?

It happens. Hit the "Login to Ask the community" button to create a question for the PayPal community.