Skip to content

Commit

Permalink
Php-cs-fixer
Browse files Browse the repository at this point in the history
  • Loading branch information
Matthieu Cutin committed May 27, 2016
1 parent 674b874 commit 9a3a51a
Show file tree
Hide file tree
Showing 28 changed files with 302 additions and 305 deletions.
19 changes: 9 additions & 10 deletions AppVentusMangopayEvents.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,49 +4,48 @@

final class AppVentusMangopayEvents
{

/**
* The NEW_USER event occurs when a user is created
* The NEW_USER event occurs when a user is created.
*/
const NEW_USER = 'appventus_mangopay.user.new';

/**
* The NEW_WALLET event occurs when a wallet is created
* The NEW_WALLET event occurs when a wallet is created.
*/
const NEW_WALLET = 'appventus_mangopay.wallet.new';

/**
* The NEW_CARD_PREAUTHORISATION event occurs when a card preauthorisation is created
* The NEW_CARD_PREAUTHORISATION event occurs when a card preauthorisation is created.
*/
const NEW_CARD_PREAUTHORISATION = 'appventus_mangopay.card.preauthorisation.new';

/**
* The UPDATE_CARD_PREAUTHORISATION event occurs when a card preauthorisation is updated
* The UPDATE_CARD_PREAUTHORISATION event occurs when a card preauthorisation is updated.
*/
const UPDATE_CARD_PREAUTHORISATION = 'appventus_mangopay.card.preauthorisation.update';

/**
* The CANCEL_CARD_PREAUTHORISATION event occurs when a card preauthorisation is canceled
* The CANCEL_CARD_PREAUTHORISATION event occurs when a card preauthorisation is canceled.
*/
const CANCEL_CARD_PREAUTHORISATION = 'appventus_mangopay.card.preauthorisation.cancel';

/**
* The NEW_CARD_REGISTRATION event occurs when a card registration is created
* The NEW_CARD_REGISTRATION event occurs when a card registration is created.
*/
const NEW_CARD_REGISTRATION = 'appventus_mangopay.card.registration.new';

/**
* The UPDATE_CARD_REGISTRATION event occurs when a card registration is updated
* The UPDATE_CARD_REGISTRATION event occurs when a card registration is updated.
*/
const UPDATE_CARD_REGISTRATION = 'appventus_mangopay.card.registration.update';

/**
* The NEW_PAY_IN event occurs when a apyin is created
* The NEW_PAY_IN event occurs when a apyin is created.
*/
const NEW_PAY_IN = 'appventus_mangopay.pay_in.new';

/**
* The ERROR_PAY_IN event occurs when a apyin is errored
* The ERROR_PAY_IN event occurs when a apyin is errored.
*/
const ERROR_PAY_IN = 'appventus_mangopay.pay_in.error';
}
37 changes: 16 additions & 21 deletions Controller/PaymentController.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,20 @@
use AppVentus\MangopayBundle\OrderEvents;
use MangoPay\CardRegistration;
use MangoPay\PayIn;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\Request;

/**
* Manage payment
* Manage payment.
*
* @Route("/payment")
*/
class PaymentController extends Controller
{

/**
* Create a payment
* Create a payment.
*
* @Route("/new/{order}", name="appventus_mangopaybundle_payment_new", defaults={"order" = null, "type" = "card"})
**/
Expand Down Expand Up @@ -63,18 +62,18 @@ public function newAction(Request $request, $order)
/**
* @param Request $request The request
* @param Reservation $reservation The reservation
* @param integer $cardId The cardId
* @param int $cardId The cardId
*
* This method is called by paymentAction callback, with the authorized cardId as argument.
* It creates a PreAuthorisation with reservation price, and store its id in the Reservation.
* When the owner will accept the reservation, we will be able to fetch the PreAuthorisation and create the PayIn
*
* @Route("/finalize/{orderId}/{cardId}", name="appventus_mangopaybundle_payment_finalize")
*
* @return JsonResponse return json
*/
public function paymentFinalizeAction(Request $request, $orderId, $cardId)
{

$em = $this->getDoctrine()->getManager();
$orderRepository = $em->getRepository($this->container->getParameter('appventus_mangopay.order.class'));
$order = $orderRepository->findOneById($orderId);
Expand All @@ -87,15 +86,13 @@ public function paymentFinalizeAction(Request $request, $orderId, $cardId)

// Handle error
if ((property_exists($updatedCardRegister, 'ResultCode')
&& $updatedCardRegister->ResultCode !== "000000")
|| $updatedCardRegister->Status == 'ERROR')
{

$errorMessage = $this->get('translator')->trans('mangopay.error.' . $updatedCardRegister->ResultCode);
&& $updatedCardRegister->ResultCode !== '000000')
|| $updatedCardRegister->Status == 'ERROR') {
$errorMessage = $this->get('translator')->trans('mangopay.error.'.$updatedCardRegister->ResultCode);

return new JsonResponse(array(
'success' => false,
'message' => $errorMessage
'message' => $errorMessage,
));
}

Expand All @@ -104,19 +101,18 @@ public function paymentFinalizeAction(Request $request, $orderId, $cardId)

// Handle error
if ((property_exists($preAuth, 'Code') && $preAuth->Code !== 200) || $preAuth->Status == 'FAILED') {

$errorMessage = $this->get('translator')->trans('mangopay.error.' . $preAuth->ResultCode);
$errorMessage = $this->get('translator')->trans('mangopay.error.'.$preAuth->ResultCode);

return new JsonResponse(array(
'success' => false,
'message' => $errorMessage
'message' => $errorMessage,
));
}
// Handle secure mode
if (property_exists($preAuth, 'SecureModeNeeded') && $preAuth->SecureModeNeeded == 1) {
return new JsonResponse(array(
'success' => true,
'redirect' => $preAuth->SecureModeRedirectURL
'redirect' => $preAuth->SecureModeRedirectURL,
));
}

Expand All @@ -139,9 +135,8 @@ public function paymentFinalizeAction(Request $request, $orderId, $cardId)
);

return new JsonResponse(array(
'success' => true
'success' => true,
));

}

/**
Expand All @@ -151,11 +146,11 @@ public function paymentFinalizeAction(Request $request, $orderId, $cardId)
* This method is called by paymentFinalizeActionif 3dsecure is required. 3DSecure is needed when 250€ are reached
*
* @Route("/finalize-secure/{orderId}", name="appventus_mangopaybundle_payment_finalize_secure")
*
* @return RedirectResponse
*/
public function paymentFinalizeSecureAction(Request $request, $orderId)
{

$em = $this->getDoctrine()->getManager();
$orderRepository = $em->getRepository($this->container->getParameter('appventus_mangopay.order.class'));
$order = $orderRepository->findOneById($orderId);
Expand All @@ -166,11 +161,10 @@ public function paymentFinalizeSecureAction(Request $request, $orderId)
$preAuth = $mangopayApi->CardPreAuthorizations->Get($preAuthId);

if ((property_exists($preAuth, 'Code') && $preAuth->Code !== 200) || $preAuth->Status != 'SUCCEEDED') {

if (property_exists($preAuth, 'Code')) {
$this->get('session')->getFlashBag()->add(
'danger',
$this->get('translator')->trans('mangopay.error.' . $preAuth->Code)
$this->get('translator')->trans('mangopay.error.'.$preAuth->Code)
);
} else {
$this->get('session')->getFlashBag()->add('error', $preAuth->ResultMessage);
Expand Down Expand Up @@ -208,6 +202,7 @@ public function paymentFinalizeSecureAction(Request $request, $orderId)
* This method shows the congratulations
*
* @Route("/success", name="appventus_mangopaybundle_payment_success")
*
* @return Response
*/
public function successAction(Request $request)
Expand Down
6 changes: 3 additions & 3 deletions DependencyInjection/AppVentusMangopayExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@
use Symfony\Component\DependencyInjection\Loader;

/**
* This is the class that loads and manages your bundle configuration
* This is the class that loads and manages your bundle configuration.
*
* To learn more see {@link http://symfony.com/doc/current/cookbook/bundles/extension.html}
*/
class AppVentusMangopayExtension extends Extension
{
/**
* {@inheritDoc}
* {@inheritdoc}
*/
public function load(array $configs, ContainerBuilder $container)
{
Expand All @@ -24,7 +24,7 @@ public function load(array $configs, ContainerBuilder $container)

$loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
$loader->load('services.yml');

$container->setParameter('appventus_mangopay.debug_mode', $config['debug_mode'] === true);
$container->setParameter('appventus_mangopay.client_id', $config['client_id']);
$container->setParameter('appventus_mangopay.client_password', $config['client_password']);
Expand Down
6 changes: 3 additions & 3 deletions DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,20 @@
use Symfony\Component\Config\Definition\ConfigurationInterface;

/**
* This is the class that validates and merges configuration from your app/config files
* This is the class that validates and merges configuration from your app/config files.
*
* To learn more see {@link http://symfony.com/doc/current/cookbook/bundles/extension.html#cookbook-bundles-extension-config-class}
*/
class Configuration implements ConfigurationInterface
{
/**
* {@inheritDoc}
* {@inheritdoc}
*/
public function getConfigTreeBuilder()
{
$treeBuilder = new TreeBuilder();
$rootNode = $treeBuilder->root('appventus_mangopay');

$rootNode
->children()
->booleanNode('debug_mode')->defaultValue(false)->end()
Expand Down
8 changes: 4 additions & 4 deletions Entity/BankInformationInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,22 @@

/**
* Defines mandatory methods BankInformation need to be used in Mango
* https://docs.mangopay.com/api-references/users/natural-users/
* https://docs.mangopay.com/api-references/users/natural-users/.
*/
interface BankInformationInterface
{
/**
* Author Mango Id
* Author Mango Id.
*
* @var string
*/
public function getAddress();

/**
* It represents the amount debited on the bank account of the Author.In cents so 100€ will be written like « Amount » : 10000
* DebitedFunds – Fees = CreditedFunds (amount received on wallet)
* DebitedFunds – Fees = CreditedFunds (amount received on wallet).
*
* @var string
*/
public function getIban();

}
Loading

0 comments on commit 9a3a51a

Please sign in to comment.