-
Notifications
You must be signed in to change notification settings - Fork 29
Expand file tree
/
Copy pathtwoStagePayment.php
More file actions
38 lines (29 loc) · 1.05 KB
/
Copy pathtwoStagePayment.php
File metadata and controls
38 lines (29 loc) · 1.05 KB
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
<?php
header('Content-Type: text/html; charset=UTF-8');
/**
* Two-stage payments: confirm (capture) or cancel (release) held funds.
* Note: confirmPayment/cancelPayment return `message` at the top level,
* not `result->message`.
*
* @link https://help.unitpay.ru/api/confirm-payment
* @link https://help.unitpay.ru/api/cancel-payment
*/
use Unitpay\Exception\UnitpayExceptionInterface;
use Unitpay\Unitpay;
require_once __DIR__ . '/../vendor/autoload.php';
require_once __DIR__ . '/config.php';
$unitpay = new Unitpay($domain, $secretKey);
$paymentId = 3403575;
try {
// Capture the held funds.
$response = $unitpay->payments()->confirmPayment($paymentId);
// ...or release without capturing.
// $response = $unitpay->payments()->cancelPayment($paymentId);
if (isset($response->message)) {
print $response->message;
} elseif (isset($response->error->message)) {
print 'Error: ' . $response->error->message;
}
} catch (UnitpayExceptionInterface $exception) {
print 'SDK error: ' . $exception->getMessage();
}