Skip to content

Commit

Permalink
Move to Troopers organization (#25)
Browse files Browse the repository at this point in the history
  • Loading branch information
lenybernard authored Sep 23, 2016
1 parent 896477c commit e079afd
Show file tree
Hide file tree
Showing 39 changed files with 293 additions and 1,948 deletions.
9 changes: 0 additions & 9 deletions AppVentusMangopayBundle.php

This file was deleted.

56 changes: 28 additions & 28 deletions Controller/PaymentController.php
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
<?php

namespace AppVentus\MangopayBundle\Controller;

use AppVentus\MangopayBundle\AppVentusMangopayEvents;
use AppVentus\MangopayBundle\Entity\Order;
use AppVentus\MangopayBundle\Event\OrderEvent;
use AppVentus\MangopayBundle\Event\PreAuthorisationEvent;
use AppVentus\MangopayBundle\Form\CardType;
use AppVentus\MangopayBundle\OrderEvents;
namespace Troopers\MangopayBundle\Controller;

use MangoPay\CardRegistration;
use MangoPay\PayIn;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\Request;
use Troopers\MangopayBundle\Entity\Order;
use Troopers\MangopayBundle\Event\OrderEvent;
use Troopers\MangopayBundle\Event\PreAuthorisationEvent;
use Troopers\MangopayBundle\Form\CardType;
use Troopers\MangopayBundle\OrderEvents;
use Troopers\MangopayBundle\TroopersMangopayEvents;

/**
* Manage payment.
Expand All @@ -25,12 +25,12 @@ class PaymentController extends Controller
/**
* Create a payment.
*
* @Route("/new/{order}", name="appventus_mangopaybundle_payment_new", defaults={"order" = null, "type" = "card"})
* @Route("/new/{order}", name="troopers_mangopaybundle_payment_new", defaults={"order" = null, "type" = "card"})
**/
public function newAction(Request $request, $order)
{
$orderRepository = $this->getDoctrine()->getManager()
->getRepository($this->container->getParameter('appventus_mangopay.order.class'));
->getRepository($this->container->getParameter('troopers_mangopay.order.class'));
$order = $orderRepository->findOneById($order);
if (!$order instanceof Order) {
throw $this->createNotFoundException('Order not found');
Expand All @@ -41,19 +41,19 @@ public function newAction(Request $request, $order)

if ($form->isValid()) {
//find or create a mango user
$mangoUser = $this->container->get('appventus_mangopay.user_helper')
$mangoUser = $this->container->get('troopers_mangopay.user_helper')
->findOrCreateMangoUser($this->getUser());
//create a cardRegistration
$callback = $this->container->get('appventus_mangopay.payment_helper')
$callback = $this->container->get('troopers_mangopay.payment_helper')
->prepareCardRegistrationCallback($mangoUser, $order);
//return js callback
return new JsonResponse($callback);
}

return $this->render(
'AppVentusMangopayBundle::cardPayment.html.twig',
'TroopersMangopayBundle::cardPayment.html.twig',
[
'form' => $form->createView(),
'form' => $form->createView(),
'order' => $order,
]
);
Expand All @@ -68,20 +68,20 @@ public function newAction(Request $request, $order)
* 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")
* @Route("/finalize/{orderId}/{cardId}", name="troopers_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'));
$orderRepository = $em->getRepository($this->container->getParameter('troopers_mangopay.order.class'));
$order = $orderRepository->findOneById($orderId);

$data = $request->get('data');
$errorCode = $request->get('errorCode');

$paymentHelper = $this->container->get('appventus_mangopay.payment_helper');
$paymentHelper = $this->container->get('troopers_mangopay.payment_helper');
$updatedCardRegister = $paymentHelper->updateCardRegistration($cardId, $data, $errorCode);

// Handle error
Expand Down Expand Up @@ -111,14 +111,14 @@ public function paymentFinalizeAction(Request $request, $orderId, $cardId)
// Handle secure mode
if (property_exists($preAuth, 'SecureModeNeeded') && $preAuth->SecureModeNeeded == 1) {
return new JsonResponse([
'success' => true,
'success' => true,
'redirect' => $preAuth->SecureModeRedirectURL,
]);
}

// store payin transaction
$event = new PreAuthorisationEvent($order, $preAuth);
$this->get('event_dispatcher')->dispatch(AppVentusMangopayEvents::UPDATE_CARD_PREAUTHORISATION, $event);
$this->get('event_dispatcher')->dispatch(TroopersMangopayEvents::UPDATE_CARD_PREAUTHORISATION, $event);

$event = new OrderEvent($order);
$this->get('event_dispatcher')->dispatch(OrderEvents::ORDER_CREATED, $event);
Expand All @@ -131,7 +131,7 @@ public function paymentFinalizeAction(Request $request, $orderId, $cardId)

$this->get('session')->getFlashBag()->add(
'success',
$this->get('translator')->trans('appventus_mangopay.alert.pre_authorisation.success')
$this->get('translator')->trans('troopers_mangopay.alert.pre_authorisation.success')
);

return new JsonResponse([
Expand All @@ -145,16 +145,16 @@ 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")
* @Route("/finalize-secure/{orderId}", name="troopers_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'));
$orderRepository = $em->getRepository($this->container->getParameter('troopers_mangopay.order.class'));
$order = $orderRepository->findOneById($orderId);
$mangopayApi = $this->container->get('appventus_mangopay.mango_api');
$mangopayApi = $this->container->get('troopers_mangopay.mango_api');

$preAuthId = $request->get('preAuthorizationId');

Expand All @@ -178,7 +178,7 @@ public function paymentFinalizeSecureAction(Request $request, $orderId)
}

$event = new PreAuthorisationEvent($order, $preAuth);
$this->get('event_dispatcher')->dispatch(AppVentusMangopayEvents::UPDATE_CARD_PREAUTHORISATION, $event);
$this->get('event_dispatcher')->dispatch(TroopersMangopayEvents::UPDATE_CARD_PREAUTHORISATION, $event);

$event = new OrderEvent($order);
$this->get('event_dispatcher')->dispatch(OrderEvents::ORDER_CREATED, $event);
Expand All @@ -190,10 +190,10 @@ public function paymentFinalizeSecureAction(Request $request, $orderId)

$this->get('session')->getFlashBag()->add(
'success',
$this->get('translator')->trans('appventus_mangopay.alert.pre_authorisation.success')
$this->get('translator')->trans('troopers_mangopay.alert.pre_authorisation.success')
);

return $this->redirect($this->get('appventus_mangopay.payment_helper')->generateSuccessUrl($orderId));
return $this->redirect($this->get('troopers_mangopay.payment_helper')->generateSuccessUrl($orderId));
}

/**
Expand All @@ -202,14 +202,14 @@ public function paymentFinalizeSecureAction(Request $request, $orderId)
*
* This method shows the congratulations
*
* @Route("/success/{orderId}", name="appventus_mangopaybundle_payment_success")
* @Route("/success/{orderId}", name="troopers_mangopaybundle_payment_success")
*
* @return Response
*/
public function successAction(Request $request, $orderId)
{
return $this->render(
'AppVentusMangopayBundle::success.html.twig',
'TroopersMangopayBundle::success.html.twig',
['orderId' => $orderId]
);
}
Expand Down
4 changes: 2 additions & 2 deletions DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace AppVentus\MangopayBundle\DependencyInjection;
namespace Troopers\MangopayBundle\DependencyInjection;

use Symfony\Component\Config\Definition\Builder\TreeBuilder;
use Symfony\Component\Config\Definition\ConfigurationInterface;
Expand All @@ -18,7 +18,7 @@ class Configuration implements ConfigurationInterface
public function getConfigTreeBuilder()
{
$treeBuilder = new TreeBuilder();
$rootNode = $treeBuilder->root('appventus_mangopay');
$rootNode = $treeBuilder->root('troopers_mangopay');

$rootNode
->children()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
<?php

namespace AppVentus\MangopayBundle\DependencyInjection;
namespace Troopers\MangopayBundle\DependencyInjection;

use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\Config\FileLocator;
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Loader;
use Symfony\Component\HttpKernel\DependencyInjection\Extension;

/**
* 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
class TroopersMangopayExtension extends Extension
{
/**
* {@inheritdoc}
Expand All @@ -25,9 +25,9 @@ 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']);
$container->setParameter('appventus_mangopay.base_url', $config['base_url']);
$container->setParameter('troopers_mangopay.debug_mode', $config['debug_mode'] === true);
$container->setParameter('troopers_mangopay.client_id', $config['client_id']);
$container->setParameter('troopers_mangopay.client_password', $config['client_password']);
$container->setParameter('troopers_mangopay.base_url', $config['base_url']);
}
}
2 changes: 1 addition & 1 deletion Entity/BankInformationInterface.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace AppVentus\MangopayBundle\Entity;
namespace Troopers\MangopayBundle\Entity;

/**
* Defines mandatory methods BankInformation need to be used in Mango
Expand Down
19 changes: 18 additions & 1 deletion Entity/CardPreAuthorisation.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace AppVentus\MangopayBundle\Entity;
namespace Troopers\MangopayBundle\Entity;

use Doctrine\ORM\Mapping as ORM;
use Gedmo\Timestampable\Traits\TimestampableEntity;
Expand Down Expand Up @@ -203,6 +203,7 @@ public function setAuthorId($authorId)

return $this;
}

/**
* Get debitedFunds.
*
Expand All @@ -226,6 +227,7 @@ public function setDebitedFunds($debitedFunds)

return $this;
}

/**
* Get status.
*
Expand All @@ -249,6 +251,7 @@ public function setStatus($status)

return $this;
}

/**
* Get paymentStatus.
*
Expand All @@ -272,6 +275,7 @@ public function setPaymentStatus($paymentStatus)

return $this;
}

/**
* Get resultCode.
*
Expand All @@ -295,6 +299,7 @@ public function setResultCode($resultCode)

return $this;
}

/**
* Get resultMessage.
*
Expand All @@ -318,6 +323,7 @@ public function setResultMessage($resultMessage)

return $this;
}

/**
* Get executionType.
*
Expand All @@ -341,6 +347,7 @@ public function setExecutionType($executionType)

return $this;
}

/**
* Get secureMode.
*
Expand All @@ -364,6 +371,7 @@ public function setSecureMode($secureMode)

return $this;
}

/**
* Get cardId.
*
Expand All @@ -387,6 +395,7 @@ public function setCardId($cardId)

return $this;
}

/**
* Get secureModeNeeded.
*
Expand All @@ -410,6 +419,7 @@ public function setSecureModeNeeded($secureModeNeeded)

return $this;
}

/**
* Get secureModeRedirectURL.
*
Expand All @@ -433,6 +443,7 @@ public function setSecureModeRedirectURL($secureModeRedirectURL)

return $this;
}

/**
* Get secureModeReturnURL.
*
Expand All @@ -456,6 +467,7 @@ public function setSecureModeReturnURL($secureModeReturnURL)

return $this;
}

/**
* Get expirationDate.
*
Expand All @@ -479,6 +491,7 @@ public function setExpirationDate($expirationDate)

return $this;
}

/**
* Get authorizationDate.
*
Expand All @@ -502,6 +515,7 @@ public function setAuthorizationDate($authorizationDate)

return $this;
}

/**
* Get paymentType.
*
Expand All @@ -525,6 +539,7 @@ public function setPaymentType($paymentType)

return $this;
}

/**
* Get payInId.
*
Expand Down Expand Up @@ -572,6 +587,7 @@ public function setMangoId($mangoId)

return $this;
}

/**
* Get tag.
*
Expand All @@ -595,6 +611,7 @@ public function setTag($tag)

return $this;
}

/**
* Get creationDate.
*
Expand Down
Loading

0 comments on commit e079afd

Please sign in to comment.