PHP code example of cryptomus / api-php-sdk

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

    

cryptomus / api-php-sdk example snippets




const PAYMENT_KEY = 'uQ4LFWCBE3dT84uQnt7ycL7p9WcSwjkSPQaZbik3ChoWO0egw51f4EAaZQKmefhPP0F1cX8OpRcl2c3HexNedoR7FGEYGA1mTgMPI8lzKl7Ct2I43R6SSC3gVDS3rkGX';
const MERCHANT_UUID = 'c26b80a8-9549-4a66-bb53-774f12809249';

$payment = \Cryptomus\Api\Client::payment(PAYMENT_KEY, MERCHANT_UUID);




const PAYOUT_KEY = 'qseRhcxu6wsxhygfhyidwrrgryrrgefhPP0F1cNedoR7FGEYGA1mTgMPX8OpRcl2c3HexNedoR7FGEYGA1mTgMPI8lzKl7Ct2I43R6S1f4EAaZQKmefhSC3gVDS3rkGX';
const MERCHANT_UUID = 'c26b80a8-9549-4a66-bb53-774f12809249';

$payout = \Cryptomus\Api\Client::payout(PAYOUT_KEY, MERCHANT_UUID);




$data = [
    'amount' => '15',
    'currency' => 'USD',
    'network' => 'TRON',
    'order_id' => '555321',
    'address' => 'TXguLRFtrAFrEDA17WuPfrxB84jVzJcNNV',
    'is_subtract' => '1',
    'url_callback' => 'https://example.com/callback'
];

$result = $payout->create($data);




$data = ["uuid" => "a7c0caec-a594-4aaa-b1c4-77d511857594"];
// or
$data = ["order_id" => "12345"];

$result = $payout->info($data);




$result = $payment->services();




$data = [
    'amount' => '16',
    'currency' => 'USD',
    'network' => 'ETH',
    'order_id' => '555123',
    'url_return' => 'https://example.com/return',
    'url_callback' => 'https://example.com/callback',
    'is_payment_multiple' => false,
    'lifetime' => '7200',
    'to_currency' => 'ETH'
];

$result = $payment->create($data);




$data = ["uuid" => "a7c0caec-a594-4aaa-b1c4-77d511857594"];
// or
$data = ["order_id" => "12345"];

$result = $payment->info($data);




$page = 3;

$result = $payment->history($page);




$result = $payment->balance();




$data = ["uuid" => "a7c0caec-a594-4aaa-b1c4-77d511857594"];
// or
$data = ["order_id" => "12345"];

$result = $payment->reSendNotifications($data);




$data = [
    'network' => 'TRON',
    'currency' => 'USDT',
    'order_id' => '5535321',
    'url_callback' => 'https://example.com/callback'
];

$result = $payment->createWallet($data);




$payment = \Cryptomus\Api\Client::payment(PAYOUT_KEY, MERCHANT_UUID);

try {
    $result = $payment->services();
} catch (\Cryptomus\Api\RequestBuilderException $e) {
    log('Error request Cryptomus to method ' . $e->getMethod() . ': ' . $e->getMessage());
}

bash
$ composer 

array(1) {
  [0]=>
  array(5) {
    ["network"]=>
    string(4) "TRON"
    ["currency"]=>
    string(3) "TRX"
    ["is_available"]=>
    bool(true)
    ["limit"]=>
    array(2) {
      ["min_amount"]=>
      string(10) "1.00000000"
      ["max_amount"]=>
      string(11) "10.00000000"
    }
    ["commission"]=>
    array(2) {
      ["fee_amount"]=>
      string(4) "0.00"
      ["percent"]=>
      string(4) "0.00"
    }
  }
}


array(2) {
  ["items"]=>
  array(1) {
    [0]=>
    array(15) {
      ["uuid"]=>
      string(36) "87094a43-5fe4-4629-b2fd-c37e8e2af76c"
      ["order_id"]=>
      string(10) "1650956609"
      ["amount"]=>
      string(11) "16.00000000"
      ["payment_amount"]=>
      string(10) "0.01200000"
      ["currency"]=>
      string(3) "ETH"
      ["comments"]=>
      NULL
      ["network"]=>
      string(3) "eth"
      ["address"]=>
      string(5) "0x..."
      ["from"]=>
      string(6) "0x4..."
      ["txid"]=>
      NULL
      ["payment_status"]=>
      string(4) "paid"
      ["url"]=>
      string(66) "https://pay.cryptomus.com/pay/87094a43-5fe4-4629-b2fd-c37e8e2af76c"
      ["expired_at"]=>
      int(1650960209)
      ["status"]=>
      string(4) "paid"
      ["is_final"]=>
      bool(true)
    }
  }
  ["paginate"]=>
  array(5) {
    ["count"]=>
    int(2)
    ["hasPages"]=>
    bool(false)
    ["nextCursor"]=>
    NULL
    ["previousCursor"]=>
    NULL
    ["perPage"]=>
    int(15)
  }
}

array(1) {
  [0]=>
  array(1) {
    ["balance"]=>
    array(2) {
      ["merchant"]=>
      array(6) {
        [0]=>
        array(3) {
          ["uuid"]=>
          string(32) "abcdabcd-abcd-1234-1234-abcdabcd"
          ["balance"]=>
          string(10) "0.00000000"
          ["currency_code"]=>
          string(3) "ETH"
        }
        [1]=>
        array(3) {
          ["uuid"]=>
          string(32) "abcdabcd-abcd-1234-1234-abcdabcd"
          ["balance"]=>
          string(10) "0.57000000"
          ["currency_code"]=>
          string(3) "BTC"
        }
        [2]=>
        array(3) {
          ["uuid"]=>
          string(32) "abcdabcd-abcd-1234-1234-abcdabcd"
          ["balance"]=>
          string(11) "23.57327446"
          ["currency_code"]=>
          string(3) "TRX"
        }
        [3]=>
        array(3) {
          ["uuid"]=>
          string(32) "abcdabcd-abcd-1234-1234-abcdabcd"
          ["balance"]=>
          string(10) "5.00000000"
          ["currency_code"]=>
          string(4) "USDT"
        }
        [4]=>
        array(3) {
          ["uuid"]=>
          string(32) "abcdabcd-abcd-1234-1234-abcdabcd"
          ["balance"]=>
          string(11) "10.00120000"
          ["currency_code"]=>
          string(4) "DASH"
        }
        [5]=>
        array(3) {
          ["uuid"]=>
          string(32) "abcdabcd-abcd-1234-1234-abcdabcd"
          ["balance"]=>
          string(10) "0.18500000"
          ["currency_code"]=>
          string(3) "LTC"
        }
      }
      ["user"]=>
      array(6) {
        [0]=>
        array(3) {
          ["uuid"]=>
          string(32) "abcdabcd-abcd-1234-1234-abcdabcd"
          ["balance"]=>
          string(10) "0.40000000"
          ["currency_code"]=>
          string(3) "BTC"
        }
        [1]=>
        array(3) {
          ["uuid"]=>
          string(32) "abcdabcd-abcd-1234-1234-abcdabcd"
          ["balance"]=>
          string(11) "52.00000000"
          ["currency_code"]=>
          string(4) "USDT"
        }
        [2]=>
        array(3) {
          ["uuid"]=>
          string(32) "abcdabcd-abcd-1234-1234-abcdabcd"
          ["balance"]=>
          string(10) "0.00000000"
          ["currency_code"]=>
          string(4) "DASH"
        }
        [3]=>
        array(3) {
          ["uuid"]=>
          string(32) "abcdabcd-abcd-1234-1234-abcdabcd"
          ["balance"]=>
          string(10) "0.30000000"
          ["currency_code"]=>
          string(3) "LTC"
        }
        [4]=>
        array(3) {
          ["uuid"]=>
          string(32) "abcdabcd-abcd-1234-1234-abcdabcd"
          ["balance"]=>
          string(11) "27.00000000"
          ["currency_code"]=>
          string(3) "TRX"
        }
        [5]=>
        array(3) {
          ["uuid"]=>
          string(32) "abcdabcd-abcd-1234-1234-abcdabcd"
          ["balance"]=>
          string(10) "0.19000000"
          ["currency_code"]=>
          string(3) "ETH"
        }
      }
    }
  }
}