|
@@ 22-46 (lines=25) @@
|
| 19 |
|
* @param string|int $id Can be both altapay id or order id |
| 20 |
|
* @return Response |
| 21 |
|
*/ |
| 22 |
|
public function paymentCaptureAction($id) |
| 23 |
|
{ |
| 24 |
|
$data = ['error' => false]; |
| 25 |
|
|
| 26 |
|
$payment = $this->findPaymentByOrderIdOrAltapayId($id); |
| 27 |
|
|
| 28 |
|
$altapay = $this->getAltapayClient(); |
| 29 |
|
|
| 30 |
|
$payload = new CaptureReservation($payment->getAltapayId()); |
| 31 |
|
$res = $altapay->captureReservation($payload); |
| 32 |
|
|
| 33 |
|
if($res->isSuccessful()) { |
| 34 |
|
$transactions = $res->getTransactions(); |
| 35 |
|
if(count($transactions)) { |
| 36 |
|
$data['captured_amount'] = $transactions[0]->getCapturedAmount(); |
| 37 |
|
} |
| 38 |
|
} else { |
| 39 |
|
$data['error'] = true; |
| 40 |
|
} |
| 41 |
|
|
| 42 |
|
$view = $this->view($data); |
| 43 |
|
$view->setTemplate('@LoevgaardDandomainAltapay/api/payment_capture.html.twig'); |
| 44 |
|
|
| 45 |
|
return $this->handleView($view); |
| 46 |
|
} |
| 47 |
|
|
| 48 |
|
/** |
| 49 |
|
* @Annotations\Post("/payment/{id}/refund") |
|
@@ 55-79 (lines=25) @@
|
| 52 |
|
* @param string|int $id Can be both altapay id or order id |
| 53 |
|
* @return Response |
| 54 |
|
*/ |
| 55 |
|
public function paymentRefundAction(Request $request, $id) |
| 56 |
|
{ |
| 57 |
|
$data = ['error' => false]; |
| 58 |
|
|
| 59 |
|
$payment = $this->findPaymentByOrderIdOrAltapayId($id); |
| 60 |
|
|
| 61 |
|
$altapay = $this->getAltapayClient(); |
| 62 |
|
|
| 63 |
|
$payload = new RefundCapturedReservation($payment->getAltapayId()); |
| 64 |
|
$res = $altapay->refundCapturedReservation($payload); |
| 65 |
|
|
| 66 |
|
if($res->isSuccessful()) { |
| 67 |
|
$transactions = $res->getTransactions(); |
| 68 |
|
if(count($transactions)) { |
| 69 |
|
$data['refunded_amount'] = $transactions[0]->getRefundedAmount(); |
| 70 |
|
} |
| 71 |
|
} else { |
| 72 |
|
$data['error'] = true; |
| 73 |
|
} |
| 74 |
|
|
| 75 |
|
$view = $this->view($data); |
| 76 |
|
$view->setTemplate('@LoevgaardDandomainAltapay/api/payment_capture.html.twig'); |
| 77 |
|
|
| 78 |
|
return $this->handleView($view); |
| 79 |
|
} |
| 80 |
|
|
| 81 |
|
/** |
| 82 |
|
* @param string|int $id |