public function simplePay()
 {
     $payouts = new \PayPal\Api\Payout();
     $senderBatchHeader = new \PayPal\Api\PayoutSenderBatchHeader();
     $senderBatchHeader->setSenderBatchId(uniqid())->setEmailSubject("You have a Payout!");
     $senderItem = new \PayPal\Api\PayoutItem();
     $senderItem->setRecipientType('Email')->setNote('Thanks for your patronage!')->setReceiver('*****@*****.**')->setSenderItemId("2014031400023")->setAmount(new \PayPal\Api\Currency('{
                             "value":"1.0",
                             "currency":"EUR"
                         }'));
     $payouts->setSenderBatchHeader($senderBatchHeader)->addItem($senderItem);
     $request = clone $payouts;
     try {
         $output = $payouts->createSynchronous($this->_api_context);
     } catch (\Exception $ex) {
         //	\ResultPrinter::printError("Created Single Synchronous Payout", "Payout", null, $request, $ex);
         exit(1);
     }
     // \ResultPrinter::printResult("Created Single Synchronous Payout", "Payout", $output->getBatchHeader()->getPayoutBatchId(), $request, $output);
     return $output;
 }
Example #2
0
           "sender_item_id": "item_2"
       },
       {
           "recipient_type": "EMAIL",
           "amount": {
               "value": 2.00,
               "currency": "USD"
           },
           "receiver": "*****@*****.**",
           "note": "Thank you.",
           "sender_item_id": "item_3"
       }
   ]
}
*/
$senderBatchHeader = new \PayPal\Api\PayoutSenderBatchHeader();
// ### NOTE:
// You can prevent duplicate batches from being processed. If you specify a `sender_batch_id` that was used in the last 30 days, the batch will not be processed. For items, you can specify a `sender_item_id`. If the value for the `sender_item_id` is a duplicate of a payout item that was processed in the last 30 days, the item will not be processed.
// #### Batch Header Instance
$senderBatchHeader->setSenderBatchId(uniqid())->setEmailSubject("You have a payment");
// #### Sender Item
// Please note that if you are using single payout with sync mode, you can only pass one Item in the request
$senderItem1 = new \PayPal\Api\PayoutItem();
$senderItem1->setRecipientType('Email')->setNote('Thanks you.')->setReceiver('*****@*****.**')->setSenderItemId("item_1" . uniqid())->setAmount(new \PayPal\Api\Currency('{
                        "value":"0.99",
                        "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",
Example #3
0
           },
           "items":[
               {
                   "recipient_type":"EMAIL",
                   "amount":{
                       "value":"1.0",
                       "currency":"USD"
                   },
                   "note":"Thanks for your patronage!",
                   "sender_item_id":"2014031400023",
                   "receiver":"*****@*****.**"
               }
           ]
       }
*/
$senderBatchHeader = new \PayPal\Api\PayoutSenderBatchHeader();
// ### NOTE:
// You can prevent duplicate batches from being processed. If you specify a `sender_batch_id` that was used in the last 30 days, the batch will not be processed. For items, you can specify a `sender_item_id`. If the value for the `sender_item_id` is a duplicate of a payout item that was processed in the last 30 days, the item will not be processed.
// #### Batch Header Instance
$senderBatchHeader->setSenderBatchId(uniqid())->setEmailSubject("You have a Payout!");
// #### Sender Item
// Please note that if you are using single payout with sync mode, you can only pass one Item in the request
$senderItem = new \PayPal\Api\PayoutItem();
$senderItem->setRecipientType('Email')->setNote('Thanks for your patronage!')->setReceiver('*****@*****.**')->setSenderItemId("2014031400023")->setAmount(new \PayPal\Api\Currency('{
                        "value":"1.0",
                        "currency":"USD"
                    }'));
$payouts->setSenderBatchHeader($senderBatchHeader)->addItem($senderItem);
// For Sample Purposes Only.
$request = clone $payouts;
// ### Create Payout
 public function payout(User $user, $amount, $currency, $paypalEmail, $withdrawalId)
 {
     $payouts = new Payout();
     $senderBatchHeader = new \PayPal\Api\PayoutSenderBatchHeader();
     $senderBatchHeader->setSenderBatchId($withdrawalId)->setEmailSubject("ADTW.ch withdraw");
     $senderItem = new \PayPal\Api\PayoutItem();
     $senderItem->setRecipientType('Email')->setNote('Thanks for your using ADTW.ch')->setReceiver($paypalEmail)->setSenderItemId($user->id . '_' . $withdrawalId . '_' . date('YmdHis'))->setAmount(new \PayPal\Api\Currency('{
                             "value":"' . floatval($amount) . '",
                             "currency":"' . strtoupper($currency) . '"
                         }'));
     $payouts->setSenderBatchHeader($senderBatchHeader)->addItem($senderItem);
     $output = $payouts->createSynchronous($this->apiContext);
     return $output;
 }