diff --git a/src/Controller/PayMongoController.php b/src/Controller/PayMongoController.php index 21cd864c..af698acd 100644 --- a/src/Controller/PayMongoController.php +++ b/src/Controller/PayMongoController.php @@ -11,6 +11,8 @@ use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; use Symfony\Bundle\FrameworkBundle\Controller\Controller; +use DateTime; + class PayMongoController extends Controller { protected $pm; @@ -45,10 +47,8 @@ class PayMongoController extends Controller switch ($event_name) { case "payment.paid": return $this->handlePaymentPaid($event); - break; case "payment.failed": - return $this->handlePaymentPaid($event); - break; + return $this->handlePaymentFailed($event); case "payment.refunded": // TODO: handle refunds case "payment.refund.updated": case "checkout_session.payment.paid": @@ -69,6 +69,7 @@ class PayMongoController extends Controller if (!empty($obj)) { // mark as paid $obj->setStatus(TransactionStatus::PAID); + $obj->setDatePay(new DateTime()); $this->em->flush(); } @@ -77,7 +78,7 @@ class PayMongoController extends Controller ]); } - protected function handlePaymentFailed(Request $req) + protected function handlePaymentFailed($event) { // TODO: do something about failed payments? return $this->json([