Commit d4cd8df1 by Yvon

try to catch recurring payment occurence

parent 4cee20f6
...@@ -150,22 +150,24 @@ class PaymentController extends AbstractController ...@@ -150,22 +150,24 @@ class PaymentController extends AbstractController
*/ */
public function notifyRecurringPaymentAction(Request $request) public function notifyRecurringPaymentAction(Request $request)
{ {
try { $vads_cust_email = $request->request->get("vads_cust_email");
$token = $this->payum->getHttpRequestVerifier()->verify($request); $recurringPayments = $this->em->getRepository(Payment::class)->findBy([
} catch (\Exception $e) { 'isRecurrent' => true,
// Token expired 'clientEmail' => $vads_cust_email,
return new Response("Token expired"); ]);
if(!$recurringPayments) {
return new Response("No recurring payments with email " . $vads_cust_email);
} }
// Get payment $vads_identifier = $request->request->get("vads_identifier");
$gateway = $this->payum->getGateway($token->getGatewayName()); foreach($recurringPayments as $rp) {
$gateway->execute($status = new GetHumanStatus($token)); $details = json_decode($rp->getDetails(), true);
$payment = $status->getFirstModel(); if($details['vads_identifier'] == $vads_identifier) {
if($payment->getIsRecurrent()) { return new Response("Found matching recurring payment !");
$gateway->execute(new Notify($token)); }
return new Response("Execute notify recurring payment");
} }
return new Response("Payment is not marked recurring."); return new Response("No recurring payments with vads_identifier " . $vads_identifier);
} }
/** /**
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment