Prevent success handler from catching failed paymongo payment attempts #801
This commit is contained in:
parent
75b2ada03f
commit
ad841a7e25
1 changed files with 5 additions and 4 deletions
|
|
@ -11,6 +11,8 @@ use Symfony\Component\HttpFoundation\Request;
|
||||||
use Symfony\Component\HttpFoundation\Response;
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
|
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
|
||||||
|
|
||||||
|
use DateTime;
|
||||||
|
|
||||||
class PayMongoController extends Controller
|
class PayMongoController extends Controller
|
||||||
{
|
{
|
||||||
protected $pm;
|
protected $pm;
|
||||||
|
|
@ -45,10 +47,8 @@ class PayMongoController extends Controller
|
||||||
switch ($event_name) {
|
switch ($event_name) {
|
||||||
case "payment.paid":
|
case "payment.paid":
|
||||||
return $this->handlePaymentPaid($event);
|
return $this->handlePaymentPaid($event);
|
||||||
break;
|
|
||||||
case "payment.failed":
|
case "payment.failed":
|
||||||
return $this->handlePaymentPaid($event);
|
return $this->handlePaymentFailed($event);
|
||||||
break;
|
|
||||||
case "payment.refunded": // TODO: handle refunds
|
case "payment.refunded": // TODO: handle refunds
|
||||||
case "payment.refund.updated":
|
case "payment.refund.updated":
|
||||||
case "checkout_session.payment.paid":
|
case "checkout_session.payment.paid":
|
||||||
|
|
@ -69,6 +69,7 @@ class PayMongoController extends Controller
|
||||||
if (!empty($obj)) {
|
if (!empty($obj)) {
|
||||||
// mark as paid
|
// mark as paid
|
||||||
$obj->setStatus(TransactionStatus::PAID);
|
$obj->setStatus(TransactionStatus::PAID);
|
||||||
|
$obj->setDatePay(new DateTime());
|
||||||
$this->em->flush();
|
$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?
|
// TODO: do something about failed payments?
|
||||||
return $this->json([
|
return $this->json([
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue