mirror of
https://github.com/Sylius/Sylius.git
synced 2026-07-14 17:10:53 +00:00
Merge branch 'payments-merge' into bundles-merging
This commit is contained in:
commit
dff5d2032e
45 changed files with 3776 additions and 0 deletions
5
src/Sylius/Bundle/PaymentsBundle/.gitignore
vendored
Normal file
5
src/Sylius/Bundle/PaymentsBundle/.gitignore
vendored
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
vendor/
|
||||
bin/
|
||||
|
||||
composer.phar
|
||||
composer.lock
|
||||
18
src/Sylius/Bundle/PaymentsBundle/.travis.yml
Normal file
18
src/Sylius/Bundle/PaymentsBundle/.travis.yml
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
language: php
|
||||
|
||||
php:
|
||||
- 5.3
|
||||
- 5.4
|
||||
- 5.5
|
||||
|
||||
matrix:
|
||||
allow_failure:
|
||||
- php: 5.5
|
||||
|
||||
before_script: composer install --dev --prefer-source > /dev/null
|
||||
|
||||
script: bin/phpspec run -fpretty --verbose
|
||||
|
||||
notifications:
|
||||
email: "travis-ci@sylius.org"
|
||||
irc: "irc.freenode.org#sylius-dev"
|
||||
|
|
@ -0,0 +1,128 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Sylius package.
|
||||
*
|
||||
* (c) Paweł Jędrzejewski
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Sylius\Bundle\PaymentsBundle\DependencyInjection;
|
||||
|
||||
use Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition;
|
||||
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
|
||||
use Symfony\Component\Config\Definition\ConfigurationInterface;
|
||||
|
||||
/**
|
||||
* This class contains the configuration information for the bundle.
|
||||
*
|
||||
* This information is solely responsible for how the different configuration
|
||||
* sections are normalized, and merged.
|
||||
*
|
||||
* @author Paweł Jędrzejewski <pjedrzejewski@diweb.pl>
|
||||
*/
|
||||
class Configuration implements ConfigurationInterface
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getConfigTreeBuilder()
|
||||
{
|
||||
$treeBuilder = new TreeBuilder();
|
||||
$rootNode = $treeBuilder->root('sylius_payments');
|
||||
|
||||
$rootNode
|
||||
->addDefaultsIfNotSet()
|
||||
->children()
|
||||
->scalarNode('driver')->isRequired()->cannotBeEmpty()->end()
|
||||
->scalarNode('engine')->defaultValue('twig')->cannotBeEmpty()->end()
|
||||
->arrayNode('gateways')
|
||||
->prototype('scalar')
|
||||
->end()
|
||||
->end()
|
||||
;
|
||||
|
||||
$this->addClassesSection($rootNode);
|
||||
|
||||
return $treeBuilder;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds `classes` section.
|
||||
*
|
||||
* @param ArrayNodeDefinition $node
|
||||
*/
|
||||
private function addClassesSection(ArrayNodeDefinition $node)
|
||||
{
|
||||
$node
|
||||
->children()
|
||||
->arrayNode('validation_groups')
|
||||
->addDefaultsIfNotSet()
|
||||
->children()
|
||||
->arrayNode('payment_method')
|
||||
->prototype('scalar')->end()
|
||||
->defaultValue(array('sylius'))
|
||||
->end()
|
||||
->arrayNode('payment')
|
||||
->prototype('scalar')->end()
|
||||
->defaultValue(array('sylius'))
|
||||
->end()
|
||||
->arrayNode('credit_card')
|
||||
->prototype('scalar')->end()
|
||||
->defaultValue(array('sylius'))
|
||||
->end()
|
||||
->end()
|
||||
->end()
|
||||
->arrayNode('classes')
|
||||
->addDefaultsIfNotSet()
|
||||
->children()
|
||||
->arrayNode('payment_method')
|
||||
->addDefaultsIfNotSet()
|
||||
->children()
|
||||
->scalarNode('model')->defaultValue('Sylius\Bundle\PaymentsBundle\Model\PaymentMethod')->end()
|
||||
->scalarNode('controller')->defaultValue('Sylius\\Bundle\\ResourceBundle\\Controller\\ResourceController')->end()
|
||||
->scalarNode('repository')->end()
|
||||
->scalarNode('form')->defaultValue('Sylius\\Bundle\\PaymentsBundle\\Form\\Type\\PaymentMethodType')->end()
|
||||
->end()
|
||||
->end()
|
||||
->arrayNode('payment')
|
||||
->addDefaultsIfNotSet()
|
||||
->children()
|
||||
->scalarNode('model')->defaultValue('Sylius\Bundle\PaymentsBundle\Model\Payment')->end()
|
||||
->scalarNode('controller')->defaultValue('Sylius\\Bundle\\ResourceBundle\\Controller\\ResourceController')->end()
|
||||
->scalarNode('repository')->end()
|
||||
->scalarNode('form')->defaultValue('Sylius\\Bundle\\PaymentsBundle\\Form\\Type\\PaymentType')->end()
|
||||
->end()
|
||||
->end()
|
||||
->arrayNode('transaction')
|
||||
->addDefaultsIfNotSet()
|
||||
->children()
|
||||
->scalarNode('model')->defaultValue('Sylius\Bundle\PaymentsBundle\Model\Transaction')->end()
|
||||
->scalarNode('controller')->defaultValue('Sylius\\Bundle\\ResourceBundle\\Controller\\ResourceController')->end()
|
||||
->scalarNode('repository')->end()
|
||||
->scalarNode('form')->defaultValue('Sylius\\Bundle\\PaymentsBundle\\Form\\Type\\PaymentType')->end()
|
||||
->end()
|
||||
->end()
|
||||
->arrayNode('credit_card')
|
||||
->addDefaultsIfNotSet()
|
||||
->children()
|
||||
->scalarNode('model')->defaultValue('Sylius\Bundle\PaymentsBundle\Model\CreditCard')->end()
|
||||
->scalarNode('controller')->defaultValue('Sylius\\Bundle\\ResourceBundle\\Controller\\ResourceController')->end()
|
||||
->scalarNode('repository')->end()
|
||||
->scalarNode('form')->defaultValue('Sylius\\Bundle\\PaymentsBundle\\Form\\Type\\CreditCardType')->end()
|
||||
->end()
|
||||
->end()
|
||||
->arrayNode('credit_card_owner')
|
||||
->addDefaultsIfNotSet()
|
||||
->children()
|
||||
->scalarNode('model')->isRequired()->end()
|
||||
->end()
|
||||
->end()
|
||||
->end()
|
||||
->end()
|
||||
->end()
|
||||
;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,93 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Sylius package.
|
||||
*
|
||||
* (c) Paweł Jędrzejewski
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Sylius\Bundle\PaymentsBundle\DependencyInjection;
|
||||
|
||||
use Sylius\Bundle\PaymentsBundle\SyliusPaymentsBundle;
|
||||
use Symfony\Component\Config\Definition\Processor;
|
||||
use Symfony\Component\Config\FileLocator;
|
||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
|
||||
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
|
||||
|
||||
/**
|
||||
* Sylius payments component extension.
|
||||
*
|
||||
* @author Paweł Jędrzejewski <pjedrzejewski@diweb.pl>
|
||||
*/
|
||||
class SyliusPaymentsExtension extends Extension
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function load(array $config, ContainerBuilder $container)
|
||||
{
|
||||
$processor = new Processor();
|
||||
|
||||
$config = $processor->processConfiguration(new Configuration(), $config);
|
||||
$loader = new XmlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
|
||||
|
||||
$driver = $config['driver'];
|
||||
|
||||
if (!in_array($driver, SyliusPaymentsBundle::getSupportedDrivers())) {
|
||||
throw new \InvalidArgumentException(sprintf('Driver "%s" is unsupported for SyliusPaymentsBundle.', $driver));
|
||||
}
|
||||
|
||||
$loader->load(sprintf('driver/%s.xml', $driver));
|
||||
|
||||
$container->setParameter('sylius_payments.driver', $driver);
|
||||
$container->setParameter('sylius_payments.driver.'.$driver, true);
|
||||
|
||||
$container->setParameter('sylius.payment_gateways', $config['gateways']);
|
||||
|
||||
$classes = $config['classes'];
|
||||
|
||||
$this->mapClassParameters($classes, $container);
|
||||
$this->mapValidationGroupParameters($config['validation_groups'], $container);
|
||||
|
||||
$loader->load('services.xml');
|
||||
|
||||
if ($container->hasParameter('sylius.config.classes')) {
|
||||
$classes = array_merge($classes, $container->getParameter('sylius.config.classes'));
|
||||
}
|
||||
|
||||
$container->setParameter('sylius.config.classes', $classes);
|
||||
}
|
||||
|
||||
/**
|
||||
* Remap class parameters.
|
||||
*
|
||||
* @param array $classes
|
||||
* @param ContainerBuilder $container
|
||||
*/
|
||||
protected function mapClassParameters(array $classes, ContainerBuilder $container)
|
||||
{
|
||||
foreach ($classes as $model => $serviceClasses) {
|
||||
foreach ($serviceClasses as $service => $class) {
|
||||
$service = $service === 'form' ? 'form.type' : $service;
|
||||
$container->setParameter(sprintf('sylius.%s.%s.class', $service, $model), $class);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Remap validation group parameters.
|
||||
*
|
||||
* @param array $classes
|
||||
* @param ContainerBuilder $container
|
||||
*/
|
||||
protected function mapValidationGroupParameters(array $validationGroups, ContainerBuilder $container)
|
||||
{
|
||||
foreach ($validationGroups as $model => $groups) {
|
||||
$container->setParameter(sprintf('sylius.validation_group.%s', $model), $groups);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,98 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Sylius package.
|
||||
*
|
||||
* (c) Paweł Jędrzejewski
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Sylius\Bundle\PaymentsBundle\Form\Type;
|
||||
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
use Symfony\Component\OptionsResolver\OptionsResolverInterface;
|
||||
use Symfony\Component\Form\AbstractType;
|
||||
|
||||
/**
|
||||
* Credit Card Form Type
|
||||
*
|
||||
* @author Dylan Johnson <eponymi.dev@gmail.com>
|
||||
*/
|
||||
class CreditCardType extends AbstractType
|
||||
{
|
||||
protected $dataClass;
|
||||
protected $validationGroups;
|
||||
|
||||
public function __construct($dataClass, array $validationGroups)
|
||||
{
|
||||
$this->dataClass = $dataClass;
|
||||
$this->validationGroups = $validationGroups;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function buildForm(FormBuilderInterface $builder, array $options)
|
||||
{
|
||||
$builder
|
||||
->add('type', 'choice', array(
|
||||
'label' => 'sylius.form.credit_card.type',
|
||||
'expanded' => true,
|
||||
))
|
||||
->add('cardholderName', 'text', array(
|
||||
'label' => 'sylius.form.credit_card.cardholder_name',
|
||||
))
|
||||
->add('number', 'number', array(
|
||||
'label' => 'sylius.form.credit_card.number',
|
||||
))
|
||||
->add('securityCode', 'number', array(
|
||||
'label' => 'sylius.form.credit_card.security_code',
|
||||
))
|
||||
->add('expiryMonth', 'choice', array(
|
||||
'label' => 'sylius.form.credit_card.expiry_month',
|
||||
'choices' => array_combine(range(1,12), range(1,12))
|
||||
))
|
||||
->add('expiryYear', 'choice', array(
|
||||
'label' => 'sylius.form.credit_card.expiry_year',
|
||||
'choices' => $this->getViableYears()
|
||||
))
|
||||
;
|
||||
}
|
||||
|
||||
public function setDefaultOptions(OptionsResolverInterface $resolver)
|
||||
{
|
||||
$resolver
|
||||
->setDefaults(array(
|
||||
'data_class' => $this->dataClass,
|
||||
'validation_groups' => $this->validationGroups,
|
||||
))
|
||||
;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getName()
|
||||
{
|
||||
return 'sylius_credit_card';
|
||||
}
|
||||
|
||||
/**
|
||||
* Get years to add as choices in expiryYear
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
private function getViableYears()
|
||||
{
|
||||
$yearChoices = array();
|
||||
$currentYear = (int) date("Y");
|
||||
|
||||
for ($i = 0; $i <= 20; $i++) {
|
||||
$yearChoices[$currentYear + $i] = $currentYear + $i;
|
||||
}
|
||||
|
||||
return $yearChoices;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,68 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Sylius package.
|
||||
*
|
||||
* (c) Paweł Jędrzejewski
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Sylius\Bundle\PaymentsBundle\Form\Type;
|
||||
|
||||
use Symfony\Component\Form\AbstractType;
|
||||
use Symfony\Component\OptionsResolver\OptionsResolverInterface;
|
||||
|
||||
/**
|
||||
* Payment gateway choice type.
|
||||
*
|
||||
* @author Paweł Jędrzejewski <pjedrzejewski@diweb.pl>
|
||||
*/
|
||||
class PaymentGatewayChoiceType extends AbstractType
|
||||
{
|
||||
/**
|
||||
* Choices.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $gateways;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param array $gateways
|
||||
*/
|
||||
public function __construct(array $gateways)
|
||||
{
|
||||
$this->gateways = $gateways;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function setDefaultOptions(OptionsResolverInterface $resolver)
|
||||
{
|
||||
$resolver
|
||||
->setDefaults(array(
|
||||
'choices' => $this->gateways,
|
||||
))
|
||||
;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getParent()
|
||||
{
|
||||
return 'choice';
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getName()
|
||||
{
|
||||
return 'sylius_payment_gateway_choice';
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,61 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Sylius package.
|
||||
*
|
||||
* (c) Paweł Jędrzejewski
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Sylius\Bundle\PaymentsBundle\Form\Type;
|
||||
|
||||
use Symfony\Component\Form\AbstractType;
|
||||
use Symfony\Component\OptionsResolver\OptionsResolverInterface;
|
||||
|
||||
/**
|
||||
* Base payments category choice type.
|
||||
*
|
||||
* @author Paweł Jędrzejewski <pjedrzejewski@diweb.pl>
|
||||
*/
|
||||
abstract class PaymentMethodChoiceType extends AbstractType
|
||||
{
|
||||
/**
|
||||
* Payment method class name.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $className;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param string $className
|
||||
*/
|
||||
public function __construct($className)
|
||||
{
|
||||
$this->className = $className;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function setDefaultOptions(OptionsResolverInterface $resolver)
|
||||
{
|
||||
$resolver
|
||||
->setDefaults(array(
|
||||
'class' => $this->className,
|
||||
'disabled' => false,
|
||||
))
|
||||
;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getName()
|
||||
{
|
||||
return 'sylius_payment_method_choice';
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,58 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Sylius package.
|
||||
*
|
||||
* (c) Paweł Jędrzejewski
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Sylius\Bundle\PaymentsBundle\Form\Type;
|
||||
|
||||
use Doctrine\ORM\EntityRepository;
|
||||
use Symfony\Component\OptionsResolver\Options;
|
||||
use Symfony\Component\OptionsResolver\OptionsResolverInterface;
|
||||
|
||||
/**
|
||||
* Payment method choice type for "doctrine/orm" driver.
|
||||
*
|
||||
* @author Paweł Jędrzejewski <pjedrzejewski@diweb.pl>
|
||||
*/
|
||||
class PaymentMethodEntityType extends PaymentMethodChoiceType
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function setDefaultOptions(OptionsResolverInterface $resolver)
|
||||
{
|
||||
parent::setDefaultOptions($resolver);
|
||||
|
||||
$queryBuilder = function (Options $options) {
|
||||
if (!$options['disabled']) {
|
||||
return function (EntityRepository $repository) {
|
||||
return $repository->createQueryBuilder('method')->where('method.enabled = true');
|
||||
};
|
||||
} else {
|
||||
return function (EntityRepository $repository) {
|
||||
return $repository->createQueryBuilder('method');
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
$resolver
|
||||
->setDefaults(array(
|
||||
'query_builder' => $queryBuilder
|
||||
))
|
||||
;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getParent()
|
||||
{
|
||||
return 'entity';
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,94 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Sylius package.
|
||||
*
|
||||
* (c) Paweł Jędrzejewski
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Sylius\Bundle\PaymentsBundle\Form\Type;
|
||||
|
||||
use Symfony\Component\Form\AbstractType;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
use Symfony\Component\OptionsResolver\OptionsResolverInterface;
|
||||
|
||||
/**
|
||||
* Payment method form type.
|
||||
*
|
||||
* @author Paweł Jędrzejewski <pjedrzejewski@diweb.pl>
|
||||
*/
|
||||
class PaymentMethodType extends AbstractType
|
||||
{
|
||||
/**
|
||||
* Data class.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $dataClass;
|
||||
|
||||
/**
|
||||
* Validation groups.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $validationGroups;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param string $dataClass
|
||||
* @param array $validationGroups
|
||||
*/
|
||||
public function __construct($dataClass, array $validationGroups)
|
||||
{
|
||||
$this->dataClass = $dataClass;
|
||||
$this->validationGroups = $validationGroups;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function buildForm(FormBuilderInterface $builder, array $options)
|
||||
{
|
||||
$builder
|
||||
->add('name', 'text', array(
|
||||
'label' => 'sylius.form.payment_method.name'
|
||||
))
|
||||
->add('description', 'textarea', array(
|
||||
'required' => false,
|
||||
'label' => 'sylius.form.payment_method.description'
|
||||
))
|
||||
->add('gateway', 'sylius_payment_gateway_choice', array(
|
||||
'label' => 'sylius.form.payment_method.gateway'
|
||||
))
|
||||
->add('enabled', 'checkbox', array(
|
||||
'required' => false,
|
||||
'label' => 'sylius.form.payment_method.enabled'
|
||||
))
|
||||
;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function setDefaultOptions(OptionsResolverInterface $resolver)
|
||||
{
|
||||
$resolver
|
||||
->setDefaults(array(
|
||||
'data_class' => $this->dataClass,
|
||||
'validation_groups' => $this->validationGroups,
|
||||
))
|
||||
;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getName()
|
||||
{
|
||||
return 'sylius_payment_method';
|
||||
}
|
||||
}
|
||||
86
src/Sylius/Bundle/PaymentsBundle/Form/Type/PaymentType.php
Normal file
86
src/Sylius/Bundle/PaymentsBundle/Form/Type/PaymentType.php
Normal file
|
|
@ -0,0 +1,86 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Sylius package.
|
||||
*
|
||||
* (c) Paweł Jędrzejewski
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Sylius\Bundle\PaymentsBundle\Form\Type;
|
||||
|
||||
use Symfony\Component\Form\AbstractType;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
use Symfony\Component\OptionsResolver\OptionsResolverInterface;
|
||||
|
||||
/**
|
||||
* Payment form type.
|
||||
*
|
||||
* @author Paweł Jędrzejewski <pjedrzejewski@diweb.pl>
|
||||
*/
|
||||
class PaymentType extends AbstractType
|
||||
{
|
||||
/**
|
||||
* Data class.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $dataClass;
|
||||
|
||||
/**
|
||||
* Validation groups.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $validationGroups;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param string $dataClass
|
||||
* @param array $validationGroups
|
||||
*/
|
||||
public function __construct($dataClass, array $validationGroups)
|
||||
{
|
||||
$this->dataClass = $dataClass;
|
||||
$this->validationGroups = $validationGroups;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function buildForm(FormBuilderInterface $builder, array $options)
|
||||
{
|
||||
$builder
|
||||
->add('method', 'sylius_payment_method_choice', array(
|
||||
'label' => 'sylius.form.payment.method'
|
||||
))
|
||||
->add('amount', 'sylius_money', array(
|
||||
'label' => 'sylius.form.payment.amount'
|
||||
))
|
||||
;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function setDefaultOptions(OptionsResolverInterface $resolver)
|
||||
{
|
||||
$resolver
|
||||
->setDefaults(array(
|
||||
'data_class' => $this->dataClass,
|
||||
'validation_groups' => $this->validationGroups,
|
||||
))
|
||||
;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getName()
|
||||
{
|
||||
return 'sylius_payment';
|
||||
}
|
||||
}
|
||||
286
src/Sylius/Bundle/PaymentsBundle/Model/CreditCard.php
Normal file
286
src/Sylius/Bundle/PaymentsBundle/Model/CreditCard.php
Normal file
|
|
@ -0,0 +1,286 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Sylius package.
|
||||
*
|
||||
* (c) Paweł Jędrzejewski
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Sylius\Bundle\PaymentsBundle\Model;
|
||||
|
||||
/**
|
||||
* Credit card model.
|
||||
*
|
||||
* @author Paweł Jędrzejewski <pjedrzejewski@diweb.pl>
|
||||
*/
|
||||
class CreditCard implements CreditCardInterface
|
||||
{
|
||||
/**
|
||||
* Credit card identifier.
|
||||
*
|
||||
* @var mixed
|
||||
*/
|
||||
protected $id;
|
||||
|
||||
/**
|
||||
* Special token for payment gateway.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $token;
|
||||
|
||||
/**
|
||||
* CC type.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $type;
|
||||
|
||||
/**
|
||||
* Owner.
|
||||
*
|
||||
* @var CreditCardOwnerInterface
|
||||
*/
|
||||
protected $owner;
|
||||
|
||||
/**
|
||||
* Cardholder name.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $cardholderName;
|
||||
|
||||
/**
|
||||
* Card number.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $number;
|
||||
|
||||
/**
|
||||
* Security code.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $securityCode;
|
||||
|
||||
/**
|
||||
* Expiry month number.
|
||||
*
|
||||
* @var integer
|
||||
*/
|
||||
protected $expiryMonth;
|
||||
|
||||
/**
|
||||
* Expiry year number.
|
||||
*
|
||||
* @var integer
|
||||
*/
|
||||
protected $expiryYear;
|
||||
|
||||
/**
|
||||
* Creation date.
|
||||
*
|
||||
* @var DateTime
|
||||
*/
|
||||
protected $createdAt;
|
||||
|
||||
/**
|
||||
* Last update time.
|
||||
*
|
||||
* @var DateTime
|
||||
*/
|
||||
protected $updatedAt;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->createdAt = new \DateTime('now');
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function __toString()
|
||||
{
|
||||
return $this->getMaskedNumber();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getId()
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getToken()
|
||||
{
|
||||
return $this->token;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function setToken($token)
|
||||
{
|
||||
$this->token = $token;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getType()
|
||||
{
|
||||
return $this->type;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function setType($type)
|
||||
{
|
||||
$this->type = $type;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getOwner()
|
||||
{
|
||||
return $this->owner;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function setOwner(CreditCardOwnerInterface $owner)
|
||||
{
|
||||
$this->owner = $owner;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getCardholderName()
|
||||
{
|
||||
return $this->cardholderName;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function setCardholderName($cardholderName)
|
||||
{
|
||||
$this->cardholderName = $cardholderName;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getNumber()
|
||||
{
|
||||
return $this->number;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function setNumber($number)
|
||||
{
|
||||
$this->number = $number;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getMaskedNumber()
|
||||
{
|
||||
return sprintf('XXXX XXXX XXXX %s', substr($this->number, -4));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getSecurityCode()
|
||||
{
|
||||
return $this->securityCode;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function setSecurityCode($securityCode)
|
||||
{
|
||||
$this->securityCode = $securityCode;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getExpiryMonth()
|
||||
{
|
||||
return $this->expiryMonth;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function setExpiryMonth($expiryMonth)
|
||||
{
|
||||
$this->expiryMonth = $expiryMonth;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getExpiryYear()
|
||||
{
|
||||
return $this->expiryYear;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function setExpiryYear($expiryYear)
|
||||
{
|
||||
$this->expiryYear = $expiryYear;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getCreatedAt()
|
||||
{
|
||||
return $this->createdAt;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getUpdatedAt()
|
||||
{
|
||||
return $this->updatedAt;
|
||||
}
|
||||
}
|
||||
178
src/Sylius/Bundle/PaymentsBundle/Model/CreditCardInterface.php
Normal file
178
src/Sylius/Bundle/PaymentsBundle/Model/CreditCardInterface.php
Normal file
|
|
@ -0,0 +1,178 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Sylius package.
|
||||
*
|
||||
* (c) Paweł Jędrzejewski
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Sylius\Bundle\PaymentsBundle\Model;
|
||||
|
||||
/**
|
||||
* Payment method interface.
|
||||
*
|
||||
* @author Paweł Jędrzejewski <pjedrzejewski@diweb.pl>
|
||||
*/
|
||||
interface CreditCardInterface extends PaymentSourceInterface
|
||||
{
|
||||
/**
|
||||
* Supported Credit Card Brands
|
||||
*
|
||||
*/
|
||||
const BRAND_VISA = 'visa';
|
||||
const BRAND_MASTERCARD = 'mastercard';
|
||||
const BRAND_DISCOVER = 'discover';
|
||||
const BRAND_AMEX = 'amex';
|
||||
const BRAND_DINERS_CLUB = 'diners_club';
|
||||
const BRAND_JCB = 'jcb';
|
||||
const BRAND_SWITCH = 'switch';
|
||||
const BRAND_SOLO = 'solo';
|
||||
const BRAND_DANKORT = 'dankort';
|
||||
const BRAND_MAESTRO = 'maestro';
|
||||
const BRAND_FORBRUGSFORENINGEN = 'forbrugsforeningen';
|
||||
const BRAND_LASER = 'laser';
|
||||
|
||||
/**
|
||||
* Get payments method identifier.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function getId();
|
||||
|
||||
/**
|
||||
* Get payment gateway token.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getToken();
|
||||
|
||||
/**
|
||||
* Set payment gateway token.
|
||||
*
|
||||
* @param string $token
|
||||
*/
|
||||
public function setToken($token);
|
||||
|
||||
/**
|
||||
* Get the type of credit card.
|
||||
* VISA, MasterCard...
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getType();
|
||||
|
||||
/**
|
||||
* Set the type of cc.
|
||||
*
|
||||
* @param string $type
|
||||
*/
|
||||
public function setType($type);
|
||||
|
||||
/**
|
||||
* Get owner.
|
||||
*
|
||||
* @return CreditCardOwnerInterface
|
||||
*/
|
||||
public function getOwner();
|
||||
|
||||
/**
|
||||
* Set owner.
|
||||
*
|
||||
* @param CreditCardOwnerInterface
|
||||
*/
|
||||
public function setOwner(CreditCardOwnerInterface $owner);
|
||||
|
||||
/**
|
||||
* Get cardholder name.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getCardholderName();
|
||||
|
||||
/**
|
||||
* Set cardholder name.
|
||||
*
|
||||
* @param string $cardholderName
|
||||
*/
|
||||
public function setCardholderName($cardholderName);
|
||||
|
||||
/**
|
||||
* Get number.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getNumber();
|
||||
|
||||
/**
|
||||
* Set number.
|
||||
*
|
||||
* @param string $number
|
||||
*/
|
||||
public function setNumber($number);
|
||||
|
||||
/**
|
||||
* Get last 4 digits of number.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getMaskedNumber();
|
||||
|
||||
/**
|
||||
* Get security code.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getSecurityCode();
|
||||
|
||||
/**
|
||||
* Set security code.
|
||||
*
|
||||
* @param string $securityCode
|
||||
*/
|
||||
public function setSecurityCode($securityCode);
|
||||
|
||||
/**
|
||||
* Get expiry month.
|
||||
*
|
||||
* @return integer
|
||||
*/
|
||||
public function getExpiryMonth();
|
||||
|
||||
/**
|
||||
* Set expiry month.
|
||||
*
|
||||
* @param integer
|
||||
*/
|
||||
public function setExpiryMonth($expiryMonth);
|
||||
|
||||
/**
|
||||
* Get expiry year.
|
||||
*
|
||||
* @return integer
|
||||
*/
|
||||
public function getExpiryYear();
|
||||
|
||||
/**
|
||||
* Set expiry year.
|
||||
*
|
||||
* @param integer $expiryYear
|
||||
*/
|
||||
public function setExpiryYear($expiryYear);
|
||||
|
||||
/**
|
||||
* Get creation time.
|
||||
*
|
||||
* @return DateTime
|
||||
*/
|
||||
public function getCreatedAt();
|
||||
|
||||
/**
|
||||
* Get last update time.
|
||||
*
|
||||
* @return DateTime
|
||||
*/
|
||||
public function getUpdatedAt();
|
||||
}
|
||||
|
|
@ -0,0 +1,27 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Sylius package.
|
||||
*
|
||||
* (c) Paweł Jędrzejewski
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Sylius\Bundle\PaymentsBundle\Model;
|
||||
|
||||
/**
|
||||
* Credit card owner interface.
|
||||
*
|
||||
* @author Paweł Jędrzejewski <pjedrzejewski@diweb.pl>
|
||||
*/
|
||||
interface CreditCardOwnerInterface
|
||||
{
|
||||
/**
|
||||
* Get all credit cards of this owner.
|
||||
*
|
||||
* @return CreditCardInterface[]
|
||||
*/
|
||||
public function getCreditCards();
|
||||
}
|
||||
207
src/Sylius/Bundle/PaymentsBundle/Model/Payment.php
Normal file
207
src/Sylius/Bundle/PaymentsBundle/Model/Payment.php
Normal file
|
|
@ -0,0 +1,207 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Sylius package.
|
||||
*
|
||||
* (c) Paweł Jędrzejewski
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Sylius\Bundle\PaymentsBundle\Model;
|
||||
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
|
||||
/**
|
||||
* Payments model.
|
||||
*
|
||||
* @author Paweł Jędrzejewski <pjedrzejewski@diweb.pl>
|
||||
*/
|
||||
class Payment implements PaymentInterface
|
||||
{
|
||||
/**
|
||||
* Payments method identifier.
|
||||
*
|
||||
* @var mixed
|
||||
*/
|
||||
protected $id;
|
||||
|
||||
/**
|
||||
* Method.
|
||||
*
|
||||
* @var PaymentMethodInterface
|
||||
*/
|
||||
protected $method;
|
||||
|
||||
/**
|
||||
* Currency.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $currency;
|
||||
|
||||
/**
|
||||
* Amount.
|
||||
*
|
||||
* @var integer
|
||||
*/
|
||||
protected $amount;
|
||||
|
||||
/**
|
||||
* Transactions.
|
||||
*
|
||||
* @var Collection
|
||||
*/
|
||||
protected $transactions;
|
||||
|
||||
/**
|
||||
* Credit card as a source.
|
||||
*
|
||||
* @var CreditCardInterface
|
||||
*/
|
||||
protected $creditCard;
|
||||
|
||||
/**
|
||||
* Creation date.
|
||||
*
|
||||
* @var DateTime
|
||||
*/
|
||||
protected $createdAt;
|
||||
|
||||
/**
|
||||
* Last update time.
|
||||
*
|
||||
* @var DateTime
|
||||
*/
|
||||
protected $updatedAt;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->amount = 0;
|
||||
$this->transactions = new ArrayCollection();
|
||||
$this->createdAt = new \DateTime('now');
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getId()
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
public function getMethod()
|
||||
{
|
||||
return $this->method;
|
||||
}
|
||||
|
||||
public function setMethod(PaymentMethodInterface $method = null)
|
||||
{
|
||||
$this->method = $method;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setSource(PaymentSourceInterface $source = null)
|
||||
{
|
||||
if (null === $source) {
|
||||
$this->creditCard = null;
|
||||
}
|
||||
|
||||
if ($source instanceof CreditCardInterface) {
|
||||
$this->creditCard = $source;
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getSource()
|
||||
{
|
||||
if (null !== $this->creditCard) {
|
||||
return $this->creditCard;
|
||||
}
|
||||
}
|
||||
|
||||
public function getCurrency()
|
||||
{
|
||||
return $this->currency;
|
||||
}
|
||||
|
||||
public function setCurrency($currency)
|
||||
{
|
||||
$this->currency = $currency;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getAmount()
|
||||
{
|
||||
return $this->amount;
|
||||
}
|
||||
|
||||
public function setAmount($amount)
|
||||
{
|
||||
$this->amount = $amount;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function addTransaction(TransactionInterface $transaction)
|
||||
{
|
||||
if (!$this->hasTransaction($transaction)) {
|
||||
$transaction->setPayment($this);
|
||||
$this->transactions->add($transaction);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getTransactions()
|
||||
{
|
||||
return $this->transactions;
|
||||
}
|
||||
|
||||
public function hasTransaction(TransactionInterface $transaction)
|
||||
{
|
||||
return $this->transactions->contains($transaction);
|
||||
}
|
||||
|
||||
public function getBalance()
|
||||
{
|
||||
$total = 0;
|
||||
|
||||
foreach ($this->transactions as $transaction) {
|
||||
$total += $transaction->getAmount();
|
||||
}
|
||||
|
||||
return $this->amount - $total;
|
||||
}
|
||||
|
||||
public function removeTransaction(TransactionInterface $transaction)
|
||||
{
|
||||
if ($this->hasTransaction($transaction)) {
|
||||
$transaction->setPayment(null);
|
||||
$this->transactions->removeElement($transaction);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getCreatedAt()
|
||||
{
|
||||
return $this->createdAt;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getUpdatedAt()
|
||||
{
|
||||
return $this->updatedAt;
|
||||
}
|
||||
}
|
||||
132
src/Sylius/Bundle/PaymentsBundle/Model/PaymentInterface.php
Normal file
132
src/Sylius/Bundle/PaymentsBundle/Model/PaymentInterface.php
Normal file
|
|
@ -0,0 +1,132 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Sylius package.
|
||||
*
|
||||
* (c) Paweł Jędrzejewski
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Sylius\Bundle\PaymentsBundle\Model;
|
||||
|
||||
/**
|
||||
* Single payment interface.
|
||||
*
|
||||
* @author Paweł Jędrzejewski <pjedrzejewski@diweb.pl>
|
||||
*/
|
||||
interface PaymentInterface
|
||||
{
|
||||
/**
|
||||
* Get payments identifier.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function getId();
|
||||
|
||||
/**
|
||||
* Get payment method associated with this payment.
|
||||
*
|
||||
* @return PaymentMethodInterface
|
||||
*/
|
||||
public function getMethod();
|
||||
|
||||
/**
|
||||
* Set payment method.
|
||||
*
|
||||
* @param PaymentMethodInterface $method
|
||||
*/
|
||||
public function setMethod(PaymentMethodInterface $method = null);
|
||||
|
||||
/**
|
||||
* Get payment source.
|
||||
*
|
||||
* @return PaymentSourceInterface
|
||||
*/
|
||||
public function getSource();
|
||||
|
||||
/**
|
||||
* Set payment source.
|
||||
*
|
||||
* @param null|PaymentSourceInterface $source
|
||||
*/
|
||||
public function setSource(PaymentSourceInterface $source = null);
|
||||
|
||||
/**
|
||||
* Get payment currency.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getCurrency();
|
||||
|
||||
/**
|
||||
* Set currency.
|
||||
*
|
||||
* @param string
|
||||
*/
|
||||
public function setCurrency($currency);
|
||||
|
||||
/**
|
||||
* Get amount.
|
||||
*
|
||||
* @return integer
|
||||
*/
|
||||
public function getAmount();
|
||||
|
||||
/**
|
||||
* Set amount.
|
||||
*
|
||||
* @param integer $amount
|
||||
*/
|
||||
public function setAmount($amount);
|
||||
|
||||
/**
|
||||
* Return the balance.
|
||||
*
|
||||
* @return integer
|
||||
*/
|
||||
public function getBalance();
|
||||
|
||||
/**
|
||||
* Get all transactions for this payment.
|
||||
*
|
||||
* @return Collection
|
||||
*/
|
||||
public function getTransactions();
|
||||
|
||||
/**
|
||||
* Add transaction to payment.
|
||||
*
|
||||
* @param TransactionInterface
|
||||
*/
|
||||
public function addTransaction(TransactionInterface $transaction);
|
||||
|
||||
/**
|
||||
* Remove transaction from payment.
|
||||
*
|
||||
* @param TransactionInterface
|
||||
*/
|
||||
public function removeTransaction(TransactionInterface $transaction);
|
||||
|
||||
/**
|
||||
* Has transaction?
|
||||
*
|
||||
* @return Boolean
|
||||
*/
|
||||
public function hasTransaction(TransactionInterface $transaction);
|
||||
|
||||
/**
|
||||
* Get creation time.
|
||||
*
|
||||
* @return DateTime
|
||||
*/
|
||||
public function getCreatedAt();
|
||||
|
||||
/**
|
||||
* Get last update time.
|
||||
*
|
||||
* @return DateTime
|
||||
*/
|
||||
public function getUpdatedAt();
|
||||
}
|
||||
211
src/Sylius/Bundle/PaymentsBundle/Model/PaymentMethod.php
Normal file
211
src/Sylius/Bundle/PaymentsBundle/Model/PaymentMethod.php
Normal file
|
|
@ -0,0 +1,211 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Sylius package.
|
||||
*
|
||||
* (c) Paweł Jędrzejewski
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Sylius\Bundle\PaymentsBundle\Model;
|
||||
|
||||
/**
|
||||
* Payments method model.
|
||||
*
|
||||
* @author Paweł Jędrzejewski <pjedrzejewski@diweb.pl>
|
||||
*/
|
||||
class PaymentMethod implements PaymentMethodInterface
|
||||
{
|
||||
/**
|
||||
* Payments method identifier.
|
||||
*
|
||||
* @var mixed
|
||||
*/
|
||||
protected $id;
|
||||
|
||||
/**
|
||||
* Is method enabled?
|
||||
*
|
||||
* @var Boolean
|
||||
*/
|
||||
protected $enabled;
|
||||
|
||||
/**
|
||||
* Name.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $name;
|
||||
|
||||
/**
|
||||
* Description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description;
|
||||
|
||||
/**
|
||||
* Gateway name.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $gateway;
|
||||
|
||||
/**
|
||||
* Required environment.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $environment;
|
||||
|
||||
/**
|
||||
* Creation date.
|
||||
*
|
||||
* @var DateTime
|
||||
*/
|
||||
protected $createdAt;
|
||||
|
||||
/**
|
||||
* Last update time.
|
||||
*
|
||||
* @var DateTime
|
||||
*/
|
||||
protected $updatedAt;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->enabled = true;
|
||||
$this->createdAt = new \DateTime('now');
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function __toString()
|
||||
{
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getId()
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function isEnabled()
|
||||
{
|
||||
return $this->enabled;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function setEnabled($enabled)
|
||||
{
|
||||
$this->enabled = (Boolean) $enabled;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getName()
|
||||
{
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function setName($name)
|
||||
{
|
||||
$this->name = $name;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getDescription()
|
||||
{
|
||||
return $this->description;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function setDescription($description)
|
||||
{
|
||||
$this->description = $description;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getGateway()
|
||||
{
|
||||
return $this->gateway;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function setGateway($gateway)
|
||||
{
|
||||
$this->gateway = $gateway;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getEnvironment()
|
||||
{
|
||||
return $this->environment;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function setEnvironment($environment)
|
||||
{
|
||||
$this->environment = $environment;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getCreatedAt()
|
||||
{
|
||||
return $this->createdAt;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getUpdatedAt()
|
||||
{
|
||||
return $this->updatedAt;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the default requirement labels.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function getCategoryRequirementLabels()
|
||||
{
|
||||
return array(
|
||||
PaymentsMethodInterface::CATEGORY_REQUIREMENT_MATCH_NONE => 'None of items have to match method category',
|
||||
PaymentsMethodInterface::CATEGORY_REQUIREMENT_MATCH_ANY => 'At least 1 item have to match method category',
|
||||
PaymentsMethodInterface::CATEGORY_REQUIREMENT_MATCH_ALL => 'All items have to match method category',
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,111 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Sylius package.
|
||||
*
|
||||
* (c) Paweł Jędrzejewski
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Sylius\Bundle\PaymentsBundle\Model;
|
||||
|
||||
/**
|
||||
* Payment method interface.
|
||||
*
|
||||
* @author Paweł Jędrzejewski <pjedrzejewski@diweb.pl>
|
||||
*/
|
||||
interface PaymentMethodInterface
|
||||
{
|
||||
/**
|
||||
* Get payments method identifier.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function getId();
|
||||
|
||||
/**
|
||||
* Check whether the payments method is currently enabled.
|
||||
*
|
||||
* @return Boolean
|
||||
*/
|
||||
public function isEnabled();
|
||||
|
||||
/**
|
||||
* Enable or disable the payments method.
|
||||
*
|
||||
* @param Boolean $enabled
|
||||
*/
|
||||
public function setEnabled($enabled);
|
||||
|
||||
/**
|
||||
* Get payments method name.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getName();
|
||||
|
||||
/**
|
||||
* Set the name.
|
||||
*
|
||||
* @param string $name
|
||||
*/
|
||||
public function setName($name);
|
||||
|
||||
/**
|
||||
* Get payment method description.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getDescription();
|
||||
|
||||
/**
|
||||
* Set description.
|
||||
*
|
||||
* @param string $description
|
||||
*/
|
||||
public function setDescription($description);
|
||||
|
||||
/**
|
||||
* Set the payment gateway to use.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getGateway();
|
||||
|
||||
/**
|
||||
* Set gateway.
|
||||
*
|
||||
* @param string $gateway
|
||||
*/
|
||||
public function setGateway($gateway);
|
||||
|
||||
/**
|
||||
* Get the required app environment.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getEnvironment();
|
||||
|
||||
/**
|
||||
* Set the environment requirement.
|
||||
*
|
||||
* @param string $environment
|
||||
*/
|
||||
public function setEnvironment($environment);
|
||||
|
||||
/**
|
||||
* Get creation time.
|
||||
*
|
||||
* @return DateTime
|
||||
*/
|
||||
public function getCreatedAt();
|
||||
|
||||
/**
|
||||
* Get last update time.
|
||||
*
|
||||
* @return DateTime
|
||||
*/
|
||||
public function getUpdatedAt();
|
||||
}
|
||||
|
|
@ -0,0 +1,21 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Sylius package.
|
||||
*
|
||||
* (c) Paweł Jędrzejewski
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Sylius\Bundle\PaymentsBundle\Model;
|
||||
|
||||
/**
|
||||
* Payment source interface.
|
||||
*
|
||||
* @author Paweł Jędrzejewski <pjedrzejewski@diweb.pl>
|
||||
*/
|
||||
interface PaymentSourceInterface
|
||||
{
|
||||
}
|
||||
122
src/Sylius/Bundle/PaymentsBundle/Model/Transaction.php
Normal file
122
src/Sylius/Bundle/PaymentsBundle/Model/Transaction.php
Normal file
|
|
@ -0,0 +1,122 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Sylius package.
|
||||
*
|
||||
* (c) Paweł Jędrzejewski
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Sylius\Bundle\PaymentsBundle\Model;
|
||||
|
||||
/**
|
||||
* Payment transaction model.
|
||||
*
|
||||
* @author Paweł Jędrzejewski <pjedrzejewski@diweb.pl>
|
||||
*/
|
||||
class Transaction implements TransactionInterface
|
||||
{
|
||||
/**
|
||||
* Payments method identifier.
|
||||
*
|
||||
* @var mixed
|
||||
*/
|
||||
protected $id;
|
||||
|
||||
/**
|
||||
* Payment.
|
||||
*
|
||||
* @var PaymentInterface
|
||||
*/
|
||||
protected $payment;
|
||||
|
||||
/**
|
||||
* Amount.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $amount;
|
||||
|
||||
/**
|
||||
* Creation date.
|
||||
*
|
||||
* @var DateTime
|
||||
*/
|
||||
protected $createdAt;
|
||||
|
||||
/**
|
||||
* Last update time.
|
||||
*
|
||||
* @var DateTime
|
||||
*/
|
||||
protected $updatedAt;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->amount = 0;
|
||||
$this->createdAt = new \DateTime('now');
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getId()
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
public function getPayment()
|
||||
{
|
||||
return $this->payment;
|
||||
}
|
||||
|
||||
public function setPayment(PaymentInterface $payment = null)
|
||||
{
|
||||
$this->payment = $payment;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getAmount()
|
||||
{
|
||||
return $this->amount;
|
||||
}
|
||||
|
||||
public function setAmount($amount)
|
||||
{
|
||||
$this->amount = $amount;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getCurrency()
|
||||
{
|
||||
if (null === $this->payment) {
|
||||
throw new \BadMethodCallException('Cannot get transaction currency without payment assigned.');
|
||||
}
|
||||
|
||||
return $this->payment->getCurrency();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getCreatedAt()
|
||||
{
|
||||
return $this->createdAt;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getUpdatedAt()
|
||||
{
|
||||
return $this->updatedAt;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,76 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Sylius package.
|
||||
*
|
||||
* (c) Paweł Jędrzejewski
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Sylius\Bundle\PaymentsBundle\Model;
|
||||
|
||||
/**
|
||||
* Transaction interface.
|
||||
*
|
||||
* @author Paweł Jędrzejewski <pjedrzejewski@diweb.pl>
|
||||
*/
|
||||
interface TransactionInterface
|
||||
{
|
||||
/**
|
||||
* Get payments transaction identifier.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function getId();
|
||||
|
||||
/**
|
||||
* Get payment associated with this transaction.
|
||||
*
|
||||
* @return PaymentInterface
|
||||
*/
|
||||
public function getPayment();
|
||||
|
||||
/**
|
||||
* Set payment.
|
||||
*
|
||||
* @param null|PaymentInterface $payment
|
||||
*/
|
||||
public function setPayment(PaymentInterface $payment = null);
|
||||
|
||||
/**
|
||||
* Get trasnaction currency via the payment.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getCurrency();
|
||||
|
||||
/**
|
||||
* Get amount.
|
||||
*
|
||||
* @return integer
|
||||
*/
|
||||
public function getAmount();
|
||||
|
||||
/**
|
||||
* Set amount.
|
||||
*
|
||||
* @param integer $amount
|
||||
*/
|
||||
public function setAmount($amount);
|
||||
|
||||
/**
|
||||
* Get creation time.
|
||||
*
|
||||
* @return DateTime
|
||||
*/
|
||||
public function getCreatedAt();
|
||||
|
||||
/**
|
||||
* Get last update time.
|
||||
*
|
||||
* @return DateTime
|
||||
*/
|
||||
public function getUpdatedAt();
|
||||
}
|
||||
69
src/Sylius/Bundle/PaymentsBundle/README.md
Normal file
69
src/Sylius/Bundle/PaymentsBundle/README.md
Normal file
|
|
@ -0,0 +1,69 @@
|
|||
SyliusPaymentsBundle [](http://travis-ci.org/Sylius/SyliusPaymentsBundle)
|
||||
====================
|
||||
|
||||
Payments component for [**Symfony2**](http://symfony.com) ecommerce applications.
|
||||
|
||||
Sylius
|
||||
------
|
||||
|
||||
**Sylius** - Modern ecommerce for Symfony2. Visit [Sylius.org](http://sylius.org).
|
||||
|
||||
[phpspec2](http://phpspec.net) examples
|
||||
---------------------------------------
|
||||
|
||||
``` bash
|
||||
$ composer install --dev --prefer-dist
|
||||
$ bin/phpspec run -f pretty
|
||||
```
|
||||
|
||||
Documentation
|
||||
-------------
|
||||
|
||||
Documentation is available on [**docs.sylius.org**](http://docs.sylius.org/en/latest/bundles/SyliusPaymentsBundle/index.html).
|
||||
|
||||
Contributing
|
||||
------------
|
||||
|
||||
All informations about contributing to Sylius can be found on [this page](http://sylius.readthedocs.org/en/latest/contributing/index.html).
|
||||
|
||||
Mailing lists
|
||||
-------------
|
||||
|
||||
Questions? Feel free to ask on [users mailing list](http://groups.google.com/group/sylius).
|
||||
To contribute and develop this bundle, use the [developers mailing list](http://groups.google.com/group/sylius-dev).
|
||||
|
||||
Sylius twitter account
|
||||
----------------------
|
||||
|
||||
If you want to keep up with updates, [follow the official Sylius account on twitter](http://twitter.com/Sylius).
|
||||
|
||||
Bug tracking
|
||||
------------
|
||||
|
||||
This bundle uses [GitHub issues](https://github.com/Sylius/SyliusPaymentsBundle/issues).
|
||||
If you have found bug, please create an issue.
|
||||
|
||||
Versioning
|
||||
----------
|
||||
|
||||
Releases will be numbered with the format `major.minor.patch`.
|
||||
|
||||
And constructed with the following guidelines.
|
||||
|
||||
* Breaking backwards compatibility bumps the major.
|
||||
* New additions without breaking backwards compatibility bumps the minor.
|
||||
* Bug fixes and misc changes bump the patch.
|
||||
|
||||
For more information on SemVer, please visit [semver.org website](http://semver.org/).
|
||||
This versioning method is same for all **Sylius** bundles and applications.
|
||||
|
||||
MIT License
|
||||
-----------
|
||||
|
||||
License can be found [here](https://github.com/Sylius/SyliusPaymentsBundle/blob/master/Resources/meta/LICENSE).
|
||||
|
||||
Authors
|
||||
-------
|
||||
|
||||
The bundle was originally created by [Paweł Jędrzejewski](http://pjedrzejewski.com).
|
||||
See the list of [contributors](https://github.com/Sylius/SyliusPaymentsBundle/contributors).
|
||||
|
|
@ -0,0 +1,42 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<!--
|
||||
|
||||
This file is part of the Sylius package.
|
||||
|
||||
(c) Paweł Jędrzejewski
|
||||
|
||||
For the full copyright and license information, please view the LICENSE
|
||||
file that was distributed with this source code.
|
||||
|
||||
-->
|
||||
|
||||
<doctrine-mapping xmlns="http://doctrine-project.org/schemas/orm/doctrine-mapping"
|
||||
xmlns:gedmo="http://gediminasm.org/schemas/orm/doctrine-extensions-mapping">
|
||||
|
||||
<mapped-superclass name="Sylius\Bundle\PaymentsBundle\Model\CreditCard" table="sylius_credit_card">
|
||||
<id name="id" column="id" type="integer">
|
||||
<generator strategy="AUTO" />
|
||||
</id>
|
||||
|
||||
<many-to-one field="owner" target-entity="Sylius\Bundle\PaymentsBundle\Model\CreditCardOwnerInterface">
|
||||
<join-column name="owner_id" referenced-column-name="id" nullable="true" on-delete="SET NULL" />
|
||||
</many-to-one>
|
||||
|
||||
<field name="token" column="token" type="string" nullable="true" />
|
||||
<field name="type" column="type" type="string" nullable="true" />
|
||||
<field name="cardholderName" column="cardholder_name" type="string" nullable="true" />
|
||||
<field name="number" column="number" type="string" nullable="true" />
|
||||
<field name="securityCode" column="security_code" type="string" nullable="true" />
|
||||
<field name="expiryMonth" column="expiry_month" type="integer" nullable="true" />
|
||||
<field name="expiryYear" column="expiry_year" type="integer" nullable="true" />
|
||||
|
||||
<field name="createdAt" column="created_at" type="datetime">
|
||||
<gedmo:timestampable on="create"/>
|
||||
</field>
|
||||
<field name="updatedAt" column="updated_at" type="datetime" nullable="true">
|
||||
<gedmo:timestampable on="update"/>
|
||||
</field>
|
||||
</mapped-superclass>
|
||||
|
||||
</doctrine-mapping>
|
||||
|
|
@ -0,0 +1,47 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<!--
|
||||
|
||||
This file is part of the Sylius package.
|
||||
|
||||
(c) Paweł Jędrzejewski
|
||||
|
||||
For the full copyright and license information, please view the LICENSE
|
||||
file that was distributed with this source code.
|
||||
|
||||
-->
|
||||
|
||||
<doctrine-mapping xmlns="http://doctrine-project.org/schemas/orm/doctrine-mapping"
|
||||
xmlns:gedmo="http://gediminasm.org/schemas/orm/doctrine-extensions-mapping">
|
||||
|
||||
<mapped-superclass name="Sylius\Bundle\PaymentsBundle\Model\Payment" table="sylius_payment">
|
||||
<id name="id" column="id" type="integer">
|
||||
<generator strategy="AUTO" />
|
||||
</id>
|
||||
|
||||
<many-to-one field="method" target-entity="Sylius\Bundle\PaymentsBundle\Model\PaymentMethodInterface">
|
||||
<join-column name="method_id" referenced-column-name="id" nullable="true" on-delete="SET NULL" />
|
||||
</many-to-one>
|
||||
|
||||
<field name="currency" column="currency" type="string" />
|
||||
<field name="amount" column="amount" type="integer" />
|
||||
|
||||
<one-to-many field="transactions" target-entity="Sylius\Bundle\PaymentsBundle\Model\TransactionInterface" mapped-by="payment" orphan-removal="true">
|
||||
<cascade>
|
||||
<cascade-all/>
|
||||
</cascade>
|
||||
</one-to-many>
|
||||
|
||||
<many-to-one field="creditCard" target-entity="Sylius\Bundle\PaymentsBundle\Model\CreditCardInterface">
|
||||
<join-column name="credit_card_id" referenced-column-name="id" nullable="true" on-delete="SET NULL" />
|
||||
</many-to-one>
|
||||
|
||||
<field name="createdAt" column="created_at" type="datetime">
|
||||
<gedmo:timestampable on="create"/>
|
||||
</field>
|
||||
<field name="updatedAt" column="updated_at" type="datetime" nullable="true">
|
||||
<gedmo:timestampable on="update"/>
|
||||
</field>
|
||||
</mapped-superclass>
|
||||
|
||||
</doctrine-mapping>
|
||||
|
|
@ -0,0 +1,36 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<!--
|
||||
|
||||
This file is part of the Sylius package.
|
||||
|
||||
(c) Paweł Jędrzejewski
|
||||
|
||||
For the full copyright and license information, please view the LICENSE
|
||||
file that was distributed with this source code.
|
||||
|
||||
-->
|
||||
|
||||
<doctrine-mapping xmlns="http://doctrine-project.org/schemas/orm/doctrine-mapping"
|
||||
xmlns:gedmo="http://gediminasm.org/schemas/orm/doctrine-extensions-mapping">
|
||||
|
||||
<mapped-superclass name="Sylius\Bundle\PaymentsBundle\Model\PaymentMethod" table="sylius_payment_method">
|
||||
<id name="id" column="id" type="integer">
|
||||
<generator strategy="AUTO" />
|
||||
</id>
|
||||
|
||||
<field name="name" column="name" type="string" />
|
||||
<field name="description" column="description" type="string" nullable="true" />
|
||||
<field name="gateway" column="gateway" type="string" />
|
||||
<field name="environment" column="environment" type="string" nullable="true" />
|
||||
<field name="enabled" column="is_enabled" type="boolean" />
|
||||
|
||||
<field name="createdAt" column="created_at" type="datetime">
|
||||
<gedmo:timestampable on="create"/>
|
||||
</field>
|
||||
<field name="updatedAt" column="updated_at" type="datetime" nullable="true">
|
||||
<gedmo:timestampable on="update"/>
|
||||
</field>
|
||||
</mapped-superclass>
|
||||
|
||||
</doctrine-mapping>
|
||||
|
|
@ -0,0 +1,36 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<!--
|
||||
|
||||
This file is part of the Sylius package.
|
||||
|
||||
(c) Paweł Jędrzejewski
|
||||
|
||||
For the full copyright and license information, please view the LICENSE
|
||||
file that was distributed with this source code.
|
||||
|
||||
-->
|
||||
|
||||
<doctrine-mapping xmlns="http://doctrine-project.org/schemas/orm/doctrine-mapping"
|
||||
xmlns:gedmo="http://gediminasm.org/schemas/orm/doctrine-extensions-mapping">
|
||||
|
||||
<mapped-superclass name="Sylius\Bundle\PaymentsBundle\Model\Transaction" table="sylius_transaction">
|
||||
<id name="id" column="id" type="integer">
|
||||
<generator strategy="AUTO" />
|
||||
</id>
|
||||
|
||||
<many-to-one field="payment" target-entity="Sylius\Bundle\PaymentsBundle\Model\PaymentInterface" inversed-by="transactions">
|
||||
<join-column name="payment_id" referenced-column-name="id" />
|
||||
</many-to-one>
|
||||
|
||||
<field name="amount" column="amount" type="integer" />
|
||||
|
||||
<field name="createdAt" column="created_at" type="datetime">
|
||||
<gedmo:timestampable on="create"/>
|
||||
</field>
|
||||
<field name="updatedAt" column="updated_at" type="datetime" nullable="true">
|
||||
<gedmo:timestampable on="update"/>
|
||||
</field>
|
||||
</mapped-superclass>
|
||||
|
||||
</doctrine-mapping>
|
||||
|
|
@ -0,0 +1,86 @@
|
|||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
|
||||
<!--
|
||||
|
||||
This file is part of the Sylius package.
|
||||
|
||||
(c) Paweł Jędrzejewski
|
||||
|
||||
For the full copyright and license information, please view the LICENSE
|
||||
file that was distributed with this source code.
|
||||
|
||||
-->
|
||||
|
||||
<container xmlns="http://symfony.com/schema/dic/services"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://symfony.com/schema/dic/services
|
||||
http://symfony.com/schema/dic/services/services-1.0.xsd">
|
||||
|
||||
<parameters>
|
||||
<parameter key="sylius.repository.payment_method.class">Sylius\Bundle\ResourceBundle\Doctrine\ORM\EntityRepository</parameter>
|
||||
<parameter key="sylius.repository.payment.class">Sylius\Bundle\ResourceBundle\Doctrine\ORM\EntityRepository</parameter>
|
||||
<parameter key="sylius.repository.transaction.class">Sylius\Bundle\ResourceBundle\Doctrine\ORM\EntityRepository</parameter>
|
||||
<parameter key="sylius.repository.credit_card.class">Sylius\Bundle\ResourceBundle\Doctrine\ORM\EntityRepository</parameter>
|
||||
|
||||
<parameter key="sylius.form.type.payment_method_choice.class">Sylius\Bundle\PaymentsBundle\Form\Type\PaymentMethodEntityType</parameter>
|
||||
</parameters>
|
||||
|
||||
<services>
|
||||
<service id="sylius.manager.payment_method" alias="doctrine.orm.entity_manager" />
|
||||
<service id="sylius.repository.payment_method" class="%sylius.repository.payment_method.class%">
|
||||
<argument type="service" id="sylius.manager.payment_method" />
|
||||
<argument type="service">
|
||||
<service
|
||||
factory-service="sylius.manager.payment_method"
|
||||
factory-method="getClassMetadata"
|
||||
class="Doctrine\ORM\Mapping\ClassMetadata"
|
||||
>
|
||||
<argument>%sylius.model.payment_method.class%</argument>
|
||||
</service>
|
||||
</argument>
|
||||
</service>
|
||||
|
||||
<service id="sylius.manager.payment" alias="doctrine.orm.entity_manager" />
|
||||
<service id="sylius.repository.payment" class="%sylius.repository.payment.class%">
|
||||
<argument type="service" id="sylius.manager.payment" />
|
||||
<argument type="service">
|
||||
<service
|
||||
factory-service="sylius.manager.payment"
|
||||
factory-method="getClassMetadata"
|
||||
class="Doctrine\ORM\Mapping\ClassMetadata"
|
||||
>
|
||||
<argument>%sylius.model.payment.class%</argument>
|
||||
</service>
|
||||
</argument>
|
||||
</service>
|
||||
|
||||
<service id="sylius.manager.transaction" alias="doctrine.orm.entity_manager" />
|
||||
<service id="sylius.repository.transaction" class="%sylius.repository.transaction.class%">
|
||||
<argument type="service" id="sylius.manager.transaction" />
|
||||
<argument type="service">
|
||||
<service
|
||||
factory-service="sylius.manager.transaction"
|
||||
factory-method="getClassMetadata"
|
||||
class="Doctrine\ORM\Mapping\ClassMetadata"
|
||||
>
|
||||
<argument>%sylius.model.transaction.class%</argument>
|
||||
</service>
|
||||
</argument>
|
||||
</service>
|
||||
|
||||
<service id="sylius.manager.credit_card" alias="doctrine.orm.entity_manager" />
|
||||
<service id="sylius.repository.credit_card" class="%sylius.repository.credit_card.class%">
|
||||
<argument type="service" id="sylius.manager.credit_card" />
|
||||
<argument type="service">
|
||||
<service
|
||||
factory-service="sylius.manager.credit_card"
|
||||
factory-method="getClassMetadata"
|
||||
class="Doctrine\ORM\Mapping\ClassMetadata"
|
||||
>
|
||||
<argument>%sylius.model.credit_card.class%</argument>
|
||||
</service>
|
||||
</argument>
|
||||
</service>
|
||||
</services>
|
||||
|
||||
</container>
|
||||
|
|
@ -0,0 +1,69 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<!--
|
||||
|
||||
This file is part of the Sylius package.
|
||||
|
||||
(c) Paweł Jędrzejewski
|
||||
|
||||
For the full copyright and license information, please view the LICENSE
|
||||
file that was distributed with this source code.
|
||||
|
||||
-->
|
||||
|
||||
<container xmlns="http://symfony.com/schema/dic/services"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://symfony.com/schema/dic/services
|
||||
http://symfony.com/schema/dic/services/services-1.0.xsd">
|
||||
|
||||
<parameters>
|
||||
<parameter key="sylius.form.type.payment_gateway_choice.class">Sylius\Bundle\PaymentsBundle\Form\Type\PaymentGatewayChoiceType</parameter>
|
||||
<parameter key="sylius.form.type.credit_card.class">Sylius\Bundle\PaymentsBundle\Form\Type\CreditCardType</parameter>
|
||||
</parameters>
|
||||
|
||||
<services>
|
||||
<service id="sylius.controller.payment_method" class="%sylius.controller.payment_method.class%">
|
||||
<argument>sylius</argument>
|
||||
<argument>payment_method</argument>
|
||||
<argument>SyliusPaymentsBundle:PaymentMethod</argument>
|
||||
<call method="setContainer">
|
||||
<argument type="service" id="service_container" />
|
||||
</call>
|
||||
</service>
|
||||
|
||||
<service id="sylius.controller.payment" class="%sylius.controller.payment.class%">
|
||||
<argument>sylius</argument>
|
||||
<argument>payment</argument>
|
||||
<argument>SyliusPaymentsBundle:Payment</argument>
|
||||
<call method="setContainer">
|
||||
<argument type="service" id="service_container" />
|
||||
</call>
|
||||
</service>
|
||||
|
||||
<service id="sylius.form.type.payment_method" class="%sylius.form.type.payment_method.class%">
|
||||
<argument>%sylius.model.payment_method.class%</argument>
|
||||
<argument>%sylius.validation_group.payment_method%</argument>
|
||||
<tag name="form.type" alias="sylius_payment_method" />
|
||||
</service>
|
||||
<service id="sylius.form.type.payment_method_choice" class="%sylius.form.type.payment_method_choice.class%">
|
||||
<argument>%sylius.model.payment_method.class%</argument>
|
||||
<tag name="form.type" alias="sylius_payment_method_choice" />
|
||||
</service>
|
||||
|
||||
<service id="sylius.form.type.payment" class="%sylius.form.type.payment.class%">
|
||||
<argument>%sylius.model.payment.class%</argument>
|
||||
<argument>%sylius.validation_group.payment%</argument>
|
||||
<tag name="form.type" alias="sylius_payment" />
|
||||
</service>
|
||||
<service id="sylius.form.type.payment_gateway_choice" class="%sylius.form.type.payment_gateway_choice.class%">
|
||||
<argument>%sylius.payment_gateways%</argument>
|
||||
<tag name="form.type" alias="sylius_payment_gateway_choice" />
|
||||
</service>
|
||||
<service id="sylius.form.type.credit_card" class="%sylius.form.type.credit_card.class%">
|
||||
<argument>%sylius.model.credit_card.class%</argument>
|
||||
<argument>%sylius.validation_group.credit_card%</argument>
|
||||
<tag name="form.type" alias="sylius_credit_card" />
|
||||
</service>
|
||||
</services>
|
||||
|
||||
</container>
|
||||
|
|
@ -0,0 +1,75 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<!--
|
||||
|
||||
This file is part of the Sylius package.
|
||||
|
||||
(c) Paweł Jędrzejewski
|
||||
|
||||
For the full copyright and license information, please view the LICENSE
|
||||
file that was distributed with this source code.
|
||||
|
||||
-->
|
||||
|
||||
<constraint-mapping xmlns="http://symfony.com/schema/dic/constraint-mapping"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://symfony.com/schema/dic/constraint-mapping
|
||||
http://symfony.com/schema/dic/services/constraint-mapping-1.0.xsd">
|
||||
|
||||
<class name="Sylius\Bundle\PaymentsBundle\Model\PaymentMethod">
|
||||
<property name="name">
|
||||
<constraint name="NotBlank">
|
||||
<option name="message">sylius.payment_method.name.not_blank</option>
|
||||
<option name="groups">sylius</option>
|
||||
</constraint>
|
||||
<constraint name="Length">
|
||||
<option name="min">2</option>
|
||||
<option name="minMessage">sylius.payment_method.name.min_length</option>
|
||||
<option name="max">255</option>
|
||||
<option name="minMessage">sylius.payment_method.name.max_length</option>
|
||||
</constraint>
|
||||
</property>
|
||||
<property name="gateway">
|
||||
<constraint name="NotBlank">
|
||||
<option name="message">sylius.payment_method.gateway.not_blank</option>
|
||||
<option name="groups">sylius</option>
|
||||
</constraint>
|
||||
</property>
|
||||
</class>
|
||||
|
||||
<class name="Sylius\Bundle\PaymentsBundle\Model\CreditCard">
|
||||
<property name="number">
|
||||
<constraint name="Luhn">
|
||||
<option name="message">sylius.credit_card.number.luhn</option>
|
||||
<option name="groups">sylius</option>
|
||||
</constraint>
|
||||
</property>
|
||||
<property name="cardholderName">
|
||||
<constraint name="NotBlank">
|
||||
<option name="message">sylius.credit_card.cardholder_name.not_blank</option>
|
||||
<option name="groups">sylius</option>
|
||||
</constraint>
|
||||
<constraint name="Length">
|
||||
<option name="min">4</option>
|
||||
<option name="minMessage">sylius.credit_card.cardholder_name.min_length</option>
|
||||
</constraint>
|
||||
</property>
|
||||
<property name="securityCode">
|
||||
<constraint name="Length">
|
||||
<option name="min">3</option>
|
||||
<option name="minMessage">sylius.credit_card.security_code.min_length</option>
|
||||
<option name="max">4</option>
|
||||
<option name="maxMessage">sylius.credit_card.security_code.max_length</option>
|
||||
</constraint>
|
||||
</property>
|
||||
<property name="expiryMonth">
|
||||
<constraint name="Range">
|
||||
<option name="min">1</option>
|
||||
<option name="minMessage">sylius.credit_card.expiry_month.min_range</option>
|
||||
<option name="max">12</option>
|
||||
<option name="maxMessage">sylius.credit_card.expiry_month.max_range</option>
|
||||
</constraint>
|
||||
</property>
|
||||
</class>
|
||||
|
||||
</constraint-mapping>
|
||||
19
src/Sylius/Bundle/PaymentsBundle/Resources/meta/LICENSE
Normal file
19
src/Sylius/Bundle/PaymentsBundle/Resources/meta/LICENSE
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
Copyright (c) 2011-2013 Paweł Jędrzejewski
|
||||
|
||||
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.
|
||||
|
|
@ -0,0 +1,55 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<xliff xmlns="urn:oasis:names:tc:xliff:document:1.2" version="1.2">
|
||||
<file source-language="en" datatype="plaintext" original="file.ext">
|
||||
<body>
|
||||
<trans-unit id="3c3fad9ed9e9dce4693320d03211fb69" resname="sylius.form.credit_card.cardholder_name">
|
||||
<source>sylius.form.credit_card.cardholder_name</source>
|
||||
<target>Cardholer Name</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="5c4d48acc6f51d1fdceb046c7a2d7e97" resname="sylius.form.credit_card.expiry_month">
|
||||
<source>sylius.form.credit_card.expiry_month</source>
|
||||
<target>Expiration Month</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="9e2fafcc68bd9c5f56704bf3e2311867" resname="sylius.form.credit_card.expiry_year">
|
||||
<source>sylius.form.credit_card.expiry_year</source>
|
||||
<target>Expiration Year</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="4f8aea56447f3b7dfdc83403769b07b7" resname="sylius.form.credit_card.number">
|
||||
<source>sylius.form.credit_card.number</source>
|
||||
<target>Card Number</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="b0e830dcbd1c0e54516f28f6a5f0f779" resname="sylius.form.credit_card.security_code">
|
||||
<source>sylius.form.credit_card.security_code</source>
|
||||
<target>Security (CVV) Code</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="835d77d0421cdf3e75a65363205aa3a0" resname="sylius.form.credit_card.type">
|
||||
<source>sylius.form.credit_card.type</source>
|
||||
<target>Card Type</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="4b2bd16369add8f5e09952df5e2da02f" resname="sylius.form.payment.amount">
|
||||
<source>sylius.form.payment.amount</source>
|
||||
<target>sylius.form.payment.amount</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="cfd694e828dc0f90777547eeaa2dba13" resname="sylius.form.payment.method">
|
||||
<source>sylius.form.payment.method</source>
|
||||
<target>sylius.form.payment.method</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="a5c8dae58a59fe570e21ce2283d0c5e6" resname="sylius.form.payment_method.description">
|
||||
<source>sylius.form.payment_method.description</source>
|
||||
<target>Description</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="b4663fd843dbc9413d9a6f67d0ee7a71" resname="sylius.form.payment_method.enabled">
|
||||
<source>sylius.form.payment_method.enabled</source>
|
||||
<target>Enabled?</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="587e7779da2b4dd688f67313d76b6428" resname="sylius.form.payment_method.gateway">
|
||||
<source>sylius.form.payment_method.gateway</source>
|
||||
<target>Gateway</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="9eea5f1c89f4fa2dc8bd8abb0d380316" resname="sylius.form.payment_method.name">
|
||||
<source>sylius.form.payment_method.name</source>
|
||||
<target>Name</target>
|
||||
</trans-unit>
|
||||
</body>
|
||||
</file>
|
||||
</xliff>
|
||||
|
|
@ -0,0 +1,55 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<xliff xmlns="urn:oasis:names:tc:xliff:document:1.2" version="1.2">
|
||||
<file source-language="fr" datatype="plaintext" original="file.ext">
|
||||
<body>
|
||||
<trans-unit id="3c3fad9ed9e9dce4693320d03211fb69" resname="sylius.form.credit_card.cardholder_name">
|
||||
<source>sylius.form.credit_card.cardholder_name</source>
|
||||
<target>sylius.form.credit_card.cardholder_name</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="5c4d48acc6f51d1fdceb046c7a2d7e97" resname="sylius.form.credit_card.expiry_month">
|
||||
<source>sylius.form.credit_card.expiry_month</source>
|
||||
<target>sylius.form.credit_card.expiry_month</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="9e2fafcc68bd9c5f56704bf3e2311867" resname="sylius.form.credit_card.expiry_year">
|
||||
<source>sylius.form.credit_card.expiry_year</source>
|
||||
<target>sylius.form.credit_card.expiry_year</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="4f8aea56447f3b7dfdc83403769b07b7" resname="sylius.form.credit_card.number">
|
||||
<source>sylius.form.credit_card.number</source>
|
||||
<target>sylius.form.credit_card.number</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="b0e830dcbd1c0e54516f28f6a5f0f779" resname="sylius.form.credit_card.security_code">
|
||||
<source>sylius.form.credit_card.security_code</source>
|
||||
<target>sylius.form.credit_card.security_code</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="835d77d0421cdf3e75a65363205aa3a0" resname="sylius.form.credit_card.type">
|
||||
<source>sylius.form.credit_card.type</source>
|
||||
<target>sylius.form.credit_card.type</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="4b2bd16369add8f5e09952df5e2da02f" resname="sylius.form.payment.amount">
|
||||
<source>sylius.form.payment.amount</source>
|
||||
<target>sylius.form.payment.amount</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="cfd694e828dc0f90777547eeaa2dba13" resname="sylius.form.payment.method">
|
||||
<source>sylius.form.payment.method</source>
|
||||
<target>sylius.form.payment.method</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="a5c8dae58a59fe570e21ce2283d0c5e6" resname="sylius.form.payment_method.description">
|
||||
<source>sylius.form.payment_method.description</source>
|
||||
<target>Description</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="b4663fd843dbc9413d9a6f67d0ee7a71" resname="sylius.form.payment_method.enabled">
|
||||
<source>sylius.form.payment_method.enabled</source>
|
||||
<target>Activé ?</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="587e7779da2b4dd688f67313d76b6428" resname="sylius.form.payment_method.gateway">
|
||||
<source>sylius.form.payment_method.gateway</source>
|
||||
<target>Passerelle</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="9eea5f1c89f4fa2dc8bd8abb0d380316" resname="sylius.form.payment_method.name">
|
||||
<source>sylius.form.payment_method.name</source>
|
||||
<target>Nom</target>
|
||||
</trans-unit>
|
||||
</body>
|
||||
</file>
|
||||
</xliff>
|
||||
|
|
@ -0,0 +1,55 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<xliff xmlns="urn:oasis:names:tc:xliff:document:1.2" version="1.2">
|
||||
<file source-language="nl" datatype="plaintext" original="file.ext">
|
||||
<body>
|
||||
<trans-unit id="3c3fad9ed9e9dce4693320d03211fb69" resname="sylius.form.credit_card.cardholder_name">
|
||||
<source>sylius.form.credit_card.cardholder_name</source>
|
||||
<target>sylius.form.credit_card.cardholder_name</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="5c4d48acc6f51d1fdceb046c7a2d7e97" resname="sylius.form.credit_card.expiry_month">
|
||||
<source>sylius.form.credit_card.expiry_month</source>
|
||||
<target>sylius.form.credit_card.expiry_month</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="9e2fafcc68bd9c5f56704bf3e2311867" resname="sylius.form.credit_card.expiry_year">
|
||||
<source>sylius.form.credit_card.expiry_year</source>
|
||||
<target>sylius.form.credit_card.expiry_year</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="4f8aea56447f3b7dfdc83403769b07b7" resname="sylius.form.credit_card.number">
|
||||
<source>sylius.form.credit_card.number</source>
|
||||
<target>sylius.form.credit_card.number</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="b0e830dcbd1c0e54516f28f6a5f0f779" resname="sylius.form.credit_card.security_code">
|
||||
<source>sylius.form.credit_card.security_code</source>
|
||||
<target>sylius.form.credit_card.security_code</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="835d77d0421cdf3e75a65363205aa3a0" resname="sylius.form.credit_card.type">
|
||||
<source>sylius.form.credit_card.type</source>
|
||||
<target>sylius.form.credit_card.type</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="4b2bd16369add8f5e09952df5e2da02f" resname="sylius.form.payment.amount">
|
||||
<source>sylius.form.payment.amount</source>
|
||||
<target>sylius.form.payment.amount</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="cfd694e828dc0f90777547eeaa2dba13" resname="sylius.form.payment.method">
|
||||
<source>sylius.form.payment.method</source>
|
||||
<target>sylius.form.payment.method</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="a5c8dae58a59fe570e21ce2283d0c5e6" resname="sylius.form.payment_method.description">
|
||||
<source>sylius.form.payment_method.description</source>
|
||||
<target>Omschrijving</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="b4663fd843dbc9413d9a6f67d0ee7a71" resname="sylius.form.payment_method.enabled">
|
||||
<source>sylius.form.payment_method.enabled</source>
|
||||
<target>Actief?</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="587e7779da2b4dd688f67313d76b6428" resname="sylius.form.payment_method.gateway">
|
||||
<source>sylius.form.payment_method.gateway</source>
|
||||
<target>Gateway</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="9eea5f1c89f4fa2dc8bd8abb0d380316" resname="sylius.form.payment_method.name">
|
||||
<source>sylius.form.payment_method.name</source>
|
||||
<target>Naam</target>
|
||||
</trans-unit>
|
||||
</body>
|
||||
</file>
|
||||
</xliff>
|
||||
|
|
@ -0,0 +1,55 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<xliff xmlns="urn:oasis:names:tc:xliff:document:1.2" version="1.2">
|
||||
<file source-language="pl" datatype="plaintext" original="file.ext">
|
||||
<body>
|
||||
<trans-unit id="3c3fad9ed9e9dce4693320d03211fb69" resname="sylius.form.credit_card.cardholder_name">
|
||||
<source>sylius.form.credit_card.cardholder_name</source>
|
||||
<target>sylius.form.credit_card.cardholder_name</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="5c4d48acc6f51d1fdceb046c7a2d7e97" resname="sylius.form.credit_card.expiry_month">
|
||||
<source>sylius.form.credit_card.expiry_month</source>
|
||||
<target>sylius.form.credit_card.expiry_month</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="9e2fafcc68bd9c5f56704bf3e2311867" resname="sylius.form.credit_card.expiry_year">
|
||||
<source>sylius.form.credit_card.expiry_year</source>
|
||||
<target>sylius.form.credit_card.expiry_year</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="4f8aea56447f3b7dfdc83403769b07b7" resname="sylius.form.credit_card.number">
|
||||
<source>sylius.form.credit_card.number</source>
|
||||
<target>sylius.form.credit_card.number</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="b0e830dcbd1c0e54516f28f6a5f0f779" resname="sylius.form.credit_card.security_code">
|
||||
<source>sylius.form.credit_card.security_code</source>
|
||||
<target>sylius.form.credit_card.security_code</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="835d77d0421cdf3e75a65363205aa3a0" resname="sylius.form.credit_card.type">
|
||||
<source>sylius.form.credit_card.type</source>
|
||||
<target>sylius.form.credit_card.type</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="4b2bd16369add8f5e09952df5e2da02f" resname="sylius.form.payment.amount">
|
||||
<source>sylius.form.payment.amount</source>
|
||||
<target>sylius.form.payment.amount</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="cfd694e828dc0f90777547eeaa2dba13" resname="sylius.form.payment.method">
|
||||
<source>sylius.form.payment.method</source>
|
||||
<target>sylius.form.payment.method</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="a5c8dae58a59fe570e21ce2283d0c5e6" resname="sylius.form.payment_method.description">
|
||||
<source>sylius.form.payment_method.description</source>
|
||||
<target>Opis</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="b4663fd843dbc9413d9a6f67d0ee7a71" resname="sylius.form.payment_method.enabled">
|
||||
<source>sylius.form.payment_method.enabled</source>
|
||||
<target>Aktywna?</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="587e7779da2b4dd688f67313d76b6428" resname="sylius.form.payment_method.gateway">
|
||||
<source>sylius.form.payment_method.gateway</source>
|
||||
<target>Bramka</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="9eea5f1c89f4fa2dc8bd8abb0d380316" resname="sylius.form.payment_method.name">
|
||||
<source>sylius.form.payment_method.name</source>
|
||||
<target>Nazwa</target>
|
||||
</trans-unit>
|
||||
</body>
|
||||
</file>
|
||||
</xliff>
|
||||
|
|
@ -0,0 +1,51 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<xliff xmlns="urn:oasis:names:tc:xliff:document:1.2" version="1.2">
|
||||
<file source-language="en" datatype="plaintext" original="file.ext">
|
||||
<body>
|
||||
<trans-unit id="0135f4a9050b2172a6274ff5ed335de3" resname="sylius.credit_card.cardholder_name.min_length">
|
||||
<source>sylius.credit_card.cardholder_name.min_length</source>
|
||||
<target>The cardholder's name must be at least {{ limit }} characters long.</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="cfbcb5233474af103b61baa1b6637d44" resname="sylius.credit_card.cardholder_name.not_blank">
|
||||
<source>sylius.credit_card.cardholder_name.not_blank</source>
|
||||
<target>Please enter the name of the cardholder.</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="e03769f284ba64c8505927805b4a889f" resname="sylius.credit_card.expiry_month.max_range">
|
||||
<source>sylius.credit_card.expiry_month.max_range</source>
|
||||
<target>The credit card's expiration month must be between {{ min }} and {{ max }}.</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="47d9533424a1bfc6631fe10ffd4d82fc" resname="sylius.credit_card.expiry_month.min_range">
|
||||
<source>sylius.credit_card.expiry_month.min_range</source>
|
||||
<target>The credit card's expiration month must be between {{ min }} and {{ max }}.</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="2b096919bf414678b46a4b8f07fe4324" resname="sylius.credit_card.number.luhn">
|
||||
<source>sylius.credit_card.number.luhn</source>
|
||||
<target>The credit card number you entered is invalid.</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="0f08d631b8f41daae9e15e10965e4dd7" resname="sylius.credit_card.security_code.max_length">
|
||||
<source>sylius.credit_card.security_code.max_length</source>
|
||||
<target>The credit card's CVV code must be between {{ min }} and {{ max }} characters long.</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="f599005ad3026c8602a760e8af300326" resname="sylius.credit_card.security_code.min_length">
|
||||
<source>sylius.credit_card.security_code.min_length</source>
|
||||
<target>The credit card's CVV code must be between {{ min }} and {{ max }} characters long.</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="3c34c8e2f8fce1a0d7c56792a02d4c0d" resname="sylius.payment_method.gateway.not_blank">
|
||||
<source>sylius.payment_method.gateway.not_blank</source>
|
||||
<target>Please select payment method gateway.</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="f41645c1dcdbdd4cdcd2db4cc7ba9d59" resname="sylius.payment_method.name.max_length">
|
||||
<source>sylius.payment_method.name.max_length</source>
|
||||
<target>Payment method name must be {{ limit }} characters long or less.</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="9c2009461136661b1e9f9d33ad8ba830" resname="sylius.payment_method.name.min_length">
|
||||
<source>sylius.payment_method.name.min_length</source>
|
||||
<target>Payment method name must be at least {{ limit }} characters long.</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="06d969be39f9e2a7eb04877e855c4903" resname="sylius.payment_method.name.not_blank">
|
||||
<source>sylius.payment_method.name.not_blank</source>
|
||||
<target>Please enter payment method name.</target>
|
||||
</trans-unit>
|
||||
</body>
|
||||
</file>
|
||||
</xliff>
|
||||
|
|
@ -0,0 +1,51 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<xliff xmlns="urn:oasis:names:tc:xliff:document:1.2" version="1.2">
|
||||
<file source-language="fr" datatype="plaintext" original="file.ext">
|
||||
<body>
|
||||
<trans-unit id="0135f4a9050b2172a6274ff5ed335de3" resname="sylius.credit_card.cardholder_name.min_length">
|
||||
<source>sylius.credit_card.cardholder_name.min_length</source>
|
||||
<target>sylius.credit_card.cardholder_name.min_length</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="cfbcb5233474af103b61baa1b6637d44" resname="sylius.credit_card.cardholder_name.not_blank">
|
||||
<source>sylius.credit_card.cardholder_name.not_blank</source>
|
||||
<target>sylius.credit_card.cardholder_name.not_blank</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="e03769f284ba64c8505927805b4a889f" resname="sylius.credit_card.expiry_month.max_range">
|
||||
<source>sylius.credit_card.expiry_month.max_range</source>
|
||||
<target>sylius.credit_card.expiry_month.max_range</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="47d9533424a1bfc6631fe10ffd4d82fc" resname="sylius.credit_card.expiry_month.min_range">
|
||||
<source>sylius.credit_card.expiry_month.min_range</source>
|
||||
<target>sylius.credit_card.expiry_month.min_range</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="2b096919bf414678b46a4b8f07fe4324" resname="sylius.credit_card.number.luhn">
|
||||
<source>sylius.credit_card.number.luhn</source>
|
||||
<target>sylius.credit_card.number.luhn</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="0f08d631b8f41daae9e15e10965e4dd7" resname="sylius.credit_card.security_code.max_length">
|
||||
<source>sylius.credit_card.security_code.max_length</source>
|
||||
<target>sylius.credit_card.security_code.max_length</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="f599005ad3026c8602a760e8af300326" resname="sylius.credit_card.security_code.min_length">
|
||||
<source>sylius.credit_card.security_code.min_length</source>
|
||||
<target>sylius.credit_card.security_code.min_length</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="3c34c8e2f8fce1a0d7c56792a02d4c0d" resname="sylius.payment_method.gateway.not_blank">
|
||||
<source>sylius.payment_method.gateway.not_blank</source>
|
||||
<target>Veuillez sélectionner la passerelle de la méthode de paiement.</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="f41645c1dcdbdd4cdcd2db4cc7ba9d59" resname="sylius.payment_method.name.max_length">
|
||||
<source>sylius.payment_method.name.max_length</source>
|
||||
<target>Le nom de la méthode de paiement doit avoir au maximum {{ limit }} caractères.</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="9c2009461136661b1e9f9d33ad8ba830" resname="sylius.payment_method.name.min_length">
|
||||
<source>sylius.payment_method.name.min_length</source>
|
||||
<target>Le nom de la méthode de paiement doit avoir au minimum {{ limit }} caractères.</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="06d969be39f9e2a7eb04877e855c4903" resname="sylius.payment_method.name.not_blank">
|
||||
<source>sylius.payment_method.name.not_blank</source>
|
||||
<target>Veuillez entrer le nom de la méthode de paiement.</target>
|
||||
</trans-unit>
|
||||
</body>
|
||||
</file>
|
||||
</xliff>
|
||||
|
|
@ -0,0 +1,51 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<xliff xmlns="urn:oasis:names:tc:xliff:document:1.2" version="1.2">
|
||||
<file source-language="nl" datatype="plaintext" original="file.ext">
|
||||
<body>
|
||||
<trans-unit id="0135f4a9050b2172a6274ff5ed335de3" resname="sylius.credit_card.cardholder_name.min_length">
|
||||
<source>sylius.credit_card.cardholder_name.min_length</source>
|
||||
<target>sylius.credit_card.cardholder_name.min_length</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="cfbcb5233474af103b61baa1b6637d44" resname="sylius.credit_card.cardholder_name.not_blank">
|
||||
<source>sylius.credit_card.cardholder_name.not_blank</source>
|
||||
<target>sylius.credit_card.cardholder_name.not_blank</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="e03769f284ba64c8505927805b4a889f" resname="sylius.credit_card.expiry_month.max_range">
|
||||
<source>sylius.credit_card.expiry_month.max_range</source>
|
||||
<target>sylius.credit_card.expiry_month.max_range</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="47d9533424a1bfc6631fe10ffd4d82fc" resname="sylius.credit_card.expiry_month.min_range">
|
||||
<source>sylius.credit_card.expiry_month.min_range</source>
|
||||
<target>sylius.credit_card.expiry_month.min_range</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="2b096919bf414678b46a4b8f07fe4324" resname="sylius.credit_card.number.luhn">
|
||||
<source>sylius.credit_card.number.luhn</source>
|
||||
<target>sylius.credit_card.number.luhn</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="0f08d631b8f41daae9e15e10965e4dd7" resname="sylius.credit_card.security_code.max_length">
|
||||
<source>sylius.credit_card.security_code.max_length</source>
|
||||
<target>sylius.credit_card.security_code.max_length</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="f599005ad3026c8602a760e8af300326" resname="sylius.credit_card.security_code.min_length">
|
||||
<source>sylius.credit_card.security_code.min_length</source>
|
||||
<target>sylius.credit_card.security_code.min_length</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="3c34c8e2f8fce1a0d7c56792a02d4c0d" resname="sylius.payment_method.gateway.not_blank">
|
||||
<source>sylius.payment_method.gateway.not_blank</source>
|
||||
<target>Selecteer een betalingsmethode gateway.</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="f41645c1dcdbdd4cdcd2db4cc7ba9d59" resname="sylius.payment_method.name.max_length">
|
||||
<source>sylius.payment_method.name.max_length</source>
|
||||
<target>Betalingsmethode naam mag niet langer zijn dan {{ limit }} karakters.</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="9c2009461136661b1e9f9d33ad8ba830" resname="sylius.payment_method.name.min_length">
|
||||
<source>sylius.payment_method.name.min_length</source>
|
||||
<target>Betalingsmethode naam moet minstens {{ limit }} karakters lang zijn.</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="06d969be39f9e2a7eb04877e855c4903" resname="sylius.payment_method.name.not_blank">
|
||||
<source>sylius.payment_method.name.not_blank</source>
|
||||
<target>Voer een betalingsmethode naam in.</target>
|
||||
</trans-unit>
|
||||
</body>
|
||||
</file>
|
||||
</xliff>
|
||||
|
|
@ -0,0 +1,51 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<xliff xmlns="urn:oasis:names:tc:xliff:document:1.2" version="1.2">
|
||||
<file source-language="pl" datatype="plaintext" original="file.ext">
|
||||
<body>
|
||||
<trans-unit id="0135f4a9050b2172a6274ff5ed335de3" resname="sylius.credit_card.cardholder_name.min_length">
|
||||
<source>sylius.credit_card.cardholder_name.min_length</source>
|
||||
<target>sylius.credit_card.cardholder_name.min_length</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="cfbcb5233474af103b61baa1b6637d44" resname="sylius.credit_card.cardholder_name.not_blank">
|
||||
<source>sylius.credit_card.cardholder_name.not_blank</source>
|
||||
<target>sylius.credit_card.cardholder_name.not_blank</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="e03769f284ba64c8505927805b4a889f" resname="sylius.credit_card.expiry_month.max_range">
|
||||
<source>sylius.credit_card.expiry_month.max_range</source>
|
||||
<target>sylius.credit_card.expiry_month.max_range</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="47d9533424a1bfc6631fe10ffd4d82fc" resname="sylius.credit_card.expiry_month.min_range">
|
||||
<source>sylius.credit_card.expiry_month.min_range</source>
|
||||
<target>sylius.credit_card.expiry_month.min_range</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="2b096919bf414678b46a4b8f07fe4324" resname="sylius.credit_card.number.luhn">
|
||||
<source>sylius.credit_card.number.luhn</source>
|
||||
<target>sylius.credit_card.number.luhn</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="0f08d631b8f41daae9e15e10965e4dd7" resname="sylius.credit_card.security_code.max_length">
|
||||
<source>sylius.credit_card.security_code.max_length</source>
|
||||
<target>sylius.credit_card.security_code.max_length</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="f599005ad3026c8602a760e8af300326" resname="sylius.credit_card.security_code.min_length">
|
||||
<source>sylius.credit_card.security_code.min_length</source>
|
||||
<target>sylius.credit_card.security_code.min_length</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="3c34c8e2f8fce1a0d7c56792a02d4c0d" resname="sylius.payment_method.gateway.not_blank">
|
||||
<source>sylius.payment_method.gateway.not_blank</source>
|
||||
<target>Proszę wybrać bramkę płatności.</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="f41645c1dcdbdd4cdcd2db4cc7ba9d59" resname="sylius.payment_method.name.max_length">
|
||||
<source>sylius.payment_method.name.max_length</source>
|
||||
<target>Nazwa metody płatności powinna mieć mniej niż {{ limit }} znaków.</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="9c2009461136661b1e9f9d33ad8ba830" resname="sylius.payment_method.name.min_length">
|
||||
<source>sylius.payment_method.name.min_length</source>
|
||||
<target>Nazwa metody płatności musi składać się z co najmniej {{ limit }} znaków.</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="06d969be39f9e2a7eb04877e855c4903" resname="sylius.payment_method.name.not_blank">
|
||||
<source>sylius.payment_method.name.not_blank</source>
|
||||
<target>Proszę podać nazwę metody płatności.</target>
|
||||
</trans-unit>
|
||||
</body>
|
||||
</file>
|
||||
</xliff>
|
||||
60
src/Sylius/Bundle/PaymentsBundle/SyliusPaymentsBundle.php
Normal file
60
src/Sylius/Bundle/PaymentsBundle/SyliusPaymentsBundle.php
Normal file
|
|
@ -0,0 +1,60 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Sylius package.
|
||||
*
|
||||
* (c) Paweł Jędrzejewski
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Sylius\Bundle\PaymentsBundle;
|
||||
|
||||
use Doctrine\Bundle\DoctrineBundle\DependencyInjection\Compiler\DoctrineOrmMappingsPass;
|
||||
use Sylius\Bundle\ResourceBundle\DependencyInjection\Compiler\ResolveDoctrineTargetEntitiesPass;
|
||||
use Sylius\Bundle\ResourceBundle\SyliusResourceBundle;
|
||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||
use Symfony\Component\HttpKernel\Bundle\Bundle;
|
||||
|
||||
/**
|
||||
* Payments component for Symfony2 applications.
|
||||
*
|
||||
* @author Paweł Jędrzejewski <pjedrzejewski@diweb.pl>
|
||||
*/
|
||||
class SyliusPaymentsBundle extends Bundle
|
||||
{
|
||||
/**
|
||||
* Return array of currently supported database drivers.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function getSupportedDrivers()
|
||||
{
|
||||
return array(
|
||||
SyliusResourceBundle::DRIVER_DOCTRINE_ORM
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function build(ContainerBuilder $container)
|
||||
{
|
||||
$interfaces = array(
|
||||
'Sylius\Bundle\PaymentsBundle\Model\PaymentMethodInterface' => 'sylius.model.payment_method.class',
|
||||
'Sylius\Bundle\PaymentsBundle\Model\PaymentInterface' => 'sylius.model.payment.class',
|
||||
'Sylius\Bundle\PaymentsBundle\Model\TransactionInterface' => 'sylius.model.transaction.class',
|
||||
'Sylius\Bundle\PaymentsBundle\Model\CreditCardInterface' => 'sylius.model.credit_card.class',
|
||||
'Sylius\Bundle\PaymentsBundle\Model\CreditCardOwnerInterface' => 'sylius.model.credit_card_owner.class',
|
||||
);
|
||||
|
||||
$container->addCompilerPass(new ResolveDoctrineTargetEntitiesPass('sylius_payments', $interfaces));
|
||||
|
||||
$mappings = array(
|
||||
realpath(__DIR__.'/Resources/config/doctrine/model') => 'Sylius\Bundle\PaymentsBundle\Model',
|
||||
);
|
||||
|
||||
$container->addCompilerPass(DoctrineOrmMappingsPass::createXmlMappingDriver($mappings, array('doctrine.orm.entity_manager'), 'sylius_payments.driver.doctrine/orm'));
|
||||
}
|
||||
}
|
||||
44
src/Sylius/Bundle/PaymentsBundle/composer.json
Normal file
44
src/Sylius/Bundle/PaymentsBundle/composer.json
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
{
|
||||
"name": "sylius/payments-bundle",
|
||||
"type": "symfony-bundle",
|
||||
"description": "Flexible payments system for Symfony2 ecommerce applications.",
|
||||
"keywords": ["payments", "payment", "shop", "webshop", "ecommerce"],
|
||||
"homepage": "http://sylius.com",
|
||||
"license": "MIT",
|
||||
"authors": [
|
||||
{
|
||||
"name": "Paweł Jędrzejewski",
|
||||
"email": "pjedrzejewski@diweb.pl",
|
||||
"homepage": "http://pjedrzejewski.com"
|
||||
},
|
||||
{
|
||||
"name": "Community contributions",
|
||||
"homepage": "https://github.com/Sylius/SyliusPaymentsBundle/contributors"
|
||||
}
|
||||
],
|
||||
"minimum-stability": "dev",
|
||||
"require": {
|
||||
"php": ">=5.3.3",
|
||||
|
||||
"symfony/framework-bundle": "~2.3",
|
||||
"sylius/resource-bundle": "0.3.*",
|
||||
"stof/doctrine-extensions-bundle": "1.1.*"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpspec/phpspec": "2.0.*@dev",
|
||||
"doctrine/orm": "~2.2",
|
||||
"symfony/form": "~2.3"
|
||||
},
|
||||
"config": {
|
||||
"bin-dir": "bin"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-0": { "Sylius\\Bundle\\PaymentsBundle": "" }
|
||||
},
|
||||
"target-dir": "Sylius/Bundle/PaymentsBundle",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "0.2.x-dev"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,96 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is an addition to the Sylius package.
|
||||
*
|
||||
* (c) Paweł Jędrzejewski
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace spec\Sylius\Bundle\PaymentsBundle\Form\Type;
|
||||
|
||||
use PhpSpec\ObjectBehavior;
|
||||
use Prophecy\Argument;
|
||||
|
||||
/**
|
||||
* @author Dylan Johnson <eponymi.dev@gmail.com>
|
||||
*/
|
||||
class CreditCardTypeSpec extends ObjectBehavior
|
||||
{
|
||||
public function let()
|
||||
{
|
||||
$this->beConstructedWith('CreditCard', array('sylius'));
|
||||
}
|
||||
|
||||
public function it_is_a_form_type()
|
||||
{
|
||||
$this->shouldImplement('Symfony\Component\Form\FormTypeInterface');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Symfony\Component\Form\FormBuilder $builder
|
||||
*/
|
||||
public function it_builds_form_with_proper_fields($builder)
|
||||
{
|
||||
$builder
|
||||
->add('type', 'choice', Argument::any())
|
||||
->shouldBeCalled()
|
||||
->willReturn($builder)
|
||||
;
|
||||
|
||||
$builder
|
||||
->add('cardholderName', 'text', Argument::any())
|
||||
->shouldBeCalled()
|
||||
->willReturn($builder)
|
||||
;
|
||||
|
||||
$builder
|
||||
->add('number', 'number', Argument::any())
|
||||
->shouldBeCalled()
|
||||
->willReturn($builder)
|
||||
;
|
||||
|
||||
$builder
|
||||
->add('securityCode', 'number', Argument::any())
|
||||
->shouldBeCalled()
|
||||
->willReturn($builder)
|
||||
;
|
||||
|
||||
$builder
|
||||
->add('expiryMonth', 'choice', Argument::any())
|
||||
->shouldBeCalled()
|
||||
->willReturn($builder)
|
||||
;
|
||||
|
||||
$builder
|
||||
->add('expiryYear', 'choice', Argument::any())
|
||||
->shouldBeCalled()
|
||||
->willReturn($builder)
|
||||
;
|
||||
|
||||
$this->buildForm($builder, array());
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Symfony\Component\OptionsResolver\OptionsResolverInterface $resolver
|
||||
*/
|
||||
public function it_defines_assigned_data_class($resolver)
|
||||
{
|
||||
$resolver
|
||||
->setDefaults(array(
|
||||
'data_class' => 'CreditCard',
|
||||
'validation_groups' => array('sylius'),
|
||||
))
|
||||
->shouldBeCalled()
|
||||
;
|
||||
|
||||
$this->setDefaultOptions($resolver);
|
||||
}
|
||||
|
||||
function it_has_valid_name()
|
||||
{
|
||||
$this->getName()->shouldReturn('sylius_credit_card');
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,84 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Sylius package.
|
||||
*
|
||||
* (c) Paweł Jędrzejewski
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace spec\Sylius\Bundle\PaymentsBundle\Form\Type;
|
||||
|
||||
use PhpSpec\ObjectBehavior;
|
||||
use Prophecy\Argument;
|
||||
|
||||
/**
|
||||
* @author Paweł Jędrzejewski <pjedrzejewski@diweb.pl>
|
||||
*/
|
||||
class PaymentMethodTypeSpec extends ObjectBehavior
|
||||
{
|
||||
function let()
|
||||
{
|
||||
$this->beConstructedWith('PaymentMethod', array('sylius'));
|
||||
}
|
||||
|
||||
function it_is_a_form_type()
|
||||
{
|
||||
$this->shouldImplement('Symfony\Component\Form\FormTypeInterface');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Symfony\Component\Form\FormBuilder $builder
|
||||
*/
|
||||
function it_builds_form_with_proper_fields($builder)
|
||||
{
|
||||
$builder
|
||||
->add('name', 'text', Argument::any())
|
||||
->shouldBeCalled()
|
||||
->willReturn($builder)
|
||||
;
|
||||
|
||||
$builder
|
||||
->add('description', 'textarea', Argument::any())
|
||||
->shouldBeCalled()
|
||||
->willReturn($builder)
|
||||
;
|
||||
|
||||
$builder
|
||||
->add('enabled', 'checkbox', Argument::any())
|
||||
->shouldBeCalled()
|
||||
->willReturn($builder)
|
||||
;
|
||||
|
||||
$builder
|
||||
->add('gateway', 'sylius_payment_gateway_choice', Argument::any())
|
||||
->shouldBeCalled()
|
||||
->willReturn($builder)
|
||||
;
|
||||
|
||||
$this->buildForm($builder, array());
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Symfony\Component\OptionsResolver\OptionsResolverInterface $resolver
|
||||
*/
|
||||
function it_defines_assigned_data_class($resolver)
|
||||
{
|
||||
$resolver
|
||||
->setDefaults(array(
|
||||
'data_class' => 'PaymentMethod',
|
||||
'validation_groups' => array('sylius'),
|
||||
))
|
||||
->shouldBeCalled()
|
||||
;
|
||||
|
||||
$this->setDefaultOptions($resolver);
|
||||
}
|
||||
|
||||
function it_has_valid_name()
|
||||
{
|
||||
$this->getName()->shouldReturn('sylius_payment_method');
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,142 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Sylius package.
|
||||
*
|
||||
* (c) Paweł Jędrzejewski
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace spec\Sylius\Bundle\PaymentsBundle\Model;
|
||||
|
||||
use PhpSpec\ObjectBehavior;
|
||||
|
||||
/**
|
||||
* @author Paweł Jędrzejewski <pjedrzejewski@diweb.pl>
|
||||
*/
|
||||
class CreditCardSpec extends ObjectBehavior
|
||||
{
|
||||
function it_is_initializable()
|
||||
{
|
||||
$this->shouldHaveType('Sylius\Bundle\PaymentsBundle\Model\CreditCard');
|
||||
}
|
||||
|
||||
function it_implements_Sylius_credit_card_interface()
|
||||
{
|
||||
$this->shouldImplement('Sylius\Bundle\PaymentsBundle\Model\CreditCardInterface');
|
||||
}
|
||||
|
||||
function it_implements_Sylius_payment_source_interface()
|
||||
{
|
||||
$this->shouldImplement('Sylius\Bundle\PaymentsBundle\Model\PaymentSourceInterface');
|
||||
}
|
||||
|
||||
function it_has_no_id_by_default()
|
||||
{
|
||||
$this->getId()->shouldReturn(null);
|
||||
}
|
||||
|
||||
function it_has_no_owner_by_default()
|
||||
{
|
||||
$this->getOwner()->shouldReturn(null);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Sylius\Bundle\PaymentsBundle\Model\CreditCardOwnerInterface $owner
|
||||
*/
|
||||
function it_allows_to_assign_an_owner($owner)
|
||||
{
|
||||
$this->setOwner($owner);
|
||||
$this->getOwner()->shouldReturn($owner);
|
||||
}
|
||||
|
||||
function it_has_no_cardholder_name_by_default()
|
||||
{
|
||||
$this->getCardholderName()->shouldReturn(null);
|
||||
}
|
||||
|
||||
function its_carholder_name_is_mutable()
|
||||
{
|
||||
$this->setCardholderName('John Doe');
|
||||
$this->getCardholderName()->shouldReturn('John Doe');
|
||||
}
|
||||
|
||||
function it_has_no_number_by_default()
|
||||
{
|
||||
$this->getNumber()->shouldReturn(null);
|
||||
}
|
||||
|
||||
function its_number_is_mutable()
|
||||
{
|
||||
$this->setNumber('5321');
|
||||
$this->getNumber()->shouldReturn('5321');
|
||||
}
|
||||
|
||||
function it_returns_last_4_digits_in_masked_number()
|
||||
{
|
||||
$this->setNumber('1244 1242 5434 1234');
|
||||
$this->getMaskedNumber()->shouldReturn('XXXX XXXX XXXX 1234');
|
||||
}
|
||||
|
||||
function it_returns_masked_number_when_converted_to_string()
|
||||
{
|
||||
$this->setNumber('1244 1242 5434 1234');
|
||||
$this->__toString()->shouldReturn('XXXX XXXX XXXX 1234');
|
||||
}
|
||||
|
||||
function it_has_no_security_code_by_default()
|
||||
{
|
||||
$this->getSecurityCode()->shouldReturn(null);
|
||||
}
|
||||
|
||||
function its_security_code_is_mutable()
|
||||
{
|
||||
$this->setSecurityCode('373');
|
||||
$this->getSecurityCode()->shouldReturn('373');
|
||||
}
|
||||
|
||||
function it_has_no_expiry_month_by_default()
|
||||
{
|
||||
$this->getExpiryMonth()->shouldReturn(null);
|
||||
}
|
||||
|
||||
function its_expiry_month_is_mutable()
|
||||
{
|
||||
$this->setExpiryMonth(11);
|
||||
$this->getExpiryMonth()->shouldReturn(11);
|
||||
}
|
||||
|
||||
function it_has_no_expiry_year_by_default()
|
||||
{
|
||||
$this->getExpiryYear()->shouldReturn(null);
|
||||
}
|
||||
|
||||
function its_expiry_year_is_mutable()
|
||||
{
|
||||
$this->setExpiryYear(15);
|
||||
$this->getExpiryYear()->shouldReturn(15);
|
||||
}
|
||||
|
||||
function it_has_no_token_by_default()
|
||||
{
|
||||
$this->getToken()->shouldReturn(null);
|
||||
}
|
||||
|
||||
function its_token_is_mutable()
|
||||
{
|
||||
$this->setToken('2sa42aaSOx');
|
||||
$this->getToken()->shouldReturn('2sa42aaSOx');
|
||||
}
|
||||
|
||||
function it_initializes_creation_date_by_default()
|
||||
{
|
||||
$this->getCreatedAt()->shouldHaveType('DateTime');
|
||||
}
|
||||
|
||||
function it_has_no_last_update_date_by_default()
|
||||
{
|
||||
$this->getUpdatedAt()->shouldReturn(null);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,108 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Sylius package.
|
||||
*
|
||||
* (c) Paweł Jędrzejewski
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace spec\Sylius\Bundle\PaymentsBundle\Model;
|
||||
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
use PhpSpec\ObjectBehavior;
|
||||
use Sylius\Bundle\PaymentsBundle\Model\PaymentMethodInterface;
|
||||
|
||||
/**
|
||||
* @author Paweł Jędrzejewski <pjedrzejewski@diweb.pl>
|
||||
*/
|
||||
class PaymentMethodSpec extends ObjectBehavior
|
||||
{
|
||||
function it_is_initializable()
|
||||
{
|
||||
$this->shouldHaveType('Sylius\Bundle\PaymentsBundle\Model\PaymentMethod');
|
||||
}
|
||||
|
||||
function it_implements_Sylius_payment_method_interface()
|
||||
{
|
||||
$this->shouldImplement('Sylius\Bundle\PaymentsBundle\Model\PaymentMethodInterface');
|
||||
}
|
||||
|
||||
function it_has_no_id_by_default()
|
||||
{
|
||||
$this->getId()->shouldReturn(null);
|
||||
}
|
||||
|
||||
function it_is_unnamed_by_default()
|
||||
{
|
||||
$this->getName()->shouldReturn(null);
|
||||
}
|
||||
|
||||
function its_name_is_mutable()
|
||||
{
|
||||
$this->setName('Stripe');
|
||||
$this->getName()->shouldReturn('Stripe');
|
||||
}
|
||||
|
||||
function it_is_convertable_to_string_and_returns_its_name()
|
||||
{
|
||||
$this->setName('PayPal');
|
||||
$this->__toString()->shouldReturn('PayPal');
|
||||
}
|
||||
|
||||
function it_has_no_description_by_default()
|
||||
{
|
||||
$this->getDescription()->shouldReturn(null);
|
||||
}
|
||||
|
||||
function its_description_is_mutable()
|
||||
{
|
||||
$this->setDescription('Pay by check.');
|
||||
$this->getDescription()->shouldReturn('Pay by check.');
|
||||
}
|
||||
|
||||
function it_does_not_require_app_environment_by_default()
|
||||
{
|
||||
$this->getEnvironment()->shouldReturn(null);
|
||||
}
|
||||
|
||||
function its_app_environment_is_mutable()
|
||||
{
|
||||
$this->setEnvironment('dev');
|
||||
$this->getEnvironment()->shouldReturn('dev');
|
||||
}
|
||||
|
||||
function it_has_no_gateway_by_default()
|
||||
{
|
||||
$this->getGateway()->shouldReturn(null);
|
||||
}
|
||||
|
||||
function its_gateway_is_mutable()
|
||||
{
|
||||
$this->setGateway('dev');
|
||||
$this->getGateway()->shouldReturn('dev');
|
||||
}
|
||||
|
||||
function it_is_enabled_by_default()
|
||||
{
|
||||
$this->shouldBeEnabled();
|
||||
}
|
||||
|
||||
function it_allows_disabling_itself()
|
||||
{
|
||||
$this->setEnabled(false);
|
||||
$this->shouldNotBeEnabled();
|
||||
}
|
||||
|
||||
function it_initializes_creation_date_by_default()
|
||||
{
|
||||
$this->getCreatedAt()->shouldHaveType('DateTime');
|
||||
}
|
||||
|
||||
function it_has_no_last_update_date_by_default()
|
||||
{
|
||||
$this->getUpdatedAt()->shouldReturn(null);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,159 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Sylius package.
|
||||
*
|
||||
* (c) Paweł Jędrzejewski
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace spec\Sylius\Bundle\PaymentsBundle\Model;
|
||||
|
||||
use PhpSpec\ObjectBehavior;
|
||||
|
||||
/**
|
||||
* @author Paweł Jędrzejewski <pjedrzejewski@diweb.pl>
|
||||
*/
|
||||
class PaymentSpec extends ObjectBehavior
|
||||
{
|
||||
function it_is_initializable()
|
||||
{
|
||||
$this->shouldHaveType('Sylius\Bundle\PaymentsBundle\Model\Payment');
|
||||
}
|
||||
|
||||
function it_implements_Sylius_payment_instruction_interface()
|
||||
{
|
||||
$this->shouldImplement('Sylius\Bundle\PaymentsBundle\Model\PaymentInterface');
|
||||
}
|
||||
|
||||
function it_has_no_id_by_default()
|
||||
{
|
||||
$this->getId()->shouldReturn(null);
|
||||
}
|
||||
|
||||
function it_has_no_payment_method_by_default()
|
||||
{
|
||||
$this->getMethod()->shouldReturn(null);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Sylius\Bundle\PaymentsBundle\Model\PaymentMethodInterface $method
|
||||
*/
|
||||
function its_method_is_mutable($method)
|
||||
{
|
||||
$this->setMethod($method);
|
||||
$this->getMethod()->shouldReturn($method);
|
||||
}
|
||||
|
||||
function it_has_no_source_by_default()
|
||||
{
|
||||
$this->getSource()->shouldReturn(null);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Sylius\Bundle\PaymentsBundle\Model\CreditCardInterface $source
|
||||
*/
|
||||
function it_allows_to_assign_a_source($source)
|
||||
{
|
||||
$this->setSource($source);
|
||||
$this->getSource()->shouldReturn($source);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Sylius\Bundle\PaymentsBundle\Model\CreditCardInterface $source
|
||||
*/
|
||||
function it_allows_to_remove_a_source($source)
|
||||
{
|
||||
$this->setSource($source);
|
||||
$this->setSource(null);
|
||||
$this->getSource()->shouldReturn(null);
|
||||
}
|
||||
|
||||
function it_has_no_currency_by_default()
|
||||
{
|
||||
$this->getCurrency()->shouldReturn(null);
|
||||
}
|
||||
|
||||
function its_currency_is_mutable()
|
||||
{
|
||||
$this->setCurrency('EUR');
|
||||
$this->getCurrency()->shouldReturn('EUR');
|
||||
}
|
||||
|
||||
function it_has_amount_equal_to_0_by_defualt()
|
||||
{
|
||||
$this->getAmount()->shouldReturn(0);
|
||||
}
|
||||
|
||||
function its_amount_is_mutable()
|
||||
{
|
||||
$this->setAmount(4999);
|
||||
$this->getAmount()->shouldReturn(4999);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Sylius\Bundle\PaymentsBundle\Model\TransactionInterface $transactionA
|
||||
* @param Sylius\Bundle\PaymentsBundle\Model\TransactionInterface $transactionB
|
||||
*/
|
||||
function it_calculates_balance_by_subtracting_transacttions_total_from_amount($transactionA, $transactionB)
|
||||
{
|
||||
$transactionA->getAmount()->willReturn(5000);
|
||||
$transactionB->getAmount()->willReturn(2500);
|
||||
|
||||
$transactionA->setPayment($this)->shouldBeCalled();
|
||||
$transactionB->setPayment($this)->shouldBeCalled();
|
||||
|
||||
$this->addTransaction($transactionA);
|
||||
$this->addTransaction($transactionB);
|
||||
|
||||
$this->setAmount(7500);
|
||||
$this->getBalance()->shouldReturn(0);
|
||||
|
||||
$this->setAmount(10000);
|
||||
$this->getBalance()->shouldReturn(2500);
|
||||
}
|
||||
|
||||
function it_initializes_transaction_collection_by_default()
|
||||
{
|
||||
$this->getTransactions()->shouldHaveType('Doctrine\Common\Collections\Collection');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Sylius\Bundle\PaymentsBundle\Model\TransactionInterface $transaction
|
||||
*/
|
||||
function it_adds_transactions($transaction)
|
||||
{
|
||||
$this->hasTransaction($transaction)->shouldReturn(false);
|
||||
|
||||
$transaction->setPayment($this)->shouldBeCalled();
|
||||
$this->addTransaction($transaction);
|
||||
|
||||
$this->hasTransaction($transaction)->shouldReturn(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Sylius\Bundle\PaymentsBundle\Model\TransactionInterface $transaction
|
||||
*/
|
||||
function it_removes_transactions($transaction)
|
||||
{
|
||||
$transaction->setPayment($this)->shouldBeCalled();
|
||||
$this->addTransaction($transaction);
|
||||
|
||||
$transaction->setPayment(null)->shouldBeCalled();
|
||||
$this->removeTransaction($transaction);
|
||||
|
||||
$this->hasTransaction($transaction)->shouldReturn(false);
|
||||
}
|
||||
|
||||
function it_initializes_creation_date_by_default()
|
||||
{
|
||||
$this->getCreatedAt()->shouldHaveType('DateTime');
|
||||
}
|
||||
|
||||
function it_has_no_last_update_date_by_default()
|
||||
{
|
||||
$this->getUpdatedAt()->shouldReturn(null);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,100 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Sylius package.
|
||||
*
|
||||
* (c) Paweł Jędrzejewski
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace spec\Sylius\Bundle\PaymentsBundle\Model;
|
||||
|
||||
use PhpSpec\ObjectBehavior;
|
||||
|
||||
/**
|
||||
* @author Paweł Jędrzejewski <pjedrzejewski@diweb.pl>
|
||||
*/
|
||||
class TransactionSpec extends ObjectBehavior
|
||||
{
|
||||
function it_is_initializable()
|
||||
{
|
||||
$this->shouldHaveType('Sylius\Bundle\PaymentsBundle\Model\Transaction');
|
||||
}
|
||||
|
||||
function it_implements_Sylius_transaction_interface()
|
||||
{
|
||||
$this->shouldImplement('Sylius\Bundle\PaymentsBundle\Model\TransactionInterface');
|
||||
}
|
||||
|
||||
function it_has_no_id_by_default()
|
||||
{
|
||||
$this->getId()->shouldReturn(null);
|
||||
}
|
||||
|
||||
function it_does_not_belong_to_a_payment_by_default()
|
||||
{
|
||||
$this->getPayment()->shouldReturn(null);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Sylius\Bundle\PaymentsBundle\Model\PaymentInterface $payment
|
||||
*/
|
||||
function it_allows_assigning_itself_to_a_payment($payment)
|
||||
{
|
||||
$this->setPayment($payment);
|
||||
$this->getPayment()->shouldReturn($payment);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Sylius\Bundle\PaymentsBundle\Model\PaymentInterface $payment
|
||||
*/
|
||||
function it_allows_detaching_itself_from_a_payment($payment)
|
||||
{
|
||||
$this->setPayment($payment);
|
||||
$this->setPayment(null);
|
||||
|
||||
$this->getPayment()->shouldReturn(null);
|
||||
}
|
||||
|
||||
function it_throws_exception_if_trying_to_get_currency_without_payment_defined()
|
||||
{
|
||||
$this
|
||||
->shouldThrow('BadMethodCallException')
|
||||
->duringGetCurrency()
|
||||
;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Sylius\Bundle\PaymentsBundle\Model\PaymentInterface $payment
|
||||
*/
|
||||
function it_gets_currency_via_payment($payment)
|
||||
{
|
||||
$payment->getCurrency()->willReturn('USD')->shouldBeCalled();
|
||||
$this->setPayment($payment);
|
||||
|
||||
$this->getCurrency()->shouldReturn('USD');
|
||||
}
|
||||
|
||||
function it_has_amount_equal_to_0_by_defualt()
|
||||
{
|
||||
$this->getAmount()->shouldReturn(0);
|
||||
}
|
||||
|
||||
function its_amount_is_mutable()
|
||||
{
|
||||
$this->setAmount(4999);
|
||||
$this->getAmount()->shouldReturn(4999);
|
||||
}
|
||||
|
||||
function it_initializes_creation_date_by_default()
|
||||
{
|
||||
$this->getCreatedAt()->shouldHaveType('DateTime');
|
||||
}
|
||||
|
||||
function it_has_no_last_update_date_by_default()
|
||||
{
|
||||
$this->getUpdatedAt()->shouldReturn(null);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Reference in a new issue