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
84b2bd30
Commit
84b2bd30
authored
Sep 09, 2020
by
Damien Moulard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix adhesion cb
parent
b932702c
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
76 additions
and
10 deletions
+76
-10
FluxController.php
src/Controller/FluxController.php
+16
-6
IndexController.php
src/Controller/IndexController.php
+3
-4
Payment.php
src/Entity/Payment.php
+26
-0
Version20200909121737.php
src/Migrations/Version20200909121737.php
+31
-0
No files found.
src/Controller/FluxController.php
View file @
84b2bd30
...
@@ -218,7 +218,7 @@ class FluxController extends AbstractController
...
@@ -218,7 +218,7 @@ class FluxController extends AbstractController
/**
/**
* Crée une instance de Payment et redirige vers la page de paiement
* Crée une instance de Payment et redirige vers la page de paiement
*/
*/
public
function
preparePaymentAction
(
Form
$form
,
$type
)
public
function
preparePaymentAction
(
Form
$form
,
$type
,
$extra_data
=
null
)
{
{
// Enregistre les données du Flux en json, pour l'enregistrer une fois le paiement validé
// Enregistre les données du Flux en json, pour l'enregistrer une fois le paiement validé
$serializer
=
$this
->
container
->
get
(
'serializer'
);
$serializer
=
$this
->
container
->
get
(
'serializer'
);
...
@@ -253,6 +253,11 @@ class FluxController extends AbstractController
...
@@ -253,6 +253,11 @@ class FluxController extends AbstractController
$payment
->
setDescription
(
$type
);
$payment
->
setDescription
(
$type
);
$payment
->
setFluxData
(
$jsondata
);
$payment
->
setFluxData
(
$jsondata
);
// Data to persist when payment is valid (other than Flux data)
if
(
$extra_data
!=
null
)
{
$payment
->
setExtraData
(
$extra_data
);
}
if
(
$type
==
Payment
::
TYPE_ADHESION
)
{
if
(
$type
==
Payment
::
TYPE_ADHESION
)
{
$payment
->
setTotalAmount
(
$form
->
get
(
'cotisation'
)
->
get
(
'montant'
)
->
getData
()
*
100
);
// 1.23 EUR
$payment
->
setTotalAmount
(
$form
->
get
(
'cotisation'
)
->
get
(
'montant'
)
->
getData
()
*
100
);
// 1.23 EUR
$payment
->
setClientId
(
'Nouvel adhérent'
);
$payment
->
setClientId
(
'Nouvel adhérent'
);
...
@@ -299,7 +304,12 @@ class FluxController extends AbstractController
...
@@ -299,7 +304,12 @@ class FluxController extends AbstractController
// Token expiré : retour sur site après paiement
// Token expiré : retour sur site après paiement
// Get last payment
// Get last payment
try
{
$payment
=
$this
->
em
->
getRepository
(
Payment
::
class
)
->
getUserLastPayment
(
$this
->
getUser
()
->
getId
());
$payment
=
$this
->
em
->
getRepository
(
Payment
::
class
)
->
getUserLastPayment
(
$this
->
getUser
()
->
getId
());
}
catch
(
\Exception
$e
)
{
return
$this
->
redirectToRoute
(
'index'
);
}
if
(
!
is_null
(
$payment
))
{
if
(
!
is_null
(
$payment
))
{
if
(
$payment
->
getStatus
()
==
GetHumanStatus
::
STATUS_CAPTURED
||
$payment
->
getStatus
()
==
GetHumanStatus
::
STATUS_AUTHORIZED
)
{
if
(
$payment
->
getStatus
()
==
GetHumanStatus
::
STATUS_CAPTURED
||
$payment
->
getStatus
()
==
GetHumanStatus
::
STATUS_AUTHORIZED
)
{
...
@@ -358,6 +368,8 @@ class FluxController extends AbstractController
...
@@ -358,6 +368,8 @@ class FluxController extends AbstractController
$this
->
em
->
persist
(
$payment
);
$this
->
em
->
persist
(
$payment
);
$this
->
em
->
flush
();
$this
->
em
->
flush
();
$type
=
''
;
// If payment succesful, persist serialized 'Flux' stored in payment
// If payment succesful, persist serialized 'Flux' stored in payment
if
(
$status
->
getValue
()
==
GetHumanStatus
::
STATUS_CAPTURED
||
$status
->
getValue
()
==
GetHumanStatus
::
STATUS_AUTHORIZED
)
{
if
(
$status
->
getValue
()
==
GetHumanStatus
::
STATUS_CAPTURED
||
$status
->
getValue
()
==
GetHumanStatus
::
STATUS_AUTHORIZED
)
{
...
@@ -434,7 +446,7 @@ class FluxController extends AbstractController
...
@@ -434,7 +446,7 @@ class FluxController extends AbstractController
$flux
->
setRecu
(
true
);
$flux
->
setRecu
(
true
);
}
else
if
(
Payment
::
TYPE_ADHESION
==
$type
)
{
}
else
if
(
Payment
::
TYPE_ADHESION
==
$type
)
{
$new_adherent_data
=
json_decode
(
$
this
->
session
->
get
(
'new_adherent'
));
$new_adherent_data
=
json_decode
(
$
payment
->
getExtraData
(
));
$adherent
=
new
Adherent
();
$adherent
=
new
Adherent
();
$user
=
$this
->
userManager
->
createUser
();
$user
=
$this
->
userManager
->
createUser
();
...
@@ -466,9 +478,6 @@ class FluxController extends AbstractController
...
@@ -466,9 +478,6 @@ class FluxController extends AbstractController
$this
->
em
->
persist
(
$adherent
);
$this
->
em
->
persist
(
$adherent
);
$this
->
em
->
flush
();
$this
->
em
->
flush
();
// Remove new user data from session
$this
->
session
->
remove
(
'new_adherent'
);
// Create first cotisation
// Create first cotisation
$flux
=
$serializer
->
deserialize
(
$flux
=
$serializer
->
deserialize
(
$payment
->
getFluxData
(),
$payment
->
getFluxData
(),
...
@@ -483,8 +492,9 @@ class FluxController extends AbstractController
...
@@ -483,8 +492,9 @@ class FluxController extends AbstractController
$flux
->
setRole
(
'Adherent'
);
$flux
->
setRole
(
'Adherent'
);
$flux
->
setRecu
(
true
);
$flux
->
setRecu
(
true
);
// Update payment with new user id
// Update payment with new user id
, remove user data
$payment
->
setClientId
(
$user
->
getId
());
$payment
->
setClientId
(
$user
->
getId
());
$payment
->
setExtraData
(
''
);
$this
->
em
->
persist
(
$payment
);
$this
->
em
->
persist
(
$payment
);
}
else
{
}
else
{
return
new
Response
(
''
,
Response
::
HTTP_BAD_REQUEST
);
return
new
Response
(
''
,
Response
::
HTTP_BAD_REQUEST
);
...
...
src/Controller/IndexController.php
View file @
84b2bd30
...
@@ -213,20 +213,19 @@ class IndexController extends AbstractController
...
@@ -213,20 +213,19 @@ class IndexController extends AbstractController
if
(
$form
->
isValid
())
{
if
(
$form
->
isValid
())
{
$adherentNew
=
$form
->
getData
();
$adherentNew
=
$form
->
getData
();
// S
tore form data in session to deal with it at payment callback
// S
erialize form data in json to store with payment object and persist when payment is valid
$serializer
=
$this
->
container
->
get
(
'serializer'
);
$serializer
=
$this
->
container
->
get
(
'serializer'
);
$data
=
$serializer
->
normalize
(
$adherentNew
,
null
,
$data
=
$serializer
->
normalize
(
$adherentNew
,
null
,
[
AbstractNormalizer
::
ATTRIBUTES
=>
[
'user'
=>
[
'username'
,
'email'
,
'firstname'
,
'lastname'
,
'plainPassword'
],
[
AbstractNormalizer
::
ATTRIBUTES
=>
[
'user'
=>
[
'username'
,
'email'
,
'firstname'
,
'lastname'
,
'plainPassword'
],
'groupe'
=>
[
'id'
],
'groupe'
=>
[
'id'
],
'geoloc'
=>
[
'adresse'
,
'cpostal'
,
'ville'
]]]);
'geoloc'
=>
[
'adresse'
,
'cpostal'
,
'ville'
]]]);
$jsondata
=
$serializer
->
serialize
(
$data
,
'json'
);
$jsondata
=
$serializer
->
serialize
(
$data
,
'json'
);
$this
->
session
->
set
(
'new_adherent'
,
$jsondata
);
// Redirect to payment page
// Redirect to payment page
return
$this
->
forward
(
'App\Controller\FluxController::preparePaymentAction'
,
[
return
$this
->
forward
(
'App\Controller\FluxController::preparePaymentAction'
,
[
'form'
=>
$form
,
'form'
=>
$form
,
'type'
=>
Payment
::
TYPE_ADHESION
'type'
=>
Payment
::
TYPE_ADHESION
,
'extra_data'
=>
$jsondata
]);
]);
}
else
{
}
else
{
$this
->
addFlash
(
$this
->
addFlash
(
...
...
src/Entity/Payment.php
View file @
84b2bd30
...
@@ -42,6 +42,14 @@ class Payment extends BasePayment
...
@@ -42,6 +42,14 @@ class Payment extends BasePayment
protected
$flux_data
;
protected
$flux_data
;
/**
/**
* @var string|null
* Extra data to persist if payment valid
*
* @ORM\Column(type="text", nullable=true)
*/
protected
$extra_data
;
/**
* @return string
* @return string
*/
*/
public
function
getStatus
()
:
?
string
public
function
getStatus
()
:
?
string
...
@@ -76,4 +84,22 @@ class Payment extends BasePayment
...
@@ -76,4 +84,22 @@ class Payment extends BasePayment
$this
->
flux_data
=
$flux_data
;
$this
->
flux_data
=
$flux_data
;
return
$this
;
return
$this
;
}
}
/**
* @return string
*/
public
function
getExtraData
()
:
?
string
{
return
$this
->
extra_data
;
}
/**
* @param string $extra_data
* @return Payment
*/
public
function
setExtraData
(
string
$extra_data
)
:
self
{
$this
->
extra_data
=
$extra_data
;
return
$this
;
}
}
}
src/Migrations/Version20200909121737.php
0 → 100644
View file @
84b2bd30
<?php
declare
(
strict_types
=
1
);
namespace
DoctrineMigrations
;
use
Doctrine\DBAL\Schema\Schema
;
use
Doctrine\Migrations\AbstractMigration
;
/**
* Auto-generated Migration: Please modify to your needs!
*/
final
class
Version20200909121737
extends
AbstractMigration
{
public
function
getDescription
()
:
string
{
return
''
;
}
public
function
up
(
Schema
$schema
)
:
void
{
// this up() migration is auto-generated, please modify it to your needs
$this
->
addSql
(
'ALTER TABLE payment ADD extra_data LONGTEXT DEFAULT NULL'
);
}
public
function
down
(
Schema
$schema
)
:
void
{
// this down() migration is auto-generated, please modify it to your needs
$this
->
addSql
(
'ALTER TABLE payment DROP extra_data'
);
}
}
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