Download the PHP package upgplc/php-clientlibrary without Composer

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

UPG Client Library for PHP

Build Status Codacy Badge

PHP Client Library for the UPG API. Based on the API Documentation found here: https://documentation.upgplc.com/hostedpagesdraft/en/topic/introduction

Current Issues

Currently there are issues with some of the calls these are:

Using the Library

Config Object

The API requires the configuration to work correctly. All classes and methods that require cofiguration can be passed a populated instance of Upg\Library\Config.

The config object should be fully populated at instantiation by providing an associative array.

The fields for the config that must be provided are:

Log Levels

When referencing log levels be sure to use the Psr\Log\LogLevel static constants E.g. \Psr\Log\LogLevel::ALERT

Starting an API request

The Library for requests is split in three parts: Upg\Library\Request contains the request classes. Upg\Library\Request\Objects contains classes for the JSON objects that are documented in the API docs. If a request has a property that requires a JSON object please pass in the appropriately populated Upg\Library\Request\Objects class for that property.

All properties in the request and JSON objects have getters and setters. For example, to set a field called userType on the request or object you would call setUserType and to get it you would call getUserType.

Notes on Date fields

Any field in the Requests and JSON Objects that requires a Date should be passed a PHP DateTime object - even if the field only requires month and year. For fields that require only a month and year such as the validity of a payment instrument, please look at DateTime::setDate. Simply running the code like this would give you a DateTime object to populate the field

The serializer will serialize the date to a correctly formatted string for the request.

Notes on Amount Fields

Any field that requires a JSON amount fields should be provided the Upg\Library\Request\Objects\Amount object. This object has three properties:

All amount values must be in the lowest currency unit (i.e. Cents, Pence, etc). So for example a 10 Euro transaction with 20% VAT would need to be populated:

Sending the request

Once you have populated a request object with the appropriate values simply instantiate an instance of a Upg\Library\Api class for the appropriate method call. Pass in a config object and the request you want to send. Then, calling the sendRequest() method will send the response. Raise any exception or provide a success response.

The exceptions which can be raised are in Upg\Library\Api\Exception. For any parsed responses you will have access to an Upg\Library\Response\SuccessResponse or Upg\Library\Response\FailureResponse object. The success object is returned if no exception is thrown. The failure object is returned in Upg\Library\Api\Exception\ApiError exception.

The response object has two types of properties: Fixed properties such as the resultCode which are in every request, and Dynamic properties such as allowedPaymentMethods which are not in every request. To access a property that is Fixed or Dynamic, simply use the following:

If any response contains JSON objects or an array of objects then the library will attempt to serialize them into Upg\Library\Request\Objects classes. The properties names in responses that will be serialized are as follows:

For example the response on the getUser API call contains the following properties that will be serialized to the following objects

The MAC validation/calculation for requests and responses is handled by the library and if these fail an exception will be raised.

All variables that are not ISO values are defined in classes as constants for you to use in the request. For possible fixed field values please see the following constants:

The library implements stubs for all the methods except for registerMerchant as at this time UPG is restricting this to authorised parties only.

Handling Callback

For the reserve API call you may be provided a callback from the API as a POST/GET request. For this the client library implements a helper for you to use: Upg\Library\Callback\Handler.

This takes in the following for the constructor:

The processor should implement two methods: sendData which the handler uses to pass data to the processor to use and another method called run, which will get invoked to handle call back processing. This processor should return a string which contains a URL where the user should be redirected to after UPG has processed the transaction.

To run the handler simply call the run method on the object. Please note the following exceptions can be raised in which case the store must still send a URL, but respond with a non 200 HTTP result code to indicate there has been an issue. The following exceptions may be raised:

Handling MNS notifications

For the MNS notification the API provides a helper class to validate MNS notification. This class is Upg\Library\Mns\Handler. It takes the following as a constructor:

The processor object should implement sendData to get data from the handler and a run method which executes your callback after successful validation.

The processor callback should avoid processing the request, instead it should save it to a database for asynchronous processing via a cron script.

Please note the MNS call must always return a 200 response to UPG otherwise no other MNS would be sent until a given MNS notification is accepted with a HTTP 200 response.

Working with PayCoBridge.js

Please note this plugin does not provide any javascript libraries for the paybridge. Integrations using paybridge are expected to implement the javascript library. However, this library can be used to implement the server side functionality for any paybridge integrations, using PHP on the backend.

If you use the handler class to save a MNS to the database for later processing you can assume the MNS is perfectly valid with out checking the MAC.

Working on the plugin

If you want to contribute o the library, please note that all code should be written according to the PSR2 standard. This is very easy to set up in PHPStorm by using PHP-Codesniffer. To configure PHP-Codesniffer for PHPStorm follow these steps:

  1. Run the following.

  2. In PHPStorm open the settings dialog and navigate to Languages & Framework -> PHP -> Code Sniffer
  3. On configuration option click the ... button and in that prompt point PHPStorm to the path of Code Sniffer
  4. To set the code style navigate to Editor -> Code Style -> PHP
  5. In the setting click on Set From and go to Predefined Style -> PSR1/PSR2
  6. Click on the OK button

All versions of php-clientlibrary with dependencies

PHP Build Version
Package Version
Requires php Version >=5.3
monolog/monolog Version >=1.16.0,<1.20
siriusphp/validation Version dev-master
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 upgplc/php-clientlibrary contains the following files

Loading the files please wait ....