Skip to content

Commit

Permalink
Merge pull request #16 from IDCI-Consulting/feat/eureka-payment-gateway
Browse files Browse the repository at this point in the history
Add: Eureka Payment Gateway
  • Loading branch information
BeBlood authored Jul 10, 2020
2 parents fc1574c + 918195d commit 0fd4195
Show file tree
Hide file tree
Showing 23 changed files with 2,013 additions and 13 deletions.
1 change: 1 addition & 0 deletions Controller/Test/PaymentGatewayFrontTestController.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ public function configureAction(Request $request, string $configuration_alias)
'customer_id' => $transactionData['customer_id'],
'customer_email' => $transactionData['customer_email'],
'description' => $transactionData['description'],
'metadata' => $transactionData['metadata'],
]);
}

Expand Down
3 changes: 3 additions & 0 deletions Event/Subscriber/TransactionManagerEventSubscriber.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ public static function getSubscribedEvents()
TransactionEvent::UNVERIFIED => [
['save', 0],
],
TransactionEvent::UPDATED => [
['save', 0],
],
];
}

Expand Down
1 change: 1 addition & 0 deletions Event/TransactionEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ class TransactionEvent extends Event
const FAILED = 'idci_payment.transaction.failed';
const PENDING = 'idci_payment.transaction.pending';
const UNVERIFIED = 'idci_payment.transaction.unverified';
const UPDATED = 'idci_payment.transaction.updated';

protected $transaction;

Expand Down
17 changes: 17 additions & 0 deletions Form/TransactionFormType.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use IDCI\Bundle\PaymentBundle\Manager\PaymentManager;
use Payum\ISO4217\ISO4217;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\CallbackTransformer;
use Symfony\Component\Form\Extension\Core\Type as Type;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
Expand Down Expand Up @@ -62,9 +63,25 @@ public function buildForm(FormBuilderInterface $builder, array $options)
->add('description', Type\TextareaType::class, [
'required' => false,
])
->add('metadata', Type\TextareaType::class, [
'required' => false,
])
->add('submit', Type\SubmitType::class)
;

$builder->get('metadata')->addModelTransformer(new CallbackTransformer(
function ($metadata) {
if (null === $metadata) {
$metadata = [];
}

return json_encode($metadata);
},
function ($metadata) {
return json_decode($metadata, true);
}
));

if (null !== $options['payment_gateway_configuration_alias']) {
$builder->add('payment_gateway_configuration_alias', Type\HiddenType::class, [
'data' => $options['payment_gateway_configuration_alias'],
Expand Down
13 changes: 11 additions & 2 deletions Gateway/AbstractPaymentGateway.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use IDCI\Bundle\PaymentBundle\Model\PaymentGatewayConfigurationInterface;
use IDCI\Bundle\PaymentBundle\Model\Transaction;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Contracts\EventDispatcher\EventDispatcherInterface;

abstract class AbstractPaymentGateway implements PaymentGatewayInterface
{
Expand All @@ -14,9 +15,17 @@ abstract class AbstractPaymentGateway implements PaymentGatewayInterface
*/
protected $templating;

public function __construct(\Twig_Environment $templating)
{
/**
* @var EventDispatcherInterface
*/
protected $dispatcher;

public function __construct(
\Twig_Environment $templating,
EventDispatcherInterface $dispatcher
) {
$this->templating = $templating;
$this->dispatcher = $dispatcher;
}

abstract public function initialize(
Expand Down
4 changes: 3 additions & 1 deletion Gateway/AtosSipsBinPaymentGateway.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
use Payum\ISO4217\ISO4217;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Process\Process;
use Symfony\Contracts\EventDispatcher\EventDispatcherInterface;

class AtosSipsBinPaymentGateway extends AbstractPaymentGateway
{
Expand All @@ -30,11 +31,12 @@ class AtosSipsBinPaymentGateway extends AbstractPaymentGateway

public function __construct(
\Twig_Environment $templating,
EventDispatcherInterface $dispatcher,
string $pathfile,
string $requestBinPath,
string $responseBinPath
) {
parent::__construct($templating);
parent::__construct($templating, $dispatcher);

$this->pathfile = $pathfile;
$this->requestBinPath = $requestBinPath;
Expand Down
4 changes: 3 additions & 1 deletion Gateway/AtosSipsJsonPaymentGateway.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
use IDCI\Bundle\PaymentBundle\Payment\PaymentStatus;
use Payum\ISO4217\ISO4217;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Contracts\EventDispatcher\EventDispatcherInterface;

class AtosSipsJsonPaymentGateway extends AbstractPaymentGateway
{
Expand All @@ -21,9 +22,10 @@ class AtosSipsJsonPaymentGateway extends AbstractPaymentGateway

public function __construct(
\Twig_Environment $templating,
EventDispatcherInterface $dispatcher,
string $serverHostName
) {
parent::__construct($templating);
parent::__construct($templating, $dispatcher);

$this->serverHostName = $serverHostName;
}
Expand Down
4 changes: 3 additions & 1 deletion Gateway/AtosSipsPostPaymentGateway.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
use IDCI\Bundle\PaymentBundle\Payment\PaymentStatus;
use Payum\ISO4217\ISO4217;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Contracts\EventDispatcher\EventDispatcherInterface;

class AtosSipsPostPaymentGateway extends AbstractPaymentGateway
{
Expand All @@ -19,9 +20,10 @@ class AtosSipsPostPaymentGateway extends AbstractPaymentGateway

public function __construct(
\Twig_Environment $templating,
EventDispatcherInterface $dispatcher,
string $serverHostName
) {
parent::__construct($templating);
parent::__construct($templating, $dispatcher);

$this->serverHostName = $serverHostName;
}
Expand Down
Loading

0 comments on commit 0fd4195

Please sign in to comment.