Skip to content

Commit

Permalink
Merge pull request #16 from Stiffel/feature/zf3-compatibility
Browse files Browse the repository at this point in the history
Upgrade modules to ZF3 compatible version.  Update unit tests to ZF3 …
  • Loading branch information
Stiffel committed Nov 26, 2016
2 parents c3b28bd + 4717140 commit 3241e69
Show file tree
Hide file tree
Showing 60 changed files with 6,130 additions and 6,217 deletions.
31 changes: 30 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Via composer
```
{
"require": {
"soliantconsulting/soliant-payment": "dev-master"
"soliantconsulting/soliant-payment": "^2.0.0" // ZF2 v1.0.1
},
"repositories": [
{
Expand All @@ -31,6 +31,24 @@ Via composer

### Usage

ZF3 v2.0.0

Add modules to modules.config.php

```
return [
'Zend\Filter',
'Zend\Hydrator',
'Zend\Router',
'Zend\Validator',
'Soliant\Payment\Base',
'Soliant\Payment\Authnet',
'Soliant\Payment\Demo', // (Optional) Access demo via /soliant-payment route
];
```

ZF2 v1.0.1

Add modules to project config/application.config.php.

```
Expand All @@ -52,6 +70,17 @@ Inject the desired payment service via factory using one of the following availa

"authorizeAndCapture" // Authorize and capture credit card or eCheck

ZF3 v2.0.0

```
public function __invoke(ContainerInterface $sm)
{
return new MyService($sm->get("[Service Alias]"));
}
```

ZF2 v1.0.1

```
public function createService(ServiceLocatorInterface $serviceLocator)
{
Expand Down
31 changes: 11 additions & 20 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,27 +20,19 @@
}
],
"require": {
"wikimedia/composer-merge-plugin": "^1.3",
"php": "^5.5 || ^7.0",
"authorizenet/authorizenet": "1.8.9",
"jms/serializer": "serializer-master-dev as 1.0",
"zendframework/zend-console": "^2.5",
"zendframework/zend-di": "^2.5",
"zendframework/zend-i18n": "^2.5",
"zendframework/zend-modulemanager": "^2.5",
"zendframework/zend-mvc": "^2.5",
"zendframework/zend-log": "^2.5",
"zendframework/zend-serializer": "^2.5",
"zendframework/zend-servicemanager": "^2.5",
"zendframework/zend-stdlib": "^2.5",
"zendframework/zend-http": "^2.5",
"zendframework/zend-version": "^2.5",
"zendframework/zend-view": "^2.5"
"php": "^5.6 || ^7.0",
"zendframework/zend-component-installer": "^1.0 || ^0.3 || ^1.0.0-dev@dev",
"zendframework/zend-filter": "^2.7.1",
"zendframework/zend-hydrator": "^2.2.1",
"zendframework/zend-mvc": "^3.0.1",
"zfcampus/zf-development-mode": "^3.0",
"authorizenet/authorizenet": "1.9.1",
"jms/serializer": "serializer-master-dev as 1.0"
},
"require-dev": {
"phpunit/phpunit": "^5.3",
"squizlabs/php_codesniffer": "^2.6",
"zendframework/zend-debug": "^2.5"
"zendframework/zend-debug": "^2.5.1"
},
"repositories": [
{
Expand All @@ -53,8 +45,7 @@
"include": [
"composer.local.json"
],
"require": [
],
"require": [],
"recurse": true,
"replace": false,
"merge-dev": true,
Expand Down Expand Up @@ -87,4 +78,4 @@
},
"minimum-stability": "dev",
"prefer-stable": true
}
}
7 changes: 0 additions & 7 deletions composer.local.json.dist

This file was deleted.

38 changes: 17 additions & 21 deletions config/application.config.php
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,12 @@
/**
* If you need an environment-specific system or application configuration,
* there is an example in the documentation
* @see http://framework.zend.com/manual/current/en/tutorials/config.advanced.html#environment-specific-system-configuration
* @see http://framework.zend.com/manual/current/en/tutorials/config.advanced.html#environment-specific-application-configuration
* @see https://docs.zendframework.com/tutorials/advanced-config/#environment-specific-system-configuration
* @see https://docs.zendframework.com/tutorials/advanced-config/#environment-specific-application-configuration
*/
return [
// This should be an array of module namespaces used in the application.
'modules' => [
'Soliant\Payment\Base',
'Soliant\Payment\Authnet',
'Soliant\Payment\Demo',
],
// Retrieve list of modules used in this application.
'modules' => require __DIR__ . '/modules.config.php',

// These are various options for the listeners attached to the ModuleManager
'module_listener_options' => [
Expand All @@ -28,27 +24,27 @@
// modules are loaded. These effectively override configuration
// provided by modules themselves. Paths may use GLOB_BRACE notation.
'config_glob_paths' => [
'config/autoload/{{,*.}global,{,*.}local}.php',
realpath(__DIR__) . '/autoload/{{,*.}global,{,*.}local}.php',
],

// Whether or not to enable a configuration cache.
// If enabled, the merged configuration will be cached and used in
// subsequent requests.
//'config_cache_enabled' => $booleanValue,
'config_cache_enabled' => true,

// The key used to create the configuration cache file name.
//'config_cache_key' => $stringKey,
'config_cache_key' => 'application.config.cache',

// Whether or not to enable a module class map cache.
// If enabled, creates a module class map cache which will be used
// by in future requests, to reduce the autoloading process.
//'module_map_cache_enabled' => $booleanValue,
'module_map_cache_enabled' => true,

// The key used to create the class map cache file name.
//'module_map_cache_key' => $stringKey,
'module_map_cache_key' => 'application.module.cache',

// The path in which to cache merged configuration.
//'cache_dir' => $stringPath,
'cache_dir' => 'data/cache/',

// Whether or not to enable modules dependency checking.
// Enabled by default, prevents usage of modules that depend on other modules
Expand All @@ -57,16 +53,16 @@
],

// Used to create an own service manager. May contain one or more child arrays.
//'service_listener_options' => array(
// array(
// 'service_listener_options' => [
// [
// 'service_manager' => $stringServiceManagerName,
// 'config_key' => $stringConfigKey,
// 'interface' => $stringOptionalInterface,
// 'method' => $stringRequiredMethodName,
// ),
// ),
// ],
// ],

// Initial configuration with which to seed the ServiceManager.
// Should be compatible with Zend\ServiceManager\Config.
// 'service_manager' => array(),
// Initial configuration with which to seed the ServiceManager.
// Should be compatible with Zend\ServiceManager\Config.
// 'service_manager' => [],
];
18 changes: 18 additions & 0 deletions config/development.config.php.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php
/**
* @link http://github.com/zendframework/ZendSkeletonApplication for the canonical source repository
* @copyright Copyright (c) 2005-2016 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/

return [
// Additional modules to include when in development mode
'modules' => [
],
// Configuration overrides during development mode
'module_listener_options' => [
'config_glob_paths' => [realpath(__DIR__) . '/autoload/{,*.}{global,local}-development.php'],
'config_cache_enabled' => false,
'module_map_cache_enabled' => false,
],
];
21 changes: 21 additions & 0 deletions config/modules.config.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php
/**
* @link http://github.com/zendframework/ZendSkeletonApplication for the canonical source repository
* @copyright Copyright (c) 2005-2016 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/

/**
* List of enabled modules for this application.
*
* This should be an array of module namespaces used in the application.
*/
return [
'Zend\Filter',
'Zend\Hydrator',
'Zend\Router',
'Zend\Validator',
'Soliant\Payment\Base',
'Soliant\Payment\Authnet',
'Soliant\Payment\Demo',
];
52 changes: 0 additions & 52 deletions init_autoloader.php

This file was deleted.

4 changes: 0 additions & 4 deletions module/Authnet/config/module.config.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,6 @@
Soliant\Payment\Authnet\Payment\Request\Factory\TransactionModeFactory::class,
net\authorize\api\contract\v1\CreateTransactionRequest::class =>
Soliant\Payment\Authnet\Payment\Request\Factory\CreateTransactionRequestFactory::class,
],
],
'hydrators' => [
'factories' => [
Soliant\Payment\Authnet\Payment\Hydrator\TransactionRequestHydrator::class =>
Soliant\Payment\Authnet\Payment\Hydrator\Factory\TransactionRequestHydratorFactory::class,
],
Expand Down
4 changes: 1 addition & 3 deletions module/Authnet/src/Module.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
<?php
namespace Soliant\Payment\Authnet;

use Zend\ModuleManager\Feature\ConfigProviderInterface;

class Module implements ConfigProviderInterface
class Module
{
public function getConfig()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,13 @@

use net\authorize\api\contract\v1\MerchantAuthenticationType;
use OutOfBoundsException;
use Zend\ServiceManager\FactoryInterface;
use Zend\ServiceManager\ServiceLocatorInterface;
use Interop\Container\ContainerInterface;

class AuthenticationFactory implements FactoryInterface
class AuthenticationFactory
{
public function createService(ServiceLocatorInterface $serviceLocator)
public function __invoke(ContainerInterface $sm)
{
$config = $serviceLocator->get('config');
$config = $sm->get('config');

if (!array_key_exists('soliant_payment_authnet', $config)
|| !array_key_exists('login', $config['soliant_payment_authnet'])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,13 @@

use OutOfBoundsException;
use Soliant\Payment\Authnet\Payment\Hydrator\TransactionRequestHydrator;
use Zend\ServiceManager\FactoryInterface;
use Zend\ServiceManager\ServiceLocatorInterface;
use Interop\Container\ContainerInterface;

class TransactionRequestHydratorFactory implements FactoryInterface
class TransactionRequestHydratorFactory
{
public function createService(ServiceLocatorInterface $hydratorManager)
public function __invoke(ContainerInterface $sm)
{
$serviceLocator = $hydratorManager->getServiceLocator();
$config = $serviceLocator->get('config');
$config = $sm->get('config');

if (!array_key_exists('soliant_payment_authnet', $config)
|| !array_key_exists('service', $config['soliant_payment_authnet'])
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<?php
namespace Soliant\Payment\Authnet\Payment\Hydrator;

use net\authorize\api\contract\v1\TransactionRequestType;
use Zend\Hydrator\ClassMethods;

class TransactionRequestHydrator extends ClassMethods
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,13 @@
use Soliant\Payment\Authnet\Payment\Hydrator\TransactionRequestHydrator;
use Soliant\Payment\Authnet\Payment\Request\AuthorizeAndCaptureService;
use Soliant\Payment\Authnet\Payment\Request\TransactionMode;
use Zend\ServiceManager\FactoryInterface;
use Zend\ServiceManager\ServiceLocatorInterface;
use Interop\Container\ContainerInterface;

class AuthorizeAndCaptureServiceFactory implements FactoryInterface
class AuthorizeAndCaptureServiceFactory
{
public function createService(ServiceLocatorInterface $serviceLocator)
public function __invoke(ContainerInterface $sm)
{
$hydratorManager = $serviceLocator->get('HydratorManager');
$config = $serviceLocator->get('config');
$config = $sm->get('config');

if (!array_key_exists('soliant_payment_authnet', $config)
|| !array_key_exists('subset', $config['soliant_payment_authnet'])
Expand All @@ -27,13 +25,13 @@ public function createService(ServiceLocatorInterface $serviceLocator)
}

/** @var RequestHydrator $transactionRequestHydrator */
$transactionRequestHydrator = $hydratorManager->get(TransactionRequestHydrator::class);
$transactionRequestHydrator = $sm->get(TransactionRequestHydrator::class);
$transactionRequestHydrator->setTransactionRequestType(AuthorizeAndCaptureService::PAYMENT_TRANSACTION_TYPE);

return new AuthorizeAndCaptureService(
new TransactionRequestType(),
$serviceLocator->get(CreateTransactionRequest::class),
$serviceLocator->get(TransactionMode::class),
$sm->get(CreateTransactionRequest::class),
$sm->get(TransactionMode::class),
$transactionRequestHydrator,
$config['soliant_payment_authnet']['subset'],
$config['soliant_payment_authnet']['subset_collection'],
Expand Down
Loading

0 comments on commit 3241e69

Please sign in to comment.