PHP
The PHP language is an open source language called server side: this means that, unlike languages such as HTML, CSS or JavaScript which are first interpreted by the browser, the PHP code is executed directly on the web server, in which the scripts formulate HTML instructions which are only finally transmitted to the browser and therefore to the visitor.
Installation
You can install the Nexi SDK for PHP via the composer command:
Configuration
In order to communicate with the gateway, you need to create a configuration object that implements the IConfiguration interface.
Once instantiated, this object can call the PaymentGatewayClient constructor which instantiates the object that handles calls to the gateway.
Example of use
Having obtained the object indicated in the previous section, it is possible to proceed with the requests to the gateway. Below is an example of payment using the method Hosted Payment Page:
Objects, as well as "set" methods for setting parameters, are referenced by the API POST /orders/hpp. The SDK was developed keeping the parameter names the same as those of the gateway API, to facilitate and improve the user experience.
API Overview
Below is the list of XPay APIs available in the SDK, accessible through the functions in the PaymentGatewayClient.php file:
- Hosted Payment Page (POST /orders/hpp)
- Pay-By-Link (POST /orders/paybylink)
- M.O.T.O. (POST /orders/moto)
- Recurring Payment (POST /orders/mit)
- Order List (GET /orders)
- Order Search (GET /orders/{orderId})
- Operations List (GET /operations)
- Operation Search (GET /operations/{operationId})
- Refund (POST /operations/{operationId}/refunds)
- Capture (POST /operations/{operationId}/captures)
- Capture Cancellation(POST /operations/{operationId}/cancels)
- Payment Methods List (GET /payment_methods)
- Card Verification (POST /orders/card_verification)
- Pay-By-Link Cancelation (POST /paybylink/{linkId}/cancels)
- Contract Search (GET /contracts/customers/{customerId})
- Deactivate Contract (POST /contracts/{contractId}/deactivation)
- 3 Step Initiation (POST /orders/3steps/init)
- 3 Step Validation (POST /orders/3steps/validation)
- 3 Step Payment (POST /orders/3steps/payment)