-
Notifications
You must be signed in to change notification settings - Fork 29
Expand file tree
/
Copy pathrefund.php
More file actions
30 lines (23 loc) · 817 Bytes
/
Copy pathrefund.php
File metadata and controls
30 lines (23 loc) · 817 Bytes
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
<?php
header('Content-Type: text/html; charset=UTF-8');
/**
* Payment refund (full or partial)
*
* @link https://help.unitpay.ru/api/payment-refund
*/
use Unitpay\Exception\UnitpayExceptionInterface;
use Unitpay\Unitpay;
require_once __DIR__ . '/../vendor/autoload.php';
require_once __DIR__ . '/config.php';
$unitpay = new Unitpay($domain, $secretKey);
try {
// Omit the options for a full refund; pass ['sum' => 100] to refund part of it.
$response = $unitpay->payments()->refundPayment(3403575);
if (isset($response->result->message)) {
print $response->result->message;
} elseif (isset($response->error->message)) {
print 'Error: ' . $response->error->message;
}
} catch (UnitpayExceptionInterface $exception) {
print 'SDK error: ' . $exception->getMessage();
}