Download the PHP package ilrwebservices/cardpointe-gateway-rest-api-client without Composer
On this page you can find all versions of the php package ilrwebservices/cardpointe-gateway-rest-api-client. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download ilrwebservices/cardpointe-gateway-rest-api-client
More information about ilrwebservices/cardpointe-gateway-rest-api-client
Files in ilrwebservices/cardpointe-gateway-rest-api-client
Package cardpointe-gateway-rest-api-client
Short Description PHP library for the CardPointe Gateway API
License MIT
Homepage https://github.com/ilrWebServices/cardpointe-gateway-rest-api-client
Informations about the package cardpointe-gateway-rest-api-client
CardPointe Gateway REST API Client for PHP
A simple PHP http client for the CardPointe Gateway REST API. Optimized for JSON and authentication via username and password. Based on Guzzle.
CardPointeGatewayRestClient
is an extended GuzzleHttp\Client
, so it can do all the things that Guzzle can and a bit more.
Be sure to refer to the CardPointe Gateway API documentation for details.
Installation
Via composer:
Usage
Note how these settings are passed into the client constructor options along with other Guzzle-compatible options. In this example, some sensitive settings are stored in environment variables since they should not be stored in code.
The CardPointeGatewayRestClient
will set the base_uri
option to https://<cp_site>.cardconnect.com/cardconnect/rest/
automatically.
You can now make API calls just as you would in Guzzle:
Since the base_uri
option is pre-configured, you can use a relative URL (be sure not to add a leading /
, though):
And because it's Guzzle, there are shorthand methods:
Responses are PSR-7 response messages, just like Guzzle, so you can get returned data via getBody()
:
For application/json
responses, CardPointeGatewayRestClient
adds a non-standard getData()
method that decodes the JSON response for you:
Be careful with large responses, however, as they can consume too much memory.
Sending JSON data to API endpoints can be done using the json
request option from Guzzle:
Error handling
You can use Guzzle exceptions for error handling. CardPointe Gateway API endpoints generally use 4xx codes for errors, so GuzzleHttp\Exception\ClientException
is a good match for catching those errors.
Inspired by drewm/mailchimp-api.