|
3 | 3 | namespace Danielz\SettleApi\MerchantApi; |
4 | 4 |
|
5 | 5 | use Danielz\SettleApi\SettleApi; |
| 6 | +use Danielz\SettleApi\SettleApiException; |
6 | 7 |
|
| 8 | +/** |
| 9 | + * Class PaymentRequests |
| 10 | + * @package Danielz\SettleApi\MerchantApi |
| 11 | + */ |
7 | 12 | class PaymentRequests extends SettleApi |
8 | 13 | { |
| 14 | + /** |
| 15 | + * @return array |
| 16 | + * @throws SettleApiException |
| 17 | + */ |
9 | 18 | public function list() |
10 | 19 | { |
11 | 20 | return $this->call('GET', 'payment_request/'); |
12 | 21 | } |
13 | 22 |
|
| 23 | + /** |
| 24 | + * @param string $payment_request_id |
| 25 | + * @return array |
| 26 | + * @throws SettleApiException |
| 27 | + */ |
14 | 28 | public function get($payment_request_id) |
15 | 29 | { |
16 | 30 | return $this->call('GET', "payment_request/{$payment_request_id}/"); |
17 | 31 | } |
18 | 32 |
|
| 33 | + /** |
| 34 | + * @param array $data |
| 35 | + * @return array |
| 36 | + * @throws SettleApiException |
| 37 | + */ |
19 | 38 | public function create(array $data) |
20 | 39 | { |
21 | 40 | return $this->call('POST', 'payment_request/', $data); |
22 | 41 | } |
23 | 42 |
|
| 43 | + /** |
| 44 | + * @param string $payment_request_id |
| 45 | + * @param array $data |
| 46 | + * @return array |
| 47 | + * @throws SettleApiException |
| 48 | + */ |
24 | 49 | public function update($payment_request_id, array $data) |
25 | 50 | { |
26 | 51 | return $this->call('PUT', "payment_request/{$payment_request_id}/", $data); |
27 | 52 | } |
28 | 53 |
|
| 54 | + /** |
| 55 | + * @param string $payment_request_id |
| 56 | + * @return array |
| 57 | + * @throws SettleApiException |
| 58 | + */ |
29 | 59 | public function outcome($payment_request_id) |
30 | 60 | { |
31 | 61 | return $this->call('GET', "payment_request/{$payment_request_id}/outcome/"); |
32 | 62 | } |
| 63 | + |
| 64 | + /** |
| 65 | + * @param string $payment_request_id |
| 66 | + * @param string $currency |
| 67 | + * @param float|int $amount |
| 68 | + * @param float|int $additional_amount |
| 69 | + * @return array |
| 70 | + */ |
| 71 | + public function capture($payment_request_id, $currency, $amount, $additional_amount = 0) |
| 72 | + { |
| 73 | + $data = [ |
| 74 | + 'action' => 'capture', |
| 75 | + 'currency' => $currency, |
| 76 | + 'amount' => $amount, |
| 77 | + 'additional_amount' => $additional_amount, |
| 78 | + 'capture_id' => 'cap_' . date('YmdHis'), |
| 79 | + ]; |
| 80 | + |
| 81 | + return $this->update($payment_request_id, $data); |
| 82 | + } |
| 83 | + |
| 84 | + /** |
| 85 | + * @param string $payment_request_id |
| 86 | + * @param string $currency |
| 87 | + * @param float $amount |
| 88 | + * @param float|int $additional_amount |
| 89 | + * @param string $message |
| 90 | + * @return array |
| 91 | + */ |
| 92 | + public function refund($payment_request_id, $currency, $amount, $additional_amount = 0, $message = '') |
| 93 | + { |
| 94 | + $data = [ |
| 95 | + 'action' => 'refund', |
| 96 | + 'currency' => $currency, |
| 97 | + 'amount' => $amount, |
| 98 | + 'additional_amount' => $additional_amount, |
| 99 | + 'refund_id' => 'ref_' . date('YmdHis'), |
| 100 | + 'text' => $message, |
| 101 | + ]; |
| 102 | + |
| 103 | + return $this->update($payment_request_id, $data); |
| 104 | + } |
| 105 | + |
| 106 | + /** |
| 107 | + * @param string $payment_request_id |
| 108 | + * @return string |
| 109 | + */ |
| 110 | + public function getPaymentLink($payment_request_id) |
| 111 | + { |
| 112 | + return $this->createLink('payment_link', compact('payment_request_id')); |
| 113 | + } |
| 114 | + |
| 115 | + /** |
| 116 | + * @param string $payment_request_id |
| 117 | + * @return string |
| 118 | + */ |
| 119 | + public function getMobilePaymentLink($payment_request_id) |
| 120 | + { |
| 121 | + return $this->createLink('payment_link_mobile', compact('payment_request_id')); |
| 122 | + } |
33 | 123 | } |
0 commit comments