Skip to content

Commit

Permalink
Merge pull request #1 from dpfaffenbauer/master
Browse files Browse the repository at this point in the history
Rename namespaces to OmnipayV3Bridge and refactoring to support Omnipay 3.0
  • Loading branch information
makasim authored Sep 1, 2017
2 parents d1a36d5 + 33934fa commit ff7d75f
Show file tree
Hide file tree
Showing 26 changed files with 70 additions and 392 deletions.
3 changes: 2 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
language: php

php:
- 5.5
- 5.6
- 7.0
- 7.1
- hhvm
- nightly

Expand Down
19 changes: 11 additions & 8 deletions composer.json
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"name": "payum/omnipay-bridge",
"name": "payum/omnipay-v3-bridge",
"type": "library",
"description": "This bridge allows you to use omnipay gateways but in payum like way.",
"description": "This bridge allows you to use omnipay gateways but in payum like way.",
"keywords": ["payment", "omnipay"],
"homepage": "https://github.com/Payum/OmnipayBridge",
"homepage": "https://github.com/Payum/OmnipayV3Bridge",
"license": "MIT",
"authors": [
{
Expand All @@ -22,24 +22,27 @@
"require": {
"php": ">=5.5.0",
"payum/core": "^1.3",
"omnipay/common": "^2.3"
"omnipay/common": "^3.0@alpha",
"php-http/guzzle6-adapter": "^1.1"
},
"require-dev": {
"phpunit/phpunit": "^4",
"omnipay/dummy": "^2"
"omnipay/dummy": "^3.0@alpha"
},
"config": {
"bin-dir": "bin"
},
"autoload": {
"psr-4": { "Payum\\OmnipayBridge\\": "src" }
"psr-4": { "Payum\\OmnipayV3Bridge\\": "src" }
},
"autoload-dev": {
"psr-4": { "Payum\\OmnipayBridge\\Tests\\": "tests" }
"psr-4": { "Payum\\OmnipayV3Bridge\\Tests\\": "tests" }
},
"extra": {
"branch-alias": {
"dev-master": "1.0-dev"
}
}
},
"minimum-stability": "dev",
"prefer-stable": true
}
2 changes: 1 addition & 1 deletion src/Action/BaseApiAwareAction.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?php
namespace Payum\OmnipayBridge\Action;
namespace Payum\OmnipayV3Bridge\Action;

use Omnipay\Common\GatewayInterface;

Expand Down
2 changes: 1 addition & 1 deletion src/Action/CaptureAction.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?php
namespace Payum\OmnipayBridge\Action;
namespace Payum\OmnipayV3Bridge\Action;

use Payum\Core\Bridge\Spl\ArrayObject;
use Payum\Core\Exception\LogicException;
Expand Down
2 changes: 1 addition & 1 deletion src/Action/ConvertPaymentAction.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?php
namespace Payum\OmnipayBridge\Action;
namespace Payum\OmnipayV3Bridge\Action;

use Payum\Core\Action\GatewayAwareAction;
use Payum\Core\Exception\RequestNotSupportedException;
Expand Down
2 changes: 1 addition & 1 deletion src/Action/NotifyAction.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Payum\OmnipayBridge\Action;
namespace Payum\OmnipayV3Bridge\Action;

use Omnipay\Common\GatewayInterface;
use Payum\Core\Action\ActionInterface;
Expand Down
2 changes: 1 addition & 1 deletion src/Action/OffsiteCaptureAction.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?php
namespace Payum\OmnipayBridge\Action;
namespace Payum\OmnipayV3Bridge\Action;

use Payum\Core\Bridge\Spl\ArrayObject;
use Payum\Core\Exception\RequestNotSupportedException;
Expand Down
2 changes: 1 addition & 1 deletion src/Action/StatusAction.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?php
namespace Payum\OmnipayBridge\Action;
namespace Payum\OmnipayV3Bridge\Action;

use Payum\Core\Action\ActionInterface;
use Payum\Core\Bridge\Spl\ArrayObject;
Expand Down
19 changes: 0 additions & 19 deletions src/OmnipayDirectGatewayFactory.php

This file was deleted.

30 changes: 9 additions & 21 deletions src/OmnipayGatewayFactory.php
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?php
namespace Payum\OmnipayBridge;
namespace Payum\OmnipayV3Bridge;

use Omnipay\Common\Exception\OmnipayException;
use Omnipay\Common\GatewayFactory as OmnipayOmnipayGatewayFactory;
Expand All @@ -9,19 +9,14 @@
use Payum\Core\Exception\LogicException;
use Payum\Core\GatewayFactory;
use Payum\Core\GatewayFactoryInterface;
use Payum\OmnipayBridge\Action\CaptureAction;
use Payum\OmnipayBridge\Action\ConvertPaymentAction;
use Payum\OmnipayBridge\Action\NotifyAction;
use Payum\OmnipayBridge\Action\OffsiteCaptureAction;
use Payum\OmnipayBridge\Action\StatusAction;
use Payum\OmnipayV3Bridge\Action\CaptureAction;
use Payum\OmnipayV3Bridge\Action\ConvertPaymentAction;
use Payum\OmnipayV3Bridge\Action\NotifyAction;
use Payum\OmnipayV3Bridge\Action\OffsiteCaptureAction;
use Payum\OmnipayV3Bridge\Action\StatusAction;

class OmnipayGatewayFactory extends GatewayFactory
{
/**
* @var string
*/
private $omnipayGatewayTypeOrClass;

/**
* @var OmnipayOmnipayGatewayFactory|null
*/
Expand All @@ -30,14 +25,12 @@ class OmnipayGatewayFactory extends GatewayFactory
/**
* {@inheritDoc}
*
* @param string $omnipayGatewayTypeOrClass
* @param OmnipayOmnipayGatewayFactory|null $omnipayGatewayFactory
*/
public function __construct($omnipayGatewayTypeOrClass = null, OmnipayOmnipayGatewayFactory $omnipayGatewayFactory = null, array $defaultConfig = array(), GatewayFactoryInterface $coreGatewayFactory = null)
public function __construct(OmnipayOmnipayGatewayFactory $omnipayGatewayFactory = null, array $defaultConfig = array(), GatewayFactoryInterface $coreGatewayFactory = null)
{
parent::__construct($defaultConfig, $coreGatewayFactory);

$this->omnipayGatewayTypeOrClass = $omnipayGatewayTypeOrClass;
$this->omnipayGatewayFactory = $omnipayGatewayFactory ?: Omnipay::getFactory();
}

Expand All @@ -60,10 +53,6 @@ protected function populateConfig(ArrayObject $config)
$config->defaults($config['options']);
}

$config->defaults([
'type' => $this->omnipayGatewayTypeOrClass,
]);

// omnipay does not provide required options.
$config['payum.required_options'] = ['type'];

Expand All @@ -74,9 +63,8 @@ protected function populateConfig(ArrayObject $config)
$gateway = $this->omnipayGatewayFactory->create($config['type']);
} catch (OmnipayException $e) {
throw new LogicException(sprintf(
'Given omnipay gateway type %s or class is not supported. Supported: %s',
$config['type'],
implode(', ', $this->omnipayGatewayFactory->getSupportedGateways())
'Given omnipay gateway type %s or class is not supported.',
$config['type']
), 0, $e);
}

Expand Down
19 changes: 0 additions & 19 deletions src/OmnipayOffsiteGatewayFactory.php

This file was deleted.

6 changes: 4 additions & 2 deletions src/Resources/docs/get-it-started.md
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ $payum = (new PayumBuilder())
// direct payment like Stripe or Authorize.Net

->addGateway('gatewayName', [
'factory' => 'omnipay_stripe',
'factory' => 'omnipay',
'type' => 'stripe',
'username' => 'REPLACE IT',
'password' => 'REPLACE IT',
'signature' => 'REPLACE IT',
Expand All @@ -43,7 +44,8 @@ $payum = (new PayumBuilder())
// or offsite payment like Paypal ExpressCheckout

->addGateway('gatewayName', [
'factory' => 'omnipay_paypal_express',
'factory' => 'omnipay',
'type' => 'paypal_express'
'username' => 'REPLACE IT',
'password' => 'REPLACE IT',
'signature' => 'REPLACE IT',
Expand Down
2 changes: 1 addition & 1 deletion src/Resources/docs/why-should-you-use-this-bridge.md
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ use Payum\Core\Model\ArrayObject;

$payum = (new PayumBuilder())
->addDefaultStorages()
->addGateway('stripe', ['factory' => 'omnipay_stripe', 'apiKey' => 'abc123'])
->addGateway('stripe', ['factory' => 'omnipay', 'type' => 'stripe', 'apiKey' => 'abc123'])
->getPayum()
;

Expand Down
12 changes: 6 additions & 6 deletions tests/Action/BaseApiAwareActionTest.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?php
namespace Payum\OmnipayBridge\Tests\Action;
namespace Payum\OmnipayV3Bridge\Tests\Action;

class BaseApiAwareActionTest extends \PHPUnit_Framework_TestCase
{
Expand All @@ -8,7 +8,7 @@ class BaseApiAwareActionTest extends \PHPUnit_Framework_TestCase
*/
public function shouldImplementActionInterface()
{
$rc = new \ReflectionClass('Payum\OmnipayBridge\Action\BaseApiAwareAction');
$rc = new \ReflectionClass('Payum\OmnipayV3Bridge\Action\BaseApiAwareAction');

$this->assertTrue($rc->isSubclassOf('Payum\Core\Action\ActionInterface'));
}
Expand All @@ -18,7 +18,7 @@ public function shouldImplementActionInterface()
*/
public function shouldImplementApiAwareInterface()
{
$rc = new \ReflectionClass('Payum\OmnipayBridge\Action\BaseApiAwareAction');
$rc = new \ReflectionClass('Payum\OmnipayV3Bridge\Action\BaseApiAwareAction');

$this->assertTrue($rc->isSubclassOf('Payum\Core\ApiAwareInterface'));
}
Expand All @@ -28,7 +28,7 @@ public function shouldImplementApiAwareInterface()
*/
public function shouldBeAbstract()
{
$rc = new \ReflectionClass('Payum\OmnipayBridge\Action\BaseApiAwareAction');
$rc = new \ReflectionClass('Payum\OmnipayV3Bridge\Action\BaseApiAwareAction');

$this->assertTrue($rc->isAbstract());
}
Expand All @@ -40,7 +40,7 @@ public function shouldAllowSetApi()
{
$expectedApi = $this->createGatewayMock();

$action = $this->getMockForAbstractClass('Payum\OmnipayBridge\Action\BaseApiAwareAction');
$action = $this->getMockForAbstractClass('Payum\OmnipayV3Bridge\Action\BaseApiAwareAction');

$action->setApi($expectedApi);

Expand All @@ -54,7 +54,7 @@ public function shouldAllowSetApi()
*/
public function throwIfUnsupportedApiGiven()
{
$action = $this->getMockForAbstractClass('Payum\OmnipayBridge\Action\BaseApiAwareAction');
$action = $this->getMockForAbstractClass('Payum\OmnipayV3Bridge\Action\BaseApiAwareAction');

$action->setApi(new \stdClass);
}
Expand Down
10 changes: 5 additions & 5 deletions tests/Action/CaptureActionTest.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?php
namespace Payum\OmnipayBridge\Tests\Action;
namespace Payum\OmnipayV3Bridge\Tests\Action;

use Omnipay\Common\Message\AbstractResponse as OmnipayAbstractResponse;
use Omnipay\Common\Message\RequestInterface as OmnipayRequestInterface;
Expand All @@ -13,10 +13,10 @@
use Payum\Core\Security\GenericTokenFactoryAwareInterface;
use Payum\Core\Security\SensitiveValue;
use Payum\Core\Tests\GenericActionTest;
use Payum\OmnipayBridge\Action\BaseApiAwareAction;
use Payum\OmnipayBridge\Action\CaptureAction;
use Payum\OmnipayBridge\Tests\CreditCardGateway;
use Payum\OmnipayBridge\Tests\OffsiteGateway;
use Payum\OmnipayV3Bridge\Action\BaseApiAwareAction;
use Payum\OmnipayV3Bridge\Action\CaptureAction;
use Payum\OmnipayV3Bridge\Tests\CreditCardGateway;
use Payum\OmnipayV3Bridge\Tests\OffsiteGateway;

class CaptureActionTest extends GenericActionTest
{
Expand Down
6 changes: 3 additions & 3 deletions tests/Action/ConvertPaymentActionTest.php
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
<?php
namespace Payum\OmnipayBridge\Tests\Action\Api;
namespace Payum\OmnipayV3Bridge\Tests\Action\Api;

use Payum\Core\Model\CreditCard;
use Payum\Core\Request\GetCurrency;
use Payum\Core\Security\SensitiveValue;
use Payum\OmnipayBridge\Action\ConvertPaymentAction;
use Payum\OmnipayV3Bridge\Action\ConvertPaymentAction;
use Payum\Core\Model\Payment;
use Payum\Core\Request\Convert;
use Payum\Core\Tests\GenericActionTest;

class ConvertPaymentActionTest extends GenericActionTest
{
protected $actionClass = 'Payum\OmnipayBridge\Action\ConvertPaymentAction';
protected $actionClass = 'Payum\OmnipayV3Bridge\Action\ConvertPaymentAction';

protected $requestClass = 'Payum\Core\Request\Convert';

Expand Down
6 changes: 3 additions & 3 deletions tests/Action/NotifyActionTest.php
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
<?php

namespace Payum\OmnipayBridge\Tests\Action;
namespace Payum\OmnipayV3Bridge\Tests\Action;

use Omnipay\Common\Message\AbstractResponse as OmnipayAbstractResponse;
use Omnipay\Common\Message\RequestInterface as OmnipayRequestInterface;
use Omnipay\Common\Message\ResponseInterface as OmnipayResponseInterface;
use Payum\Core\Reply\HttpResponse;
use Payum\Core\Request\Notify;
use Payum\Core\Tests\GenericActionTest;
use Payum\OmnipayBridge\Action\NotifyAction;
use Payum\OmnipayBridge\Tests\OffsiteGateway;
use Payum\OmnipayV3Bridge\Action\NotifyAction;
use Payum\OmnipayV3Bridge\Tests\OffsiteGateway;

/**
* @author Steffen Brem <[email protected]>
Expand Down
10 changes: 5 additions & 5 deletions tests/Action/OffsiteCaptureActionTest.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?php
namespace Payum\OmnipayBridge\Tests\Action;
namespace Payum\OmnipayV3Bridge\Tests\Action;

use Omnipay\Common\Message\AbstractResponse as OmnipayAbstractResponse;
use Omnipay\Common\Message\RequestInterface as OmnipayRequestInterface;
Expand All @@ -12,10 +12,10 @@
use Payum\Core\Security\GenericTokenFactoryAwareInterface;
use Payum\Core\Security\GenericTokenFactoryInterface;
use Payum\Core\Tests\GenericActionTest;
use Payum\OmnipayBridge\Action\BaseApiAwareAction;
use Payum\OmnipayBridge\Action\OffsiteCaptureAction;
use Payum\OmnipayBridge\Tests\CreditCardGateway;
use Payum\OmnipayBridge\Tests\OffsiteGateway;
use Payum\OmnipayV3Bridge\Action\BaseApiAwareAction;
use Payum\OmnipayV3Bridge\Action\OffsiteCaptureAction;
use Payum\OmnipayV3Bridge\Tests\CreditCardGateway;
use Payum\OmnipayV3Bridge\Tests\OffsiteGateway;

class OffsiteCaptureActionTest extends GenericActionTest
{
Expand Down
6 changes: 3 additions & 3 deletions tests/Action/StatusActionTest.php
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
<?php
namespace Payum\OmnipayBridge\Tests\Action;
namespace Payum\OmnipayV3Bridge\Tests\Action;

use Payum\Core\Request\GetBinaryStatus;
use Payum\Core\Tests\GenericActionTest;
use Payum\OmnipayBridge\Action\StatusAction;
use Payum\OmnipayV3Bridge\Action\StatusAction;

class StatusActionTest extends GenericActionTest
{
protected $actionClass = 'Payum\OmnipayBridge\Action\StatusAction';
protected $actionClass = 'Payum\OmnipayV3Bridge\Action\StatusAction';

protected $requestClass = 'Payum\Core\Request\GetHumanStatus';

Expand Down
Loading

0 comments on commit ff7d75f

Please sign in to comment.