Commit 10dcf00f by Yvon

clean debug and try another way to handle recurring payments separately and avoid duplicates

parent f424b1b8
...@@ -211,24 +211,6 @@ class PaymentController extends AbstractController ...@@ -211,24 +211,6 @@ class PaymentController extends AbstractController
*/ */
public function doneAction(Request $request) public function doneAction(Request $request)
{ {
//As I don't understand why so many events are created here, I am just trying to
//canalyze the recurring paiement creations out of here without generating any event.
if($request->request->get('vads_page_action') === 'REGISTER_PAY_SUBSCRIBE')
{
if($request->request->get('vads_identifier_status') === 'CREATED') {
$this->addFlash(
'success',
$this->translator->trans('Cotisation payée et payment récurrent enregistré !')
);
} else {
$this->addFlash(
'error',
$this->translator->trans('Cotisation non payée et payement récurrent non enregistré.')
);
}
return $this->redirectToRoute('index');
}
try { try {
$token = $this->payum->getHttpRequestVerifier()->verify($request); $token = $this->payum->getHttpRequestVerifier()->verify($request);
} catch (\Exception $e) { } catch (\Exception $e) {
...@@ -239,29 +221,12 @@ class PaymentController extends AbstractController ...@@ -239,29 +221,12 @@ class PaymentController extends AbstractController
// Get payment // Get payment
$gateway = $this->payum->getGateway($token->getGatewayName()); $gateway = $this->payum->getGateway($token->getGatewayName());
$gateway->execute($status = new GetHumanStatus($token)); $gateway->execute($status = new GetHumanStatus($token));
var_dump("I bet postExecute is called before I die");
die;
$payment = $status->getFirstModel(); $payment = $status->getFirstModel();
//Done action is normaly only accessed by users browser, not by Payzen agent, if (GetHumanStatus::STATUS_NEW == $payment->getStatus()) {
//so we should not be handling recurring payment after the initial payement.
//We must indeed prevent a user from a browser reload e.g.
if ($payment->getIsRecurrent()) {
var_dump("This is recurring payment, yes !");
die;
//Because we take into account all incoming notifications for recurring payments,
//neither successive recurring payment occurences nor initial recurring payment should be
//handled by this controler as it will lead to duplicates.
//so...
//- do not execute notify
//- do not invalidate token
} elseif (GetHumanStatus::STATUS_NEW == $payment->getStatus()) {
// First time we receive notification for this payment : execute Notify action and invalidate token
$gateway->execute(new Notify($token)); $gateway->execute(new Notify($token));
$this->payum->getHttpRequestVerifier()->invalidate($token);
} else { } else {
//maybe user is trying to trigger another occurence of a recurring payment $this->payum->getHttpRequestVerifier()->invalidate($token);
return $this->redirectToRoute('index'); return $this->redirectToRoute('index');
} }
......
...@@ -59,7 +59,6 @@ class PaymentStatusExtension implements ExtensionInterface ...@@ -59,7 +59,6 @@ class PaymentStatusExtension implements ExtensionInterface
*/ */
public function onPostExecute(Context $context) public function onPostExecute(Context $context)
{ {
var_dump("onPostExecute called !!!!");
$request = $context->getRequest(); $request = $context->getRequest();
if (false == $request instanceof Generic) { if (false == $request instanceof Generic) {
return; return;
...@@ -79,6 +78,13 @@ class PaymentStatusExtension implements ExtensionInterface ...@@ -79,6 +78,13 @@ class PaymentStatusExtension implements ExtensionInterface
return; return;
} }
if ($payment->getIsRecurrent()) {
//Do not handle recurring payments here as it causes lot of weird duplicates.
//Recurring payment are handled manually by direct call to core handler from
//payment controller, without calling event
return;
}
// Get current & new status // Get current & new status
$context->getGateway()->execute($status = new GetHumanStatus($payment)); $context->getGateway()->execute($status = new GetHumanStatus($payment));
......
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