Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
kohinos
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
9
Issues
9
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
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
cooperatic-mlc
kohinos
Commits
e5c29138
Commit
e5c29138
authored
Sep 09, 2020
by
Damien Moulard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix paiement payzen adhesion
parent
84b2bd30
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
56 additions
and
97 deletions
+56
-97
FluxController.php
src/Controller/FluxController.php
+56
-97
No files found.
src/Controller/FluxController.php
View file @
e5c29138
...
...
@@ -11,6 +11,7 @@ use Symfony\Component\Form\AbstractType;
use
Symfony\Component\Form\Form
;
use
Symfony\Component\HttpFoundation\Request
;
use
Symfony\Component\HttpFoundation\Response
;
use
Symfony\Component\HttpFoundation\JsonResponse
;
use
Symfony\Component\HttpFoundation\StreamedResponse
;
use
Symfony\Component\HttpFoundation\Session\SessionInterface
;
use
Symfony\Component\Routing\Annotation\Route
;
...
...
@@ -291,7 +292,7 @@ class FluxController extends AbstractController
/**
* Fonction de traitement du paiement, à appeler :
* - automatiquement lorsqu'un événement se produit sur le site de Paiement
* - automatiquement lorsqu'un événement se produit sur le site de Paiement
(notification)
* - au retour sur le site par l'utilisateur
*
* @Route("/payment/done/", name="payment_done")
...
...
@@ -301,56 +302,7 @@ class FluxController extends AbstractController
try
{
$token
=
$this
->
payum
->
getHttpRequestVerifier
()
->
verify
(
$request
);
}
catch
(
\Exception
$e
)
{
// Token expiré : retour sur site après paiement
// Get last payment
try
{
$payment
=
$this
->
em
->
getRepository
(
Payment
::
class
)
->
getUserLastPayment
(
$this
->
getUser
()
->
getId
());
}
catch
(
\Exception
$e
)
{
return
$this
->
redirectToRoute
(
'index'
);
}
if
(
!
is_null
(
$payment
))
{
if
(
$payment
->
getStatus
()
==
GetHumanStatus
::
STATUS_CAPTURED
||
$payment
->
getStatus
()
==
GetHumanStatus
::
STATUS_AUTHORIZED
)
{
$type
=
$payment
->
getDescription
();
if
(
Payment
::
TYPE_ACHAT_MONNAIE_ADHERENT
==
$type
||
Payment
::
TYPE_ACHAT_MONNAIE_PRESTA
==
$type
)
{
$this
->
addFlash
(
'success'
,
$this
->
translator
->
trans
(
'Achat de monnaie locale bien effectué !'
)
);
}
else
if
(
Payment
::
TYPE_COTISATION_ADHERENT
==
$type
||
Payment
::
TYPE_COTISATION_PRESTA
==
$type
)
{
$this
->
addFlash
(
'success'
,
$this
->
translator
->
trans
(
'Cotisation bien reçue. Merci !'
)
);
}
else
if
(
Payment
::
TYPE_ADHESION
==
$type
)
{
$this
->
addFlash
(
'success'
,
$this
->
translator
->
trans
(
'Votre adhésion a bien été prise en compte, bienvenue !'
)
);
}
// Update payment status
$payment
->
setStatus
(
$payment
->
getStatus
()
.
';done'
);
$this
->
em
->
persist
(
$payment
);
$this
->
em
->
flush
();
}
else
if
(
$payment
->
getStatus
()
==
GetHumanStatus
::
STATUS_CANCELED
||
$payment
->
getStatus
()
==
GetHumanStatus
::
STATUS_EXPIRED
||
$payment
->
getStatus
()
==
GetHumanStatus
::
STATUS_FAILED
)
{
$this
->
addFlash
(
'error'
,
$this
->
translator
->
trans
(
'La transaction a été annulée.'
)
);
$payment
->
setStatus
(
$payment
->
getStatus
()
.
';done'
);
$this
->
em
->
persist
(
$payment
);
$this
->
em
->
flush
();
}
}
// Token expired
return
$this
->
redirectToRoute
(
'index'
);
}
...
...
@@ -362,8 +314,59 @@ class FluxController extends AbstractController
// Execute 'done' action according to payment status
$gateway
->
execute
(
$status
=
new
GetHumanStatus
(
$token
));
// Get payment
& update status
// Get payment
$payment
=
$status
->
getFirstModel
();
// Check for actual payment status. If not null or new: payment has already been processed.
if
(
$payment
->
getStatus
()
==
GetHumanStatus
::
STATUS_CAPTURED
||
$payment
->
getStatus
()
==
GetHumanStatus
::
STATUS_AUTHORIZED
)
{
// Invalidate token
$this
->
payum
->
getHttpRequestVerifier
()
->
invalidate
(
$token
);
$type
=
$payment
->
getDescription
();
if
(
Payment
::
TYPE_ACHAT_MONNAIE_ADHERENT
==
$type
||
Payment
::
TYPE_ACHAT_MONNAIE_PRESTA
==
$type
)
{
$this
->
addFlash
(
'success'
,
$this
->
translator
->
trans
(
'Achat de monnaie locale bien effectué !'
)
);
}
else
if
(
Payment
::
TYPE_COTISATION_ADHERENT
==
$type
||
Payment
::
TYPE_COTISATION_PRESTA
==
$type
)
{
$this
->
addFlash
(
'success'
,
$this
->
translator
->
trans
(
'Cotisation bien reçue. Merci !'
)
);
}
else
if
(
Payment
::
TYPE_ADHESION
==
$type
)
{
$this
->
addFlash
(
'success'
,
$this
->
translator
->
trans
(
'Votre adhésion a bien été prise en compte, bienvenue !'
)
);
// Connect new user
return
$this
->
guardHandler
->
authenticateUserAndHandleSuccess
(
$this
->
em
->
getRepository
(
User
::
class
)
->
findOneBy
(
array
(
'id'
=>
$payment
->
getClientId
())),
$request
,
$this
->
authenticator
,
'main'
);
}
return
$this
->
redirectToRoute
(
'index'
);
}
else
if
(
$payment
->
getStatus
()
==
GetHumanStatus
::
STATUS_CANCELED
||
$payment
->
getStatus
()
==
GetHumanStatus
::
STATUS_EXPIRED
||
$payment
->
getStatus
()
==
GetHumanStatus
::
STATUS_FAILED
)
{
// Invalidate token
$this
->
payum
->
getHttpRequestVerifier
()
->
invalidate
(
$token
);
$this
->
addFlash
(
'error'
,
$this
->
translator
->
trans
(
'La transaction a été annulée.'
)
);
return
$this
->
redirectToRoute
(
'index'
);
}
// We got here, payment hasn't been processed, we're in the notification process. Update payment status and go on.
$payment
->
setStatus
(
$status
->
getValue
());
$this
->
em
->
persist
(
$payment
);
$this
->
em
->
flush
();
...
...
@@ -507,53 +510,9 @@ class FluxController extends AbstractController
MLCEvents
::
FLUX
,
new
FluxEvent
(
$flux
)
);
// Add flash message here too in case Gataway doesn't notify
if
(
Payment
::
TYPE_ACHAT_MONNAIE_ADHERENT
==
$type
||
Payment
::
TYPE_ACHAT_MONNAIE_PRESTA
==
$type
)
{
$this
->
addFlash
(
'success'
,
$this
->
translator
->
trans
(
'Achat de monnaie locale bien effectué !'
)
);
}
else
if
(
Payment
::
TYPE_COTISATION_ADHERENT
==
$type
||
Payment
::
TYPE_COTISATION_PRESTA
==
$type
)
{
$this
->
addFlash
(
'success'
,
$this
->
translator
->
trans
(
'Cotisation bien reçue. Merci !'
)
);
}
else
if
(
Payment
::
TYPE_ADHESION
==
$type
)
{
$this
->
addFlash
(
'success'
,
$this
->
translator
->
trans
(
'Votre adhésion a bien été prise en compte, bienvenue !'
)
);
}
// Invalidate token
$this
->
payum
->
getHttpRequestVerifier
()
->
invalidate
(
$token
);
}
else
if
(
$status
->
getValue
()
==
GetHumanStatus
::
STATUS_CANCELED
||
$status
->
getValue
()
==
GetHumanStatus
::
STATUS_EXPIRED
||
$status
->
getValue
()
==
GetHumanStatus
::
STATUS_FAILED
)
{
$this
->
addFlash
(
'error'
,
$this
->
translator
->
trans
(
'La transaction a été annulée.'
)
);
$this
->
payum
->
getHttpRequestVerifier
()
->
invalidate
(
$token
);
}
if
(
Payment
::
TYPE_ADHESION
==
$type
)
{
// Auto login after adhesion
return
$this
->
guardHandler
->
authenticateUserAndHandleSuccess
(
$user
,
$request
,
$this
->
authenticator
,
'main'
);
}
else
{
return
$this
->
redirectToRoute
(
'index'
);
}
return
new
Response
(
'ok'
,
Response
::
HTTP_OK
);
}
}
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