1. Go to this page and download the library: Download fintreen/laravel-client library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
fintreen / laravel-client example snippets
$fintreen = new FintreenModel();
$fintreen->initClient();
$this->data['fintreenCurrencies'] = $fintreen->getClient()->getCurrenciesList();
$this->data['statusesList'] = $fintreen->getClient()->getOrderStatusList();
$this->data['calculation'] = $fintreen->getClient()->calculate($amount, $cryptoCodes);
/*####....*/
$fintreen->getClient()->createTransaction($amount, $cryptoCode)
/* you can also use:
checkTransaction(), getTransactionsList() and sendRequest() methods, just like in the php client with getClient() method.
*/
/* Alternatively you can use createTransaction and getCurrenciesList without getClient*/
$fintreen->getCurrenciesList(); // This has cache wrapper with TTL of 10 minutes by default
// but you can use raw no cache method via client $fintreen->getClient()->getCurrenciesList();
[$linkToRedirect, $createdTransaction] = $fintreen->createTransaction($amount, $cryptoCode);
$fintreen = new FintreenModel();
$fintreen->initClient($token, $email, $isTest);
use Fintreen\Laravel\app\Models\Fintreen\FintreenModel;
....
$fintreen = new FintreenModel();
$fintreen->initClient();
$calcData = $fintreen->getClient()->calculate($amount, $cryptoCodes);
[$linkToRedirect, $createdTransaction] = $fintreen->createTransaction($amount, $cryptoCode);
return redirect($linkToRedirect); // Redirect user to gateway link
use Fintreen\Laravel\app\Exceptions\FintreenApiException;
use Fintreen\Laravel\app\Models\Fintreen\FintreenModel;
use Illuminate\Support\Facades\Log;
use Illuminate\Support\Facades\Response;
use Illuminate\Http\Request;
// .........
$fintreen = new FintreenModel();
$fintreen->initClient();
$this->data['fintreenCurrencies'] = $fintreen->getCurrenciesList();
if ($request->isMethod('post')) {
$error = false;
$token = $request->post('g-recaptcha-response');
$cryptoCode = $request->post('crypto-code');
$amount = (float)$request->post('amount');
$captchaValidaion = $this->validateRecaptcha($token, 'submit');
if (!$captchaValidaion) {
$error = true;
$this->data['validationErrors'][] = 'Google recaaptcha check failed';
}
if (!$amount) {
$error = true;
$this->data['validationErrors'][] = 'Minimum amount is ' . FintreenModel::MIN_EURO_AMOUNT_DEFAULT;
}
if (isset($this->data['fintreenCurrencies']['crypto'])) {
$exists = false;
foreach ($this->data['fintreenCurrencies']['crypto'] as $fintreenCryptoCurrency) {
if ($fintreenCryptoCurrency['code'] == $cryptoCode) {
if ( $fintreenCryptoCurrency['min_eur_api'] > $amount) {
$error = true;
$this->data['validationErrors'][] = 'Minimum amount is ' . $fintreenCryptoCurrency['min_eur_api'];
}
$exists = true;
break;
}
}
if (!$exists) {
$error = true;
$this->data['validationErrors'][] = 'Crypto code validation error';
}
} else {
$error = true;
$this->data['validationErrors'][] = 'Crypto code validation error';
}
if ($error === false) {
try {
[$linkToRedirect, $createdTransaction] = $fintreen->createTransaction($amount, $cryptoCode);
return redirect($linkToRedirect);
} catch (FintreenApiException $e) {
Log::channel('fintreen_deposit')->debug($e->getMessage(), ['context' => $e]);
$this->data['validationErrors'][] = 'Something went wrong';
} catch (\Exception $e) {
Log::channel('fintreen_deposit')->debug($e->getMessage(), ['context' => $e]);
$this->data['validationErrors'][] = 'Something went wrong';
}
}
}
use Fintreen\Laravel\app\Models\Fintreen\FintreenModel;
$fintreenModel = new FintreenModel();
$fintreenModel->initClient();
$filters = [];
$fintreenModel->getClient()->getTransactionsList($filters); // returns array
// Or use raw
$fintreenModel->getClient()->sendRequest('transactions', 'GET', $filters); // returns json string
use Fintreen\Laravel\app\Models\Fintreen\FintreenModel;
//***
$fintreenModel = new FintreenModel();
$modelItem = $fintreenModel->find(1); // Use local id here
$modelItem->initClient(); //
$modelItem->check();
// ! Or use callable
// Callback usage in the application
$modelItem->check(function ($successfullTransaction) {
// Code to deposit amount to user balance
});
$fintreenModel->check(function ($successfullTransaction) use ($someData) {
// Code to deposit amount to user balance
});
use Fintreen\Laravel\app\Events\FintreenTransactionIsSuccess;
Event::listen(FintreenTransactionIsSuccess::class, function ($event) {
// Handle the event, e.g., update user balance
});
namespace App\Listeners;
use Fintreen\Laravel\app\Events\FintreenTransactionIsSuccess;
class FintreenTransactionIsSuccessListener
{
/**
* Create the event listener.
*
* @return void
*/
public function __construct()
{}
/**
* Handle the event.
*
* @param object $event
* @return void
*/
public function handle(FintreenTransactionIsSuccess $event)
{
$a = 1;
}
}