Giter Club home page Giter Club logo

soliant-payment's Introduction

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();
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.