@@ 86-106 (lines=21) @@ | ||
83 | /** |
|
84 | * {@inheritdoc} |
|
85 | */ |
|
86 | public function capturePayment($order_id, $text, $amount = 0) |
|
87 | { |
|
88 | // Build request object from data passed to method. |
|
89 | $request = (new RequestCapturePayment()) |
|
90 | ->setMerchantInfo( |
|
91 | (new MerchantInfo()) |
|
92 | ->setMerchantSerialNumber($this->getMerchantSerialNumber()) |
|
93 | ) |
|
94 | ->setTransaction( |
|
95 | (new Transaction()) |
|
96 | ->setTransactionText($text) |
|
97 | ); |
|
98 | // If amount is 0 (default) all remaining founds will be captured. |
|
99 | if ($amount !== 0) { |
|
100 | $request->getTransaction()->setAmount($amount); |
|
101 | } |
|
102 | $resource = new CapturePayment($this->app, $this->getSubscriptionKey(), $order_id, $request); |
|
103 | /** @var \zaporylie\Vipps\Model\Payment\ResponseCapturePayment $response */ |
|
104 | $response = $resource->call(); |
|
105 | return $response; |
|
106 | } |
|
107 | ||
108 | /** |
|
109 | * {@inheritdoc} |
|
@@ 178-200 (lines=23) @@ | ||
175 | /** |
|
176 | * {@inheritdoc} |
|
177 | */ |
|
178 | public function refundPayment($order_id, $text, $amount = 0) |
|
179 | { |
|
180 | // Prepare request object based on data passed to method. |
|
181 | $request = (new RequestRefundPayment()) |
|
182 | ->setMerchantInfo( |
|
183 | (new MerchantInfo()) |
|
184 | ->setMerchantSerialNumber($this->getMerchantSerialNumber()) |
|
185 | ) |
|
186 | ->setTransaction( |
|
187 | (new Transaction()) |
|
188 | ->setTransactionText($text) |
|
189 | ); |
|
190 | ||
191 | // If amount is 0 all remaining founds will be refunded. |
|
192 | if ($amount !== 0) { |
|
193 | $request->getTransaction()->setAmount($amount); |
|
194 | } |
|
195 | // Create a resource. |
|
196 | $resource = new RefundPayment($this->app, $this->getSubscriptionKey(), $order_id, $request); |
|
197 | /** @var \zaporylie\Vipps\Model\Payment\ResponseRefundPayment $response */ |
|
198 | $response = $resource->call(); |
|
199 | return $response; |
|
200 | } |
|
201 | } |
|
202 |