|
@@ 136-154 (lines=19) @@
|
| 133 |
|
* |
| 134 |
|
* @return RedirectResponse |
| 135 |
|
*/ |
| 136 |
|
public function captureAction(int $paymentId, Request $request) |
| 137 |
|
{ |
| 138 |
|
$payment = $this->getPaymentFromId($paymentId); |
| 139 |
|
|
| 140 |
|
if ($payment) { |
| 141 |
|
$paymentHandler = $this->getPaymentHandler(); |
| 142 |
|
$res = $paymentHandler->capture($payment, $request->query->get('amount')); |
| 143 |
|
|
| 144 |
|
if ($res->isSuccessful()) { |
| 145 |
|
$this->addFlash('success', 'The payment for order '.$payment->getOrderId().' was captured.'); // @todo fix translation |
| 146 |
|
} else { |
| 147 |
|
$this->addFlash('danger', 'An error occurred during capture of the payment: '.$res->getErrorMessage()); // @todo fix translation |
| 148 |
|
} |
| 149 |
|
} |
| 150 |
|
|
| 151 |
|
$redirect = $request->headers->get('referer') ? $request->headers->get('referer') : $this->generateUrl('loevgaard_dandomain_altapay_payment_index'); |
| 152 |
|
|
| 153 |
|
return $this->redirect($redirect); |
| 154 |
|
} |
| 155 |
|
|
| 156 |
|
/** |
| 157 |
|
* @Method({"POST", "GET"}) |
|
@@ 165-183 (lines=19) @@
|
| 162 |
|
* |
| 163 |
|
* @return RedirectResponse |
| 164 |
|
*/ |
| 165 |
|
public function refundAction(int $paymentId, Request $request) |
| 166 |
|
{ |
| 167 |
|
$payment = $this->getPaymentFromId($paymentId); |
| 168 |
|
|
| 169 |
|
if ($payment) { |
| 170 |
|
$paymentHandler = $this->getPaymentHandler(); |
| 171 |
|
$res = $paymentHandler->refund($payment, null, $request->query->get('amount')); |
| 172 |
|
|
| 173 |
|
if ($res->isSuccessful()) { |
| 174 |
|
$this->addFlash('success', 'The payment for order '.$payment->getOrderId().' was refunded.'); // @todo fix translation |
| 175 |
|
} else { |
| 176 |
|
$this->addFlash('danger', 'An error occurred during refund of the payment: '.$res->getErrorMessage()); // @todo fix translation |
| 177 |
|
} |
| 178 |
|
} |
| 179 |
|
|
| 180 |
|
$redirect = $request->headers->get('referer') ?: $this->generateUrl('loevgaard_dandomain_altapay_payment_index'); |
| 181 |
|
|
| 182 |
|
return $this->redirect($redirect); |
| 183 |
|
} |
| 184 |
|
|
| 185 |
|
/** |
| 186 |
|
* @Method("GET") |