fdm / netaxept
Netaxept API integration package
Installs: 6 457
Dependents: 2
Suggesters: 0
Security: 0
Stars: 0
Watchers: 4
Forks: 1
Open Issues: 0
Requires
- guzzlehttp/guzzle: ^6.3
- webmozart/assert: ^1.3
Requires (Dev)
- phpstan/phpstan: ^0.9.2
- phpunit/phpunit: ^7.2
- symplify/easy-coding-standard: ^4.4
This package is auto-updated.
Last update: 2021-07-06 03:00:02 UTC
README
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.