Introduction

The secuconnect API is our REST API that gives you access to manage payments, loyalty card transactions, and all the other good thing we provide.

Our secuconnect SDKs help you to ease the access to the secuconnect API. SDK stands for “Software Development Kit” and provide a set of tools, libraries, relevant documentation, code samples, processes and/or guides that developers allow to create software applications on a specific platform. More

This guide is to use our SDK to quickly connect and manage all kind of transactions did in secupay. The following Getting Started section will help you to install our SDK and to make your first payment transaction at secupay.

Our SDKs are generated by using the Swagger/OpenAPI 2.0 annotation. We also provide this here (https://github.com/secuconnect/oas-spec) and you can use it to write your own client for the secuconnect API if you wish so.

Getting Started

GitHub-Repository: https://github.com/secuconnect/secuconnect-php-sdk

Requirements

PHP

You need at least the version 7.0.

We recommend to use the version 7.2.

Additionally you need the following extensions for PHP:

You can find the install instructions for PHP here.

Composer

For the simplest installation method you need the "composer" tool.

You can found more information about this tool on the website getcomposer.org.

To install it you need only some simple php calls, which are described here.

Installing the SDK

We recommend installing secuconnect-php-sdk as dependency managed by composer.

You can also find other ways to install the secuconnect-php-sdk on the page .

composer require "secuconnect/secuconnect-php-sdk"

For more information please consult Composer documentation.

Configuration

See Configuration section for list of configuration parameters.

Authentication

See Authentication section to learn about authentication process, options and requirements.

Here you can see a working example for our testing environment which authenticate you against the secuconnect API and return you an "Access-Token", which you can use for all your upcoming calls:

require __DIR__ . '/vendor/autoload.php';

use Secuconnect\Client\Configuration;
use Secuconnect\Client\Authentication\Authenticator;
use Secuconnect\Client\Authentication\OAuthClientCredentials;

$clientId = '09ae83af7c37121b2de929b211bad944';
$clientSecret = '9c5f250b69f6436cb38fd780349bc00810d8d5051d3dcf821e428f65a32724bd';

// If you use cache solution, and want SDK to store tokens through it
// Configuration::getDefaultConfiguration()->setCache($yourPSR6Cache);

// Creates authenticator object with OAuth authentication and obtains token
$auth = new Authenticator(OAuthClientCredentials::from($clientId, $clientSecret));
$accessToken = $auth->getToken();

// Saves the token to the Swagger default configuration
Configuration::getDefaultConfiguration()->setAccessToken($accessToken);

A sample application

In this sample we create a first payment transaction (with the payment method "prepay") for the payer "John Doe".

// Build request objects
use Secuconnect\Client\Model\Address;
use Secuconnect\Client\Model\PaymentCustomersDTOContact;
use Secuconnect\Client\Model\PaymentCustomersDTO;
use Secuconnect\Client\Api\PaymentCustomersApi;
use Secuconnect\Client\ApiException;

$contactAddress = new Address();
$customerContact = new PaymentCustomersDTOContact();
$customer = new PaymentCustomersDTO();

$contactAddress
  ->setStreet('Frankfurter Str.')
  ->setStreetNumber('125a')
  ->setPostalCode('60326')
  ->setCity('Frankfurt am Main')
  ->setCountry('Germany');
 
$customerContact
  ->setSalutation('Mr.')
  ->setTitle('Dr.')
  ->setForename('John')
  ->setSurname('Doe')
  ->setCompanyname('My Company Inc.')
  ->setDob('1905-03-03')
  ->setEmail('mr-john-doe@mail.com')
  ->setPhone('0049-123-456789')
  ->setMobile('0049-987-654321')
  ->setAddress($contactAddress);

$customer->setContact($customerContact);

// Make request
try {
  $api = new PaymentCustomersApi();
  $response = $api->paymentCustomersPost($customer);
  // Success. $response contain PaymentCustomersProductModel
  $customerId = $response->getId();

  echo 'Created new payment customer product with ID: ' . $customerId . PHP_EOL;
  echo 'Payment customer product data after create:' . PHP_EOL . $response . PHP_EOL;
} catch (ApiException $e) {
  // Failure. $e->getResponseBody() contains ProductExceptionPayload
  echo $e->getResponseBody() . PHP_EOL;
  throw $e;
}

Sample Response

Created new payment customer product with ID: PCU_2H9PU0FD72MMV8TVASAXV353NAJBAH
Payment customer product data after create:
{
    "object": "payment.customers",
    "id": "PCU_2H9PU0FD72MMV8TVASAXV353NAJBAH",
    "contract": {
        "object": "payment.contracts",
        "id": "PCR_2046JDZQA2MYSP0QQSAXV0QFNWFNAH"
    },
    "contact": {
        "forename": "John",
        "surname": "Doe",
        "companyname": "My Company Inc.",
        "salutation": "Mr.",
        "title": "Dr.",
        "email": "mr-john-doe@mail.com",
        "phone": "0049-123-456789",
        "mobile": "0049-987-654321",
        "dob": "1905-03-03T00:00:00+01:00",
        "address": {
            "street": "Frankfurter Str.",
            "street_number": "125a",
            "city": "Frankfurt am Main",
            "postal_code": "60326",
            "country": "Germany"
        }
    },
    "created": "2018-04-24T17:04:30+02:00"
}