Ejemplo n.º 1
0
<?php

// # Create Single Synchronous Payout Sample
//
// This sample code demonstrate how you can create a synchronous payout sample, as documented here at:
// https://developer.paypal.com/docs/integration/direct/create-single-payout/
// API used: /v1/payments/payouts?sync_mode=true
require __DIR__ . '/../bootstrap.php';
// Create a new instance of Payout object
$payouts = new \PayPal\Api\Payout();
// This is how our body should look like:
/*
* {
           "sender_batch_header":{
               "sender_batch_id":"2014021801",
               "email_subject":"You have a Payout!"
           },
           "items":[
               {
                   "recipient_type":"EMAIL",
                   "amount":{
                       "value":"1.0",
                       "currency":"USD"
                   },
                   "note":"Thanks for your patronage!",
                   "sender_item_id":"2014031400023",
                   "receiver":"*****@*****.**"
               }
           ]
       }
*/
 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;
 }
Ejemplo n.º 3
0
<?php

// # Create Bulk Payout Sample
//
// This sample code demonstrate how you can create a synchronous payout sample, as documented here at:
// https://developer.paypal.com/docs/integration/direct/create-batch-payout/
// API used: /v1/payments/payouts
require __DIR__ . '/../bootstrap.php';
// Create a new instance of Payout object
$payouts = new \PayPal\Api\Payout();
// This is how our body should look like:
/*
*{
   "sender_batch_header": {
       "sender_batch_id": "random_uniq_id",
       "email_subject": "You have a payment"
   },
   "items": [
       {
           "recipient_type": "EMAIL",
           "amount": {
               "value": 0.99,
               "currency": "USD"
           },
           "receiver": "*****@*****.**",
           "note": "Thank you.",
           "sender_item_id": "item_1"
       },
       {
           "recipient_type": "EMAIL",
           "amount": {