soliantconsulting / soliant-payment

A ZF2 / ZF3 payment processing package designed to allow connectivity to a multitude of payment processors by providing a common easy-to-use request interface. Current implementation provides functionality for Authorize.net.


Soliant Payment

Build Status Coverage Status Latest Stable Version Latest Unstable Version Total Downloads License

Quickstart

Installation

Via composer

{
    "require": {
        "soliantconsulting/soliant-payment": "^2.0.0" // ZF2 v1.0.1
    },
    "repositories": [
        {
            "type": "vcs",
            "url": "https://github.com/goetas/serializer.git"
        }
    ],
    "minimum-stability": "dev",
    "prefer-stable": true
}

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.

'modules' => [
    'Soliant\Payment\Base', // Required for all payment modules
    'Soliant\Payment\[Payment Module]', // Where "Payment Module" is one of the following ("Authnet")
    'Soliant\Payment\Demo', // Access demo via /soliant-payment route
 ],

Copy the local.php.dist file from the payment module config directory to the project autoload directory.

$ cp vendor/soliantconsulting/soliant-payment/module/[Payment Module]/[Payment Module].payment.local.php.dist 
config/autoload/[Payment Module].payment.local.php

Inject the desired payment service via factory using one of the following available aliases.

"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)
{
    return new MyService($serviceLocator->get("[Service Alias]"));
}

Each payment service should implement the following request structure. Request data is passed via array to the "sendRequest" method which returns a response object. (See the implemented payment modules payment.local.php.dist file for data array structure and info on overriding data field names. Ex. a link). The response object can be tested for success with the "isSuccess" method which returns a boolean response.

If the request was successful, any data returned from the requested service should be access via the "getData" method.
The "getMessages" method will be populated in the event the request was unsuccessful.

$response = $this->[Service Alias]->sendRequest([
    'paymentType' => 'creditCard',
    'amount' => '5.00',
    'expirationDate' => '2017-01',
    'cardNumber' => '4111111111111111'
]);

if ($response->isSuccess()) {
    // get the response data
    $data = $response->getData();
} else {
    // get the errors
    $errors = $response->getMessages();
}
No license file found for this Module
php composer.phar require "soliantconsulting/soliant-payment"

Require

  • 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.1