| Total Complexity | 7 |
| Total Lines | 120 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 8 | abstract class Driver implements DriverInterface |
||
| 9 | { |
||
| 10 | /** |
||
| 11 | * Invoice |
||
| 12 | * |
||
| 13 | * @var Invoice |
||
| 14 | */ |
||
| 15 | protected $invoice; |
||
| 16 | |||
| 17 | /** |
||
| 18 | * Driver's settings |
||
| 19 | * |
||
| 20 | * @var |
||
| 21 | */ |
||
| 22 | protected $settings; |
||
| 23 | |||
| 24 | /** |
||
| 25 | * Driver constructor. |
||
| 26 | * |
||
| 27 | * Driver constructor. |
||
| 28 | * @param Invoice $invoice |
||
| 29 | * @param $settings |
||
| 30 | */ |
||
| 31 | abstract public function __construct(Invoice $invoice, $settings); |
||
| 32 | |||
| 33 | /** |
||
| 34 | * Set payment amount. |
||
| 35 | * |
||
| 36 | * @param $amount |
||
| 37 | * @return $this |
||
| 38 | * @throws \Exception |
||
| 39 | */ |
||
| 40 | public function amount($amount) |
||
| 41 | { |
||
| 42 | $this->invoice->amount($amount); |
||
| 43 | |||
| 44 | return $this; |
||
| 45 | } |
||
| 46 | |||
| 47 | /** |
||
| 48 | * Set a piece of data to the details. |
||
| 49 | * |
||
| 50 | * @param $key |
||
| 51 | * @param $value|null |
||
| 52 | * @return $this|DriverInterface |
||
| 53 | */ |
||
| 54 | public function detail($key, $value = null) |
||
| 55 | { |
||
| 56 | $key = is_array($key) ? $key : [$key => $value]; |
||
| 57 | |||
| 58 | foreach ($key as $k => $v) { |
||
| 59 | $this->invoice->detail($key, $value); |
||
| 60 | } |
||
| 61 | |||
| 62 | return $this; |
||
| 63 | } |
||
| 64 | |||
| 65 | /** |
||
| 66 | * Set invoice. |
||
| 67 | * |
||
| 68 | * @param Invoice $invoice |
||
| 69 | * @return $this |
||
| 70 | */ |
||
| 71 | public function invoice(Invoice $invoice) |
||
| 76 | } |
||
| 77 | |||
| 78 | /** |
||
| 79 | * Retrieve invoice. |
||
| 80 | * |
||
| 81 | * @return Invoice |
||
| 82 | */ |
||
| 83 | public function getInvoice() |
||
| 86 | } |
||
| 87 | |||
| 88 | /** |
||
| 89 | * Create payment redirection form. |
||
| 90 | * |
||
| 91 | * @param $action |
||
| 92 | * @param array $inputs |
||
| 93 | * @param string $method |
||
| 94 | * @return string |
||
| 95 | */ |
||
| 96 | public function redirectWithForm($action, array $inputs = [], $method = 'POST') |
||
| 104 | ] |
||
| 105 | ); |
||
| 106 | } |
||
| 107 | |||
| 108 | /** |
||
| 109 | * Purchase the invoice |
||
| 110 | * |
||
| 111 | * @return string |
||
| 112 | */ |
||
| 113 | abstract public function purchase(); |
||
| 114 | |||
| 115 | /** |
||
| 116 | * Pay the invoice |
||
| 117 | * |
||
| 118 | * @return mixed |
||
| 119 | */ |
||
| 120 | abstract public function pay(); |
||
| 121 | |||
| 122 | /** |
||
| 123 | * Verify the payment |
||
| 124 | * |
||
| 125 | * @return mixed |
||
| 126 | */ |
||
| 127 | abstract public function verify(); |
||
| 128 | } |
||
| 129 |