Download the PHP package thepay/api-client without Composer

On this page you can find all versions of the php package thepay/api-client. 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 api-client

PHP SDK for ThePay.cz

This is the official highly compatible public package of The Pay SDK which interacts with The Pay's REST API. To get started see examples below.

Requirements

All necessary requirements are defined in composer.json require property. We strongly recommend SDK installation using Composer!

Installation

Installation with suggested PSR http client.

This project adheres to Semantic Versioning.

Support & Contributions

If you find any bug, please submit the issue in Github directly.

Feel free to contribute via Github issues and pull requests. We will response as soon as possible. Please have on mind the backwards compatibility and do not change requirements without previous admin agreement.

Preconditions

Make sure that you have all required credentials and that you've set up the API access in administration:

To test the integration you can create simplified "ready-to-go" DEMO account in our DEMO environment.

You can find all the necessary credentials in "Implementation" section under your merchant profile:

Usage

You will work with only two classes when using this SDK.

Configuration

All constructor parameters are described in php doc

TheClient instance

Before making \ThePay\ApiClient\TheClient instance, some dependencies must be prepared.

If you use some DI container automation, all other dependencies than TheConfig should be auto-injected even PSR interfaces if you have some implementations already installed in your application.

Usual workflow

There are three steps when creating a payment:

All of these steps will need to be implemented by yourself, but fear not, we have prepared examples that you can take on your journey through our SDK.

1. Payment creation

The payment (link) can be created via two methods:

No matter what method you choose, you have two more options, based on preselection of payment method:

Even if you (or your customer) preselect the payment method, it can still be changed after redirection, unless specifically forbidden.

REST API

You can create payment (link) via REST API and redirect user to that link. The payment itself is created through an API call. This is the preferred way for custom forms and if you want to redirect user after the whole cart process is finished.

The payment method can be preselected on your side and simply added as payment parameter to the API. Otherwise, the customer will be presented with payment method selection on visiting ThePay gate through generated link.

The payment link is returned to you in a response, upon calling the API endpoint for payment creation.

Redirection of customer

The second (simpler) method is to redirect customer to payment gate with payment parameters. The payment itself will be created as soon as customer is redirected. This SDK will generate payment buttons which will do all the work.

The payment method can be preselected in your e-shop and simply added as payment parameter to the correct method. Otherwise, the customer will be presented with payment method selection on visiting ThePay gate through generated link.

The payment link is generated by the SDK, upon using the method for generating the payment button/s. The payment on our side is created at the moment the customer visits the link.

Payment amount is unchangeable

In case your order amount changes, a new payment needs to be created.

Payment flow and changes

You should always create only one payment (with its unique UID) for each order in your e-shop. You should never create new payments, except when changing the payment amount.

TL;DR - summary

These are the usual ways for payment creation:

Always create only one payment for your order for all payment creation options, unless you need to change the payment amount. In that case, consider it a whole new payment.

For more examples see create-payment.md

See how to make TheClient

2. Customer return

The customer is returned from ThePay gate to the return url address.

Return url is set in administration and customer gets redirected there with two query parameters added - payment_uid and project_id (needed if you have one endpoint for multiple projects).

The state of payment must be checked at the time of customer return, since the payment may not always be in the paid state at this time. For example the customer simply returns to the e-shop without paying.

General example of handling the customer return

See how to make TheClient

3. Server to server notification

It's basically the same as second step (customer return), it's triggered everytime the payment has changed, for example when the state of payment has been changed.

See how to make TheClient

More and detailed usage examples

You can find more usage examples at folder /doc.

Money calculations

For safe money calculations we recommend to use moneyphp/money package. Please, do not use float to save information about prices because of its inaccuracy.


All versions of api-client with dependencies

PHP Build Version
Package Version
Requires php Version ~7.4|~8.0
ext-json Version *
psr/http-client Version ^1.0
psr/http-factory Version ^1.0
psr/http-message Version ^1.0|^2.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 thepay/api-client contains the following files

Loading the files please wait ....