From 581b3aaea6ac6b7c99eb875db52fb768731a5f2e Mon Sep 17 00:00:00 2001 From: Kotlyar Maksim Date: Tue, 25 Nov 2014 16:29:34 +0000 Subject: [PATCH 1/2] [bitcoind] wip --- .../Payment/BitcoindPaymentFactory.php | 74 +++++++++++++++++++ Resources/config/payment/bitcoind.xml | 7 ++ 2 files changed, 81 insertions(+) create mode 100644 DependencyInjection/Factory/Payment/BitcoindPaymentFactory.php create mode 100644 Resources/config/payment/bitcoind.xml diff --git a/DependencyInjection/Factory/Payment/BitcoindPaymentFactory.php b/DependencyInjection/Factory/Payment/BitcoindPaymentFactory.php new file mode 100644 index 00000000..7fde8491 --- /dev/null +++ b/DependencyInjection/Factory/Payment/BitcoindPaymentFactory.php @@ -0,0 +1,74 @@ +load('bitcoind.xml'); + + return parent::create($container, $contextName, $config); + } + + /** + * {@inheritdoc} + */ + public function getName() + { + return 'bitcoind'; + } + + /** + * {@inheritdoc} + */ + public function addConfiguration(ArrayNodeDefinition $builder) + { + parent::addConfiguration($builder); + + $builder->children() + ->scalarNode('rpcuser')->isRequired()->cannotBeEmpty()->end() + ->scalarNode('rpcpassword')->isRequired()->cannotBeEmpty()->end() + ->scalarNode('rpchost')->isRequired()->cannotBeEmpty()->end() + ->scalarNode('rpcport')->isRequired()->cannotBeEmpty()->end() + ->end(); + } + + /** + * {@inheritDoc} + */ + public function prepend(ContainerBuilder $container) + { + $container->prependExtensionConfig('twig', array( + 'paths' => array_flip(array_filter(array( + 'PayumCore' => TwigFactory::guessViewsPath('Payum\Core\Payment'), + 'PayumBitcoind' => TwigFactory::guessViewsPath('Payum\Bitcoind\PaymentFactory'), + ))) + )); + } + + /** + * {@inheritDoc} + */ + protected function addApis(Definition $paymentDefinition, ContainerBuilder $container, $contextName, array $config) + { + } +} \ No newline at end of file diff --git a/Resources/config/payment/bitcoind.xml b/Resources/config/payment/bitcoind.xml new file mode 100644 index 00000000..d9175663 --- /dev/null +++ b/Resources/config/payment/bitcoind.xml @@ -0,0 +1,7 @@ + + + + + \ No newline at end of file From 02b9ccebb45b04dbe8d6a9a2be3c7ccffe5eb15c Mon Sep 17 00:00:00 2001 From: Kotlyar Maksim Date: Tue, 25 Nov 2014 20:09:16 +0000 Subject: [PATCH 2/2] [bitcoind] add payment factory. --- .../Payment/BitcoindPaymentFactory.php | 18 ++++-- PayumBundle.php | 2 + Resources/config/payment/bitcoind.xml | 55 ++++++++++++++++++- 3 files changed, 70 insertions(+), 5 deletions(-) diff --git a/DependencyInjection/Factory/Payment/BitcoindPaymentFactory.php b/DependencyInjection/Factory/Payment/BitcoindPaymentFactory.php index 7fde8491..9352cffd 100644 --- a/DependencyInjection/Factory/Payment/BitcoindPaymentFactory.php +++ b/DependencyInjection/Factory/Payment/BitcoindPaymentFactory.php @@ -45,10 +45,7 @@ public function addConfiguration(ArrayNodeDefinition $builder) parent::addConfiguration($builder); $builder->children() - ->scalarNode('rpcuser')->isRequired()->cannotBeEmpty()->end() - ->scalarNode('rpcpassword')->isRequired()->cannotBeEmpty()->end() - ->scalarNode('rpchost')->isRequired()->cannotBeEmpty()->end() - ->scalarNode('rpcport')->isRequired()->cannotBeEmpty()->end() + ->scalarNode('dsn')->isRequired()->cannotBeEmpty()->end() ->end(); } @@ -70,5 +67,18 @@ public function prepend(ContainerBuilder $container) */ protected function addApis(Definition $paymentDefinition, ContainerBuilder $container, $contextName, array $config) { + $client = new DefinitionDecorator('payum.bitcoind.client.prototype'); + $client->replaceArgument(0, $config['dsn']); + $client->setPublic(true); + $clientId = 'payum.context.'.$contextName.'.client'; + $container->setDefinition($clientId, $client); + + $bitcoind = new DefinitionDecorator('payum.bitcoind.bitcoind.prototype'); + $bitcoind->replaceArgument(0, new Reference($clientId)); + $bitcoind->setPublic(true); + $bitcoindId = 'payum.context.'.$contextName.'.bitcoind'; + $container->setDefinition($bitcoindId, $bitcoind); + + $paymentDefinition->addMethodCall('addApi', array(new Reference($bitcoindId))); } } \ No newline at end of file diff --git a/PayumBundle.php b/PayumBundle.php index b532e07a..ceedb253 100644 --- a/PayumBundle.php +++ b/PayumBundle.php @@ -5,6 +5,7 @@ use Payum\Bundle\PayumBundle\DependencyInjection\Compiler\PayumStorageExtensionsPass; use Payum\Bundle\PayumBundle\DependencyInjection\Factory\Payment\Be2BillOnsitePaymentFactory; use Payum\Bundle\PayumBundle\DependencyInjection\Factory\Payment\Be2BillPaymentFactory; +use Payum\Bundle\PayumBundle\DependencyInjection\Factory\Payment\BitcoindPaymentFactory; use Payum\Bundle\PayumBundle\DependencyInjection\Factory\Payment\KlarnaCheckoutPaymentFactory; use Payum\Bundle\PayumBundle\DependencyInjection\Factory\Payment\KlarnaInvoicePaymentFactory; use Payum\Bundle\PayumBundle\DependencyInjection\Factory\Payment\OfflinePaymentFactory; @@ -46,6 +47,7 @@ public function build(ContainerBuilder $container) $extension->addPaymentFactory(new KlarnaInvoicePaymentFactory); $extension->addPaymentFactory(new StripeJsPaymentFactory); $extension->addPaymentFactory(new StripeCheckoutPaymentFactory); + $extension->addPaymentFactory(new BitcoindPaymentFactory); $extension->addStorageFactory(new FilesystemStorageFactory); $extension->addStorageFactory(new DoctrineStorageFactory); diff --git a/Resources/config/payment/bitcoind.xml b/Resources/config/payment/bitcoind.xml index d9175663..03fae41c 100644 --- a/Resources/config/payment/bitcoind.xml +++ b/Resources/config/payment/bitcoind.xml @@ -3,5 +3,58 @@ - + + + Nbobtc\Bitcoind\Bitcoind + Nbobtc\Bitcoind\Client + Payum\Bitcoind\Action\CaptureAction + Payum\Bitcoind\Action\StatusAction + Payum\Bitcoind\Action\Api\GetNewAddressAction + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file