Skip to content
No description, website, or topics provided.
PHP
Branch: master
Clone or download
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
docs
samples
sdk/EasyTransac Generation of the sdk documentation Jun 25, 2019
tests
.coveralls.yml NEW - Coveralls.io and Travis integration. Jan 5, 2017
.travis.yml Update .travis.yml Jan 6, 2017
README.md
composer.json Update composer.json Jan 5, 2017

README.md

EasyTransac SDK (PHP)

Build Status Latest Stable Version Coverage Status

Make your EasyTransac API implementation easier with our SDK.

The EasyTransac SDK is a tool to process payments with the EasyTransac API.

Currently it processes credit cards and SEPA Direct Debit (SDD).

Requirements

You need at least:

  • PHP >=5.5
  • cURL in order to get clear error messages
  • an API key provided by EasyTransac (register an account at EasyTransac website)
  • OpenSSL version 1.0.1 to support TLSv1.2 ciphers

Installation

By composer

Execute this command on you terminal in your project folder:

composer require easytransac/easytransac-sdk-php

Or add in your composer.json:

"require": {
  ...
  "easytransac/easytransac-sdk-php": "*",
}

Manually

In order to use it, you only need to require the autoload file easytransac/easytransac-sdk-php/sdk/EasyTransac/autoload.php.

Unit Testing

Our test cases are written under PHPUnit 4.4.1, also if you want to launch tests, please check your PHPUnit version for methods compatibility.

Samples

Samples are provided with the SDK.

Set up the configuration

// Don't forget to require the composer autoload or sdk's
require_once(__DIR__.'/vendor/easytransac/easytransac-sdk-php/sdk/EasyTransac/autoload.php');

// Provide the API key
EasyTransac\Core\Services::getInstance()->provideAPIKey('YOUR_API_KEY_HERE');

// For testing, you can activate logs
EasyTransac\Core\Services::getInstance()->setDebug(true);

// You can change the log directory (by default the path is the running script path)
Logger::getInstance()->setFilePath('YOU_CUSTOM_PATH');

Make a direct payment request

$customer = (new EasyTransac\Entities\Customer())
    ->setFirstname('Demo')
    ->setLastname('Mini SDK')
    ->setCity('Strasbourg')
    ->setUid('a1b2c3d4');

$card = (new EasyTransac\Entities\CreditCard())
    ->setNumber('1111111111111111')
    ->setMonth('10')
    ->setYear('2017')
    ->setCVV('123');

$transaction = (new EasyTransac\Entities\DirectTransaction())
    ->setAmount(100)
    ->setClientIp('127.0.0.1')
    ->setCustomer($customer)
    ->setCreditCard($card);

$dp = new EasyTransac\Requests\DirectPayment();
$response = $dp->execute($transaction);

if ($response->isSuccess())
{
	$transactionItem = $response->getContent();
    
	// Check if the 3DSecure is forced by the server on this transaction, 
	// if yes, then we must use the 3DS url to finish the transaction
	if ($transactionItem->getSecure())
	{
	    // Using of the 3DS url
	    // You have to call this url to proceed the 3DS process
	    // $transactionItem->getSecureUrl();
	    
	}
	else
	{
	    // Shows the transaction status and id      
	    var_dump($transactionItem->getStatus());
	    var_dump($transactionItem->getTid());
	}
}
else
{
    var_dump($response->getErrorMessage());
}

Push payment notification

// EasyTransac notifies you for the payment status
// Then in your website, you have to create a script to receive the notification
$response = \EasyTransac\Core\PaymentNotification::getContent($_POST, $myApiKey);

// Response of type \EasyTransac\Entities\Notification
var_dump($response->toArray());

// Payment status
var_dump($response->getStatus());
You can’t perform that action at this time.