Installation

For easy installation use composer which you can download from the composer homepage.

What is composer and how to use it?

Composer is a package dependency manager for PHP. You may know Linux package managers like APT for Ubuntu or Debian, composer is the same for your PHP project.

Composer has two main advantages. First it is easy to use and second it has a build-in autoloader, which will be covered later in this section.

Can I use the SDK without composer?

Yes, but you would have to build your own autoloader.

In this case you can download the latest release directly from GitHub.

Add composer.json to your application

Please skip this section if you already use composer to manage your project.

The installation of composer depends strongly on your operating system. Installation instructions can be found on the composer homepage.

Please open your command-line, navigate to the root directory of your project and type the following command to create the composer.json file:

composer init

Now you will be asked to enter some project information like package name, description, author, minimum stability, packages type and license. All we need for now is the package name.

Next you will be asked the following questions: Would you like to define your dependencies (require) interactively? Would you like to define your dev dependencies (require-dev) interactively? Both can be skipped by typing no and return.

Finally you need to answer the question Do you confirm generation? by typing yes and return. The composer.json will be created, which looks like this:

{
   “name”: “myproject/shop-abc”,
   “type”: “project”,
   “require”: { 
   } 
}

Now you are ready to add install the SDK.

composer require heidelpay/heidelpay-php

This will install the latest version of the SDK into the vendor folder and add the dependency to your composer.json.

Congrats
You have successfully installed the UnzerPHP SDK.

Include the autoloader in your application

The easiest way to make the SDK sources available to your code is to use the composer autoloader like this:

require_once(__DIR__ . '/vendor/autoload.php');

Please make sure to use the correct path.

If your framework is already using the autoloader, nothing more needs to be done.

PHP configuration

In order to avoid rounding errors when transmitting floating point values to the API we recommend you to set the following value in your php.ini, which will select an enhanced algorithm for rounding such numbers.

// php.ini
; When floats & doubles are serialized store serialize_precision significant
; digits after the floating point. The default value ensures that when floats
; are decoded with unserialize, the data will remain the same.
serialize_precision = -1

Please refer to the following article for further information: https://wiki.php.net/rfc/precise_float_value.