Download the PHP package mlocati/nexi-xpay-web without Composer

On this page you can find all versions of the php package mlocati/nexi-xpay-web. 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 nexi-xpay-web

Tests

MLocati's unofficial Nexi XPay Web client library for PHP

This project contains a PHP library that makes it easy to use the Nexi XPay Web APIs (for Intesa Sanpaolo bank).

This requires an API Key. If instead you have a Terminal Alias and a MAC Key, you may need to use this other library.

It has been built (almost) automatically from the official documentation (see the /build directory, which is only available if you clone this repository).

Installation

Install with composer

Simply run the following command:

Manual installation

Download the code of this library, place it somewhere in your project, and add this PHP instruction before using anything of this library:

Usage

Configuration

First of all, you have need an API Key (generated by your XPay back office). For test environment, you can use the value of the MLocati\Nexi\XPayWeb\Configuration::DEFAULT_APIKEY_TEST constant.

You also need the base URL of the Nexi XPay Web API. You can find them again in MLocati\Nexi\XPayWeb\Configuration:

This library provides an easy way to represent a configuration, by using the MLocati\Nexi\XPayWeb\Configuration\FromArray class:

Of course you can override the default base URL (use the baseUrl array key).

You can also use a custom class, provided it implements the MLocati\Nexi\XPayWeb\Configuration interface.

The Nexi Client

The main class of this library is MLocati\Nexi\XPayWeb\Client: it allows you invoking the Nexi APIs.

You can create an instance of it simply with:

HTTP Communications

The Nexi client needs to perform HTTP requests. In order to do that, it automatically detects the best available way to do that:

You can also provide your own implementation, provided it implements the MLocati\Nexi\XPayWeb\HttpClient interface. That way you can easily log the communication with the Nexi servers, as well as customize the HTTP client (for example because you are behind a proxy).

For example, if you want to use your custom HTTP client implementation, you can simply write:

The Correlation-Id Header

Every request to the Nexi servers is associated to an unique identifier, sent via an HTTP header named Correlation-Id. By default, the Next client randomly generates it and doesn't store it. If you want to generate the value of the Correlation-Id header on your own, or if you want to log the generated Correlation-Id values, you can create a custom class that implements the MLocati\Nexi\XPayWeb\CorrelationProvider interface. Then, when you create the Nexi client, you can write some code like this:

Sample Usage

The methods provided by Nexi client has well documented documentation (see the PHPDoc comments). The Nexi client provided by this library allows you to use all the methods you can find in the Nexi documentation website.

Here's a sample code that allows you to accept payments:

  1. Your customer is on your website and clicks a "Pay" button which invokes a route on your project that executes this code:

  2. you then redirects your customer to the URL provided by $response->getHostedPage()
  3. when the customer pays on the Nexi website, he is redirected to your website at the URL used in the setResultUrl() above. When that URL is called, you can have some code like this:

All versions of nexi-xpay-web with dependencies

PHP Build Version
Package Version
Requires php Version >= 7.2
ext-json Version *
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 mlocati/nexi-xpay-web contains the following files

Loading the files please wait ....