| Conditions | 2 |
| Paths | 2 |
| Total Lines | 34 |
| Code Lines | 21 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 27 | public function createPayout( |
||
| 28 | string $subject, |
||
| 29 | string $note, |
||
| 30 | string $receiverEmail, |
||
| 31 | string $itemId, |
||
| 32 | float $amount, |
||
| 33 | string $currency |
||
| 34 | ): ?PayoutBatch { |
||
| 35 | $payout = new Payout(); |
||
| 36 | $senderBatchHeader = new PayoutSenderBatchHeader(); |
||
| 37 | $senderBatchHeader |
||
| 38 | ->setSenderBatchId(uniqid()) |
||
| 39 | ->setEmailSubject($subject); |
||
| 40 | $senderItem = new PayoutItem(); |
||
| 41 | $senderItem->setRecipientType('Email') |
||
| 42 | ->setNote($note) |
||
| 43 | ->setReceiver($receiverEmail) |
||
| 44 | ->setSenderItemId($itemId) |
||
| 45 | ->setAmount(new Currency(json_encode((object) [ |
||
| 46 | 'value' => $amount, |
||
| 47 | 'currency' => $currency, |
||
| 48 | ]))); |
||
| 49 | |||
| 50 | $payout->setSenderBatchHeader($senderBatchHeader) |
||
| 51 | ->addItem($senderItem); |
||
| 52 | |||
| 53 | try { |
||
| 54 | $payouts = $payout->create(null, $this->apiContext); |
||
| 55 | } catch (Exception $e) { |
||
| 56 | $this->logger->error('Error on PayPal::createPayout = ' . $e->getMessage()); |
||
| 57 | return null; |
||
| 58 | } |
||
| 59 | |||
| 60 | return $payouts; |
||
| 61 | } |
||
| 80 |