forked from tpay-com/tpay-php
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTransactionApiExample.php
More file actions
80 lines (63 loc) · 2.02 KB
/
TransactionApiExample.php
File metadata and controls
80 lines (63 loc) · 2.02 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
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
73
74
75
76
77
78
79
80
<?php
/*
* Created by tpay.com
*/
namespace tpayLibs\examples;
use tpayLibs\src\_class_tpay\Utilities\TException;
use tpayLibs\src\_class_tpay\TransactionApi;
include_once 'config.php';
include_once 'loader.php';
class TransactionApiExample extends TransactionApi
{
const TRID = 'TR-C4Y-HJVWYX';
private $trId;
public function __construct()
{
$this->merchantSecret = 'demo';
$this->merchantId = 1010;
$this->trApiKey = '';
$this->trApiPass = '';
parent::__construct();
}
public function getTransaction()
{
/**
* Get info about transaction
*/
$transactionId = $this->trId;
try {
$transaction = $this->setTransactionID($transactionId)->get();
print_r($transaction);
} catch (TException $e) {
var_dump($e);
}
}
public function createTransaction()
{
/**
* Create new transaction
*/
$config = array(
'kwota' => 999.99,
'opis' => 'Transaction description',
'crc' => '100020003000',
'wyn_url' => 'http://example.pl/examples/TransactionApiExample.php?transaction_confirmation',
'wyn_email' => 'shop@example.com',
'pow_url' => 'http://example.pl/examples/TransactionApiExample.php',
'email' => 'customer@example.com',
'imie' => 'Jan123',
'nazwisko' => 'Kowalski',
'kanal' => 21,
'wybor' => 1,
'akceptuje_regulamin' => 1,
);
try {
$res = $this->create($config);
$this->trId = $res['title'];
echo '<a href="https://secure.tpay.com/?gtitle=' . $this->trId . '">go to payment</a>';
} catch (TException $e) {
var_dump($e);
}
}
}
(new TransactionApiExample())->createTransaction();