Wallogit.com
2017 © Pedro Peláez
Make your EasyTransac API implementation easier with our SDK., (*2)
The EasyTransac SDK is a tool to process payments with the EasyTransac API., (*3)
You need at least: - PHP >=5.6 - 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, (*4)
Execute this command on your terminal in the project folder:, (*5)
composer require easytransac/easytransac-sdk-php
Or add this in your composer.json:, (*6)
"require": {
...
"easytransac/easytransac-sdk-php": "*",
}
In order to use it, you only need to require the autoload file easytransac/easytransac-sdk-php/sdk/EasyTransac/autoload.php., (*7)
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., (*8)
Samples are provided with the SDK., (*9)
// 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);
// Connexion timeout in second
EasyTransac\Core\Services::getInstance()->setRequestTimeout(30);
// You can change the log directory (by default the path is the running script path)
Logger::getInstance()->setFilePath('YOU_CUSTOM_PATH');
$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());
}
// 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()); // If you have a doubt about a value that does not exist in the response, // you can print the superglobal $_POST, all notification values are there: var_dump($_POST);
// You can get the complete response from the api with these methods bellow $dp = new EasyTransac\Requests\DirectPayment(); $response = $dp->execute($transaction); var_dump($response->getRealJsonResponse()); // Jsonified response (stdClass object) var_dump($response->getRealArrayResponse()); // Array item