/soliant-payment

Primary LanguagePHPOtherNOASSERTION

Soliant Payment

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

Quickstart

Installation

Via composer

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

Usage

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

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