forked from tpay-com/tpay-php
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBlikTransactionExample.php
72 lines (61 loc) · 1.74 KB
/
BlikTransactionExample.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
67
68
69
70
71
72
<?php
/*
* Created by tpay.com
*/
namespace tpayLibs\examples;
use tpayLibs\src\_class_tpay\PaymentBlik;
use tpayLibs\src\_class_tpay\Utilities\TException;
use tpayLibs\src\_class_tpay\Utilities\Util;
include_once 'config.php';
include_once 'loader.php';
class BlikTransactionExample extends PaymentBlik
{
public function __construct()
{
$this->merchantSecret = 'demo';
$this->merchantId = 1010;
$this->trApiKey = '75f86137a6635df826e3efe2e66f7c9a946fdde1';
$this->trApiPass = 'p@$$w0rd#@!';
parent::__construct();
$this->init();
}
public function init()
{
if (isset($_POST['blik_code'])) {
$this->blikTransaction($_POST['blik_code']);
} else {
echo $this->getBlikForm();
}
}
private function getBlikForm()
{
return $this->getBlikSelectionForm('BlikTransactionExample.php');
}
/**
* Pass BLIK code to created transaction
* Bank group for create method must be 150
* @param string $blikCode
*/
private function blikTransaction($blikCode)
{
$config = array(
'description' => 'Test API transaction',
'amount' => 0.20,
'crc' => 'test',
'group' => 150,
'name' => 'John Doe',
'email' => '[email protected]',
'accept_tos' => 1,
'result_url' => 'https://example.com/notify.php',
);
$transaction = $this->create($config);
$title = $transaction['title'];
try {
$responseBlik = $this->blik($title, $blikCode);
var_dump($responseBlik);
} catch (TException $e) {
var_dump($e);
}
}
}
new BlikTransactionExample;