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
83738085
Commit
83738085
authored
Nov 14, 2024
by
Yvon Kerdoncuff
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
block user if another starting payment has been found
parent
4d371b7e
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
21 additions
and
13 deletions
+21
-13
PaymentController.php
src/Controller/PaymentController.php
+0
-9
PaymentRepository.php
src/Repository/PaymentRepository.php
+10
-3
TAVCotisationUtils.php
src/Utils/TAVCotisationUtils.php
+11
-1
No files found.
src/Controller/PaymentController.php
View file @
83738085
...
...
@@ -54,15 +54,6 @@ class PaymentController extends AbstractController
*/
public
function
preparePaymentAction
(
Form
$form
,
$type
,
$extra_data
=
null
)
{
/* @var PaymentRepository $repo */
$repo
=
$this
->
em
->
getRepository
(
Payment
::
class
);
//Redirect to starting payment page if a valid starting payment page exists
$url
=
$repo
->
findUrlOfValidStartingPayment
(
$this
->
getUser
()
->
getUsername
());
$this
->
em
->
flush
();
//save status updates when looking to valid starting payment page
if
(
$url
)
{
return
$this
->
redirect
(
$url
);
}
// Enregistre les données du Flux en json, pour l'enregistrer une fois le paiement validé
$serializer
=
$this
->
container
->
get
(
'serializer'
);
$toSerialize
=
Payment
::
TYPE_ADHESION
==
$type
?
$form
->
get
(
'cotisation'
)
->
getData
()
:
$form
->
getData
();
...
...
src/Repository/PaymentRepository.php
View file @
83738085
...
...
@@ -50,8 +50,11 @@ class PaymentRepository extends ServiceEntityRepository
* If we find a valid starting Payment, we will return the payzen URL used to start the payment.
* We mark as unvalid Payment that are unvalid when we check them.
*/
public
function
find
UrlOf
ValidStartingPayment
(
$clientEmail
)
public
function
findValidStartingPayment
(
$clientEmail
)
{
//At first, this method was created to return the url of an existing starting payment.
//As we don't know how to use this url to redirect the user to the existing payment page,
//we simply return the datetime when the payment will be expired.
$candidates
=
$this
->
findBy
([
'clientEmail'
=>
$clientEmail
,
'startingPaymentAnalysisStatus'
=>
null
,
...
...
@@ -73,10 +76,14 @@ class PaymentRepository extends ServiceEntityRepository
if
(
$timeout
<
new
\DateTime
())
{
$p
->
setStartingPaymentAnalysisStatus
(
'TIMEOUT'
);
}
else
{
return
$
url
;
return
$
timeout
;
}
}
//Note : some fields updates are done in this method to exclude non-candidate payment from future research.
//We may not want to flush here so flushing will probably not occur when an ongoing starting payment is found,
//but it will occur only when the payment process succeeds, which is fine.
//no valid payment found
return
''
;
return
null
;
}
}
src/Utils/TAVCotisationUtils.php
View file @
83738085
...
...
@@ -12,6 +12,7 @@ use App\Entity\Flux;
use
App\Entity\CotisationTavReversement
;
use
App\Entity\CotisationTavPrelevement
;
use
App\Enum\MoyenEnum
;
use
App\Repository\PaymentRepository
;
use
App\Utils\CustomEntityManager
;
use
Payum\Core\Request\GetHumanStatus
;
use
Symfony\Component\Security\Core\Security
;
...
...
@@ -38,14 +39,23 @@ class TAVCotisationUtils
*/
public
function
preventCotisationDuplication
(
Adherent
$adherent
)
{
$email
=
$adherent
->
getUser
()
->
getEmail
();
//Look for existing recurring payment
if
(
$reason
=
$this
->
checkExistingRecurringPayment
(
$
adherent
->
getUser
()
->
getEmail
()
))
{
if
(
$reason
=
$this
->
checkExistingRecurringPayment
(
$
email
))
{
return
implode
(
" "
,
array_column
(
$reason
,
'reason'
));
}
//Look for existing cotisation
if
(
$this
->
checkExistingCotisation
(
$adherent
))
{
return
"Cotisation déjà payée ce mois-ci."
;
}
//Look for possible Payzen starting payment (neither finished nor expired yet)
/* @var PaymentRepository $repo */
$repo
=
$this
->
em
->
getRepository
(
Payment
::
class
);
$foundStartingPaymentTimeout
=
$repo
->
findValidStartingPayment
(
$email
);
if
(
$foundStartingPaymentTimeout
)
{
return
"Détection d'un possible paiement en cours. Merci de réessayer à partir de "
.
$foundStartingPaymentTimeout
->
format
(
"H:i:s"
)
.
"."
;
}
return
""
;
}
...
...
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