|
@@ 172-196 (lines=25) @@
|
| 169 |
|
* |
| 170 |
|
* @return RedirectResponse |
| 171 |
|
*/ |
| 172 |
|
public function captureAction(int $paymentId, Request $request) |
| 173 |
|
{ |
| 174 |
|
$payment = $this->getPaymentFromId($paymentId); |
| 175 |
|
|
| 176 |
|
if ($payment) { |
| 177 |
|
$paymentHandler = $this->getPaymentHandler(); |
| 178 |
|
|
| 179 |
|
$amount = $request->query->get('amount'); |
| 180 |
|
if($amount) { |
| 181 |
|
$amount = AltaPay\createMoneyFromFloat($payment->getCurrencySymbol(), $amount); |
| 182 |
|
} |
| 183 |
|
|
| 184 |
|
$res = $paymentHandler->capture($payment, $amount); |
| 185 |
|
|
| 186 |
|
if ($res->isSuccessful()) { |
| 187 |
|
$this->addFlash('success', 'The payment for order '.$payment->getOrderId().' was captured.'); // @todo fix translation |
| 188 |
|
} else { |
| 189 |
|
$this->addFlash('danger', 'An error occurred during capture of the payment: '.$res->getErrorMessage()); // @todo fix translation |
| 190 |
|
} |
| 191 |
|
} |
| 192 |
|
|
| 193 |
|
$redirect = $request->headers->get('referer') ? $request->headers->get('referer') : $this->generateUrl('loevgaard_dandomain_altapay_payment_index'); |
| 194 |
|
|
| 195 |
|
return $this->redirect($redirect); |
| 196 |
|
} |
| 197 |
|
|
| 198 |
|
/** |
| 199 |
|
* @Method({"POST", "GET"}) |
|
@@ 207-231 (lines=25) @@
|
| 204 |
|
* |
| 205 |
|
* @return RedirectResponse |
| 206 |
|
*/ |
| 207 |
|
public function refundAction(int $paymentId, Request $request) |
| 208 |
|
{ |
| 209 |
|
$payment = $this->getPaymentFromId($paymentId); |
| 210 |
|
|
| 211 |
|
if ($payment) { |
| 212 |
|
$paymentHandler = $this->getPaymentHandler(); |
| 213 |
|
|
| 214 |
|
$amount = $request->query->get('amount'); |
| 215 |
|
if ($amount) { |
| 216 |
|
$amount = AltaPay\createMoneyFromFloat($payment->getCurrencySymbol(), $amount); |
| 217 |
|
} |
| 218 |
|
|
| 219 |
|
$res = $paymentHandler->refund($payment, $amount); |
| 220 |
|
|
| 221 |
|
if ($res->isSuccessful()) { |
| 222 |
|
$this->addFlash('success', 'The payment for order '.$payment->getOrderId().' was refunded.'); // @todo fix translation |
| 223 |
|
} else { |
| 224 |
|
$this->addFlash('danger', 'An error occurred during refund of the payment: '.$res->getErrorMessage()); // @todo fix translation |
| 225 |
|
} |
| 226 |
|
} |
| 227 |
|
|
| 228 |
|
$redirect = $request->headers->get('referer') ?: $this->generateUrl('loevgaard_dandomain_altapay_payment_index'); |
| 229 |
|
|
| 230 |
|
return $this->redirect($redirect); |
| 231 |
|
} |
| 232 |
|
|
| 233 |
|
/** |
| 234 |
|
* @Method("GET") |