PHP code example of kryptoexpress / kryptoexpress-php

1. Go to this page and download the library: Download kryptoexpress/kryptoexpress-php 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/ */

    

kryptoexpress / kryptoexpress-php example snippets




use KryptoExpress\SDK\KryptoExpressClient;

$client = new KryptoExpressClient('your-api-key');

$payment = $client->payments()->createPayment(
    cryptoCurrency: 'BTC',
    fiatCurrency: 'USD',
    fiatAmount: 10.0,
    callbackUrl: 'https://merchant.example/callback',
    callbackSecret: 'shared-secret',
);

$wallet = $client->wallet()->get();
$prices = $client->currencies()->getPrices(['BTC', 'ETH'], 'USD');
$fiatCurrencies = $client->fiat()->list();

$client->payments()->create($request);
$client->payments()->createPayment(...);
$client->payments()->createDeposit(...);
$client->payments()->getByHash(...);

$client->wallet()->get();
$client->wallet()->withdraw(...);
$client->wallet()->calculate(...);
$client->wallet()->withdrawAll(...);
$client->wallet()->withdrawSingle(...);
$client->wallet()->calculateAll(...);
$client->wallet()->calculateSingle(...);

$client->currencies()->listAll();
$client->currencies()->listNative();
$client->currencies()->listStable();
$client->currencies()->getPrices(...);

$client->fiat()->list();



use KryptoExpress\SDK\ClientConfig;
use KryptoExpress\SDK\KryptoExpressClient;
use KryptoExpress\SDK\Rules\StaticFiatConverter;

$client = new KryptoExpressClient(
    'your-api-key',
    new ClientConfig(
        fiatConverter: new StaticFiatConverter([
            'EUR' => 0.91,
            'GBP' => 0.79,
        ]),
    ),
);



use KryptoExpress\SDK\ClientConfig;
use KryptoExpress\SDK\KryptoExpressClient;

$client = new KryptoExpressClient(
    'your-api-key',
    new ClientConfig(validateMinimumAmounts: false),
);



$isValid = $client->webhook()->verify($rawBody, 'callback-secret', $_SERVER['HTTP_X_SIGNATURE'] ?? null);



use KryptoExpress\SDK\KryptoExpressClient;
use Nyholm\Psr7\Factory\Psr17Factory;
use Symfony\Component\HttpClient\Psr18Client;

$client = KryptoExpressClient::withPsr18(
    'your-api-key',
    new Psr18Client(),
    new Psr17Factory(),
);
bash
composer