-
Notifications
You must be signed in to change notification settings - Fork 7
/
example.php
66 lines (54 loc) · 1.59 KB
/
example.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
<?php
require 'vendor/autoload.php';
use Onetoweb\NOWPayments\Client as NOWPaymentsClient;
// params
$apiKey = 'api key';
$testModus = true;
// init NOWPayments client
$nowPaymentsClient = new NOWPaymentsClient($apiKey, $testModus);
// get status
$status = $nowPaymentsClient->status->get();
// get currencies
$currencies = $nowPaymentsClient->currency->get();
// estimate
$estimate = $nowPaymentsClient->estimate->get([
'amount' => 1,
'currency_from' => 'eur',
'currency_to' => 'doge'
]);
// create payment
$payment = $nowPaymentsClient->payment->create([
'price_amount' => 32,
'price_currency' => 'eur',
'pay_currency' => 'doge',
'ipn_callback_url' => 'https://example.com/webhook.php',
'order_id' => 'order 1',
'order_description' => 'order_description'
]);
// get payment
$paymentId = 42;
$payment = $nowPaymentsClient->payment->get($paymentId);
// list payments
$payments = $nowPaymentsClient->payment->list([
'limit' => 10,
'page' => 0,
'sortBy' => 'created_at',
'orderBy' => 'asc',
'dateFrom' => '2020-01-01',
'dateTo' => '2022-01-01'
]);
// get min amount
$minAmount = $nowPaymentsClient->minAmount->get([
'currency_from' => 'btc',
'currency_to' => 'doge',
]);
// create invoice
$invoice = $nowPaymentsClient->invoice->create([
'price_amount' => 1000,
'price_currency' => 'eur',
'order_id' => 'order 1',
'order_description' => 'order_description',
'ipn_callback_url' => 'https://example.com/webhook.php',
'success_url' => 'https://example.com/webhook.php',
'cancel_url' => 'https://example.com/webhook.php'
]);