PHP SDK
PHP SDK module for working with the Cryptomus API
Installation and connection
Installation using composer:
1composer require cryptomus/api-php-sdk
COPYAuthorization
php_sdk.PAYOUT_KEY or PAYMENT_KEY, also MERCHANT_UUID required to use SDK details in documentation
1const PAYMENT_KEY = 'uQ4LFWCBE3dT84uQnt7ycL7p9WcSwjkSPQaZbik3ChoWO0egw51f4EAaZQKmefhPP0F1cX8OpRcl2c3HexNedoR7FGEYGA1mTgMPI8lzKl7Ct2I43R6SSC3gVDS3rkGX';
2const MERCHANT_UUID = 'c26b80a8-9549-4a66-bb53-774f12809249';
3
4$payment = \Cryptomus\Api\Client::payment(PAYMENT_KEY, MERCHANT_UUID);
COPY
1const PAYOUT_KEY = 'qseRhcxu6wsxhygfhyidwrrgryrrgefhPP0F1cNedoR7FGEYGA1mTgMPX8OpRcl2c3HexNedoR7FGEYGA1mTgMPI8lzKl7Ct2I43R6S1f4EAaZQKmefhSC3gVDS3rkGX';
2const MERCHANT_UUID = 'c26b80a8-9549-4a66-bb53-774f12809249';
3
4$payout = \Cryptomus\Api\Client::payout(PAYOUT_KEY, MERCHANT_UUID);
COPYPayout methods
Payout request
1$data = [
2 'amount' => '15',
3 'currency' => 'USD',
4 'network' => 'TRON',
5 'order_id' => '555321',
6 'address' => 'TXguLRFtrAFrEDA17WuPfrxB84jVzJcNNV',
7 'is_subtract' => '1',
8 'url_callback' => 'https://example.com/callback'
9];
10
11$result = $payout->create($data);
COPYcomposer:
1array(9) {
2 ["uuid"]=>
3 string(36) "a7c0caec-a594-4aaa-b1c4-77d511857594"
4 ["amount"]=>
5 string(1) "3"
6 ["currency"]=>
7 string(3) "TRX"
8 ["network"]=>
9 string(4) "tron"
10 ["address"]=>
11 string(5) "TJ..."
12 ["txid"]=>
13 NULL
14 ["status"]=>
15 string(7) "process"
16 ["is_final"]=>
17 bool(false)
18 ["balance"]=>
19 int(129)
20}
COPYInfo
1$data = ["uuid" => "a7c0caec-a594-4aaa-b1c4-77d511857594"];
2// or
3$data = ["order_id" => "12345"];
4
5$result = $payout->info($data);
COPYcomposer:
1array(9) {
2 ["uuid"]=>
3 string(36) "a7c0caec-a594-4aaa-b1c4-77d511857594"
4 ["amount"]=>
5 string(10) "3.00000000"
6 ["currency"]=>
7 string(3) "TRX"
8 ["network"]=>
9 string(4) "tron"
10 ["address"]=>
11 string(6) "TJZ..."
12 ["txid"]=>
13 NULL
14 ["status"]=>
15 string(7) "process"
16 ["is_final"]=>
17 bool(false)
18 ["balance"]=>
19 string(12) "129.00000000"
20}
COPYPayment methods
Payment services
1$result = $payment->services();
COPYcomposer:
1array(1) {
2 [0]=>
3 array(5) {
4 ["network"]=>
5 string(4) "TRON"
6 ["currency"]=>
7 string(3) "TRX"
8 ["is_available"]=>
9 bool(true)
10 ["limit"]=>
11 array(2) {
12 ["min_amount"]=>
13 string(10) "1.00000000"
14 ["max_amount"]=>
15 string(11) "10.00000000"
16 }
17 ["commission"]=>
18 array(2) {
19 ["fee_amount"]=>
20 string(4) "0.00"
21 ["percent"]=>
22 string(4) "0.00"
23 }
24 }
25}
COPYPayment create
1$data = [
2 'amount' => '16',
3 'currency' => 'USD',
4 'network' => 'ETH',
5 'order_id' => '555123',
6 'url_return' => 'https://example.com/return',
7 'url_callback' => 'https://example.com/callback',
8 'is_payment_multiple' => false,
9 'lifetime' => '7200',
10 'to_currency' => 'ETH'
11];
12
13$result = $payment->create($data);
COPYcomposer:
1array(14) {
2 ["uuid"]=>
3 string(36) "8b03432e-385b-4670-8d06-064591096795"
4 ["amount"]=>
5 string(2) "16"
6 ["order_id"]=>
7 string(7) "test_19"
8 ["currency"]=>
9 string(3) "TRX"
10 ["comments"]=>
11 NULL
12 ["network"]=>
13 string(4) "tron"
14 ["address"]=>
15 string(5) "TW..."
16 ["from"]=>
17 NULL
18 ["txid"]=>
19 NULL
20 ["payment_status"]=>
21 string(5) "check"
22 ["url"]=>
23 string(66) "https://pay.cryptomus.com/pay/8b03432e-385b-4670-8d06-064591096795"
24 ["expired_at"]=>
25 int(1650980953)
26 ["status"]=>
27 string(5) "check"
28 ["is_final"]=>
29 bool(false)
30}
COPYInfo
1$data = ["uuid" => "a7c0caec-a594-4aaa-b1c4-77d511857594"];
2// or
3$data = ["order_id" => "12345"];
4
5$result = $payment->info($data);
COPYcomposer:
1array(15) {
2 ["uuid"]=>
3 string(36) "8b03432e-385b-4670-8d06-064591096795"
4 ["order_id"]=>
5 string(7) "test_10"
6 ["amount"]=>
7 string(11) "16.00000000"
8 ["payment_amount"]=>
9 string(8) "0.000000"
10 ["currency"]=>
11 string(3) "TRX"
12 ["comments"]=>
13 NULL
14 ["network"]=>
15 string(4) "tron"
16 ["address"]=>
17 string(5) "TW..."
18 ["from"]=>
19 NULL
20 ["txid"]=>
21 NULL
22 ["payment_status"]=>
23 string(5) "check"
24 ["url"]=>
25 string(66) "https://pay.cryptomus.com/pay/8b03432e-385b-4670-8d06-064591096795"
26 ["expired_at"]=>
27 int(1650980953)
28 ["status"]=>
29 string(4) "paid"
30 ["is_final"]=>
31 bool(true)
32}
COPYPayment history
1$page = 3;
2
3$result = $payment->history($page);
COPYcomposer:
1array(2) {
2 ["items"]=>
3 array(1) {
4 [0]=>
5 array(15) {
6 ["uuid"]=>
7 string(36) "87094a43-5fe4-4629-b2fd-c37e8e2af76c"
8 ["order_id"]=>
9 string(10) "1650956609"
10 ["amount"]=>
11 string(11) "16.00000000"
12 ["payment_amount"]=>
13 string(10) "0.01200000"
14 ["currency"]=>
15 string(3) "ETH"
16 ["comments"]=>
17 NULL
18 ["network"]=>
19 string(3) "eth"
20 ["address"]=>
21 string(5) "0x..."
22 ["from"]=>
23 string(6) "0x4..."
24 ["txid"]=>
25 NULL
26 ["payment_status"]=>
27 string(4) "paid"
28 ["url"]=>
29 string(66) "https://pay.cryptomus.com/pay/87094a43-5fe4-4629-b2fd-c37e8e2af76c"
30 ["expired_at"]=>
31 int(1650960209)
32 ["status"]=>
33 string(4) "paid"
34 ["is_final"]=>
35 bool(true)
36 }
37 }
38 ["paginate"]=>
39 array(5) {
40 ["count"]=>
41 int(2)
42 ["hasPages"]=>
43 bool(false)
44 ["nextCursor"]=>
45 NULL
46 ["previousCursor"]=>
47 NULL
48 ["perPage"]=>
49 int(15)
50 }
51}
COPYBalance
1$result = $payment->balance();
COPYcomposer:
1array(1) {
2 [0]=>
3 array(1) {
4 ["balance"]=>
5 array(2) {
6 ["merchant"]=>
7 array(6) {
8 [0]=>
9 array(3) {
10 ["uuid"]=>
11 string(32) "abcdabcd-abcd-1234-1234-abcdabcd"
12 ["balance"]=>
13 string(10) "0.00000000"
14 ["currency_code"]=>
15 string(3) "ETH"
16 }
17 [1]=>
18 array(3) {
19 ["uuid"]=>
20 string(32) "abcdabcd-abcd-1234-1234-abcdabcd"
21 ["balance"]=>
22 string(10) "0.57000000"
23 ["currency_code"]=>
24 string(3) "BTC"
25 }
26 [2]=>
27 array(3) {
28 ["uuid"]=>
29 string(32) "abcdabcd-abcd-1234-1234-abcdabcd"
30 ["balance"]=>
31 string(11) "23.57327446"
32 ["currency_code"]=>
33 string(3) "TRX"
34 }
35 [3]=>
36 array(3) {
37 ["uuid"]=>
38 string(32) "abcdabcd-abcd-1234-1234-abcdabcd"
39 ["balance"]=>
40 string(10) "5.00000000"
41 ["currency_code"]=>
42 string(4) "USDT"
43 }
44 [4]=>
45 array(3) {
46 ["uuid"]=>
47 string(32) "abcdabcd-abcd-1234-1234-abcdabcd"
48 ["balance"]=>
49 string(11) "10.00120000"
50 ["currency_code"]=>
51 string(4) "DASH"
52 }
53 [5]=>
54 array(3) {
55 ["uuid"]=>
56 string(32) "abcdabcd-abcd-1234-1234-abcdabcd"
57 ["balance"]=>
58 string(10) "0.18500000"
59 ["currency_code"]=>
60 string(3) "LTC"
61 }
62 }
63 ["user"]=>
64 array(6) {
65 [0]=>
66 array(3) {
67 ["uuid"]=>
68 string(32) "abcdabcd-abcd-1234-1234-abcdabcd"
69 ["balance"]=>
70 string(10) "0.40000000"
71 ["currency_code"]=>
72 string(3) "BTC"
73 }
74 [1]=>
75 array(3) {
76 ["uuid"]=>
77 string(32) "abcdabcd-abcd-1234-1234-abcdabcd"
78 ["balance"]=>
79 string(11) "52.00000000"
80 ["currency_code"]=>
81 string(4) "USDT"
82 }
83 [2]=>
84 array(3) {
85 ["uuid"]=>
86 string(32) "abcdabcd-abcd-1234-1234-abcdabcd"
87 ["balance"]=>
88 string(10) "0.00000000"
89 ["currency_code"]=>
90 string(4) "DASH"
91 }
92 [3]=>
93 array(3) {
94 ["uuid"]=>
95 string(32) "abcdabcd-abcd-1234-1234-abcdabcd"
96 ["balance"]=>
97 string(10) "0.30000000"
98 ["currency_code"]=>
99 string(3) "LTC"
100 }
101 [4]=>
102 array(3) {
103 ["uuid"]=>
104 string(32) "abcdabcd-abcd-1234-1234-abcdabcd"
105 ["balance"]=>
106 string(11) "27.00000000"
107 ["currency_code"]=>
108 string(3) "TRX"
109 }
110 [5]=>
111 array(3) {
112 ["uuid"]=>
113 string(32) "abcdabcd-abcd-1234-1234-abcdabcd"
114 ["balance"]=>
115 string(10) "0.19000000"
116 ["currency_code"]=>
117 string(3) "ETH"
118 }
119 }
120 }
121 }
122}
COPYResend notification
1$data = ["uuid" => "a7c0caec-a594-4aaa-b1c4-77d511857594"];
2// or
3$data = ["order_id" => "12345"];
4
5$result = $payment->reSendNotifications($data);
COPYcomposer:
1bool(true)
COPYCreate static wallet
1$data = [
2 'network' => 'TRON',
3 'currency' => 'USDT',
4 'order_id' => '5535321',
5 'url_callback' => 'https://example.com/callback'
6];
7
8$result = $payment->createWallet($data);
COPYcomposer:
1array(5) {
2 ["uuid"]=>
3 string(12) "9f64a7ce-..."
4 ["order_id"]=>
5 string(2) "24"
6 ["currency"]=>
7 string(4) "USDT"
8 ["network"]=>
9 string(4) "tron"
10 ["address"]=>
11 string(6) "TK8..."
12}
COPYExceptions
All methods can throw request builder exception.
1$payment = \Cryptomus\Api\Client::payment(PAYOUT_KEY, MERCHANT_UUID);
2
3try {
4 $result = $payment->services();
5} catch (\Cryptomus\Api\RequestBuilderException $e) {
6 log('Error request Cryptomus to method ' . $e->getMethod() . ': ' . $e->getMessage());
7}
COPY