-
Notifications
You must be signed in to change notification settings - Fork 17
/
RapidGateway.php
92 lines (79 loc) · 2.64 KB
/
RapidGateway.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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
<?php
/**
* eWAY Rapid Transparent Redirect Gateway
*/
namespace Omnipay\Eway;
use Omnipay\Common\AbstractGateway;
use Omnipay\Omnipay;
/**
* eWAY Rapid Transparent Redirect Gateway
*
* This class forms the gateway class for eWAY Rapid Transparent Redirect requests.
* The gateway is just called Eway_Rapid as it was the first implemented.
*
* The eWAY Rapid gateways use an API Key and Password for authentication.
*
* There is also a test sandbox environment, which uses a separate endpoint and
* API key and password. To access the eWAY Sandbox requires an eWAY Partner account.
* https://myeway.force.com/success/partner-registration
*
*
* @link https://eway.io/api-v3/#transparent-redirect
* @link https://eway.io/api-v3/#authentication
* @link https://go.eway.io/s/article/How-do-I-setup-my-Live-eWAY-API-Key-and-Password
*/
class RapidGateway extends AbstractGateway
{
public $transparentRedirect = true;
public function getName()
{
return 'eWAY Rapid 3.0';
}
public function getDefaultParameters()
{
return [
'apiKey' => '',
'password' => '',
'testMode' => false,
];
}
public function getApiKey()
{
return $this->getParameter('apiKey');
}
public function setApiKey($value)
{
return $this->setParameter('apiKey', $value);
}
public function getPassword()
{
return $this->getParameter('password');
}
public function setPassword($value)
{
return $this->setParameter('password', $value);
}
public function purchase(array $parameters = [])
{
if (!empty($parameters['cardTransactionType']) && $parameters['cardTransactionType'] === 'continuous') {
$gateway = Omnipay::create('Eway_RapidDirect');
$gateway->setApiKey($this->getApiKey());
$gateway->setPassword($this->getPassword());
$gateway->setTestMode($this->getTestMode());
return $gateway->createRequest('\Omnipay\Eway\Message\RapidDirectPurchaseRequest', $parameters);
}
return $this->createRequest('\Omnipay\Eway\Message\RapidPurchaseRequest', $parameters);
}
public function completePurchase(array $parameters = [])
{
return $this->createRequest('\Omnipay\Eway\Message\RapidCompletePurchaseRequest', $parameters);
}
public function refund(array $parameters = [])
{
return $this->createRequest('\Omnipay\Eway\Message\RefundRequest', $parameters);
}
public function createCard(array $parameters = [])
{
return $this->createRequest('\Omnipay\Eway\Message\RapidCreateCardRequest', $parameters);
}
}