Skip to content

Commit c81e379

Browse files
committed
Complete Create Card Request, Start work on Update Card Request
1 parent 6128d35 commit c81e379

8 files changed

+461
-0
lines changed
Lines changed: 133 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,133 @@
1+
<?php
2+
/**
3+
* eWAY Rapid Shared Page Create Card Request
4+
*/
5+
6+
namespace Omnipay\Eway\Message;
7+
8+
/**
9+
* eWAY Rapid Shared Page Create Card Request
10+
*
11+
* Creates a payment URL using eWAY's Responsive Shared Page
12+
*
13+
* @link https://eway.io/api-v3/#responsive-shared-page
14+
*/
15+
class RapidSharedCreateCardRequest extends AbstractRequest
16+
{
17+
public function getData()
18+
{
19+
$this->validate('returnUrl');
20+
21+
$data = $this->getBaseData();
22+
$data['Method'] = 'CreateTokenCustomer';
23+
$data['TransactionType'] = 'Purchase';
24+
$data['RedirectUrl'] = $this->getReturnUrl();
25+
26+
// Shared page parameters (optional)
27+
$data['CancelUrl'] = $this->getCancelUrl();
28+
$data['LogoUrl'] = $this->getLogoUrl();
29+
$data['HeaderText'] = $this->getHeaderText();
30+
$data['Language'] = $this->getLanguage();
31+
$data['CustomerReadOnly'] = $this->getCustomerReadOnly();
32+
$data['CustomView'] = $this->getCustomView();
33+
34+
$data['Payment'] = array();
35+
$data['Payment']['TotalAmount'] = 0;
36+
37+
return $data;
38+
}
39+
40+
public function sendData($data)
41+
{
42+
$httpResponse = $this->httpClient->post($this->getEndpoint(), null, json_encode($data))
43+
->setAuth($this->getApiKey(), $this->getPassword())
44+
->send();
45+
46+
return $this->response = new RapidSharedResponse($this, $httpResponse->json());
47+
}
48+
49+
protected function getEndpoint()
50+
{
51+
return $this->getEndpointBase().'/CreateAccessCodeShared.json';
52+
}
53+
54+
public function getCancelUrl()
55+
{
56+
return $this->getParameter('cancelUrl');
57+
}
58+
59+
public function setCancelUrl($value)
60+
{
61+
return $this->setParameter('cancelUrl', $value);
62+
}
63+
64+
public function getLogoUrl()
65+
{
66+
return $this->getParameter('logoUrl');
67+
}
68+
69+
public function setLogoUrl($value)
70+
{
71+
return $this->setParameter('logoUrl', $value);
72+
}
73+
74+
public function getHeaderText()
75+
{
76+
return $this->getParameter('headerText');
77+
}
78+
79+
public function setHeaderText($value)
80+
{
81+
return $this->setParameter('headerText', $value);
82+
}
83+
84+
public function getLanguage()
85+
{
86+
return $this->getParameter('language');
87+
}
88+
89+
public function setLanguage($value)
90+
{
91+
return $this->setParameter('language', $value);
92+
}
93+
94+
public function getCustomerReadOnly()
95+
{
96+
return $this->getParameter('customerReadOnly');
97+
}
98+
99+
public function setCustomerReadOnly($value)
100+
{
101+
return $this->setParameter('customerReadOnly', $value);
102+
}
103+
104+
public function getCustomView()
105+
{
106+
return $this->getParameter('customView');
107+
}
108+
109+
public function setCustomView($value)
110+
{
111+
return $this->setParameter('customView', $value);
112+
}
113+
114+
public function getVerifyCustomerPhone()
115+
{
116+
return $this->getParameter('verifyCustomerPhone');
117+
}
118+
119+
public function setVerifyCustomerPhone($value)
120+
{
121+
return $this->setParameter('verifyCustomerPhone', $value);
122+
}
123+
124+
public function getVerifyCustomerEmail()
125+
{
126+
return $this->getParameter('verifyCustomerEmail');
127+
}
128+
129+
public function setVerifyCustomerEmail($value)
130+
{
131+
return $this->setParameter('verifyCustomerEmail', $value);
132+
}
133+
}
Lines changed: 146 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,146 @@
1+
<?php
2+
/**
3+
* eWAY Rapid Shared Page Update Card Request
4+
*/
5+
6+
namespace Omnipay\Eway\Message;
7+
8+
/**
9+
* eWAY Rapid Shared Page Update Card Request
10+
*
11+
* Creates a payment URL using eWAY's Responsive Shared Page
12+
*
13+
* @link https://eway.io/api-v3/#responsive-shared-page
14+
*/
15+
class RapidSharedUpdateCardRequest extends AbstractRequest
16+
{
17+
public function getData()
18+
{
19+
$this->validate('returnUrl');
20+
21+
$data = $this->getBaseData();
22+
$data['Method'] = 'CreateTokenCustomer';
23+
$data['TransactionType'] = 'Purchase';
24+
$data['RedirectUrl'] = $this->getReturnUrl();
25+
26+
// Shared page parameters (optional)
27+
$data['CancelUrl'] = $this->getCancelUrl();
28+
$data['LogoUrl'] = $this->getLogoUrl();
29+
$data['HeaderText'] = $this->getHeaderText();
30+
$data['Language'] = $this->getLanguage();
31+
$data['CustomerReadOnly'] = $this->getCustomerReadOnly();
32+
$data['CustomView'] = $this->getCustomView();
33+
34+
$data['Payment'] = array();
35+
$data['Payment']['TotalAmount'] = 0;
36+
37+
$data['Customer'] = array();
38+
$data['Customer']['TokenCustomerID'] = $this->getTokenCustomerId();
39+
40+
return $data;
41+
}
42+
43+
public function sendData($data)
44+
{
45+
$httpResponse = $this->httpClient->post($this->getEndpoint(), null, json_encode($data))
46+
->setAuth($this->getApiKey(), $this->getPassword())
47+
->send();
48+
49+
return $this->response = new RapidSharedResponse($this, $httpResponse->json());
50+
}
51+
52+
protected function getEndpoint()
53+
{
54+
return $this->getEndpointBase().'/CreateAccessCodeShared.json';
55+
}
56+
57+
public function getCancelUrl()
58+
{
59+
return $this->getParameter('cancelUrl');
60+
}
61+
62+
public function setCancelUrl($value)
63+
{
64+
return $this->setParameter('cancelUrl', $value);
65+
}
66+
67+
public function getLogoUrl()
68+
{
69+
return $this->getParameter('logoUrl');
70+
}
71+
72+
public function setLogoUrl($value)
73+
{
74+
return $this->setParameter('logoUrl', $value);
75+
}
76+
77+
public function getHeaderText()
78+
{
79+
return $this->getParameter('headerText');
80+
}
81+
82+
public function setHeaderText($value)
83+
{
84+
return $this->setParameter('headerText', $value);
85+
}
86+
87+
public function getLanguage()
88+
{
89+
return $this->getParameter('language');
90+
}
91+
92+
public function setLanguage($value)
93+
{
94+
return $this->setParameter('language', $value);
95+
}
96+
97+
public function getCustomerReadOnly()
98+
{
99+
return $this->getParameter('customerReadOnly');
100+
}
101+
102+
public function setCustomerReadOnly($value)
103+
{
104+
return $this->setParameter('customerReadOnly', $value);
105+
}
106+
107+
public function getCustomView()
108+
{
109+
return $this->getParameter('customView');
110+
}
111+
112+
public function setCustomView($value)
113+
{
114+
return $this->setParameter('customView', $value);
115+
}
116+
117+
public function getVerifyCustomerPhone()
118+
{
119+
return $this->getParameter('verifyCustomerPhone');
120+
}
121+
122+
public function setVerifyCustomerPhone($value)
123+
{
124+
return $this->setParameter('verifyCustomerPhone', $value);
125+
}
126+
127+
public function getVerifyCustomerEmail()
128+
{
129+
return $this->getParameter('verifyCustomerEmail');
130+
}
131+
132+
public function setVerifyCustomerEmail($value)
133+
{
134+
return $this->setParameter('verifyCustomerEmail', $value);
135+
}
136+
137+
public function getTokenCustomerId()
138+
{
139+
return $this->getParameter('tokenCustomerId');
140+
}
141+
142+
public function setTokenCustomerId($value)
143+
{
144+
return $this->setParameter('tokenCustomerId', $value);
145+
}
146+
}

src/RapidSharedGateway.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,4 +73,14 @@ public function refund(array $parameters = array())
7373
{
7474
return $this->createRequest('\Omnipay\Eway\Message\RefundRequest', $parameters);
7575
}
76+
77+
public function createCard(array $parameters = array())
78+
{
79+
return $this->createRequest('\Omnipay\Eway\Message\RapidSharedCreateCardRequest', $parameters);
80+
}
81+
82+
public function updateCard(array $parameters = array())
83+
{
84+
return $this->createRequest('\Omnipay\Eway\Message\RapidSharedUpdateCardRequest', $parameters);
85+
}
7686
}

0 commit comments

Comments
 (0)