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
472721ab
Commit
472721ab
authored
Jan 05, 2023
by
Damien Moulard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
WIP connect CB payment to tav cotis
parent
d63df04c
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
85 additions
and
32 deletions
+85
-32
PaymentController.php
src/Controller/PaymentController.php
+8
-1
UserAdherentController.php
src/Controller/UserAdherentController.php
+16
-10
Payment.php
src/Entity/Payment.php
+1
-0
PaymentStatusExtension.php
src/EventListener/PaymentStatusExtension.php
+48
-13
TAVCotisationUtils.php
src/Utils/TAVCotisationUtils.php
+12
-8
No files found.
src/Controller/PaymentController.php
View file @
472721ab
...
...
@@ -132,6 +132,8 @@ class PaymentController extends AbstractController
$this
->
em
->
persist
(
$captureToken
);
$this
->
em
->
flush
();
// print_r($captureToken->getTargetUrl());
return
$this
->
redirect
(
$captureToken
->
getTargetUrl
());
}
...
...
@@ -156,7 +158,7 @@ class PaymentController extends AbstractController
if
(
$payment
->
getStatus
()
==
GetHumanStatus
::
STATUS_NEW
)
{
// No notification arrived at this point: execute Notify action
// TODO: notify token isn't deleted
// TODO: notify token isn't deleted
(still?)
$gateway
->
execute
(
new
Notify
(
$token
));
}
else
{
// Invalidate token
...
...
@@ -191,6 +193,11 @@ class PaymentController extends AbstractController
$this
->
authenticator
,
'main'
);
}
else
if
(
Payment
::
TYPE_PAIEMENT_COTISATION_TAV
==
$type
)
{
$this
->
addFlash
(
'success'
,
$this
->
translator
->
trans
(
'Cotisation payée !'
)
);
}
}
else
if
(
$payment
->
getStatus
()
==
GetHumanStatus
::
STATUS_CANCELED
||
$payment
->
getStatus
()
==
GetHumanStatus
::
STATUS_EXPIRED
||
...
...
src/Controller/UserAdherentController.php
View file @
472721ab
...
...
@@ -166,19 +166,25 @@ class UserAdherentController extends FluxController
$flux
->
setDon
(
null
);
}
$this
->
em
->
persist
(
$flux
);
$this
->
operationUtils
->
executeOperations
(
$flux
);
// TODO redirect to paiement
return
$this
->
forward
(
'App\Controller\PaymentController::preparePaymentAction'
,
[
'form'
=>
$form
,
'type'
=>
Payment
::
TYPE_PAIEMENT_COTISATION_TAV
// TODO
]);
// Apply cotisation rate, create new flux
$this
->
tavCotisationsUtils
->
applyTauxCotisation
(
$flux
);
// $this->em->persist($flux);
// $this->operationUtils->executeOperations($flux);
// // Apply cotisation rate, create new flux
// $this->tavCotisationsUtils->applyTauxCotisation($flux);
$this
->
em
->
flush
();
$this
->
addFlash
(
'success'
,
$this
->
translator
->
trans
(
'Cotisation payée ! [Paiement via Payzen temporairement désactivé]'
)
);
//
$this->em->flush();
//
$this->addFlash(
//
'success',
//
$this->translator->trans('Cotisation payée ! [Paiement via Payzen temporairement désactivé]')
//
);
return
$this
->
redirectToRoute
(
'index'
);
//
return $this->redirectToRoute('index');
}
return
$this
->
render
(
'@kohinos/flux/transaction.html.twig'
,
[
...
...
src/Entity/Payment.php
View file @
472721ab
...
...
@@ -17,6 +17,7 @@ class Payment extends BasePayment
const
TYPE_COTISATION_ADHERENT
=
'cotisation_adherent'
;
const
TYPE_COTISATION_PRESTA
=
'cotisation_presta'
;
const
TYPE_ADHESION
=
'adhesion'
;
const
TYPE_PAIEMENT_COTISATION_TAV
=
'paiement_cotisation_tav'
;
/**
* @var \Ramsey\Uuid\UuidInterface
...
...
src/EventListener/PaymentStatusExtension.php
View file @
472721ab
...
...
@@ -31,28 +31,37 @@ use App\Entity\AchatMonnaiePrestataire;
use
App\Entity\CotisationAdherent
;
use
App\Entity\CotisationPrestataire
;
use
App\Entity\Don
;
use
App\Utils\OperationUtils
;
use
App\Utils\TAVCotisationUtils
;
class
PaymentStatusExtension
implements
ExtensionInterface
{
private
$em
;
protected
$eventDispatcher
;
protected
$serializer
;
protected
$userManager
;
private
$eventDispatcher
;
private
$serializer
;
private
$userManager
;
private
$operationUtils
;
private
$tavCotisationsUtils
;
/**
* PaymentStatusExtension constructor.
*
* @param EntityManagerInterface $em
*/
public
function
__construct
(
EntityManagerInterface
$em
,
EventDispatcherInterface
$eventDispatcher
,
SerializerInterface
$serializer
,
UserManagerInterface
$userManager
)
{
public
function
__construct
(
EntityManagerInterface
$em
,
EventDispatcherInterface
$eventDispatcher
,
SerializerInterface
$serializer
,
UserManagerInterface
$userManager
,
OperationUtils
$operationUtils
,
TAVCotisationUtils
$tavCotisationsUtils
)
{
$this
->
em
=
$em
;
$this
->
eventDispatcher
=
$eventDispatcher
;
$this
->
serializer
=
$serializer
;
$this
->
userManager
=
$userManager
;
$this
->
operationUtils
=
$operationUtils
;
$this
->
tavCotisationsUtils
=
$tavCotisationsUtils
;
}
/**
...
...
@@ -244,20 +253,46 @@ class PaymentStatusExtension implements ExtensionInterface
$payment
->
setClientId
(
$user
->
getId
());
$payment
->
setExtraData
(
''
);
$this
->
em
->
persist
(
$payment
);
}
else
if
(
Payment
::
TYPE_PAIEMENT_COTISATION_TAV
==
$type
)
{
$flux
=
$this
->
serializer
->
deserialize
(
$payment
->
getFluxData
(),
AchatMonnaieAdherent
::
class
,
'json'
,
[
'disable_type_enforcement'
=>
true
]
);
$exp
=
$this
->
em
->
getRepository
(
Siege
::
class
)
->
find
(
$flux_array
[
'expediteur'
]);
$flux
->
setExpediteur
(
$exp
);
$dest
=
$this
->
em
->
getRepository
(
Adherent
::
class
)
->
find
(
$flux_array
[
'destinataire'
]);
$flux
->
setDestinataire
(
$dest
);
$op
=
$this
->
em
->
getRepository
(
User
::
class
)
->
find
(
$flux_array
[
'operateur'
]);
$flux
->
setOperateur
(
$op
);
$flux
->
setReconverti
(
true
);
if
(
null
!=
$flux
->
getDon
())
{
$flux
->
getDon
()
->
setType
(
Don
::
TYPE_DON_ADHERENT
);
$flux
->
getDon
()
->
setOperateur
(
$op
);
$flux
->
getDon
()
->
setExpediteur
(
$dest
);
$flux
->
getDon
()
->
setDestinataire
(
$this
->
em
->
getRepository
(
Prestataire
::
class
)
->
findOneBy
([
'mlc'
=>
true
]));
}
}
else
{
// Bad request
}
$this
->
em
->
persist
(
$flux
);
$this
->
em
->
flush
(
);
$this
->
operationUtils
->
executeOperations
(
$flux
);
$this
->
eventDispatcher
->
dispatch
(
MLCEvents
::
FLUX
,
new
FluxEvent
(
$flux
)
);
if
(
Payment
::
TYPE_PAIEMENT_COTISATION_TAV
==
$type
)
{
// Apply cotisation rate, create new flux
$this
->
tavCotisationsUtils
->
applyTauxCotisation
(
$flux
);
}
// Invalidate (delete) notify token after payment is captured
$this
->
em
->
remove
(
$token
);
$this
->
em
->
flush
();
}
}
...
...
src/Utils/TAVCotisationUtils.php
View file @
472721ab
...
...
@@ -32,16 +32,20 @@ class TAVCotisationUtils
*/
public
function
checkExistingCotisation
(
Flux
$flux
)
{
$first_day_this_month
=
date
(
'Y-m-01'
);
$last_day_this_month
=
date
(
'Y-m-t'
);
// FOR TESTS PURPOSES
return
false
;
// $first_day_this_month = date('Y-m-01');
// $last_day_this_month = date('Y-m-t');
$existing
=
$this
->
em
->
getRepository
(
Flux
::
class
)
->
getTavCotisationsBetweenDates
(
$flux
->
getDestinataire
(),
$first_day_this_month
,
$last_day_this_month
);
//
$existing = $this->em->getRepository(Flux::class)->getTavCotisationsBetweenDates(
//
$flux->getDestinataire(),
//
$first_day_this_month,
//
$last_day_this_month
//
);
return
count
(
$existing
)
>
0
;
//
return count($existing) > 0;
}
/**
...
...
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