Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
kohinos-tav
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
6
Merge Requests
6
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
agplv3
kohinos-tav
Commits
10dcf00f
Commit
10dcf00f
authored
Mar 26, 2024
by
Yvon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
clean debug and try another way to handle recurring payments separately and avoid duplicates
parent
f424b1b8
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
9 additions
and
38 deletions
+9
-38
PaymentController.php
src/Controller/PaymentController.php
+2
-37
PaymentStatusExtension.php
src/EventListener/PaymentStatusExtension.php
+7
-1
No files found.
src/Controller/PaymentController.php
View file @
10dcf00f
...
@@ -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'
);
}
}
...
...
src/EventListener/PaymentStatusExtension.php
View file @
10dcf00f
...
@@ -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
));
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment