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