Skip to content

Commit 58c6ae3

Browse files
committed
Finalise Update Card Request
1 parent c81e379 commit 58c6ae3

File tree

4 files changed

+162
-14
lines changed

4 files changed

+162
-14
lines changed

src/Message/RapidSharedUpdateCardRequest.php

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@ class RapidSharedUpdateCardRequest extends AbstractRequest
1616
{
1717
public function getData()
1818
{
19-
$this->validate('returnUrl');
19+
$this->validate('returnUrl', 'cardReference');
2020

2121
$data = $this->getBaseData();
22-
$data['Method'] = 'CreateTokenCustomer';
22+
$data['Method'] = 'UpdateTokenCustomer';
2323
$data['TransactionType'] = 'Purchase';
2424
$data['RedirectUrl'] = $this->getReturnUrl();
2525

@@ -34,8 +34,7 @@ public function getData()
3434
$data['Payment'] = array();
3535
$data['Payment']['TotalAmount'] = 0;
3636

37-
$data['Customer'] = array();
38-
$data['Customer']['TokenCustomerID'] = $this->getTokenCustomerId();
37+
$data['Customer']['TokenCustomerID'] = $this->getCardReference();
3938

4039
return $data;
4140
}
@@ -133,14 +132,4 @@ public function setVerifyCustomerEmail($value)
133132
{
134133
return $this->setParameter('verifyCustomerEmail', $value);
135134
}
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-
}
146135
}
Lines changed: 126 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
1+
<?php
2+
3+
namespace Omnipay\Eway\Message;
4+
5+
use Omnipay\Tests\TestCase;
6+
7+
class RapidSharedUpdateCardRequestTest extends TestCase
8+
{
9+
public function setUp()
10+
{
11+
$this->request = new RapidSharedUpdateCardRequest($this->getHttpClient(), $this->getHttpRequest());
12+
$this->request->initialize(array(
13+
'apiKey' => 'my api key',
14+
'password' => 'secret',
15+
'returnUrl' => 'https://www.example.com/return',
16+
'cardReference' => '123456789'
17+
));
18+
}
19+
20+
public function testGetData()
21+
{
22+
$this->request->initialize(array(
23+
'apiKey' => 'my api key',
24+
'password' => 'secret',
25+
'returnUrl' => 'https://www.example.com/return',
26+
'cardReference' => '123456789',
27+
'card' => array(
28+
'title' => 'Mr',
29+
'firstName' => 'Patrick',
30+
'lastName' => 'Collison',
31+
'country' => 'AU',
32+
),
33+
));
34+
35+
$data = $this->request->getData();
36+
37+
$this->assertSame('Purchase', $data['TransactionType']);
38+
$this->assertSame('UpdateTokenCustomer', $data['Method']);
39+
$this->assertSame('https://www.example.com/return', $data['RedirectUrl']);
40+
$this->assertSame(0, $data['Payment']['TotalAmount']);
41+
$this->assertSame('Mr', $data['Customer']['Title']);
42+
$this->assertSame('Patrick', $data['Customer']['FirstName']);
43+
$this->assertSame('Collison', $data['Customer']['LastName']);
44+
$this->assertSame('au', $data['ShippingAddress']['Country']);
45+
$this->assertSame('123456789', $data['Customer']['TokenCustomerID']);
46+
}
47+
48+
public function testSendSuccess()
49+
{
50+
$this->setMockHttpResponse('RapidSharedUpdateCardRequestSuccess.txt');
51+
$response = $this->request->send();
52+
53+
$this->assertFalse($response->isSuccessful());
54+
$this->assertTrue($response->isRedirect());
55+
$this->assertSame('GET', $response->getRedirectMethod());
56+
$this->assertSame('https://secure.ewaypayments.com/sharedpayment?AccessCode=F9802j0-O7sdVLnOcb_3IPryTxHDtKY8u_0pb10GbYq-Xjvbc-5Bc_LhI-oBIrTxTCjhOFn7Mq-CwpkLDja5-iu-Dr3DjVTr9u4yxSB5BckdbJqSA4WWydzDO0jnPWfBdKcWL', $response->getRedirectUrl());
57+
$this->assertNull($response->getRedirectData());
58+
$this->assertNull($response->getTransactionReference());
59+
$this->assertNull($response->getMessage());
60+
$this->assertNull($response->getCode());
61+
$this->assertNotNull($response->getCardReference());
62+
}
63+
64+
public function testSendFailure()
65+
{
66+
$this->setMockHttpResponse('RapidSharedUpdateCardRequestFailure.txt');
67+
$response = $this->request->send();
68+
69+
$this->assertFalse($response->isSuccessful());
70+
$this->assertFalse($response->isRedirect());
71+
$this->assertNull($response->getRedirectUrl());
72+
$this->assertNull($response->getRedirectData());
73+
$this->assertNull($response->getCardReference());
74+
$this->assertNull($response->getTransactionReference());
75+
$this->assertSame('V6040', $response->getCode());
76+
}
77+
78+
public function testCancelUrl()
79+
{
80+
$this->assertSame($this->request, $this->request->setCancelUrl('http://www.example.com'));
81+
$this->assertSame('http://www.example.com', $this->request->getCancelUrl());
82+
}
83+
84+
public function testLogoUrl()
85+
{
86+
$this->assertSame($this->request, $this->request->setLogoUrl('https://www.example.com/logo.jpg'));
87+
$this->assertSame('https://www.example.com/logo.jpg', $this->request->getLogoUrl());
88+
}
89+
90+
public function testHeaderText()
91+
{
92+
$this->assertSame($this->request, $this->request->setHeaderText('Header Text'));
93+
$this->assertSame('Header Text', $this->request->getHeaderText());
94+
}
95+
96+
public function testLanguage()
97+
{
98+
$this->assertSame($this->request, $this->request->setLanguage('EN'));
99+
$this->assertSame('EN', $this->request->getLanguage());
100+
}
101+
102+
public function testCustomerReadOnly()
103+
{
104+
$this->assertSame($this->request, $this->request->setCustomerReadOnly('true'));
105+
$this->assertSame('true', $this->request->getCustomerReadOnly());
106+
}
107+
108+
public function testCustomView()
109+
{
110+
$this->assertSame($this->request, $this->request->setCustomView('Bootstrap'));
111+
$this->assertSame('Bootstrap', $this->request->getCustomView());
112+
}
113+
114+
public function testVerifyCustomerPhone()
115+
{
116+
$this->assertSame($this->request, $this->request->setVerifyCustomerPhone('true'));
117+
$this->assertSame('true', $this->request->getVerifyCustomerPhone());
118+
}
119+
120+
public function testVerifyCustomerEmail()
121+
{
122+
$this->assertSame($this->request, $this->request->setVerifyCustomerEmail('true'));
123+
$this->assertSame('true', $this->request->getVerifyCustomerEmail());
124+
}
125+
126+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
HTTP/1.1 200 OK
2+
Cache-control: no-cache="set-cookie"
3+
Content-Type: application/json; charset=utf-8
4+
Date: Thu, 27 Jun 2013 05:22:52 GMT
5+
Set-Cookie: AWSELB=8361C96B088FEBBC7D3ABDFE8BA0FF6501B9705E7D00F53B19AA8D0E66C1AD34691F2170CBA3CC4FEE8666E2FB3C85D3B0E238FA2E93B31AAC1C98DFF4D0639139359FE706;PATH=/;MAX-AGE=86400
6+
X-EWAY-VIA: api-au.sandbox.ewaypayments.com/
7+
X-EWAY-VIA-FROM: http://api.sandbox.ewaypayments.com/CreateAccessCodeShared.json
8+
X-EWAY-VIA-HTTP-METHOD: POST
9+
X-EWAY-VIA-HTTP-STATUS: 200
10+
X-EWAY-VIA-TO: http://api-au.sandbox.ewaypayments.com/CreateAccessCodeShared.json
11+
X-ID: AM-131
12+
X-Powered-By: eWAY
13+
X-Staging: AU
14+
Content-Length: 649
15+
Connection: keep-alive
16+
17+
{"AccessCode":null,"Customer":{"TokenCustomerID":null,"Reference":null,"Title":null,"FirstName":null,"LastName":null,"CompanyName":null,"JobDescription":null,"Street1":null,"Street2":null,"City":null,"State":null,"PostalCode":null,"Country":null,"Email":null,"Phone":null,"Mobile":null,"Comments":null,"Fax":null,"Url":null,"CardNumber":null,"CardStartMonth":null,"CardStartYear":null,"CardIssueNumber":null,"CardName":null,"CardExpiryMonth":null,"CardExpiryYear":null,"IsActive":false},"Payment":{"TotalAmount":0,"InvoiceNumber":null,"InvoiceDescription":null,"InvoiceReference":null,"CurrencyCode":"AUD"},"FormActionURL":null,"Errors":"V6040"}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
HTTP/1.1 200 OK
2+
Cache-control: no-cache="set-cookie"
3+
Content-Type: application/json; charset=utf-8
4+
Date: Wed, 26 Jun 2013 13:11:50 GMT
5+
Set-Cookie: AWSELB=8361C96B088FEBBC7D3ABDFE8BA0FF6501B9705E7D00F53B19AA8D0E66C1AD34691F2170CB4C6B4D750DDAD028ED5C0787DEB1569F57CC58B5923AA0229EC5B49BD7647A57;PATH=/;MAX-AGE=86400
6+
X-EWAY-VIA: api-au.sandbox.ewaypayments.com/
7+
X-EWAY-VIA-FROM: http://api.sandbox.ewaypayments.com/CreateAccessCodeShared.json
8+
X-EWAY-VIA-HTTP-METHOD: POST
9+
X-EWAY-VIA-HTTP-STATUS: 200
10+
X-EWAY-VIA-TO: http://api-au.sandbox.ewaypayments.com/CreateAccessCodeShared.json
11+
X-ID: AM-143
12+
X-Powered-By: eWAY
13+
Content-Length: 1112
14+
Connection: keep-alive
15+
16+
{"SharedPaymentUrl":"https://secure.ewaypayments.com/sharedpayment?AccessCode=F9802j0-O7sdVLnOcb_3IPryTxHDtKY8u_0pb10GbYq-Xjvbc-5Bc_LhI-oBIrTxTCjhOFn7Mq-CwpkLDja5-iu-Dr3DjVTr9u4yxSB5BckdbJqSA4WWydzDO0jnPWfBdKcWL","AccessCode":"F9802j0-O7sdVLnOcb_3IPryTxHDtKY8u_0pb10GbYq-Xjvbc-5Bc_LhI-oBIrTxTCjhOFn7Mq-CwpkLDja5-iu-Dr3DjVTr9u4yxSB5BckdbJqSA4WWydzDO0jnPWfBdKcWL","Customer":{"TokenCustomerID":"","Reference":"","Title":"","FirstName":"","LastName":"","CompanyName":"","JobDescription":"","Street1":"","Street2":"","City":"","State":"","PostalCode":"","Country":"","Email":"","Phone":"","Mobile":"","Comments":"","Fax":"","Url":"","CardNumber":"","CardStartMonth":"","CardStartYear":"","CardIssueNumber":"","CardName":"","CardExpiryMonth":"","CardExpiryYear":"","IsActive":false},"Payment":{"TotalAmount":0,"InvoiceNumber":null,"InvoiceDescription":null,"InvoiceReference":null,"CurrencyCode":"AUD"},"FormActionURL":"https://secure.ewaypayments.com/AccessCode/F9802j0-O7sdVLnOcb_3IPryTxHDtKY8u_0pb10GbYq-Xjvbc-5Bc_LhI-oBIrTxTCjhOFn7Mq-CwpkLDja5-iu-Dr3DjVTr9u4yxSB5BckdbJqSA4WWydzDO0jnPWfBdKcWL","Errors":null}

0 commit comments

Comments
 (0)