|
@@ 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} |
|
@@ 202-225 (lines=24) @@
|
| 199 |
|
/** |
| 200 |
|
* {@inheritdoc} |
| 201 |
|
*/ |
| 202 |
|
public function refundPayment($order_id, $text, $amount = 0) |
| 203 |
|
{ |
| 204 |
|
// Prepare request object based on data passed to method. |
| 205 |
|
$request = (new RequestRefundPayment()) |
| 206 |
|
->setMerchantInfo( |
| 207 |
|
(new MerchantInfo()) |
| 208 |
|
->setMerchantSerialNumber($this->getMerchantSerialNumber()) |
| 209 |
|
) |
| 210 |
|
->setTransaction( |
| 211 |
|
(new Transaction()) |
| 212 |
|
->setTransactionText($text) |
| 213 |
|
); |
| 214 |
|
|
| 215 |
|
// If amount is 0 all remaining founds will be refunded. |
| 216 |
|
if ($amount !== 0) { |
| 217 |
|
$request->getTransaction()->setAmount($amount); |
| 218 |
|
} |
| 219 |
|
// Create a resource. |
| 220 |
|
$resource = new RefundPayment($this->app, $this->getSubscriptionKey(), $order_id, $request); |
| 221 |
|
$resource->setPath(str_replace('Ecomm', $this->customPath, $resource->getPath())); |
| 222 |
|
/** @var \zaporylie\Vipps\Model\Payment\ResponseRefundPayment $response */ |
| 223 |
|
$response = $resource->call(); |
| 224 |
|
return $response; |
| 225 |
|
} |
| 226 |
|
} |
| 227 |
|
|