-
Notifications
You must be signed in to change notification settings - Fork 29
Expand file tree
/
Copy pathpaymentForm.php
More file actions
38 lines (32 loc) · 1.12 KB
/
Copy pathpaymentForm.php
File metadata and controls
38 lines (32 loc) · 1.12 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
/**
* Unitpay-hosted payment form: form() builds a URL to its payment page. Before form()
* you can attach optional parameters in a fluent style — backUrl (where to return the
* payer), the customer's contact, a fiscal receipt (see receipt.php). These parameters
* are merged into the request and cleared after a successful form().
*
* @link https://help.unitpay.ru/payments/create-payment-easy
*/
use Unitpay\Exception\UnitpayExceptionInterface;
use Unitpay\Unitpay;
require_once __DIR__ . '/../vendor/autoload.php';
require_once __DIR__ . '/config.php';
require_once __DIR__ . '/order.php';
$unitpay = new Unitpay($domain, $secretKey);
try {
$redirectUrl = $unitpay
->setBackUrl('https://example.com/order/' . $orderId)
->setCustomerEmail('[email protected]')
->setCustomerPhone('79000000000')
->form(
$publicId,
$orderSum,
$orderId,
$orderDesc,
$orderCurrency
);
header("Location: " . $redirectUrl);
exit;
} catch (UnitpayExceptionInterface $exception) {
print 'SDK error: ' . $exception->getMessage();
}