diff --git a/DependencyInjection/Factory/Payment/BitcoindPaymentFactory.php b/DependencyInjection/Factory/Payment/BitcoindPaymentFactory.php new file mode 100644 index 00000000..9352cffd --- /dev/null +++ b/DependencyInjection/Factory/Payment/BitcoindPaymentFactory.php @@ -0,0 +1,84 @@ +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('dsn')->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) + { + $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 new file mode 100644 index 00000000..03fae41c --- /dev/null +++ b/Resources/config/payment/bitcoind.xml @@ -0,0 +1,60 @@ + + + + + + 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