paymentassist / paymentassist-php
PHP SDK for the Payment Assist Partner API
Installs: 3 944
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 3
Forks: 1
Open Issues: 0
Language:HTML
Requires
- php: >=7.2
- ext-curl: *
- ext-json: *
- dflydev/dot-access-data: ^3.0
- giggsey/libphonenumber-for-php: ^8.12
- guzzlehttp/guzzle: ^7.5
- guzzlehttp/guzzle-services: ^1.3
- monolog/monolog: ^2.3 | ^3.5
- paymentassist/guzzle-description-loader: ^0.0.7
- rtheunissen/guzzle-log-middleware: ^1.0
Requires (Dev)
- nesbot/carbon: ^2.53
- phpstan/phpstan: ^0.12.99
- phpunit/phpunit: ^9.6
- squizlabs/php_codesniffer: *
README
PHP SDK for the Payment Assist Partner API.
Note
paymentassist-php v2 is now the default version. For legacy integrations, please see the v1 branch.
Dependencies
- PHP >= 7.2
- PHP JSON extension
- PHP cURL extension
Workflow
Installation
Install with Composer:
composer require paymentassist/paymentassist-php:dev-v2
Publish configuration files
Use composer to publish configuration files:
composer --working-dir=vendor/paymentassist/paymentassist-php/ run-script publish-config
Usage
use PaymentAssist\ApiClient; $config = [ 'debug' => true, 'timeout' => 120, 'log' => [ 'debug' => true, 'log_file_name' => 'apiclient.log', 'log_file_path' => 'PATH-TO-YOUR-LOGS-FOLDER', 'log_request_before_response' => true, 'log_app_name' => 'ApiClient', 'log_format' => null, // if null, a default format from GuzzleHttp\MessageFormatter class will be used ], 'verify_ssl_certificate' => true, 'default' => 'partner_api_v1', 'connections' => [ 'partner_api_v1' => [ 'base_uri' => 'https://api.v1.payment-assist.co.uk', 'manifest_path' => 'default', // use manifest files stored within the package 'api_key' => 'YOUR-KEY', 'secret' => 'YOUR-SECRET', 'additional_query_param' => [], ], ], ]; $client = ApiClient::instance($config)->setConnection(ApiClient::PARTNER_API_V1); $response = $client->GetAccountConfigurationDetails(); if ($response->isOK()) { $plans = collection( $response ->getContent() ->getData() ->getPlans() ->toArray() )->map(function ($plan) { return $plan['name']; })->toList(); } else { echo($response->getStatus() . ' ' . $response->getReason()); echo('There was an error fetching plans from the API: ' . $response->getContents()->getMessage()); }
In the above example $config
variable contains a config structure which needs to be provided as an argument to ApiClient::instance()
static method.
This structure can be stored in the config section of your application. After installing the package you can publish an example config file. Composer script will copy the file apiclient.php
to the config
folder in the root folder of your app if it exists, otherwise it will copy the file to the root folder of your app.
Config file contains the structure and the default config values which can be overridden by the values stored in the file .apiclient.env
which will be copied to the root folder of your app.
Refer to API documentation for details of valid endpoints and required params.
Contributing
We welcome contributions. There are several ways to help out:
- Create an issue on GitHub, if you have found a bug.
- Write patches for open bugs/feature issues, preferably with test cases included. Please fork our repo, make your changes in a new branch and then open a pull request ensuring the correct target branch.
- Contribute to the documentation
Support
For integrations support, please email itsupport@payment-assist.co.uk.