Exemplo n.º 1
0
                        "currency":"USD"
                    }'));
// #### Sender Item 2
// There are many different ways of assigning values in PayPal SDK. Here is another way where you could directly inject json string.
$senderItem2 = new \PayPal\Api\PayoutItem('{
            "recipient_type": "EMAIL",
            "amount": {
                "value": 0.90,
                "currency": "USD"
            },
            "receiver": "*****@*****.**",
            "note": "Thank you.",
            "sender_item_id": "item_2"
        }');
// #### Sender Item 3
// One more way of assigning values in constructor when creating instance of PayPalModel object. Injecting array.
$senderItem3 = new \PayPal\Api\PayoutItem(array("recipient_type" => "EMAIL", "receiver" => "*****@*****.**", "note" => "Thank you.", "sender_item_id" => uniqid(), "amount" => array("value" => "0.90", "currency" => "USD")));
$payouts->setSenderBatchHeader($senderBatchHeader)->addItem($senderItem1)->addItem($senderItem2)->addItem($senderItem3);
// For Sample Purposes Only.
$request = clone $payouts;
// ### Create Payout
try {
    $output = $payouts->create(null, $apiContext);
} catch (Exception $ex) {
    // NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY
    ResultPrinter::printError("Created Batch Payout", "Payout", null, $request, $ex);
    exit(1);
}
// NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY
ResultPrinter::printResult("Created Batch Payout", "Payout", $output->getBatchHeader()->getPayoutBatchId(), $request, $output);
return $output;