|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Omnipay\Gtpay; |
|
4
|
|
|
|
|
5
|
|
|
use Omnipay\Gtpay\Message\Data; |
|
6
|
|
|
use \Omnipay\Common\AbstractGateway; |
|
7
|
|
|
|
|
8
|
|
|
class Gateway extends AbstractGateway |
|
9
|
|
|
{ |
|
10
|
|
|
|
|
11
|
|
|
const GATEWAY_NAME = "Gtpay"; |
|
12
|
|
|
|
|
13
|
|
|
const GATEWAY_WEBPAY = 'webpay'; |
|
14
|
|
|
|
|
15
|
|
|
const GATEWAY_BANK = 'ibank'; |
|
16
|
|
|
|
|
17
|
|
|
// - demo |
|
18
|
|
|
|
|
19
|
1 |
|
public function getName() |
|
20
|
|
|
{ |
|
21
|
1 |
|
return self::GATEWAY_NAME; |
|
22
|
|
|
} |
|
23
|
|
|
|
|
24
|
|
|
/** |
|
25
|
|
|
* Set Merchant ID parameter as required by Gtpay. |
|
26
|
|
|
* This is the GTPay-wide unique identifier of merchant, assigned by GTPay and communicated to merchant by GTBank |
|
27
|
|
|
* @param $merchantId |
|
28
|
|
|
* @return $this |
|
29
|
|
|
*/ |
|
30
|
39 |
|
public function setMerchantId($merchantId) |
|
31
|
|
|
{ |
|
32
|
39 |
|
return $this->setParameter(Data::MERCHANT_ID, $merchantId); |
|
33
|
|
|
} |
|
34
|
|
|
|
|
35
|
|
|
/** |
|
36
|
|
|
* set Gtpay Hash Key Given to Merchant at Setup |
|
37
|
|
|
* @param $hashKey |
|
38
|
|
|
* @return $this |
|
39
|
|
|
*/ |
|
40
|
39 |
|
public function setHashKey($hashKey) |
|
41
|
|
|
{ |
|
42
|
39 |
|
return $this->setParameter(Data::HASH_KEY, $hashKey); |
|
43
|
|
|
} |
|
44
|
|
|
|
|
45
|
|
|
/** |
|
46
|
|
|
* @see Gateway::setHashKey() |
|
47
|
|
|
* @return mixed |
|
48
|
|
|
*/ |
|
49
|
2 |
|
public function getHashKey() |
|
50
|
|
|
{ |
|
51
|
2 |
|
return $this->getParameter(Data::HASH_KEY); |
|
52
|
|
|
} |
|
53
|
|
|
|
|
54
|
39 |
|
public function getDefaultParameters() |
|
55
|
|
|
{ |
|
56
|
|
|
return [ |
|
57
|
39 |
|
Data::MERCHANT_ID => '', |
|
58
|
39 |
|
Data::HASH_KEY => '', |
|
59
|
|
|
'testMode' => true, |
|
60
|
39 |
|
Data::GATEWAY_FIRST=>'no', |
|
61
|
39 |
|
Data::GATEWAY_NAME=>self::GATEWAY_WEBPAY |
|
62
|
|
|
]; |
|
63
|
|
|
} |
|
64
|
|
|
|
|
65
|
|
|
/** |
|
66
|
|
|
* @see Gateway::setMerchantId() |
|
67
|
|
|
* @return mixed |
|
68
|
|
|
*/ |
|
69
|
2 |
|
public function getMerchantId() |
|
70
|
|
|
{ |
|
71
|
2 |
|
return $this->getParameter(Data::MERCHANT_ID); |
|
72
|
|
|
} |
|
73
|
|
|
|
|
74
|
|
|
|
|
75
|
|
|
/** |
|
76
|
|
|
* |
|
77
|
|
|
* If specified, then customer cannot choose what gateway to use for the transaction. |
|
78
|
|
|
* Accepted values are "webpay" or "ibank" (Bank Transfer) only. |
|
79
|
|
|
* @param $gateway |
|
80
|
|
|
* @return $this |
|
81
|
|
|
*/ |
|
82
|
39 |
|
public function setGatewayName($gateway) |
|
83
|
|
|
{ |
|
84
|
39 |
|
return $this->setParameter(Data::GATEWAY_NAME, $gateway); |
|
85
|
|
|
} |
|
86
|
|
|
|
|
87
|
|
|
/** |
|
88
|
|
|
* @see Gateway::setGatewayName() |
|
89
|
|
|
* @return mixed |
|
90
|
|
|
*/ |
|
91
|
2 |
|
public function getGatewayName() |
|
92
|
|
|
{ |
|
93
|
2 |
|
return $this->getParameter(Data::GATEWAY_NAME); |
|
94
|
|
|
} |
|
95
|
|
|
|
|
96
|
|
|
/** |
|
97
|
|
|
* @param $value |
|
98
|
|
|
* @return $this |
|
99
|
|
|
*/ |
|
100
|
39 |
|
public function setGatewayFirst($value) |
|
101
|
|
|
{ |
|
102
|
39 |
|
return $this->setParameter(Data::GATEWAY_FIRST, $value); |
|
103
|
|
|
} |
|
104
|
|
|
|
|
105
|
2 |
|
public function getGatewayFirst() |
|
106
|
|
|
{ |
|
107
|
2 |
|
return $this->getParameter(Data::GATEWAY_FIRST); |
|
108
|
|
|
} |
|
109
|
|
|
|
|
110
|
|
|
|
|
111
|
|
|
/** |
|
112
|
|
|
* @param array $parameters |
|
113
|
|
|
* @return \Omnipay\Common\Message\AbstractRequest|\Omnipay\Common\Message\RequestInterface |
|
114
|
|
|
*/ |
|
115
|
3 |
|
public function purchase(array $parameters = array()) |
|
116
|
|
|
{ |
|
117
|
3 |
|
return $this->createRequest('\Omnipay\Gtpay\Message\PurchaseRequest', $parameters); |
|
118
|
|
|
} |
|
119
|
|
|
|
|
120
|
|
|
|
|
121
|
13 |
|
public function completePurchase(array $options = array()) |
|
122
|
|
|
{ |
|
123
|
13 |
|
return $this->createRequest('\Omnipay\Gtpay\Message\CompletePurchaseRequest', $options); |
|
124
|
|
|
} |
|
125
|
|
|
} |
|
126
|
|
|
|