Download the PHP package alphagov/pay-integration-php without Composer

On this page you can find all versions of the php package alphagov/pay-integration-php. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package pay-integration-php

GOV.UK Pay - pay-integration-php

PHP client for the GOV.UK Pay API

As of September 2021, this repository is no longer actively maintained by the GOV.UK Pay team.

PSR-7 HTTP

The Pay PHP Client is based on a PSR-7 HTTP model. You therefore need to pick your preferred HTTP Client library to use.

We will show examples here using the Guzzle v6 Adapter.

Installing

The Pay PHP Client can be installed with Composer. Run this command:

Usage

Assuming you've installed the package via Composer, the Pay PHP Client will be available via the autoloader.

Create a (Guzzle v6 based) instance of the Client using:

You are then able to access the Pay API using $client.

If you need to access an environment other than production, you can pass the base URL in via the baseUrl key in the constructor:

Create a Payment

The method signature is:

Where

An example request would look like:

$response will be an instance of Alphagov\Pay\Response\Payment, which is documented here.

An instance (or sub-class) of Alphagov\Pay\Exception\PayException will be thrown if a Pay error occurs.

Lookup a Payment

The method signature is:

Where

An example request would look like:

$response will be an instance of Alphagov\Pay\Response\Payment, which is documented here; or null if the payment was not found.

An instance (or sub-class) of Alphagov\Pay\Exception\PayException will be thrown if a Pay error occurs.

Cancel a Payment

The method signature is:

An example request would look like:

$response will be bool true if the payment was cancelled. Otherwise an instance (or sub-class) of Alphagov\Pay\Exception\PayException will be thrown if a Pay error occurs.

Refund a Payment

The method signature is:

An example request would look like:

$response will be an instance of Alphagov\Pay\Response\Refund, which is documented here.

An instance (or sub-class) of Alphagov\Pay\Exception\PayException will be thrown if a Pay error occurs.

Lookup all Refunds for a Payment

The method signature is:

Where

An example request would look like:

$response will be an instance of Alphagov\Pay\Response\Refunds, which will contain an instance of Alphagov\Pay\Response\Refund (docs) for each refund processed.

An instance (or sub-class) of Alphagov\Pay\Exception\PayException will be thrown if a Pay error occurs.

Lookup a single Refund for a Payment

The method signature is:

Where

An example request would look like:

$response will be an instance of Alphagov\Pay\Response\Refund (docs), or NULL if the refund is not found.

An instance (or sub-class) of Alphagov\Pay\Exception\PayException will be thrown if a Pay error occurs.

Lookup all Events for a Payment

The method signature is:

Where

An example request would look like:

$response will be an instance of Alphagov\Pay\Response\Events, which will contain an instance of Alphagov\Pay\Response\Event (docs) for each event.

An instance (or sub-class) of Alphagov\Pay\Exception\PayException will be thrown if a Pay error occurs.

Search Payments

The method signature is:

Where

Full filter details can be found here: https://gds-payments.gelato.io/docs/versions/1.0.0/resources/general/endpoints/search-payments

An example request would look like:

$response will be an instance of Alphagov\Pay\Response\Payments, which will contain an instance of Alphagov\Pay\Response\Payment (docs) for each payment found.

An instance (or sub-class) of Alphagov\Pay\Exception\PayException will be thrown if a Pay error occurs.

Responses

All Response objects except Event have a getResponse() which returns a class implementing Psr\Http\Message\ResponseInterface, containing the original API response.

Payment

An instance of Alphagov\Pay\Response\Payment, which contains the decoded JSON response from the Pay API, representing a single payment.

A full list of returned properties can be found here: https://gds-payments.gelato.io/docs/versions/1.0.0/resources/payment-id/endpoints/find-payment-by-id

Properties can be accessed directly using the -> operator. For example:

If available, the payment page URL to direct the user to is accessible via:

This returns either:

Payment also includes methods for checking the state of the payment:

The payment is finished. i.e. the user can no longer interact with the payment page.

The payment is successful.

All other standard Pay states can also be checked via:

Refund

An instance of Alphagov\Pay\Response\Refund, which contains the decoded JSON response from the Pay API, representing a single refund.

A full list of returned properties can be found here: https://gds-payments.gelato.io/docs/versions/1.0.0/resources/payment-id/endpoints/find-payment-refund-by-id

Properties can be accessed directly using the -> operator. For example:

Event

An instance of Alphagov\Pay\Response\Event, which contains the decoded JSON response from the Pay API, representing a single event.

A full list of returned properties can be found here: https://gds-payments.gelato.io/docs/versions/1.0.0/resources/payment-id/endpoints/return-payment-events-by-id

Properties can be accessed directly using the -> operator. For example:

Payments, Refunds & Events

All three of these responses represent collections of their respective response type. They all extend PHP’s ArrayObject, thus can be treated as an array.

Both Refunds & Events also support the addition $response->payment_id property, containing the payment ID to which they relate.

License

The Pay PHP Client is released under the MIT license, a copy of which can be found in LICENSE.


All versions of pay-integration-php with dependencies

PHP Build Version
Package Version
Requires php Version >=5.4
psr/http-message Version ^1.0
php-http/httplug Version ^1.0
guzzlehttp/psr7 Version ^1.2
php-http/client-implementation Version ^1.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package alphagov/pay-integration-php contains the following files

Loading the files please wait ....