Chris
Chris

Reputation: 4495

php / paypal: How to set receiver email?

I have multiple e-mail addresses registered with my paypal account. This way I can give regional customers a local paypal email dedicated to the local site. For example [email protected] and [email protected].

But how can I set the receiver (payee) email using the php rest api?

I tried:

$transaction->setEmail('[email protected]');

But I get the error message: PHP Fatal error: Call to undefined method

I found the correct API call: https://github.com/paypal/PayPal-PHP-SDK/blob/master/lib/PayPal/Api/Payee.php But I can't get it to work.

Everything else is working so far. I am following this example: https://github.com/paypal/PayPal-PHP-SDK/blob/master/sample/payments/CreatePaymentUsingPayPal.php

Upvotes: 1

Views: 1024

Answers (1)

chrhup
chrhup

Reputation: 11

Add this to the example at https://github.com/paypal/PayPal-PHP-SDK/blob/master/sample/payments/CreatePaymentUsingPayPal.php.

You need to create the $payee object

$payee = new Api\Payee();
$payee->setEmail("[email protected]");

Then when creating the $transaction object, call the 'setPayee' method, using $payee from above as the parameter.

$transaction = new Api\Transaction();
$transaction->setAmount($amount)
            ->setItemList($itemList)
            ->setDescription("Payment description")
            ->setInvoiceNumber(uniqid())
            ->setPayee($payee);

Upvotes: 1

Related Questions