Download the PHP package fintreen/laravel-client without Composer

On this page you can find all versions of the php package fintreen/laravel-client. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package laravel-client

Laravel client for fintreen.com.

Fintreen.com laravel client for crypto-payment gateway API

MIT License

Fintreen.com laravel client


Explore the docs on apiary »

Report Bug · Request Feature .

>>> PHP Client <<<

Tested on php 8.0, 8.1, 8.2. Should be also good with php 8.3. Tested on laravel 9, 10.

Use composer2 for package installation.

Installation:

1. Add next env variables to your .env file

2. Install the client

3. Publish config

4. Migrate

Laravel BackPack + Settings integration

If you are using Laravel BackPack and Settings add-on you can use FINTREEN_USE_BAKCPACK=true at your .env. It will add fintreen_token and fintreen_email setting from the FINTREEN_TOKEN and FINTREEN_EMAIL to database, and default client initialization (without params) will use them. But if no setting were found (db records are empty) even if you are using FINTREEN_USE_BAKCPACK flag, it will fallback to configuration values from .env. Otherwise you can use own params on initClient method.

Usage:

0. General usage

You can use all methods from php-client with getClient() method. Example:

1. Client initialization

As far as this is just a laravel wrapper, you can initialize the client with no params. This will load config from config/fintreen.php file which should be published (installation point 3) which takes env variables.

Bit still you can init client with own params.

2. Calculation

You can use existing route to calculate with {{route('fintreen.calculate')}} which goes to /fintreen/calculate by default. The POST params you need to set are currency (CryptoCode) and amount (Fiat in EUR).

Exaple of using this with jQuery

But for sure its better to use custom route. Take a look on calculateAction in ./vendor/fintreen/laravel-client/src/app/Http/Controllers/FintreenController.php

Note that in custom variant you can set parameters for initClient and use comma-separated crypto codes calculate method.

3. Create transaction

Example with validation in real project:

4. Transaction list and check

4.1 Transactions list

List transactions are just like with php client.

The params to filter can be found here https://fintreen.docs.apiary.io/#/reference/order-flow/transactions-list/get-transactions-list/200?mc=reference%2Forder-flow%2Ftransactions-list%2Fget-transactions-list%2F200

4.2 Transaction check

To check if transactions are paid you can use console command fintreen:transactions:check

It run the check mehod on FintreenModel.

Also you can call this method from instance with callback.

!! Note, that callback fires only if transaction is successful.

5. How to handle transaction paid event (deposit balance in your app if transaction is successful)

This is most dangerous one. Please be careful and avoid double checking and depositing balances.

The check method on FintreenModel can get callback. In case that transaction is paid it will: 1) update status in table 2) then dispatch event FintreenTransactionIsSuccess 3) if callback is set it will fire the callback.

There are 2 ways - use custom check with callable as described above and events subscribtion.

Callback method:

!! Note, that callback fires only if transaction is successful.

Event method:

When transaction is successful FintreenTransactionIsSuccess event is triggered.

To create it read https://laravel.com/docs/10.x/events#registering-events-and-listeners

Example of listiner

Dont forget to register it at your App\Providers\EventServiceProvider

!! Note, that event dispatches only if transaction is successful.

6. Using webhook

6.1 Using exsting webhook

You can set existing webhook to retrive data when transaction is checked. By default it uses /fintreen/webhook but you still need to set it on your settings in https://fintreen.com/account/tokens at Update webhook section AND ignore CSFR in this POST request the middleware. To do that please edit your VerifyCsrfToken at App\Http\Middleware\VerifyCsrfToken

If you are using existing webhook, by default it will run check method on FintreenModel to handle transaction there. This method will mark transaction as successful and dispatch FintreenTransactionIsSuccess event.

6.2 Using custom webhook

Example how to retrieve data by custom webhook.

1) create route 2) check its working with POST request without Csrf 3) set it in your account settings https://fintreen.com/account/tokens at Update webhook section 4) get the data

In your routes/web.php

6.3 Webhook format

Format is json:

To retrieve webhook data to check transaction you can use:

7. Good practices and Exception handling

It would be good to use own logging channel for this library. Add to config/logging.php new channel

There are two types of exception for now

FintreenClientException - when client is not properly initialized

FintreenApiException - when request fails


All versions of laravel-client with dependencies

PHP Build Version
Package Version
Requires php Version ^8.0
fintreen/php-client Version ^1.0
ext-curl Version *
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package fintreen/laravel-client contains the following files

Loading the files please wait ....