From e0859fdb1f6c1b8c5bfb0edb932f52ac453def13 Mon Sep 17 00:00:00 2001 From: Anush Ramani Date: Wed, 22 Jan 2020 10:06:03 -0800 Subject: [PATCH] XOL-4975 Support for Symfony 3 (#11) * XOL-4975 Support for Symfony 3 * XOL-4975 update build matrix for travis * Updated README --- .travis.yml | 13 +- DependencyInjection/Configuration.php | 7 +- LICENSE | 2 +- README.md | 4 +- Resources/config/services.yml | 2 +- Service/Omnipay.php | 28 +- Tests/Service/OmnipayTest.php | 501 +++----------------------- composer.json | 44 +-- 8 files changed, 107 insertions(+), 494 deletions(-) diff --git a/.travis.yml b/.travis.yml index 96f6f69..6bd009d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,11 +1,18 @@ language: php php: - - 5.4 - - 5.5 - - 5.6 + - 7.2 + - 7.3 + - 7.4 + +env: + - SYMFONY_VERSION="~2" + - SYMFONY_VERSION="~3" before_script: + - composer self-update + - composer --version + - composer require symfony/framework-bundle:${SYMFONY_VERSION} --no-update - composer install -n --dev --prefer-source script: phpunit --coverage-text --configuration phpunit.xml.dist diff --git a/DependencyInjection/Configuration.php b/DependencyInjection/Configuration.php index f66c82b..fd1aa02 100644 --- a/DependencyInjection/Configuration.php +++ b/DependencyInjection/Configuration.php @@ -2,12 +2,13 @@ namespace Xola\OmnipayBundle\DependencyInjection; -use Guzzle\Log\MessageFormatter; use Symfony\Component\Config\Definition\Builder\TreeBuilder; use Symfony\Component\Config\Definition\ConfigurationInterface; class Configuration implements ConfigurationInterface { + const DEBUG_FORMAT = '>>>>>>>>\n{request}\n<<<<<<<<\n{response}\n--------\n{curl_stderr}'; + /** * Generates the configuration tree builder. * @@ -21,8 +22,8 @@ public function getConfigTreeBuilder() ->arrayNode('log') ->addDefaultsIfNotSet() ->children() - ->scalarNode('format') - ->defaultValue(MessageFormatter::DEBUG_FORMAT); + ->scalarNode('format') + ->defaultValue(Configuration::DEBUG_FORMAT); return $treeBuilder; } diff --git a/LICENSE b/LICENSE index 81e2b89..594235b 100644 --- a/LICENSE +++ b/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2012 Nelmio +Copyright (c) 2019 Xola, Inc. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/README.md b/README.md index 6f06b08..5996a47 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ Xola OmnipayBundle [![Build status...](https://secure.travis-ci.org/xola/Omnipay This bundle integrates the [Omnipay payment processing library](https://github.com/adrianmacneil/omnipay) into [Symfony2](http://symfony.com/). -This bundle supports Omnipay 2.x +This bundle supports Omnipay 3 Installation ------------ @@ -12,7 +12,7 @@ To install via [Composer](http://getcomposer.org/), add the following to your `c ```json { "require": { - "xola/omnipay-bundle": "1.*" + "xola/omnipay-bundle": "^3" } } ``` diff --git a/Resources/config/services.yml b/Resources/config/services.yml index be04ac5..3c8c43e 100644 --- a/Resources/config/services.yml +++ b/Resources/config/services.yml @@ -3,7 +3,7 @@ parameters: services: omnipay: - class: %omnipay.service.class% + class: "%omnipay.service.class%" arguments: [ "@service_container", "@logger" ] tags: - { name: monolog.logger, channel: omnipay } diff --git a/Service/Omnipay.php b/Service/Omnipay.php index c9f7881..3c516a6 100644 --- a/Service/Omnipay.php +++ b/Service/Omnipay.php @@ -2,14 +2,15 @@ namespace Xola\OmnipayBundle\Service; -use Guzzle\Http\Client; -use Guzzle\Log\MessageFormatter; -use Guzzle\Log\PsrLogAdapter; -use Guzzle\Plugin\Log\LogPlugin; -use Omnipay\Common\AbstractGateway; +use Http\Client\Common\Plugin\LoggerPlugin; +use Http\Client\Common\PluginClient; +use Http\Discovery\HttpClientDiscovery; +use Http\Message\Formatter\FullHttpMessageFormatter; use Omnipay\Common\GatewayFactory; use Omnipay\Common\GatewayInterface; +use Omnipay\Common\Http\Client; use Psr\Log\LoggerInterface; +use RuntimeException; use Symfony\Component\DependencyInjection\Container; class Omnipay @@ -43,10 +44,10 @@ private function initConfig($parameters) /** * Returns an Omnipay gateway. * - * @param string $key Gateway key as defined in the config + * @param string $key Gateway key as defined in the config * - * @throws \RuntimeException If no gateway is configured for the key - * @return AbstractGateway + * @return GatewayInterface + * @throws RuntimeException If no gateway is configured for the key */ public function get($key = null) { @@ -65,17 +66,14 @@ public function get($key = null) $gatewayName = $this->getGatewayName($key); if (!$gatewayName) { // Invalid gateway key - throw new \RuntimeException('Gateway key "' . $key . '" is not configured'); + throw new RuntimeException('Gateway key "' . $key . '" is not configured'); } - $adapter = new PsrLogAdapter($this->logger); - $logPlugin = new LogPlugin($adapter, $this->config['log']['format']); - - $client = new Client(); - $client->addSubscriber($logPlugin); + $loggerPlugin = new LoggerPlugin($this->logger, new FullHttpMessageFormatter()); + $httpClient = new PluginClient(HttpClientDiscovery::find(), [$loggerPlugin]); $factory = new GatewayFactory(); - /** @var GatewayInterface $gateway */ + $client = new Client($httpClient); $gateway = $factory->create($gatewayName, $client); if (isset($config[$key])) { diff --git a/Tests/Service/OmnipayTest.php b/Tests/Service/OmnipayTest.php index e9afc83..176b79c 100644 --- a/Tests/Service/OmnipayTest.php +++ b/Tests/Service/OmnipayTest.php @@ -2,18 +2,34 @@ namespace Xola\OmnipayBundle\Tests\Service; -use Guzzle\Log\MessageFormatter; +use Omnipay\AuthorizeNet\AIMGateway; +use Omnipay\AuthorizeNet\SIMGateway; +use Omnipay\Eway\RapidGateway; +use Omnipay\Mollie\Gateway as MollieGateway; +use Omnipay\PaymentExpress\PxPayGateway; +use Omnipay\PaymentExpress\PxPostGateway; +use Omnipay\PayPal\ExpressGateway; +use Omnipay\PayPal\ProGateway; +use Omnipay\SagePay\DirectGateway as SagePayDirectGateway; +use Omnipay\SagePay\ServerGateway as SagePayServerGateway; +use Omnipay\SecurePay\DirectPostGateway as SecurePayDirectPostGateway; use Omnipay\Stripe\Gateway as StripeGateway; -use Xola\OmnipayBundle\Service\Omnipay; +use Omnipay\WorldPay\Gateway as WorldPayGateway; +use PHPUnit\Framework\TestCase; +use Psr\Log\LoggerInterface; +use Symfony\Component\DependencyInjection\Container; +use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface; +use Xola\OmnipayBundle\DependencyInjection\Configuration; use Xola\OmnipayBundle\DependencyInjection\OmnipayExtension; +use Xola\OmnipayBundle\Service\Omnipay; -class OmnipayTest extends \PHPUnit_Framework_TestCase +class OmnipayTest extends TestCase { private function buildService($params = array()) { $defaults = array( - 'container' => $this->getMock('Symfony\Component\DependencyInjection\Container'), - 'logger' => $this->getMock('Psr\Log\LoggerInterface') + 'container' => $this->createMock(Container::class), + 'logger' => $this->createMock(LoggerInterface::class) ); $params = array_merge($defaults, $params); @@ -24,19 +40,19 @@ private function buildService($params = array()) /** * @param array $params * - * @return \Symfony\Component\DependencyInjection\Container + * @return Container */ private function getServiceContainer($params) { - $params['omnipay.log.format'] = MessageFormatter::DEBUG_FORMAT; - $parameterBag = $this->getMock('Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface'); + $params['omnipay.log.format'] = Configuration::DEBUG_FORMAT; + $parameterBag = $this->createMock(ParameterBagInterface::class); $parameterBag ->expects($this->any()) ->method('all') ->will($this->returnValue($params)); - $serviceContainer = $this->getMock('Symfony\Component\DependencyInjection\Container'); + $serviceContainer = $this->createMock(Container::class); $serviceContainer ->expects($this->once()) @@ -48,13 +64,6 @@ private function getServiceContainer($params) public function testCreateAuthorizeNetAIM() { - // Do not run test if Gateway has not been included - if (!class_exists('Omnipay\\AuthorizeNet\\AIMGateway')) { - $this->markTestSkipped('Gateway Omnipay\\AuthorizeNet\\AIMGateway not found'); - - return; - } - $config = array( 'omnipay.authorize_net_aim.apiLoginId' => 'abc123', 'omnipay.authorize_net_aim.transactionKey' => 'xyz987', @@ -63,26 +72,16 @@ public function testCreateAuthorizeNetAIM() $service = $this->buildService(array('container' => $this->getServiceContainer($config))); - /** @var \Omnipay\AuthorizeNet\AIMGateway $gateway */ + /** @var AIMGateway $gateway */ $gateway = $service->get('authorize_net_aim'); - $this->assertInstanceOf( - 'Omnipay\\AuthorizeNet\\AIMGateway', - $gateway, - 'Must return an Authorize.NET AIM gateway' - ); + $this->assertInstanceOf(AIMGateway::class, $gateway, 'Must return an Authorize.NET AIM gateway'); $this->assertEquals('abc123', $gateway->getApiLoginId(), 'API login ID must match configuration'); $this->assertEquals('xyz987', $gateway->getTransactionKey(), 'Transaction key must match configuration'); } public function testCreateAuthorizeNetSIM() { - if (!class_exists('Omnipay\\AuthorizeNet\\SIMGateway')) { - $this->markTestSkipped('Gateway Omnipay\\AuthorizeNet\\SIMGateway not found'); - - return; - } - $config = array( 'omnipay.authorize_net_sim.apiLoginId' => 'abc123', 'omnipay.authorize_net_sim.transactionKey' => 'xyz987', @@ -91,74 +90,16 @@ public function testCreateAuthorizeNetSIM() $service = $this->buildService(array('container' => $this->getServiceContainer($config))); - /** @var \Omnipay\AuthorizeNet\AIMGateway $gateway */ + /** @var AIMGateway $gateway */ $gateway = $service->get('authorize_net_sim'); - $this->assertInstanceOf( - 'Omnipay\\AuthorizeNet\\SIMGateway', - $gateway, - 'Must return an Authorize.NET SIM gateway' - ); + $this->assertInstanceOf(SIMGateway::class, $gateway, 'Must return an Authorize.NET SIM gateway'); $this->assertEquals('abc123', $gateway->getApiLoginId(), 'API login ID must match configuration'); $this->assertEquals('xyz987', $gateway->getTransactionKey(), 'Transaction key must match configuration'); } - public function testCreateBuckaroo() - { - if (!class_exists('Omnipay\\Buckaroo\\Gateway')) { - $this->markTestSkipped('Gateway Omnipay\\Buckaroo\\Gateway not found'); - - return; - } - - $config = array( - 'omnipay.buckaroo.merchantId' => 'abc123', - 'omnipay.buckaroo.secret' => 'xyz987', - 'omnipay.buckaroo.gateway' => 'Buckaroo', - ); - - $service = $this->buildService(array('container' => $this->getServiceContainer($config))); - - /** @var \Omnipay\Buckaroo\Gateway $gateway */ - $gateway = $service->get('buckaroo'); - - $this->assertInstanceOf('Omnipay\\Buckaroo\\Gateway', $gateway, 'Must return a Buckaroo gateway'); - $this->assertEquals('abc123', $gateway->getMerchantId(), 'Merchant ID must match configuration'); - $this->assertEquals('xyz987', $gateway->getSecret(), 'Secret must match configuration'); - } - - public function testCreateCardSave() - { - if (!class_exists('Omnipay\\CardSave\\Gateway')) { - $this->markTestSkipped('Gateway Omnipay\\CardSave\\Gateway not found'); - - return; - } - - $config = array( - 'omnipay.card_save.merchantId' => 'abc123', - 'omnipay.card_save.password' => 'xyz987', - 'omnipay.card_save.gateway' => 'CardSave', - ); - - $service = $this->buildService(array('container' => $this->getServiceContainer($config))); - - /** @var \Omnipay\CardSave\Gateway $gateway */ - $gateway = $service->get('card_save'); - - $this->assertInstanceOf('Omnipay\\CardSave\\Gateway', $gateway, 'Must return a CardSave gateway'); - $this->assertEquals('abc123', $gateway->getMerchantId(), 'Merchant ID must match configuration'); - $this->assertEquals('xyz987', $gateway->getPassword(), 'Password must match configuration'); - } - public function testCreateEwayRapid() { - if (!class_exists('Omnipay\\Eway\\RapidGateway')) { - $this->markTestSkipped('Gateway Omnipay\\Eway\\RapidGateway not found'); - - return; - } - $config = array( 'omnipay.eway_rapid.apiKey' => 'abc123', 'omnipay.eway_rapid.password' => 'xyz987', @@ -167,110 +108,16 @@ public function testCreateEwayRapid() $service = $this->buildService(array('container' => $this->getServiceContainer($config))); - /** @var \Omnipay\Eway\RapidGateway $gateway */ + /** @var RapidGateway $gateway */ $gateway = $service->get('eway_rapid'); - $this->assertInstanceOf('Omnipay\\Eway\\RapidGateway', $gateway, 'Must return an eWAY Rapid gateway'); + $this->assertInstanceOf(RapidGateway::class, $gateway, 'Must return an eWAY Rapid gateway'); $this->assertEquals('abc123', $gateway->getApiKey(), 'API key must match configuration'); $this->assertEquals('xyz987', $gateway->getPassword(), 'Password must match configuration'); } - public function testCreateGoCardless() - { - if (!class_exists('Omnipay\\GoCardless\\Gateway')) { - $this->markTestSkipped('Gateway Omnipay\\GoCardless\\Gateway not found'); - - return; - } - - $config = array( - 'omnipay.go_cardless.appId' => 'abc123', - 'omnipay.go_cardless.appSecret' => 'xyz987', - 'omnipay.go_cardless.merchantId' => 'pqr567', - 'omnipay.go_cardless.accessToken' => 'uvw543', - 'omnipay.go_cardless.gateway' => 'GoCardless', - ); - - $service = $this->buildService(array('container' => $this->getServiceContainer($config))); - - /** @var \Omnipay\GoCardless\Gateway $gateway */ - $gateway = $service->get('go_cardless'); - - $this->assertInstanceOf('Omnipay\\GoCardless\\Gateway', $gateway, 'Must return a GoCardless gateway'); - $this->assertEquals('abc123', $gateway->getAppId(), 'App ID must match configuration'); - $this->assertEquals('xyz987', $gateway->getAppSecret(), 'App secret must match configuration'); - $this->assertEquals('pqr567', $gateway->getMerchantId(), 'Merchant ID must match configuration'); - $this->assertEquals('uvw543', $gateway->getAccessToken(), 'Access token must match configuration'); - } - - public function testCreateMigsTwoParty() - { - if (!class_exists('Omnipay\\Migs\\TwoPartyGateway')) { - $this->markTestSkipped('Gateway Omnipay\\Migs\\TwoPartyGateway not found'); - - return; - } - - $config = array( - 'omnipay.migs_two_party.merchantId' => 'abc123', - 'omnipay.migs_two_party.merchantAccessCode' => 'xyz987', - 'omnipay.migs_two_party.secureHash' => 'pqr567', - 'omnipay.migs_two_party.gateway' => 'Migs_TwoParty', - ); - - $service = $this->buildService(array('container' => $this->getServiceContainer($config))); - - /** @var \Omnipay\Migs\TwoPartyGateway $gateway */ - $gateway = $service->get('migs_two_party'); - - $this->assertInstanceOf('Omnipay\\Migs\\TwoPartyGateway', $gateway, 'Must return a MIGS 2-Party gateway'); - $this->assertEquals('abc123', $gateway->getMerchantId(), 'Merchant ID must match configuration'); - $this->assertEquals( - 'xyz987', - $gateway->getMerchantAccessCode(), - 'Merchant access code must match configuration' - ); - $this->assertEquals('pqr567', $gateway->getSecureHash(), 'Secure hash must match configuration'); - } - - public function testCreateMigsThreeParty() - { - if (!class_exists('Omnipay\\Migs\\ThreePartyGateway')) { - $this->markTestSkipped('Gateway Omnipay\\Migs\\ThreePartyGateway not found'); - - return; - } - - $config = array( - 'omnipay.migs_three_party.merchantId' => 'abc123', - 'omnipay.migs_three_party.merchantAccessCode' => 'xyz987', - 'omnipay.migs_three_party.secureHash' => 'pqr567', - 'omnipay.migs_three_party.gateway' => 'Migs_ThreeParty', - ); - - $service = $this->buildService(array('container' => $this->getServiceContainer($config))); - - /** @var \Omnipay\Migs\ThreePartyGateway $gateway */ - $gateway = $service->get('migs_three_party'); - - $this->assertInstanceOf('Omnipay\\Migs\\ThreePartyGateway', $gateway, 'Must return a MIGS 3-Party gateway'); - $this->assertEquals('abc123', $gateway->getMerchantId(), 'Merchant ID must match configuration'); - $this->assertEquals( - 'xyz987', - $gateway->getMerchantAccessCode(), - 'Merchant access code must match configuration' - ); - $this->assertEquals('pqr567', $gateway->getSecureHash(), 'Secure hash must match configuration'); - } - public function testCreateMollie() { - if (!class_exists('Omnipay\\Mollie\\Gateway')) { - $this->markTestSkipped('Gateway Omnipay\\Mollie\\Gateway not found'); - - return; - } - $config = array( 'omnipay.mollie.apiKey' => 'fooBar', 'omnipay.mollie.gateway' => 'Mollie', @@ -278,151 +125,15 @@ public function testCreateMollie() $service = $this->buildService(array('container' => $this->getServiceContainer($config))); - /** @var \Omnipay\Mollie\Gateway $gateway */ + /** @var MollieGateway $gateway */ $gateway = $service->get('mollie'); - $this->assertInstanceOf('Omnipay\\Mollie\\Gateway', $gateway, 'Must return a Mollie gateway'); + $this->assertInstanceOf(MollieGateway::class, $gateway, 'Must return a Mollie gateway'); $this->assertEquals('fooBar', $gateway->getApiKey(), 'apiKey must match configuration'); } - public function testCreateMultiSafepay() - { - if (!class_exists('Omnipay\\MultiSafepay\\Gateway')) { - $this->markTestSkipped('Gateway Omnipay\\MultiSafepay\\Gateway not found'); - - return; - } - - $config = array( - 'omnipay.multi_safepay.accountId' => 'abc123', - 'omnipay.multi_safepay.siteId' => 'xyz987', - 'omnipay.multi_safepay.siteCode' => 'pqr567', - 'omnipay.multi_safepay.gateway' => 'MultiSafepay', - ); - - $service = $this->buildService(array('container' => $this->getServiceContainer($config))); - - /** @var \Omnipay\MultiSafepay\Gateway $gateway */ - $gateway = $service->get('multi_safepay'); - - $this->assertInstanceOf('Omnipay\\MultiSafepay\\Gateway', $gateway, 'Must return a MultiSafepay gateway'); - $this->assertEquals('abc123', $gateway->getAccountId(), 'Account ID must match configuration'); - $this->assertEquals('xyz987', $gateway->getSiteId(), 'Site ID must match configuration'); - $this->assertEquals('pqr567', $gateway->getSiteCode(), 'Site code must match configuration'); - } - - public function testCreateNetaxept() - { - if (!class_exists('Omnipay\\Netaxept\\Gateway')) { - $this->markTestSkipped('Gateway Omnipay\\Netaxept\\Gateway not found'); - - return; - } - - $config = array( - 'omnipay.netaxept.merchantId' => 'abc123', - 'omnipay.netaxept.password' => 'xyz987', - 'omnipay.netaxept.gateway' => 'Netaxept', - ); - - $service = $this->buildService(array('container' => $this->getServiceContainer($config))); - - /** @var \Omnipay\Netaxept\Gateway $gateway */ - $gateway = $service->get('netaxept'); - - $this->assertInstanceOf('Omnipay\\Netaxept\\Gateway', $gateway, 'Must return a Netaxept gateway'); - $this->assertEquals('abc123', $gateway->getMerchantId(), 'Merchant ID must match configuration'); - $this->assertEquals('xyz987', $gateway->getPassword(), 'Password must match configuration'); - } - - public function testCreateNetBanx() - { - if (!class_exists('Omnipay\\NetBanx\\Gateway')) { - $this->markTestSkipped('Gateway Omnipay\\NetBanx\\Gateway not found'); - - return; - } - - $config = array( - 'omnipay.net_banx.accountNumber' => 'abc123', - 'omnipay.net_banx.storeId' => 'xyz987', - 'omnipay.net_banx.storePassword' => 'pqr567', - 'omnipay.net_banx.gateway' => 'NetBanx', - ); - - $service = $this->buildService(array('container' => $this->getServiceContainer($config))); - - /** @var \Omnipay\NetBanx\Gateway $gateway */ - $gateway = $service->get('net_banx'); - - $this->assertInstanceOf('Omnipay\\NetBanx\\Gateway', $gateway, 'Must return a NetBanx gateway'); - $this->assertEquals('abc123', $gateway->getAccountNumber(), 'Account number must match configuration'); - $this->assertEquals('xyz987', $gateway->getStoreId(), 'Store ID must match configuration'); - $this->assertEquals('pqr567', $gateway->getStorePassword(), 'Store password must match configuration'); - } - - public function testCreatePayFast() - { - if (!class_exists('Omnipay\\PayFast\\Gateway')) { - $this->markTestSkipped('Gateway Omnipay\\PayFast\\Gateway not found'); - - return; - } - - $config = array( - 'omnipay.pay_fast.merchantId' => 'abc123', - 'omnipay.pay_fast.merchantKey' => 'xyz987', - 'omnipay.pay_fast.pdtKey' => 'pqr567', - 'omnipay.pay_fast.gateway' => 'PayFast', - ); - - $service = $this->buildService(array('container' => $this->getServiceContainer($config))); - - /** @var \Omnipay\PayFast\Gateway $gateway */ - $gateway = $service->get('pay_fast'); - - $this->assertInstanceOf('Omnipay\\PayFast\\Gateway', $gateway, 'Must return a PayFast gateway'); - $this->assertEquals('abc123', $gateway->getMerchantId(), 'Merchant ID must match configuration'); - $this->assertEquals('xyz987', $gateway->getMerchantKey(), 'Merchant key must match configuration'); - $this->assertEquals('pqr567', $gateway->getPdtKey(), 'PDT key must match configuration'); - } - - public function testCreatePayflow() - { - if (!class_exists('Omnipay\\Payflow\\ProGateway')) { - $this->markTestSkipped('Gateway Omnipay\\Payflow\\ProGateway not found'); - - return; - } - - $config = array( - 'omnipay.payflow_pro.username' => 'abc123', - 'omnipay.payflow_pro.password' => 'xyz987', - 'omnipay.payflow_pro.vendor' => 'pqr567', - 'omnipay.payflow_pro.partner' => 'uvw543', - 'omnipay.payflow_pro.gateway' => 'Payflow_Pro', - ); - - $service = $this->buildService(array('container' => $this->getServiceContainer($config))); - - /** @var \Omnipay\Payflow\ProGateway $gateway */ - $gateway = $service->get('payflow_pro'); - - $this->assertInstanceOf('Omnipay\\Payflow\\ProGateway', $gateway, 'Must return a Payflow Pro gateway'); - $this->assertEquals('abc123', $gateway->getUsername(), 'Username must match configuration'); - $this->assertEquals('xyz987', $gateway->getPassword(), 'Password must match configuration'); - $this->assertEquals('pqr567', $gateway->getVendor(), 'Vendor must match configuration'); - $this->assertEquals('uvw543', $gateway->getPartner(), 'Partner must match configuration'); - } - public function testCreatePaymentExpressPxPay() { - if (!class_exists('Omnipay\\PaymentExpress\\PxPayGateway')) { - $this->markTestSkipped('Gateway Omnipay\\PaymentExpress\\PxPayGateway not found'); - - return; - } - $config = array( 'omnipay.payment_express_px_pay.username' => 'abc123', 'omnipay.payment_express_px_pay.password' => 'xyz987', @@ -431,26 +142,16 @@ public function testCreatePaymentExpressPxPay() $service = $this->buildService(array('container' => $this->getServiceContainer($config))); - /** @var \Omnipay\PaymentExpress\PxPayGateway $gateway */ + /** @var PxPayGateway $gateway */ $gateway = $service->get('payment_express_px_pay'); - $this->assertInstanceOf( - 'Omnipay\\PaymentExpress\\PxPayGateway', - $gateway, - 'Must return a PaymentExpress PxPay gateway' - ); + $this->assertInstanceOf(PxPayGateway::class, $gateway, 'Must return a PaymentExpress PxPay gateway'); $this->assertEquals('abc123', $gateway->getUsername(), 'Username must match configuration'); $this->assertEquals('xyz987', $gateway->getPassword(), 'Password must match configuration'); } public function testCreatePaymentExpressPxPost() { - if (!class_exists('Omnipay\\PaymentExpress\\PxPostGateway')) { - $this->markTestSkipped('Gateway Omnipay\\PaymentExpress\\PxPostGateway not found'); - - return; - } - $config = array( 'omnipay.payment_express_px_post.username' => 'abc123', 'omnipay.payment_express_px_post.password' => 'xyz987', @@ -459,26 +160,16 @@ public function testCreatePaymentExpressPxPost() $service = $this->buildService(array('container' => $this->getServiceContainer($config))); - /** @var \Omnipay\PaymentExpress\PxPostGateway $gateway */ + /** @var PxPostGateway $gateway */ $gateway = $service->get('payment_express_px_post'); - $this->assertInstanceOf( - 'Omnipay\\PaymentExpress\\PxPostGateway', - $gateway, - 'Must return a PaymentExpress PxPost gateway' - ); + $this->assertInstanceOf(PxPostGateway::class, $gateway, 'Must return a PaymentExpress PxPost gateway'); $this->assertEquals('abc123', $gateway->getUsername(), 'Username must match configuration'); $this->assertEquals('xyz987', $gateway->getPassword(), 'Password must match configuration'); } public function testCreatePayPalPro() { - if (!class_exists('Omnipay\\PayPal\\ProGateway')) { - $this->markTestSkipped('Gateway Omnipay\\PayPal\\ProGateway not found'); - - return; - } - $config = array( 'omnipay.pay_pal_pro.username' => 'abc123', 'omnipay.pay_pal_pro.password' => 'xyz987', @@ -488,10 +179,10 @@ public function testCreatePayPalPro() $service = $this->buildService(array('container' => $this->getServiceContainer($config))); - /** @var \Omnipay\PayPal\ProGateway $gateway */ + /** @var ProGateway $gateway */ $gateway = $service->get('pay_pal_pro'); - $this->assertInstanceOf('Omnipay\\PayPal\\ProGateway', $gateway, 'Must return a PayPal Pro gateway'); + $this->assertInstanceOf(ProGateway::class, $gateway, 'Must return a PayPal Pro gateway'); $this->assertEquals('abc123', $gateway->getUsername(), 'Username must match configuration'); $this->assertEquals('xyz987', $gateway->getPassword(), 'Password must match configuration'); $this->assertEquals('pqr567', $gateway->getSignature(), 'Signature must match configuration'); @@ -499,12 +190,6 @@ public function testCreatePayPalPro() public function testCreatePayPalExpress() { - if (!class_exists('Omnipay\\PayPal\\ExpressGateway')) { - $this->markTestSkipped('Gateway Omnipay\\PayPal\\ExpressGateway not found'); - - return; - } - $config = array( 'omnipay.pay_pal_express.username' => 'abc123', 'omnipay.pay_pal_express.password' => 'xyz987', @@ -517,10 +202,10 @@ public function testCreatePayPalExpress() $service = $this->buildService(array('container' => $this->getServiceContainer($config))); - /** @var \Omnipay\PayPal\ExpressGateway $gateway */ + /** @var ExpressGateway $gateway */ $gateway = $service->get('pay_pal_express'); - $this->assertInstanceOf('Omnipay\\PayPal\\ExpressGateway', $gateway, 'Must return a PayPal Express gateway'); + $this->assertInstanceOf(ExpressGateway::class, $gateway, 'Must return a PayPal Express gateway'); $this->assertEquals('abc123', $gateway->getUsername(), 'Username must match configuration'); $this->assertEquals('xyz987', $gateway->getPassword(), 'Password must match configuration'); $this->assertEquals('pqr567', $gateway->getSignature(), 'Signature must match configuration'); @@ -529,36 +214,8 @@ public function testCreatePayPalExpress() $this->assertEquals('uvw543', $gateway->getHeaderImageUrl(), 'Header image URL must match configuration'); } - public function testCreatePin() - { - if (!class_exists('Omnipay\\Pin\\Gateway')) { - $this->markTestSkipped('Gateway Omnipay\\Pin\\Gateway not found'); - - return; - } - - $config = array( - 'omnipay.pin.secretKey' => 'abc123', - 'omnipay.pin.gateway' => 'Pin' - ); - - $service = $this->buildService(array('container' => $this->getServiceContainer($config))); - - /** @var \Omnipay\Pin\Gateway $gateway */ - $gateway = $service->get('pin'); - - $this->assertInstanceOf('Omnipay\\Pin\\Gateway', $gateway, 'Must return a Pin gateway'); - $this->assertEquals('abc123', $gateway->getSecretKey(), 'API key must match configuration'); - } - public function testCreateSagePayDirect() { - if (!class_exists('Omnipay\\SagePay\\DirectGateway')) { - $this->markTestSkipped('Gateway Omnipay\\SagePay\\DirectGateway not found'); - - return; - } - $config = array( 'omnipay.sage_pay_direct.vendor' => 'abc123', 'omnipay.sage_pay_direct.gateway' => 'SagePay_Direct' @@ -566,21 +223,15 @@ public function testCreateSagePayDirect() $service = $this->buildService(array('container' => $this->getServiceContainer($config))); - /** @var \Omnipay\SagePay\DirectGateway $gateway */ + /** @var SagePayDirectGateway $gateway */ $gateway = $service->get('sage_pay_direct'); - $this->assertInstanceOf('Omnipay\\SagePay\\DirectGateway', $gateway, 'Must return a SagePay Direct gateway'); + $this->assertInstanceOf(SagePayDirectGateway::class, $gateway, 'Must return a SagePay Direct gateway'); $this->assertEquals('abc123', $gateway->getVendor(), 'Vendor must match configuration'); } public function testCreateSagePayServer() { - if (!class_exists('Omnipay\\SagePay\\ServerGateway')) { - $this->markTestSkipped('Gateway Omnipay\\SagePay\\ServerGateway not found'); - - return; - } - $config = array( 'omnipay.sage_pay_server.vendor' => 'abc123', 'omnipay.sage_pay_server.gateway' => 'SagePay_Server', @@ -588,21 +239,15 @@ public function testCreateSagePayServer() $service = $this->buildService(array('container' => $this->getServiceContainer($config))); - /** @var \Omnipay\SagePay\ServerGateway $gateway */ + /** @var SagePayServerGateway $gateway */ $gateway = $service->get('sage_pay_server'); - $this->assertInstanceOf('Omnipay\\SagePay\\ServerGateway', $gateway, 'Must return a SagePay Server gateway'); + $this->assertInstanceOf(SagePayServerGateway::class, $gateway, 'Must return a SagePay Server gateway'); $this->assertEquals('abc123', $gateway->getVendor(), 'Vendor must match configuration'); } public function testCreateSecurePayDirectPost() { - if (!class_exists('Omnipay\\SecurePay\\DirectPostGateway')) { - $this->markTestSkipped('Gateway Omnipay\\SecurePay\\DirectPostGateway not found'); - - return; - } - $config = array( 'omnipay.secure_pay_direct_post.merchantId' => 'abc123', 'omnipay.secure_pay_direct_post.transactionPassword' => 'xyz987', @@ -611,14 +256,10 @@ public function testCreateSecurePayDirectPost() $service = $this->buildService(array('container' => $this->getServiceContainer($config))); - /** @var \Omnipay\SecurePay\DirectPostGateway $gateway */ + /** @var SecurePayDirectPostGateway $gateway */ $gateway = $service->get('secure_pay_direct_post'); - $this->assertInstanceOf( - 'Omnipay\\SecurePay\\DirectPostGateway', - $gateway, - 'Must return a SecurePay Direct Post gateway' - ); + $this->assertInstanceOf(SecurePayDirectPostGateway::class, $gateway, 'Must return a SecurePay Direct Post gateway'); $this->assertEquals('abc123', $gateway->getMerchantId(), 'Merchant ID must match configuration'); $this->assertEquals( 'xyz987', @@ -629,12 +270,6 @@ public function testCreateSecurePayDirectPost() public function testCreateStripe() { - if (!class_exists('Omnipay\\Stripe\\Gateway')) { - $this->markTestSkipped('Gateway Omnipay\\Stripe\\Gateway not found'); - - return; - } - $config = array( 'omnipay.stripe.apiKey' => 'abc123', 'omnipay.stripe.gateway' => 'Stripe' @@ -642,45 +277,15 @@ public function testCreateStripe() $service = $this->buildService(array('container' => $this->getServiceContainer($config))); - /** @var \Omnipay\Stripe\Gateway $gateway */ + /** @var StripeGateway $gateway */ $gateway = $service->get('stripe'); - $this->assertInstanceOf('Omnipay\\Stripe\\Gateway', $gateway, 'Must return a Stripe gateway'); + $this->assertInstanceOf(StripeGateway::class, $gateway, 'Must return a Stripe gateway'); $this->assertEquals('abc123', $gateway->getApiKey(), 'API key must match configuration'); } - public function testCreateTwoCheckout() - { - if (!class_exists('Omnipay\\TwoCheckout\\Gateway')) { - $this->markTestSkipped('Gateway Omnipay\\TwoCheckout\\Gateway not found'); - - return; - } - - $config = array( - 'omnipay.two_checkout.accountNumber' => 'abc123', - 'omnipay.two_checkout.secretWord' => 'xyz987', - 'omnipay.two_checkout.gateway' => 'TwoCheckout', - ); - - $service = $this->buildService(array('container' => $this->getServiceContainer($config))); - - /** @var \Omnipay\TwoCheckout\Gateway $gateway */ - $gateway = $service->get('two_checkout'); - - $this->assertInstanceOf('Omnipay\\TwoCheckout\\Gateway', $gateway, 'Must return a TwoCheckout gateway'); - $this->assertEquals('abc123', $gateway->getAccountNumber(), 'Account number must match configuration'); - $this->assertEquals('xyz987', $gateway->getSecretWord(), 'Secret word must match configuration'); - } - public function testCreateWorldPay() { - if (!class_exists('Omnipay\\WorldPay\\Gateway')) { - $this->markTestSkipped('Gateway Omnipay\\WorldPay\\Gateway not found'); - - return; - } - $config = array( 'omnipay.world_pay.installationId' => 'abc123', 'omnipay.world_pay.secretWord' => 'xyz987', @@ -690,10 +295,10 @@ public function testCreateWorldPay() $service = $this->buildService(array('container' => $this->getServiceContainer($config))); - /** @var \Omnipay\WorldPay\Gateway $gateway */ + /** @var WorldPayGateway $gateway */ $gateway = $service->get('world_pay'); - $this->assertInstanceOf('Omnipay\\WorldPay\\Gateway', $gateway, 'Must return a WorldPay gateway'); + $this->assertInstanceOf(WorldPayGateway::class, $gateway, 'Must return a WorldPay gateway'); $this->assertEquals('abc123', $gateway->getInstallationId(), 'Installation ID must match configuration'); $this->assertEquals('xyz987', $gateway->getSecretWord(), 'Secret word must match configuration'); $this->assertEquals('pqr567', $gateway->getCallbackPassword(), 'Callback password must match configuration'); @@ -712,7 +317,7 @@ public function testGetConfig() $expected = array( 'log' => array( - 'format' => MessageFormatter::DEBUG_FORMAT + 'format' => Configuration::DEBUG_FORMAT ), 'world_pay' => array( 'installationId' => 'abc123', @@ -812,7 +417,7 @@ public function testDefaultBundleConfig() $containerBuilder ->expects($this->at(0)) // Values get set before YAML config is loaded ->method('setParameter') - ->with('omnipay.log.format', MessageFormatter::DEBUG_FORMAT); + ->with('omnipay.log.format', Configuration::DEBUG_FORMAT); $extension = new OmnipayExtension(); $extension->load(array(), $containerBuilder); diff --git a/composer.json b/composer.json index 421ddb8..77ec074 100644 --- a/composer.json +++ b/composer.json @@ -1,32 +1,34 @@ { "name": "xola/omnipay-bundle", "type": "symfony-bundle", - "description": "Integrates Omnipay with Symfony2", - "keywords": ["omnipay", "payment", "credit card", "gateway", "symfony"], + "description": "Integrates Omnipay 3 with Symfony 2+", + "keywords": [ + "omnipay", + "payment", + "credit card", + "gateway", + "symfony" + ], "homepage": "https://github.com/xola/OmnipayBundle", "license": "MIT", - "authors": [ - { - "name": "Anush Ramani", - "email": "anush@xola.com" - }, - { - "name": "Venkata Krishna Kotra", - "email": "kotrakrishna@gmail.com" - } - ], "require": { - "php": ">=5.3.2", - "symfony/framework-bundle": "~2.1", - "omnipay/common": "~2.0", - "guzzle/http": "~3.7", - "guzzle/plugin": "~3.7", - "guzzle/log": "~3.7", - "psr/log": "1.0" + "php": ">=7", + "symfony/framework-bundle": ">=2.1 <4.0", + "league/omnipay": "^3.0", + "php-http/logger-plugin": "^1.1" }, "require-dev": { - "omnipay/omnipay": "~2.0", - "phpunit/phpunit": "~4.5" + "phpunit/phpunit": "^6", + "omnipay/authorizenet": "^3.3", + "omnipay/eway": "^3.0", + "omnipay/mollie": "^5.2", + "omnipay/paymentexpress": "^3.0", + "omnipay/paypal": "^3.0", + "omnipay/sagepay": "^3.2", + "omnipay/securepay": "^3.0", + "omnipay/stripe": "^3.1", + "omnipay/worldpay": "^3.0", + "symfony/yaml": "^3.4" }, "autoload": { "psr-0": {