forked from Adyen/adyen-php-api-library
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPosPayment.php
More file actions
100 lines (86 loc) · 2.4 KB
/
PosPayment.php
File metadata and controls
100 lines (86 loc) · 2.4 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
<?php
namespace Adyen\Service;
use Adyen\Client;
use Adyen\Environment;
use Adyen\Region;
class PosPayment extends \Adyen\ApiKeyAuthenticatedService
{
/**
* @var ResourceModel\Payment\TerminalCloudAPI
*/
protected $runTenderSync;
/**
* @var ResourceModel\Payment\TerminalCloudAPI
*/
protected $runTenderAsync;
/**
* @var
*/
protected $txType;
/**
* @var ResourceModel\Payment\ConnectedTerminals
*/
protected $connectedTerminals;
/**
* PosPayment constructor.
*
* @param \Adyen\Client $client
* @throws \Adyen\AdyenException
*/
public function __construct(Client $client)
{
parent::__construct($client);
$region = $this->getClient()->getConfig()->get('region');
$environment = $this->getClient()->getConfig()->get('environment');
if (isset($region) && $environment == Environment::LIVE) {
$this->getClient()->getConfig()->set(
'endpointTerminalCloud',
Region::TERMINAL_API_ENDPOINTS_MAPPING[$region]
);
}
$this->runTenderSync = new \Adyen\Service\ResourceModel\Payment\TerminalCloudAPI($this, false);
$this->runTenderAsync = new \Adyen\Service\ResourceModel\Payment\TerminalCloudAPI($this, true);
$this->connectedTerminals = new \Adyen\Service\ResourceModel\Payment\ConnectedTerminals($this);
}
/**
* @param $params
* @return mixed
* @throws \Adyen\AdyenException
*/
public function runTenderSync($params)
{
$result = $this->runTenderSync->request($params);
return $result;
}
/**
* @param $params
* @return mixed
* @throws \Adyen\AdyenException
*/
public function runTenderAsync($params)
{
$result = $this->runTenderAsync->request($params);
return $result;
}
/**
* @param $request
* @return null
*/
public function getServiceId($request)
{
if (isset($request['SaleToPOIRequest']['MessageHeader']['ServiceID'])) {
return $request['SaleToPOIRequest']['MessageHeader']['ServiceID'];
}
return null;
}
/**
* @param $params
* @return mixed
* @throws \Adyen\AdyenException
*/
public function getConnectedTerminals($params)
{
$result = $this->connectedTerminals->request($params);
return $result;
}
}