-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathinit.php
45 lines (34 loc) · 1.33 KB
/
init.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
<?php
use Pada\Tinkoff\Payment\PaymentClient;
use function Pada\Tinkoff\Payment\Functions\newPayment;
use function Pada\Tinkoff\Payment\Functions\newReceipt;
use function Pada\Tinkoff\Payment\Functions\newReceiptItem;
require 'vendor/autoload.php';
// ------------------------------------------------------------------------------------------------
// 1 - Создание клиента
$paymentClient = PaymentClient::create('<terminal_key>', '<password>');
// ------------------------------------------------------------------------------------------------
// 2 - Создание обьекта платежа
$payment = newPayment()
->orderId('1234')
->oneStep()
->receipt(newReceipt()
->email('[email protected]')
->taxationOSN()
->addItem(newReceiptItem()
->name('Кружка')
->price(1000)
->quantity(1)
->taxNone()
->build())
->build())
->build();
// ------------------------------------------------------------------------------------------------
// 3 - Вызываем API
$result = $paymentClient->init($payment);
if ($result->isSuccess()) {
print 'PaymentId: ' . $result->getPaymentId() . "\n";
print 'PaymentURL: ' . $result->getPaymentURL() . "\n";
} else {
print 'Error: ' . $result->getMessage() . "\n";
}