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\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([
|
||||
|
|
|
|||
Loading…
Reference in a new issue