Commit d5781cdc by Julien Jorry

Merge branch 'dev-paiement-mobile' into 'dev'

Dev paiement mobile

See merge request Kohinos/kohinos!3
parents 6c790f14 81227837
......@@ -33,3 +33,11 @@ CORS_ALLOW_ORIGIN=^https?://localhost(:[0-9]+)?$
#JWT_PUBLIC_KEY=%kernel.project_dir%/config/jwt/public.pem
#JWT_PASSPHRASE=2162f52d0600275e618fccd274c080f2
###< lexik/jwt-authentication-bundle ###
## PAYUM GATEWAYS CONFIGURATION ##
###> payum-payzen ###
PAYZEN_SITE_ID=ChangeMeWithYourPayzenCredentials
PAYZEN_CERTIFICATE=ChangeMeWithYourPayzenCredentials
PAYZEN_CTX_MODE=PRODUCTION
PAYZEN_DEBUG=false
###< payum-payzen ###
......@@ -35,3 +35,7 @@ yarn-error.log
/mlc.test-access.log
/mlc.test-error.log
###< symfony/webpack-encore-bundle ###
###> payum ###
/transactions/
###< payum ###
......@@ -14,29 +14,35 @@
"php": "^7.4",
"ext-ctype": "*",
"ext-iconv": "*",
"ext-intl" : "*",
"ext-intl": "*",
"api-platform/api-pack": "^1.2",
"beberlei/doctrineextensions": "^1.2",
"doctrine/annotations": "^1.8",
"doctrine/migrations": "^3.0",
"doctrine/doctrine-fixtures-bundle": "^3.0",
"doctrine/doctrine-migrations-bundle": "^3.0",
"doctrine/migrations": "^3.0",
"ekyna/payum-payzen": "@dev",
"friendsofsymfony/user-bundle": "^2.1",
"geocoder-php/cache-provider": "^4.1",
"geocoder-php/google-maps-provider": "^4.3",
"geocoder-php/nominatim-provider": "^5.0",
"hautelook/alice-bundle": "^2.3",
"knplabs/knp-paginator-bundle": "^2.8",
"lexik/translation-bundle": "~4.0",
"liip/imagine-bundle": "^2.1",
"nelmio/api-doc-bundle": "^3.3",
"payum/offline": "^1.6",
"payum/payum-bundle": "^2.4",
"php-http/guzzle6-adapter": "^2.0",
"php-http/message": "^1.7",
"pixassociates/sortable-behavior-bundle": "^1.5",
"prodigious/sonata-menu-bundle": "^3.0",
"sensio/framework-extra-bundle": "^5.1",
"sensiolabs/security-checker": "^5.0",
"sonata-project/admin-bundle": "^3.65",
"sonata-project/block-bundle": "^3.18",
"sonata-project/core-bundle": "^3.18",
"sonata-project/classification-bundle": "^3.11",
"sonata-project/core-bundle": "^3.18",
"sonata-project/doctrine-orm-admin-bundle": "^3.6",
"sonata-project/easy-extends-bundle": "^2.5",
"sonata-project/formatter-bundle": "^4.1",
......@@ -49,6 +55,7 @@
"symfony/asset": "4.4.*",
"symfony/cache": "4.4.*",
"symfony/console": "4.4.*",
"symfony/dotenv": "4.4.*",
"symfony/expression-language": "4.4.*",
"symfony/flex": "^1.1",
"symfony/form": "4.4.*",
......@@ -67,11 +74,7 @@
"symfony/webpack-encore-bundle": "^1.7",
"symfony/yaml": "4.4.*",
"vich/uploader-bundle": "^1.8",
"willdurand/geocoder-bundle": "^5.0",
"doctrine/doctrine-fixtures-bundle": "^3.0",
"symfony/dotenv": "4.4.*",
"sensiolabs/security-checker": "^5.0",
"hautelook/alice-bundle": "^2.3"
"willdurand/geocoder-bundle": "^5.0"
},
"require-dev": {
"symfony/browser-kit": "4.4.*",
......@@ -126,8 +129,14 @@
},
"extra": {
"symfony": {
"allow-contrib": false,
"allow-contrib": true,
"require": "4.4.*"
}
},
"repositories": [
{
"type": "path",
"url": "./lib/ekyna/payum-payzen"
}
]
}
......@@ -49,4 +49,5 @@ return [
Twig\Extra\TwigExtraBundle\TwigExtraBundle::class => ['all' => true],
Sonata\ClassificationBundle\SonataClassificationBundle::class => ['all' => true],
App\Application\Sonata\ClassificationBundle\ApplicationSonataClassificationBundle::class => ['all' => true],
Payum\Bundle\PayumBundle\PayumBundle::class => ['all' => true],
];
payum:
storages:
App\Entity\Payment: { doctrine: orm }
security:
token_storage:
App\Entity\PaymentToken: { doctrine: orm }
gateways:
offline:
factory: offline
payzen:
factory: payzen
site_id: '%env(PAYZEN_SITE_ID)%'
certificate: '%env(PAYZEN_CERTIFICATE)%' # Clé de TEST ou PRODUCTION
ctx_mode: '%env(PAYZEN_CTX_MODE)%' # TEST ou PRODUCTION
directory: '%kernel.project_dir%/transactions'
debug: '%env(bool:PAYZEN_DEBUG)%'
......@@ -236,6 +236,7 @@ sonata_admin:
items:
- admin.flux.gerer
- admin.all.cotisations
- admin.all.achatsmonnaie
- admin.transfert.gerer
- admin.transaction.gerer
- admin.reconversion.gerer
......
......@@ -30,3 +30,6 @@ app.swagger_ui:
path: /api/doc
methods: GET
defaults: { _controller: nelmio_api_doc.controller.swagger_ui }
payum_all:
resource: "@PayumBundle/Resources/config/routing/all.xml"
......@@ -167,6 +167,14 @@ services:
calls:
- [setManager, ['@doctrine.orm.entity_manager']]
app.payzen_gateway_factory:
class: Payum\Core\Bridge\Symfony\Builder\GatewayFactoryBuilder
arguments: [Ekyna\Component\Payum\Payzen\PayzenGatewayFactory]
tags:
- { name: payum.gateway_factory_builder, factory: payzen }
###### Configuration de l'admin ######
admin.block.dashboard:
class: App\Block\DashboardKohinosBlock
arguments:
......@@ -174,8 +182,6 @@ services:
tags:
- { name: sonata.block }
###### Configuration de l'admin ######
admin.adherent.gerer:
class: App\Admin\AdherentAdmin
# arguments: [~, App\Entity\OBJECT, 'PixSortableBehaviorBundle:SortableAdmin']
......@@ -206,6 +212,18 @@ services:
calls:
- [ setSecurity, ['@security.helper']]
admin.all.achatsmonnaie:
class: App\Admin\AchatMonnaieAdmin
arguments: [~, App\Entity\AchatMonnaie, ~]
tags:
- name: sonata.admin
manager_type: orm
group: "Flux"
label: "Achats de monnaie"
public: true
calls:
- [ setSecurity, ['@security.helper']]
admin.adherent.cotisations:
class: App\Admin\CotisationAdherentAdmin
arguments: [~, App\Entity\CotisationAdherent, ~]
......@@ -364,7 +382,7 @@ services:
pager_type: "simple"
public: true
calls:
- [ setSubClasses, [{transaction: 'App\Entity\Transaction', transfert: 'App\Entity\Transfert', cotisation: 'App\Entity\Cotisation'}]]
- [ setSubClasses, [{transaction: 'App\Entity\Transaction', transfert: 'App\Entity\Transfert', cotisation: 'App\Entity\Cotisation', achat_monnaie: 'App\Entity\AchatMonnaie'}]]
- [ setSecurity, ['@security.helper']]
admin.transfert.gerer:
......
......@@ -35,6 +35,7 @@ App\Entity\Usergroup:
'ROLE_SONATA_USER_ADMIN_GROUP_ALL',
'ROLE_ADMIN_ADHERENT_GERER_ALL',
'ROLE_ADMIN_ALL_COTISATIONS_ALL',
'ROLE_ADMIN_ALL_ACHATSMONNAIE_ALL',
'ROLE_ADMIN_GROUPE_GERER_ALL',
'ROLE_ADMIN_GLOBALPARAMETER_GERER_ALL',
'ROLE_ADMIN_TRANSFERT_GERER_ALL']]
......@@ -61,6 +62,7 @@ App\Entity\Usergroup:
__construct: ['Trésorier', [
'ROLE_TRESORIER',
'ROLE_ADMIN_ALL_COTISATIONS_ALL',
'ROLE_ADMIN_ALL_ACHATSMONNAIE_ALL',
'ROLE_ADMIN_RECONVERSION_GERER_ALL',
'ROLE_ADMIN_TRANSFERT_GERER_ALL']]
usergroup_gestiongroupe:
......@@ -823,4 +825,3 @@ App\Entity\Rubrique:
# name: 'Vins'
# content: <text(50)>
# enabled: true
......@@ -35,6 +35,7 @@ App\Entity\Usergroup:
'ROLE_SONATA_USER_ADMIN_GROUP_ALL',
'ROLE_ADMIN_ADHERENT_GERER_ALL',
'ROLE_ADMIN_ALL_COTISATIONS_ALL',
'ROLE_ADMIN_ALL_ACHATSMONNAIE_ALL',
'ROLE_ADMIN_GROUPE_GERER_ALL',
'ROLE_ADMIN_GLOBALPARAMETER_GERER_ALL',
'ROLE_ADMIN_TRANSFERT_GERER_ALL']]
......@@ -61,6 +62,7 @@ App\Entity\Usergroup:
__construct: ['Trésorier', [
'ROLE_TRESORIER',
'ROLE_ADMIN_ALL_COTISATIONS_ALL',
'ROLE_ADMIN_ALL_ACHATSMONNAIE_ALL',
'ROLE_ADMIN_RECONVERSION_GERER_ALL',
'ROLE_ADMIN_TRANSFERT_GERER_ALL']]
usergroup_gestiongroupe:
......@@ -629,6 +631,10 @@ App\Entity\GlobalParameter:
name: "MAP_ZOOM"
value: '9'
mandatory: 1
gp14:
name: "USE_PAYZEN"
value: 'true'
mandatory: 1
App\Entity\Siege:
siege_1:
......
<?php
namespace Ekyna\Component\Payum\Payzen\Action\Api;
use Ekyna\Component\Payum\Payzen\Api\Api;
use Payum\Core\Action\ActionInterface;
use Payum\Core\ApiAwareInterface;
use Payum\Core\Exception\UnsupportedApiException;
use Payum\Core\GatewayAwareInterface;
use Payum\Core\GatewayAwareTrait;
use Psr\Log\LoggerAwareInterface;
use Psr\Log\LoggerInterface;
/**
* Class AbstractApiAction
* @package Ekyna\Component\Payum\Payzen\Action\Api
* @author Etienne Dauvergne <contact@ekyna.com>
*/
abstract class AbstractApiAction implements ActionInterface, GatewayAwareInterface, ApiAwareInterface, LoggerAwareInterface
{
use GatewayAwareTrait;
/**
* @var Api
*/
protected $api;
/**
* @var LoggerInterface
*/
private $logger;
/**
* @inheritDoc
*/
public function setApi($api)
{
if (false == $api instanceof Api) {
throw new UnsupportedApiException('Not supported.');
}
$this->api = $api;
}
/**
* {@inheritDoc}
*/
public function setLogger(LoggerInterface $logger)
{
$this->logger = $logger;
}
/**
* Logs the given message.
*
* @param string $message
*/
protected function log($message)
{
if (!$this->logger) {
return;
}
$this->logger->debug($message);
}
/**
* Logs the given message and data.
*
* @param string $message
* @param array $data
* @param array $filterKeys
*/
protected function logData($message, array $data, array $filterKeys = [])
{
if (!$this->logger) {
return;
}
if (!empty($filterKeys)) {
$data = array_intersect_key($data, array_flip($filterKeys));
}
$data = array_map(function($key, $value) {
return "$key: $value";
}, array_keys($data), $data);
$this->logger->debug($message . ': ' . implode(', ', $data));
}
}
<?php
namespace Ekyna\Component\Payum\Payzen\Action\Api;
use Ekyna\Component\Payum\Payzen\Request\Request;
use Payum\Core\Bridge\Spl\ArrayObject;
use Payum\Core\Exception\RequestNotSupportedException;
use Payum\Core\Reply\HttpRedirect;
/**
* Class RequestAction
* @package Ekyna\Component\Payum\Payzen\Action\Api
* @author Etienne Dauvergne <contact@ekyna.com>
*/
class ApiRequestAction extends AbstractApiAction
{
/**
* @inheritdoc
*
* @throws \Payum\Core\Reply\HttpRedirect
*/
public function execute($request)
{
/** @var Request $request */
RequestNotSupportedException::assertSupports($this, $request);
$model = ArrayObject::ensureArrayObject($request->getModel());
if ($model['vads_trans_id']) {
return;
}
$model['vads_trans_id'] = $this->api->getTransactionId();
// Current UTC date time
$model['vads_trans_date'] = (new \DateTime('now', new \DateTimeZone('UTC')))->format('YmdHis');
$data = $model->getArrayCopy();
$this->logRequestData($data);
$url = $this->api->createRequestUrl($data);
throw new HttpRedirect($url);
}
/**
* Logs the request data.
*
* @param array $data
*/
private function logRequestData(array $data)
{
$this->logData("[Payzen] Request", $data, [
'vads_order_id',
'vads_amount',
'vads_ctx_mode',
'vads_currency',
'vads_payment_config',
'vads_site_id',
'vads_trans_date',
'vads_trans_id',
'vads_version',
]);
}
/**
* @inheritdoc
*/
public function supports($request)
{
return $request instanceof Request
&& $request->getModel() instanceof \ArrayAccess;
}
}
<?php
namespace Ekyna\Component\Payum\Payzen\Action\Api;
use Ekyna\Component\Payum\Payzen\Request\Response;
use Payum\Core\Bridge\Spl\ArrayObject;
use Payum\Core\Exception\RequestNotSupportedException;
use Payum\Core\Request\GetHttpRequest;
/**
* Class ResponseAction
* @package Ekyna\Component\Payum\Payzen\Action\Api
* @author Etienne Dauvergne <contact@ekyna.com>
*/
class ApiResponseAction extends AbstractApiAction
{
/**
* @inheritdoc
*/
public function execute($request)
{
/** @var Response $request */
RequestNotSupportedException::assertSupports($this, $request);
$model = ArrayObject::ensureArrayObject($request->getModel());
$this->gateway->execute($httpRequest = new GetHttpRequest());
if (isset($httpRequest->request['vads_result'])) {
$data = $httpRequest->request;
} elseif (isset($httpRequest->query['vads_result'])) {
$data = $httpRequest->query;
} else {
return;
}
$this->logResponseData($data);
// Check amount
if ($model['vads_amount'] != $data['vads_amount']) {
return;
}
// Check the response signature
if ($this->api->checkResponseIntegrity($data)) {
// Update the payment details
$model->replace($data);
$request->setModel($model);
}
}
/**
* Logs the response data.
*
* @param array $data
*/
private function logResponseData(array $data)
{
$this->logData("[Payzen] Response", $data, [
'vads_order_id',
'vads_trans_id',
'vads_amount',
'vads_auth_result',
'vads_auth_mode',
'vads_auth_number',
'vads_validation_mode',
'vads_result',
'vads_extra_result',
'vads_warranty_result',
]);
}
/**
* @inheritdec
*/
public function supports($request)
{
return $request instanceof Response
&& $request->getModel() instanceof \ArrayAccess;
}
}
<?php
namespace Ekyna\Component\Payum\Payzen\Action;
use Ekyna\Component\Commerce\Bridge\Payum\Request\GetHumanStatus;
use Payum\Core\Action\ActionInterface;
use Payum\Core\Bridge\Spl\ArrayObject;
use Payum\Core\Exception\RequestNotSupportedException;
use Payum\Core\GatewayAwareInterface;
use Payum\Core\GatewayAwareTrait;
use Payum\Core\Request\Cancel;
/**
* Class CancelAction
* @package Ekyna\Component\Payum\Payzen\Action
* @author Etienne Dauvergne <contact@ekyna.com>
*/
class CancelAction implements ActionInterface, GatewayAwareInterface
{
use GatewayAwareTrait;
/**
* {@inheritdoc}
*
* @param Cancel $request
*/
public function execute($request)
{
RequestNotSupportedException::assertSupports($this, $request);
$model = ArrayObject::ensureArrayObject($request->getModel());
$this->gateway->execute($status = new GetHumanStatus($model));
if ($status->isNew()) {
$model['state_override'] = 'canceled';
}
}
/**
* {@inheritdoc}
*/
public function supports($request)
{
return $request instanceof Cancel
&& $request->getModel() instanceof \ArrayAccess;
}
}
<?php
namespace Ekyna\Component\Payum\Payzen\Action;
use Ekyna\Component\Payum\Payzen\Request\Request;
use Payum\Core\Action\ActionInterface;
use Payum\Core\Bridge\Spl\ArrayObject;
use Payum\Core\Exception\RequestNotSupportedException;
use Payum\Core\GatewayAwareInterface;
use Payum\Core\GatewayAwareTrait;
use Payum\Core\Request\Capture;
use Payum\Core\Request\Sync;
use Payum\Core\Security\GenericTokenFactoryAwareInterface;
use Payum\Core\Security\GenericTokenFactoryAwareTrait;
/**
* Class CaptureAction
* @package Ekyna\Component\Payum\Payzen\Action
* @author Etienne Dauvergne <contact@ekyna.com>
*/
class CaptureAction implements ActionInterface, GatewayAwareInterface, GenericTokenFactoryAwareInterface
{
use GatewayAwareTrait;
use GenericTokenFactoryAwareTrait;
/**
* {@inheritdoc}
*
* @param Capture $request
*/
public function execute($request)
{
RequestNotSupportedException::assertSupports($this, $request);
$model = ArrayObject::ensureArrayObject($request->getModel());
if ($request->getToken()) {
// Done redirections
$targetUrl = $request->getToken()->getTargetUrl();
$doneUrlFields = [
'vads_url_cancel', // Annuler et retourner à la boutique
'vads_url_error', // Erreur de traitement interne
'vads_url_referral', // 02 contacter l'émetteur de la carte
'vads_url_refused', // Refus autre que 02
'vads_url_success', // 00 Success
'vads_url_return', // Retour à la boutique
];
foreach ($doneUrlFields as $field) {
if (false == $model[$field]) {
$model[$field] = $targetUrl;
}
}
// Notify url
if (empty($model['vads_url_check']) && $this->tokenFactory) {
// Custom action
$model['vads_url_check'] = $request->getToken()->getAfterUrl();
}
}
if (false == $model['vads_trans_id']) {
$this->gateway->execute(new Request($model));
}
$this->gateway->execute(new Sync($model));
}
/**
* {@inheritdoc}
*/
public function supports($request)
{
return $request instanceof Capture
&& $request->getModel() instanceof \ArrayAccess;
}
}
<?php
namespace Ekyna\Component\Payum\Payzen\Action;
use Payum\Core\Action\ActionInterface;
use Payum\Core\Bridge\Spl\ArrayObject;
use Payum\Core\Exception\RequestNotSupportedException;
use Payum\Core\Exception\RuntimeException;
use Payum\Core\GatewayAwareInterface;
use Payum\Core\GatewayAwareTrait;
use Payum\Core\Model\PaymentInterface;
use Payum\Core\Request\Convert;
use Payum\Core\Request\GetCurrency;
/**
* Class ConvertPaymentAction
* @package Ekyna\Component\Payum\Payzen\Action
* @author Etienne Dauvergne <contact@ekyna.com>
*/
class ConvertPaymentAction implements ActionInterface, GatewayAwareInterface
{
use GatewayAwareTrait;
/**
* {@inheritDoc}
*
* @param Convert $request
*/
public function execute($request)
{
RequestNotSupportedException::assertSupports($this, $request);
/** @var PaymentInterface $payment */
$payment = $request->getSource();
$model = ArrayObject::ensureArrayObject($payment->getDetails());
if (false == $model['vads_amount']) {
$this->gateway->execute($currency = new GetCurrency($payment->getCurrencyCode()));
if (2 < $currency->exp) {
throw new RuntimeException('Unexpected currency exp.');
}
$divisor = pow(10, 2 - $currency->exp);
$model['vads_currency'] = (string)$currency->numeric;
$model['vads_amount'] = (string)abs($payment->getTotalAmount() / $divisor);
}
if (false == $model['vads_order_id']) {
$model['vads_order_id'] = $payment->getNumber();
}
if (false == $model['vads_cust_id']) {
$model['vads_cust_id'] = $payment->getClientId();
}
if (false == $model['vads_cust_email']) {
$model['vads_cust_email'] = $payment->getClientEmail();
}
$request->setResult((array)$model);
}
/**
* {@inheritDoc}
*/
public function supports($request)
{
return $request instanceof Convert
&& $request->getSource() instanceof PaymentInterface
&& $request->getTo() == 'array';
}
}
<?php
namespace Ekyna\Component\Payum\Payzen\Action;
use Payum\Core\Action\ActionInterface;
use Payum\Core\Bridge\Spl\ArrayObject;
use Payum\Core\Exception\RequestNotSupportedException;
use Payum\Core\GatewayAwareInterface;
use Payum\Core\GatewayAwareTrait;
use Payum\Core\Request\Notify;
use Payum\Core\Request\Sync;
/**
* Class NotifyAction
* @package Ekyna\Component\Payum\Payzen\Action
* @author Etienne Dauvergne <contact@ekyna.com>
*/
class NotifyAction implements ActionInterface, GatewayAwareInterface
{
use GatewayAwareTrait;
/**
* {@inheritDoc}
*
* @param Notify $request
*/
public function execute($request)
{
RequestNotSupportedException::assertSupports($this, $request);
$details = ArrayObject::ensureArrayObject($request->getModel());
$this->gateway->execute(new Sync($details));
}
/**
* {@inheritDoc}
*/
public function supports($request)
{
return $request instanceof Notify
&& $request->getModel() instanceof \ArrayAccess;
}
}
<?php
namespace Ekyna\Component\Payum\Payzen\Action;
use Ekyna\Component\Commerce\Bridge\Payum\Request\GetHumanStatus;
use Payum\Core\Action\ActionInterface;
use Payum\Core\Bridge\Spl\ArrayObject;
use Payum\Core\Exception\RequestNotSupportedException;
use Payum\Core\GatewayAwareInterface;
use Payum\Core\GatewayAwareTrait;
use Payum\Core\Request\Refund;
/**
* Class CaptureAction
* @package Ekyna\Component\Payum\Payzen\Action
* @author Etienne Dauvergne <contact@ekyna.com>
*/
class RefundAction implements ActionInterface, GatewayAwareInterface
{
use GatewayAwareTrait;
/**
* {@inheritdoc}
*
* @param Refund $request
*/
public function execute($request)
{
RequestNotSupportedException::assertSupports($this, $request);
$model = ArrayObject::ensureArrayObject($request->getModel());
$this->gateway->execute($status = new GetHumanStatus($model));
if ($status->isCaptured()) {
$model['state_override'] = 'refunded';
}
}
/**
* {@inheritdoc}
*/
public function supports($request)
{
return $request instanceof Refund
&& $request->getModel() instanceof \ArrayAccess;
}
}
<?php
namespace Ekyna\Component\Payum\Payzen\Action;
use Payum\Core\Action\ActionInterface;
use Payum\Core\Bridge\Spl\ArrayObject;
use Payum\Core\Exception\RequestNotSupportedException;
use Payum\Core\Request\GetStatusInterface;
/**
* Class StatusAction
* @package Ekyna\Component\Payum\Payzen\Action
* @author Etienne Dauvergne <contact@ekyna.com>
*/
class StatusAction implements ActionInterface
{
/**
* {@inheritdoc}
*
* @param GetStatusInterface $request
*/
public function execute($request)
{
RequestNotSupportedException::assertSupports($this, $request);
/** @var GetStatusInterface $request */
$model = ArrayObject::ensureArrayObject($request->getModel());
if (false == $model['vads_trans_id']) {
$request->markNew();
return;
}
if (false != $code = $model['vads_result']) {
switch ($code) {
case "00" : // transaction approuvée ou traitée avec succès
$request->markCaptured();
break;
case "02" : // contacter l’émetteur de carte
$request->markPending(); // TODO is that the good status ?
break;
case "17" : // Annulation client.
$request->markCanceled();
break;
case "03" : // accepteur invalide
case "04" : // conserver la carte
case "05" : // ne pas honorer
case "07" : // conserver la carte, conditions spéciales
case "08" : // approuver après identification
case "12" : // transaction invalide
case "13" : // montant invalide
case "14" : // numéro de porteur invalide
case "30" : // erreur de format
case "31" : // identifiant de l’organisme acquéreur inconnu
case "33" : // date de validité de la carte dépassée
case "34" : // suspicion de fraude
case "41" : // carte perdue
case "43" : // carte volée
case "51" : // provision insuffisante ou crédit dépassé
case "54" : // date de validité de la carte dépassée
case "56" : // carte absente du fichier
case "57" : // transaction non permise à ce porteur
case "58" : // transaction interdite au terminal
case "59" : // suspicion de fraude
case "60" : // l’accepteur de carte doit contacter l’acquéreur
case "61" : // montant de retrait hors limite
case "63" : // règles de sécurité non respectées
case "68" : // réponse non parvenue ou reçue trop tard
case "90" : // arrêt momentané du système
case "91" : // émetteur de cartes inaccessible
case "96" : // mauvais fonctionnement du système
case "94" : // transaction dupliquée
case "97" : // échéance de la temporisation de surveillance globale
case "98" : // serveur indisponible routage réseau demandé à nouveau
case "99" : // incident domaine initiateur
$request->markFailed();
break;
default :
$request->markUnknown();
}
if ($request->isCaptured() && false != $code = $model['state_override']) {
if ($code == 'refunded') {
$request->markRefunded();
}
}
return;
}
if (false != $code = $model['state_override']) {
if ($code == 'canceled') {
$request->markCanceled();
return;
}
}
$request->markNew();
}
/**
* {@inheritdoc}
*/
public function supports($request)
{
return $request instanceof GetStatusInterface
&& $request->getModel() instanceof \ArrayAccess;
}
}
<?php
namespace Ekyna\Component\Payum\Payzen\Action;
use Ekyna\Component\Payum\Payzen\Request\Response;
use Payum\Core\Action\ActionInterface;
use Payum\Core\Bridge\Spl\ArrayObject;
use Payum\Core\Exception\RequestNotSupportedException;
use Payum\Core\GatewayAwareInterface;
use Payum\Core\GatewayAwareTrait;
use Payum\Core\Request\Sync;
/**
* Class SyncAction
* @package Ekyna\Component\Payum\Payzen\Action
* @author Etienne Dauvergne <contact@ekyna.com>
*/
class SyncAction implements ActionInterface, GatewayAwareInterface
{
use GatewayAwareTrait;
/**
* {@inheritdoc}
*
* @param Sync $request
*/
public function execute($request)
{
RequestNotSupportedException::assertSupports($this, $request);
$model = ArrayObject::ensureArrayObject($request->getModel());
$this->gateway->execute(new Response($model));
}
/**
* {@inheritdoc}
*/
public function supports($request)
{
return $request instanceof Sync
&& $request->getModel() instanceof \ArrayAccess;
}
}
Copyright (c) 2017 Etienne Dauvergne
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
<?php
namespace Ekyna\Component\Payum\Payzen;
use Payum\Core\Bridge\Spl\ArrayObject;
use Payum\Core\GatewayFactory;
use Payum\Core\GatewayFactoryInterface;
/**
* Class PayzenGatewayFactory
* @package Ekyna\Component\Payum\Payzen
* @author Etienne Dauvergne <contact@ekyna.com>
*/
class PayzenGatewayFactory extends GatewayFactory
{
/**
* Builds a new factory.
*
* @param array $defaultConfig
* @param GatewayFactoryInterface $coreGatewayFactory
*
* @return PayzenGatewayFactory
*/
public static function build(array $defaultConfig, GatewayFactoryInterface $coreGatewayFactory = null)
{
return new static($defaultConfig, $coreGatewayFactory);
}
/**
* @inheritDoc
*/
protected function populateConfig(ArrayObject $config)
{
$config->defaults([
'payum.factory_name' => 'payzen',
'payum.factory_title' => 'Payzen',
'payum.action.capture' => new Action\CaptureAction(),
'payum.action.convert_payment' => new Action\ConvertPaymentAction(),
'payum.action.sync' => new Action\SyncAction(),
'payum.action.cancel' => new Action\CancelAction(),
'payum.action.refund' => new Action\RefundAction(),
'payum.action.status' => new Action\StatusAction(),
'payum.action.notify' => new Action\NotifyAction(),
'payum.action.api.request' => new Action\Api\ApiRequestAction(),
'payum.action.api.response' => new Action\Api\ApiResponseAction(),
]);
if (false == $config['payum.api']) {
$config['payum.default_options'] = [
'site_id' => null,
'certificate' => null,
'ctx_mode' => null,
'directory' => null,
'endpoint' => null,
'debug' => false,
];
$config->defaults($config['payum.default_options']);
$config['payum.required_options'] = ['site_id', 'certificate', 'ctx_mode', 'directory'];
$config['payum.api'] = function (ArrayObject $config) {
$config->validateNotEmpty($config['payum.required_options']);
$payzenConfig = [
'endpoint' => $config['endpoint'],
'site_id' => $config['site_id'],
'certificate' => $config['certificate'],
'ctx_mode' => $config['ctx_mode'],
'directory' => $config['directory'],
'debug' => $config['debug'],
];
$api = new Api\Api();
$api->setConfig($payzenConfig);
return $api;
};
}
}
}
PayumPayzen
===========
PayZen Payum Gateway
## Installation / Configuration
TODO
<?php
namespace Ekyna\Component\Payum\Payzen\Request;
use Payum\Core\Request\Generic;
/**
* Class Request
* @package Ekyna\Component\Payum\Payzen\Request
* @author Etienne Dauvergne <contact@ekyna.com>
*/
class Request extends Generic
{
}
<?php
namespace Ekyna\Component\Payum\Payzen\Request;
use Payum\Core\Request\Generic;
/**
* Class Response
* @package Ekyna\Component\Payum\Payzen\Request
* @author Etienne Dauvergne <contact@ekyna.com>
*/
class Response extends Generic
{
}
{
"name": "ekyna/payum-payzen",
"description": "PayZen Payum gateway",
"type": "component",
"authors": [
{
"name": "Etienne Dauvergne",
"homepage": "http://ekyna.com"
}
],
"keywords": [
"payum",
"payzen"
],
"homepage": "https://github.com/ekyna/PayumPayzen",
"license": [
"MIT"
],
"require": {
"php": "^7.0",
"payum/core": "^1.5",
"php-http/guzzle6-adapter": "^2.0",
"symfony/process": "4.4.*",
"psr/log": "~1.0"
},
"autoload": {
"psr-4": {
"Ekyna\\Component\\Payum\\Payzen\\": ""
}
}
}
<?php
namespace App\Admin;
use App\Entity\User;
use Sonata\AdminBundle\Admin\AbstractAdmin;
use Sonata\AdminBundle\Datagrid\DatagridMapper;
use Sonata\AdminBundle\Datagrid\ListMapper;
use Sonata\AdminBundle\Form\FormMapper;
use Sonata\AdminBundle\Route\RouteCollection;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\Security\Core\Security;
/**
* Administration des flux 'Achat de monnaie'
*
* KOHINOS : Outil de gestion de Monnaie Locale Complémentaire
* @author Damien Moulard <dam.moulard@gmail.com>
*/
class AchatMonnaieAdmin extends AbstractAdmin
{
protected $baseRouteName = 'achat_monnaie';
protected $baseRoutePattern = 'achat_monnaie';
protected $security;
protected $translator;
protected $datagridValues = [
'_sort_order' => 'DESC',
'_sort_by' => 'createdAt',
];
public function setSecurity(Security $security)
{
$this->security = $security;
}
/**
* {@inheritdoc}
*/
protected function configureDatagridFilters(DatagridMapper $datagridMapper): void
{
$datagridMapper->add('type', null, array(
'advanced_filter' => false,
'show_filter' => true,
'field_type' => ChoiceType::class,
'field_options' => array(
'choices' => array('Adhérent' => 'achat_monnaie_adherent', 'Prestataire' => 'achat_monnaie_prestataire'),
'placeholder' => 'Indifférent',
'expanded' => true,
'multiple' => false
)
));
}
/**
* {@inheritdoc}
*/
protected function configureFormFields(FormMapper $formMapper)
{
}
protected function configureRoutes(RouteCollection $collection)
{
$collection->remove('delete');
if ($this->security->getUser() != null && !($this->security->getUser()->isGranted('ROLE_TRESORIER') || $this->security->getUser()->isGranted('ROLE_SUPER_ADMIN') || $this->security->getUser()->isGranted('ROLE_COMPTOIR'))) {
$collection->clearExcept(array('list', 'export'));
}
}
/**
* {@inheritdoc}
*/
protected function configureListFields(ListMapper $listMapper)
{
unset($this->listModes['mosaic']);
$listMapper
->add('createdAt', 'datetime', array('label' => 'Date'))
->add('montant', null, array('label' => 'Montant'))
->add('destinataire', null, array('label' => 'Destinataire'))
->add('operateur', null, array('label' => 'Operateur'))
->add('reference', null, array('label' => 'Reference'))
;
}
}
......@@ -81,7 +81,7 @@ class FluxAdmin extends AbstractAdmin
'show_filter' => true,
'field_type' => SChoiceType::class,
'field_options' => array(
'choices' => array('Transactions' => 'transaction', 'Transferts' => 'transfert', 'Cotisations' => 'cotisation'),
'choices' => array('Transactions' => 'transaction', 'Transferts' => 'transfert', 'Cotisations' => 'cotisation', 'Achat de monnaie' => 'achat'),
'placeholder' => 'Indifférent',
'expanded' => true,
'multiple' => false
......
......@@ -8,6 +8,7 @@ use App\Entity\Geoloc;
use App\Entity\TransactionAdherentAdherent;
use App\Entity\TransactionAdherentPrestataire;
use App\Entity\AchatMonnaieAdherent;
use App\Entity\Payment;
use App\Entity\Usergroup;
use App\Form\Type\AdherentInfosFormType;
use App\Form\Type\AdhererFormType;
......@@ -104,18 +105,19 @@ class UserAdherentController extends FluxController
}
$entity = new AchatMonnaieAdherent();
$entity->setReference("Achat Monnaie en CB");
$form = $this->createForm(AchatMonnaieAdherentFormType::class, $entity);
$form->handleRequest($request);
//TODO custom form handling -> redirect to payzen or other mean of payment
return $this->redirectToRoute('index');
return $this->manageFluxForm(
$request,
if ($form->isSubmitted() && $form->isValid()) {
return $this->preparePaymentAction(
$form,
$this->getUser()->getAdherent()->getCompte(),
$this->translator->trans('Achat de monnaie locale bien effectuée !'),
$this->translator->trans('Achat de monnaie locale')
Payment::TYPE_ACHAT_MONNAIE_ADHERENT
);
}
return $this->render('flux/transaction.html.twig', [
'form' => $form->createView(),
'title' => $this->translator->trans('Achat de monnaie locale')
]);
}
}
......@@ -5,6 +5,7 @@ namespace App\Controller;
use App\Entity\User;
use App\Entity\CotisationAdherent;
use App\Entity\CotisationPrestataire;
use App\Entity\Payment;
use App\Enum\MoyenEnum;
use App\Form\Type\CotiserFormType;
use App\Form\Type\UserInfosFormType;
......@@ -37,10 +38,13 @@ class UserController extends AbstractController
public function cotiserAction(Request $request)
{
$options = [];
$payment_type = '';
if ($this->security->getUser()->isGranted('ROLE_ADHERENT')) {
$options['data_class'] = CotisationAdherent::class;
$payment_type = Payment::TYPE_COTISATION_ADHERENT;
} elseif ($this->security->getUser()->isGranted('ROLE_PRESTATAIRE')) {
$options['data_class'] = CotisationPrestataire::class;
$payment_type = Payment::TYPE_COTISATION_PRESTA;
}
$form = $this->createForm(CotiserFormType::class, null, $options);
......@@ -65,7 +69,11 @@ class UserController extends AbstractController
);
return $this->redirectToRoute('index');
} else {
//@TODO : redirect to payment page
// Redirect to payment page
return $this->forward('App\Controller\FluxController::preparePaymentAction', [
'form' => $form,
'type' => $payment_type
]);
}
} else {
$this->addFlash(
......
......@@ -9,6 +9,7 @@ use App\Entity\TransactionPrestataireAdherent;
use App\Entity\TransfertPrestataireSiege;
use App\Entity\TypePrestataire;
use App\Entity\AchatMonnaiePrestataire;
use App\Entity\Payment;
use App\Form\Type\GroupePrestataireInscriptionFormType;
use App\Form\Type\PrestataireInfosFormType;
use App\Form\Type\TransactionPrestataireAdherentFormType;
......@@ -135,21 +136,24 @@ class UserPrestataireController extends FluxController
if (empty($this->getUser()) || empty($this->session->get('_prestagere'))) {
return $this->redirectToRoute('index');
}
$entity = new AchatMonnaiePrestataire();
$form = $this->createForm(AchatMonnaiePrestataireFormType::class, $entity);
$form->handleRequest($request);
///TODO custom form handling -> redirect to payzen or other mean of payment
return $this->redirectToRoute('index');
return $this->manageFluxForm(
$request,
if ($form->isSubmitted() && $form->isValid()) {
return $this->preparePaymentAction(
$form,
$this->session->get('_prestagere'),
$this->translator->trans('Achat de monnaie locale bien effectuée !'),
$this->translator->trans('Achat de monnaie locale')
Payment::TYPE_ACHAT_MONNAIE_PRESTA
);
}
return $this->render('flux/transaction.html.twig', [
'form' => $form->createView(),
'title' => $this->translator->trans('Achat de monnaie locale')
]);
}
/**
* Export all transferts / transactions for prestataire
*
......
......@@ -44,8 +44,8 @@ class Cotisation extends Flux
// throw new \Exception("[FLUX] Opération impossible ! Prestataire recevant la monnaie locale non configuré !");
// }
// $destinataire = $destinataires[0];
$compteExp = $this->getExpediteur()->getEcompte() - $this->getMontant();
if ($this->getMoyen() == MoyenEnum::MOYEN_MLC) {
$compteExp = $this->getExpediteur()->getEcompte() - $this->getMontant();
if ($compteExp < 0) {
throw new \Exception("[FLUX] Opération impossible ! Montant supérieur au solde de monnaie éléctronique !");
} else {
......@@ -55,6 +55,7 @@ class Cotisation extends Flux
return [$this->getExpediteur(), $this->getDestinataire()];
}
}
// Pas d'opération si la cotisation se fait par CB
return [];
}
......
......@@ -13,7 +13,7 @@ trait HasEcompteEntity
* Compte de MLC numérique
* @var int
*
* @ORM\Column(name="ecompte", type="decimal", precision=12, scale=2)
* @ORM\Column(name="ecompte", type="decimal", precision=12, scale=2, options={"default" : 0})
* @Groups({"read"})
*/
private $ecompte = 0;
......
......@@ -27,6 +27,7 @@ class GlobalParameter
const RECONVERSION_PRESTATAIRE = 'RECONVERSION_PRESTATAIRE';
const MAP_CENTER = 'MAP_CENTER';
const MAP_ZOOM = 'MAP_ZOOM';
const USE_PAYZEN = 'USE_PAYZEN';
/**
* @ORM\Id()
......
<?php
namespace App\Entity;
use Doctrine\ORM\Mapping as ORM;
use Payum\Core\Model\Payment as BasePayment;
/**
* @ORM\Entity(repositoryClass="App\Repository\PaymentRepository")
* @ORM\Table(name="payment")
*/
class Payment extends BasePayment
{
const TYPE_ACHAT_MONNAIE_ADHERENT = 'achat_monnaie_adherent';
const TYPE_ACHAT_MONNAIE_PRESTA = 'achat_monnaie_presta';
const TYPE_COTISATION_ADHERENT = 'cotisation_adherent';
const TYPE_COTISATION_PRESTA = 'cotisation_presta';
/**
* @ORM\Column(name="id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="IDENTITY")
*
* @var integer $id
*/
protected $id;
/**
* @var string|null
*
* @ORM\Column(type="string", length=50, nullable=true)
*/
protected $status;
/**
* @var string|null
* JSON array of 'Flux' to persist if payment valid
*
* @ORM\Column(type="text", nullable=true)
*/
protected $flux_data;
/**
* @return string
*/
public function getStatus(): ?string
{
return $this->status;
}
/**
* @param string $status
* @return Payment
*/
public function setStatus(string $status): self
{
$this->status = $status;
return $this;
}
/**
* @return string
*/
public function getFluxData(): ?string
{
return $this->flux_data;
}
/**
* @param string $flux_data
* @return Payment
*/
public function setFluxData(string $flux_data): self
{
$this->flux_data = $flux_data;
return $this;
}
}
<?php
namespace App\Entity;
use Doctrine\ORM\Mapping as ORM;
use Payum\Core\Model\Token;
/**
* @ORM\Entity
* @ORM\Table(name="payment_token")
*/
class PaymentToken extends Token
{
}
......@@ -10,7 +10,7 @@ use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Validator\Constraints as Assert;
/**
* @ORM\Entity
* @ORM\Entity(repositoryClass="App\Repository\SiegeRepository")
* @ORM\Table(name="siege")
*/
class Siege
......
......@@ -23,7 +23,7 @@ class AchatMonnaieAdherentFormType extends AchatMonnaieFormType
'em' => $this->em
))
->add('reference', HiddenType::class, array(
'data' => 'Achat monnaie en CB'
'data' => 'Achat monnaie en CB Adhérent'
))
->add('save', SubmitType::class, ['label' => "Payer en CB"])
;
......
......@@ -4,6 +4,7 @@ namespace App\Form\Type;
use App\Entity\Prestataire;
use Symfony\Component\Form\Extension\Core\Type\HiddenType;
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
......@@ -22,8 +23,9 @@ class AchatMonnaiePrestataireFormType extends AchatMonnaieFormType
'em' => $this->em
))
->add('reference', HiddenType::class, array(
'data' => 'Achat monnaie en CB'
'data' => 'Achat monnaie en CB Prestataire'
))
->add('save', SubmitType::class, ['label' => "Payer en CB"])
;
}
......
......@@ -54,6 +54,8 @@ class CotiserFormType extends AbstractType
$canPayWithMlc = ($this->session->get('_prestagere')->getEcompte() >= $montant);
}
$canPayWithCB = $this->em->getRepository(GlobalParameter::class)->val(GlobalParameter::USE_PAYZEN) === 'true' ? true : false;
$builder
->add('operateur', HiddenType::class, array(
'entity_class' => User::class,
......@@ -94,7 +96,9 @@ class CotiserFormType extends AbstractType
if ($canPayWithMlc) {
$builder->add('payMLC', SubmitType::class, ['label' => "Payer en eMLC"]);
}
if ($canPayWithCB) {
$builder->add('payCB', SubmitType::class, ['label' => "Payer en CB"]);
}
if ($this->security->getUser()->isGranted('ROLE_ADHERENT')) {
$builder
......
......@@ -118,6 +118,16 @@ class GlobalConfigurationFormType extends AbstractType
],
'help' => ''
))
->add('usepayzen', GlobalParameterType::class, array(
'label' => "Utiliser le paiement par CB avec Payzen :",
'name_param' => GlobalParameter::USE_PAYZEN,
'required' => true,
'_placeholder' => 'false',
'constraints_param' => [
new RegexConstraint(['pattern' => '/^true$|^false$/', 'message' => 'La valeur doit être "true" ou "false"'])
],
'help' => 'Si cette option est activée (true), les utilisateurs pourront cotiser et acheter de la monnaie locale par CB sur l\'application.'
))
;
}
......
<?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 Version20200626122137 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('CREATE TABLE payment (id INT AUTO_INCREMENT NOT NULL, number VARCHAR(255) DEFAULT NULL, description VARCHAR(255) DEFAULT NULL, client_email VARCHAR(255) DEFAULT NULL, client_id VARCHAR(255) DEFAULT NULL, total_amount INT DEFAULT NULL, currency_code VARCHAR(255) DEFAULT NULL, details LONGTEXT NOT NULL COMMENT \'(DC2Type:json_array)\', status VARCHAR(50) DEFAULT NULL, flux_data LONGTEXT DEFAULT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE `utf8_general_ci` ENGINE = InnoDB');
$this->addSql('CREATE TABLE payment_token (hash VARCHAR(255) NOT NULL, details LONGTEXT DEFAULT NULL COMMENT \'(DC2Type:object)\', after_url LONGTEXT DEFAULT NULL, target_url LONGTEXT NOT NULL, gateway_name VARCHAR(255) NOT NULL, PRIMARY KEY(hash)) DEFAULT CHARACTER SET utf8 COLLATE `utf8_general_ci` ENGINE = InnoDB');
$this->addSql('ALTER TABLE adherent CHANGE ecompte ecompte NUMERIC(12, 2) DEFAULT \'0\' NOT NULL');
$this->addSql('ALTER TABLE prestataire CHANGE ecompte ecompte NUMERIC(12, 2) DEFAULT \'0\' NOT NULL');
}
public function down(Schema $schema) : void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('DROP TABLE payment');
$this->addSql('DROP TABLE payment_token');
$this->addSql('ALTER TABLE adherent CHANGE ecompte ecompte NUMERIC(12, 2) NOT NULL');
$this->addSql('ALTER TABLE prestataire CHANGE ecompte ecompte NUMERIC(12, 2) NOT NULL');
}
}
<?php
namespace App\Repository;
use App\Entity\Payment;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
use Doctrine\Common\Persistence\ManagerRegistry;
/**
* @method Siege|null find($id, $lockMode = null, $lockVersion = null)
* @method Siege|null findOneBy(array $criteria, array $orderBy = null)
* @method Siege[] findAll()
* @method Siege[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
*/
class PaymentRepository extends ServiceEntityRepository
{
public function __construct(ManagerRegistry $registry)
{
parent::__construct($registry, Payment::class);
}
/**
* @param int $id User id
*
* @return Payment|null Returns user's last payment
*/
public function getUserLastPayment($id) {
$results = $this->findBy(
array('clientId' => $id),
array('id'=>'DESC'),
1,
0
);
if (empty($results)) {
return null;
} else {
return $results[0];
}
}
}
<?php
namespace App\Repository;
use App\Entity\Siege;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
use Doctrine\Common\Persistence\ManagerRegistry;
/**
* @method Siege|null find($id, $lockMode = null, $lockVersion = null)
* @method Siege|null findOneBy(array $criteria, array $orderBy = null)
* @method Siege[] findAll()
* @method Siege[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
*/
class SiegeRepository extends ServiceEntityRepository
{
public function __construct(ManagerRegistry $registry)
{
parent::__construct($registry, Siege::class);
}
}
......@@ -11,6 +11,7 @@ use App\Entity\Prestataire;
use App\Entity\Rubrique;
use App\Entity\Siege;
use App\Entity\User;
use App\Entity\GlobalParameter;
use Doctrine\ORM\EntityManagerInterface;
use Knp\Component\Pager\PaginatorInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
......@@ -61,10 +62,16 @@ class AppExtension extends AbstractExtension
new \Twig_SimpleFunction('getWordpressApiKey', array($this, 'getWordpressApiKey')),
new \Twig_SimpleFunction('parameter', function ($name) {
return $this->container->getParameter($name);
})
}),
new \Twig_SimpleFunction('isPayzenEnabled', array($this, 'isPayzenEnabled'))
];
}
public function isPayzenEnabled()
{
return $this->em->getRepository(GlobalParameter::class)->val(GlobalParameter::USE_PAYZEN) === 'true' ? true : false;
}
public function getFilters()
{
return array(
......
......@@ -107,6 +107,9 @@
"egulias/email-validator": {
"version": "2.1.6"
},
"ekyna/payum-payzen": {
"version": "1.5.x-dev"
},
"exsyst/swagger": {
"version": "v0.4.1"
},
......@@ -248,6 +251,27 @@
"lcobucci/jwt": {
"version": "3.3.1"
},
"league/uri": {
"version": "5.3.0"
},
"league/uri-components": {
"version": "1.8.2"
},
"league/uri-hostname-parser": {
"version": "1.1.1"
},
"league/uri-interfaces": {
"version": "1.1.1"
},
"league/uri-manipulations": {
"version": "1.5.0"
},
"league/uri-parser": {
"version": "1.4.1"
},
"league/uri-schemes": {
"version": "1.2.1"
},
"lexik/jwt-authentication-bundle": {
"version": "2.5",
"recipe": {
......@@ -320,6 +344,27 @@
"ocramius/proxy-manager": {
"version": "2.1.1"
},
"payum/core": {
"version": "1.6.0"
},
"payum/iso4217": {
"version": "1.0.1"
},
"payum/offline": {
"version": "1.6.0"
},
"payum/payum-bundle": {
"version": "2.4",
"recipe": {
"repo": "github.com/symfony/recipes-contrib",
"branch": "master",
"version": "2.4",
"ref": "72ad834a0f4a99175beddb5e2d049136f4a50a67"
},
"files": [
"config/packages/payum.yaml"
]
},
"php": {
"version": "7.4"
},
......
......@@ -24,7 +24,7 @@
{% if ((app.user and is_granted('ROLE_ADHERENT') and app.user.adherent) or (app.user and is_granted('ROLE_PRESTATAIRE') and app.session.has('_prestagere'))) %}
<a class='btn btn-xs btn-primary' href='{{ path('cotiser') }}'>
{{ 'Cotiser en MLC'|trans }}
{{ 'Cotiser'|trans }}
</a>
{% endif %}
{% endblock blockcontent %}
......
......@@ -27,7 +27,7 @@
{% if flux.type == 'reconversion' %}
<td>Demande de reconversion</td>
{% else %}
<td>{{flux.parenttype|capitalize}} de {{ flux.type|capitalize|replace({'_' : ' à '}) }}</td>
<td>{{ flux.type|capitalize|replace({'_' : ' '}) }}</td>
{% endif %}
<td>{{flux.expediteur}}</td>
<td>{{flux.destinataire}}</td>
......
......@@ -155,7 +155,9 @@
{% include 'block/cotisations.html.twig' %}
{% include 'groupepresta/block/inscription.html.twig' %}
{% endif %}
{% if isPayzenEnabled() %}
{% include 'presta/block/achat_monnaie.html.twig' %}
{% endif %}
{% include 'presta/block/transaction_presta.html.twig' %}
{% include 'presta/block/transaction_adherent.html.twig' %}
{% if getCurrentPrestataire().mlc == false and getCurrentPrestataire().ecompte > 0 %}
......@@ -170,7 +172,9 @@
{% include 'block/userpassword.html.twig' %}
{% include 'block/cotisations.html.twig' %}
{% include 'block/transactions.html.twig' %}
{% if isPayzenEnabled() %}
{% include 'adherent/block/achat_monnaie.html.twig' %}
{% endif %}
{% include 'adherent/block/transaction_presta.html.twig' %}
{% include 'adherent/block/transaction_adherent.html.twig' %}
......
......@@ -26,8 +26,15 @@
{% else %}
<div class='col-12'>
{% endif %}
{% if form.payCB is defined %}
<div class='col-6'>
{{ form_widget(form.payCB) }}
</div>
<div class='col-6'>
{% else %}
<div class='col-12'>
{% endif %}
</div>
</div>
{{ form_end(form) }}
</div>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment