forked from tpay-com/tpay-openapi-php
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAccountsApiExample.php
More file actions
152 lines (125 loc) · 3.69 KB
/
AccountsApiExample.php
File metadata and controls
152 lines (125 loc) · 3.69 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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
<?php
namespace Tpay\Example\AccountsApi;
use Tpay\Example\ExamplesConfig;
use Tpay\OpenApi\Api\TpayApi;
require_once '../ExamplesConfig.php';
require_once '../../src/Loader.php';
class AccountsApiExample extends ExamplesConfig
{
private $TpayApi;
public function __construct()
{
parent::__construct();
$this->TpayApi = new TpayApi(static::PARTNER_CLIENT_ID, static::PARTNER_CLIENT_SECRET, true, 'read');
}
public function runAllExamples()
{
$this
->createAccount()
->getAccounts()
->getCategories()
->getCategoryById(60)
->getDocuments()
->getDocumentById(1)
->getLegalForms()
->getLegalFormById(16);
}
public function getAccounts()
{
$accounts = $this->TpayApi->accounts()->getAccounts();
var_dump($accounts);
return $this;
}
public function getAccountById($accountId)
{
$account = $this->TpayApi->accounts()->getAccountById($accountId);
var_dump($account);
return $this;
}
public function getCategories()
{
$categories = $this->TpayApi->accounts()->getCategories();
var_dump($categories);
return $this;
}
public function getCategoryById($categoryId)
{
$category = $this->TpayApi->accounts()->getCategoryById($categoryId);
var_dump($category);
return $this;
}
public function getDocuments()
{
$documents = $this->TpayApi->accounts()->getDocuments();
var_dump($documents);
return $this;
}
public function getDocumentById($documentId)
{
$document = $this->TpayApi->accounts()->getDocumentById($documentId);
var_dump($document);
return $this;
}
public function getLegalForms()
{
$legalForms = $this->TpayApi->accounts()->getLegalForms();
var_dump($legalForms);
return $this;
}
public function getLegalFormById($legalFormId)
{
$legalForm = $this->TpayApi->accounts()->getLegalFormById($legalFormId);
var_dump($legalForm);
return $this;
}
public function createAccount()
{
$accountConfig = $this->getNewAccountConfig();
$newAccount = $this->TpayApi->accounts()->createAccount($accountConfig);
var_dump($newAccount);
return $this;
}
private function getNewAccountConfig()
{
$offerCode = 'PTON8';
$personContact = [
'type' => 2,
'contact' => '(0)111222333',
];
$pos = [
'name' => 'Przykladowe Zakupy Online',
'description' => 'Zakupy online - rtv i agd',
'url' => 'https://przykladowezakupy.pl',
];
$address1 = [
'friendlyName' => 'Adres Korespondencyjny',
'name' => 'Example Sp. z o.o.',
'street' => 'Ul. Jelenia',
'houseNumber' => '123',
'postalCode' => '54-134',
'city' => 'Warszawa',
'country' => 'PL',
];
$person = [
'name' => 'Jan',
'surname' => 'Kowalski',
'isRepresentative' => true,
'isContactPerson' => true,
'contact' => [
$personContact,
],
];
return [
'offerCode' => $offerCode,
'email' => 'merchant@example.com',
'taxId' => '7773061579',
'legalForm' => 3,
'categoryId' => 62,
'website' => [$pos],
'address' => [$address1],
'person' => [$person],
'notifyByEmail' => true,
];
}
}
(new AccountsApiExample())->runAllExamples();