/** * @dataProvider mockProvider * @param Payout $obj */ public function testGet($obj, $mockApiContext) { $mockPPRestCall = $this->getMockBuilder('\\PayPal\\Transport\\PayPalRestCall')->disableOriginalConstructor()->getMock(); $mockPPRestCall->expects($this->any())->method('execute')->will($this->returnValue(PayoutBatchTest::getJson())); $result = $obj->get("payoutBatchId", $mockApiContext, $mockPPRestCall); $this->assertNotNull($result); }
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; }
/** * @depends testCreate * @param $payoutBatch PayoutBatch * @return PayoutBatch */ public function testGet($payoutBatch) { $result = Payout::get($payoutBatch->getBatchHeader()->getPayoutBatchId(), $this->apiContext, $this->mockPayPalRestCall); $this->assertNotNull($result); $this->assertNotNull($result->getBatchHeader()->getBatchStatus()); $this->assertEquals(PayoutsFunctionalTest::$batchId, $result->getBatchHeader()->getSenderBatchHeader()->getSenderBatchId()); return $result; }
<?php // # Get Payout Batch Status Sample // // This sample code demonstrate how you can get the batch payout status of a created batch payout, as documented here at: // https://developer.paypal.com/docs/api/#get-the-status-of-a-batch-payout // API used: GET /v1/payments/payouts/<Payout-Batch-Id> /** @var \PayPal\Api\PayoutBatch $payoutBatch */ $payoutBatch = (require 'CreateBatchPayout.php'); // ## Payout Batch ID // You can replace this with your Payout Batch Id on already created Payout. $payoutBatchId = $payoutBatch->getBatchHeader()->getPayoutBatchId(); // ### Get Payout Batch Status try { $output = \PayPal\Api\Payout::get($payoutBatchId, $apiContext); } catch (Exception $ex) { ResultPrinter::printError("Get Payout Batch Status", "PayoutBatch", null, $payoutBatchId, $ex); exit(1); } ResultPrinter::printResult("Get Payout Batch Status", "PayoutBatch", $output->getBatchHeader()->getPayoutBatchId(), null, $output); return $output;