fdm/netaxept

This package is abandoned and no longer maintained. No replacement package was suggested.

Netaxept API integration package

v1.1.0 2018-06-21 08:26 UTC

This package is auto-updated.

Last update: 2021-07-06 03:00:02 UTC


README

Software License Build Status Latest Stable Version codecov Scrutinizer Code Quality

This project provides a simple interface to NETS' Netaxept payment gateway.

Using the library

To install using composer:

composer require fdm/netaxept
<?php
require 'vendor/autoload.php';
// Instantiate the API with the required merchantId and token
$api = new \FDM\Netaxept\Api('merchantId', 'token');

// Get a response object from the API, in this example, get a transaction.
$response = $api->getTransaction('transactionId');

// Retrieve properties on the transaction.
$status = $response->getTransactionStatus();
print_r($response->getOrderInformation());

Customising the Response factory.

The provided response classes only have methods for exposing the most common data. If you have a requirement to retrieve other data, then you simply create a response class that extends one of the existing, (or a completely new class that implements the appropriate interface.) and implement your methods. Then provide these fully qualified classnames to the constructor of the Factory() class.

// Acme/Netaxept/Response/MyCustomQuery.php

use FDM\Netaxept\Response\Query;
class MyCustomQuery extends Query
{
    public function getQueryFinished()
    {
        return (string)$this->xml->QueryFinished;
    }
}

...

// In your file that instantiates the API object
$responseFactory = new Factory(Acme\Netaxept\Response\MyCustomQuery::class);
$api = new Api('merch', 'token', $responseFactory);
$response = $api->getTransaction('transactionid');
$finished = $response->getQueryFinished(); 

Customising the Exception factory.

As with the Response factory, you can also provide your own factory class that will deal with raising the proper exceptions, allowing you to customise exception handling.

// In your file that instantiates the API object
use FDM\Netaxept\Exception\Factory;
$exceptionFactory = new Factory(Acme\Netaxept\Exception\MyCustomException::class ... [etc]);
$api = new Api('merch', 'token', null, $exceptionFactory);
try {
    $response = $api->getTransaction('transactionid');
} catch (MyCustomException $e) {
    $e->doSomethingCustom();
} 

See the exception factory constructor for the supported exceptions.

Contributing

Some tools are provided to ease development. Clone the project and run make docker-start to start a PHP Docker container. Run make docker-shell in order to get a shell inside the container. Run composer install to install dependencies. Run make test from inside the container to run tests, and make codecheck to make sure your code follows standards.

License

Copyright (c) Forenede Danske Motorejere (FDM). All rights reserved.

Licensed under the MIT License.