@@ 106-127 (lines=22) @@ | ||
103 | /** |
|
104 | * {@inheritdoc} |
|
105 | */ |
|
106 | public function capturePayment($order_id, $text, $amount = 0) |
|
107 | { |
|
108 | // Build request object from data passed to method. |
|
109 | $request = (new RequestCapturePayment()) |
|
110 | ->setMerchantInfo( |
|
111 | (new MerchantInfo()) |
|
112 | ->setMerchantSerialNumber($this->getMerchantSerialNumber()) |
|
113 | ) |
|
114 | ->setTransaction( |
|
115 | (new Transaction()) |
|
116 | ->setTransactionText($text) |
|
117 | ); |
|
118 | // If amount is 0 (default) all remaining founds will be captured. |
|
119 | if ($amount !== 0) { |
|
120 | $request->getTransaction()->setAmount($amount); |
|
121 | } |
|
122 | $resource = new CapturePayment($this->app, $this->getSubscriptionKey(), $order_id, $request); |
|
123 | $resource->setPath(str_replace('ecomm', $this->customPath, $resource->getPath())); |
|
124 | /** @var \zaporylie\Vipps\Model\Payment\ResponseCapturePayment $response */ |
|
125 | $response = $resource->call(); |
|
126 | return $response; |
|
127 | } |
|
128 | ||
129 | /** |
|
130 | * {@inheritdoc} |
|
@@ 235-258 (lines=24) @@ | ||
232 | /** |
|
233 | * {@inheritdoc} |
|
234 | */ |
|
235 | public function refundPayment($order_id, $text, $amount = 0) |
|
236 | { |
|
237 | // Prepare request object based on data passed to method. |
|
238 | $request = (new RequestRefundPayment()) |
|
239 | ->setMerchantInfo( |
|
240 | (new MerchantInfo()) |
|
241 | ->setMerchantSerialNumber($this->getMerchantSerialNumber()) |
|
242 | ) |
|
243 | ->setTransaction( |
|
244 | (new Transaction()) |
|
245 | ->setTransactionText($text) |
|
246 | ); |
|
247 | ||
248 | // If amount is 0 all remaining founds will be refunded. |
|
249 | if ($amount !== 0) { |
|
250 | $request->getTransaction()->setAmount($amount); |
|
251 | } |
|
252 | // Create a resource. |
|
253 | $resource = new RefundPayment($this->app, $this->getSubscriptionKey(), $order_id, $request); |
|
254 | $resource->setPath(str_replace('ecomm', $this->customPath, $resource->getPath())); |
|
255 | /** @var \zaporylie\Vipps\Model\Payment\ResponseRefundPayment $response */ |
|
256 | $response = $resource->call(); |
|
257 | return $response; |
|
258 | } |
|
259 | } |
|
260 |