The PHP kit consists of the following elements:
- an installation manual for the development kit
- a composer.json descriptor for the download via Composer of the library which allows you to use the functions of the Payline API
- an example of a web application using the SDK.
When the zip file is extracted, there are three directories:
The "examples" directory
The “examples" directory corresponds to the web application implementing all of the Payline functionalities available via the PHP library. Each functionality comes in the form of two files:
- a <function_name>Form.php file containing the input form.
- a <function_name>.php file that collects the data transmitted by the user via the form. The PHP code calls the desired Web Service.
For example, the "doWebPayment" function, which allows a web payment to be made via the kit, involves the presence of the following two files:
- doWebPaymentForm.php: This file simulates the summary page of your customer's order. It constitutes step 0 in the web payment process. You can change the values of the following fields in the form: Amount, Currency, and OrderRef values in order to make test payments.
- doWebPayment.php: This file contains the PHP code that retrieves the information transmitted by the form and uses the library to initialise a web payment request.
The "lib" directory
It groups together the classes which describe the requests, responses, and objects of the Payline SOAP API.
- lib_debug.php: This is the debug library which allows you to display in the form of a nested table the return message of your requests to the Payline SOAP API.
- CONFIG.php: This file contains the parameters for connection to Payline, as well as the parameters (contracts, version, currency, etc.) displayed by default in the example pages. The CONFIG.php file can be edited directly, or via the form included in the Home section.
The "logs" directory
In the archive, this directory is empty. It corresponds to the default directory for writing digital traces.
A <date>.log file (<date> being in the format yyyy-mm-dd) is created and/or updated during each call to a function of the library.
The function of adding a line to this file is called writeTrace.
It is a public function of the paylineSDK class, which can therefore be reused.
All of the Payline functions are covered by the PHP kit.
The paylineSDK class provides a function corresponding to each web service, with the same name as the latter (doWebPayment, doAuthorization, etc.).
The parameter passing between your shop and these functions is done via an associative array. Refer to the sample scripts contained in the kit to understand this mechanism.
The response of a Payline web service is also stored by the kit in an associative array. Refer to the sample scripts contained in the kit to understand the reading of a response.
If an exception occurs during the call to a function of the kit (for example due to a lack of communication with Payline because of incorrect parameterisation of the authentication or proxy), a response containing the code XXXXX as well as the text of the exception is returned.
This response is not returned by Payline, but by the PHP kit.
Download the payline-php-samples-master.zip archive
Unzip the archive to the root of your web server. If you are not yet using Composer, download the composer.phar executable via https://getcomposer.org/download/ and place it at the same level as the composer.json file included in the archive.
Via a command prompt launch php composer.phar install
Composer creates the vendor directory and places the latest version of the Payline SDK PHP in it, as well as the linked libraries.
Configuration of the kit
The kit requires the activation of the following PHP extensions on your server: php_curl, php_http, php_openssl, php_soap
You must enter the parameters in the "configuration" form of the "Home" section, or directly in the CONFIG.php file located under the lib directory.
- MERCHANT_ID: the log-in details for your retailer account, defined in a character string.
- ACCESS_KEY: the access key associated with your retailer account
- ACCESS_KEY_REF: the web2token reference associated with your access key
- PROXY_HOST: the URL of your Internet proxy
- PROXY_PORT: the communication port of your Internet proxy
- PROXY_LOGIN: the user log-in ID required by your Internet proxy
- PROXY_PASSWORD: the user password required by your proxy Internet
- ENVIRONMENT: indicator that determines the Payline environment to which the requests are addressed. Two values may be used by retailers: HOMO (homologation environment, for carrying out integration tests) and PROD (production environment).
- WS_VERSION: application version of the Payline web services.
- PAYMENT_CURRENCY: the ISO code of the currency to be used by default for the payment
- ORDER_CURRENCY: the ISO code of the currency to be used by default for the order
- SECURITY_MODE: the code of the security mode to be used by default
- LANGUAGE_CODE: the ISO code of the language to be displayed by default
- PAYMENT_ACTION: the code of the payment method to be used by default
- PAYMENT_MODE: the payment method to be used by default
- CANCEL_URL: the cancellation URL used when payment has been rejected or when your customer has cancelled the payment
- NOTIFICATION_URL: the notification URL used when Payline notifies you of a payment made
- RETURN_URL: the return URL used when the payment has been accepted
- CUSTOM_PAYMENT_TEMPLATE_URL: the URL of the dynamic template to be applied to the payment web pages
- CUSTOM_PAYMENT_PAGE_CODE: the code of customisation of the Payline payment pages to be used by default
- CONTRACT_NUMBER: the contract number which identifies your point of sale and your default payment method
- CONTRACT_NUMBER_LIST: the list of contract numbers to display if you have several. Otherwise your unique contract number.
- SECOND_CONTRACT_NUMBER_LIST: the list of contract numbers to display when the first payment attempt fails
Compatibility of the kit
The PHP kit has been tested with the following environment:
- Windows 7 Professional - CentOS release 6.7 (Final)
- Apache 2.2.22
- PHP 5.3.13 to 7