Skip to content

Commit 6807aee

Browse files
committed
Added eWAY Rapid Responsive Shared Page gateway and eWAY Rapid Refunds
(and tests)
1 parent 77ed573 commit 6807aee

20 files changed

+994
-208
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ And run composer to update your dependencies:
3232
The following gateways are provided by this package:
3333

3434
* Eway_Rapid
35+
* Eway_RapidShared
3536

3637
For general usage instructions, please see the main [Omnipay](https://github.com/thephpleague/omnipay)
3738
repository.

src/Message/AbstractRequest.php

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,43 @@ public function setInvoiceReference($value)
7474
{
7575
return $this->setParameter('invoiceReference', $value);
7676
}
77+
78+
protected function getBaseData()
79+
{
80+
$data = array();
81+
$data['DeviceID'] = 'https://github.com/adrianmacneil/omnipay';
82+
$data['CustomerIP'] = $this->getClientIp();
83+
$data['PartnerID'] = $this->getPartnerId();
84+
$data['ShippingMethod'] = $this->getShippingMethod();
85+
86+
$data['Customer'] = array();
87+
$card = $this->getCard();
88+
if ($card) {
89+
$data['Customer']['FirstName'] = $card->getFirstName();
90+
$data['Customer']['LastName'] = $card->getLastName();
91+
$data['Customer']['CompanyName'] = $card->getCompany();
92+
$data['Customer']['Street1'] = $card->getAddress1();
93+
$data['Customer']['Street2'] = $card->getAddress2();
94+
$data['Customer']['City'] = $card->getCity();
95+
$data['Customer']['State'] = $card->getState();
96+
$data['Customer']['PostalCode'] = $card->getPostCode();
97+
$data['Customer']['Country'] = strtolower($card->getCountry());
98+
$data['Customer']['Email'] = $card->getEmail();
99+
$data['Customer']['Phone'] = $card->getPhone();
100+
101+
$data['ShippingAddress']['FirstName'] = $card->getShippingFirstName();
102+
$data['ShippingAddress']['LastName'] = $card->getShippingLastName();
103+
$data['ShippingAddress']['Street1'] = $card->getShippingAddress1();
104+
$data['ShippingAddress']['Street2'] = $card->getShippingAddress2();
105+
$data['ShippingAddress']['City'] = $card->getShippingCity();
106+
$data['ShippingAddress']['State'] = $card->getShippingState();
107+
$data['ShippingAddress']['Country'] = strtolower($card->getShippingCountry());
108+
$data['ShippingAddress']['PostalCode'] = $card->getShippingPostcode();
109+
$data['ShippingAddress']['Phone'] = $card->getShippingPhone();
110+
}
111+
112+
return $data;
113+
}
77114

78115
protected function getItemData()
79116
{

src/Message/AbstractResponse.php

Lines changed: 225 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,225 @@
1+
<?php
2+
3+
namespace Omnipay\Eway\Message;
4+
5+
/**
6+
* eWAY Abstract Response
7+
*
8+
*/
9+
abstract class AbstractResponse extends \Omnipay\Common\Message\AbstractResponse
10+
{
11+
public static $MESSAGES = array(
12+
'A2000' => 'Transaction Approved',
13+
'A2008' => 'Honour With Identification',
14+
'A2010' => 'Approved For Partial Amount',
15+
'A2011' => 'Approved, VIP',
16+
'A2016' => 'Approved, Update Track 3',
17+
'D4401' => 'Refer to Issuer',
18+
'D4402' => 'Refer to Issuer, special',
19+
'D4403' => 'No Merchant',
20+
'D4404' => 'Pick Up Card',
21+
'D4405' => 'Do Not Honour',
22+
'D4406' => 'Error',
23+
'D4407' => 'Pick Up Card, Special',
24+
'D4409' => 'Request In Progress',
25+
'D4412' => 'Invalid Transaction',
26+
'D4413' => 'Invalid Amount',
27+
'D4414' => 'Invalid Card Number',
28+
'D4415' => 'No Issuer',
29+
'D4419' => 'Re-enter Last Transaction',
30+
'D4421' => 'No Action Taken',
31+
'D4422' => 'Suspected Malfunction',
32+
'D4423' => 'Unacceptable Transaction Fee',
33+
'D4425' => 'Unable to Locate Record On File',
34+
'D4430' => 'Format Error',
35+
'D4431' => 'Bank Not Supported By Switch',
36+
'D4433' => 'Expired Card, Capture',
37+
'D4434' => 'Suspected Fraud, Retain Card',
38+
'D4435' => 'Card Acceptor, Contact Acquirer, Retain Card',
39+
'D4436' => 'Restricted Card, Retain Card',
40+
'D4437' => 'Contact Acquirer Security Department, Retain Card',
41+
'D4438' => 'PIN Tries Exceeded, Capture',
42+
'D4439' => 'No Credit Account',
43+
'D4440' => 'Function Not Supported',
44+
'D4441' => 'Lost Card',
45+
'D4442' => 'No Universal Account',
46+
'D4443' => 'Stolen Card',
47+
'D4444' => 'No Investment Account',
48+
'D4451' => 'Insufficient Funds',
49+
'D4452' => 'No Cheque Account',
50+
'D4453' => 'No Savings Account',
51+
'D4454' => 'Expired Card',
52+
'D4455' => 'Incorrect PIN',
53+
'D4456' => 'No Card Record',
54+
'D4457' => 'Function Not Permitted to Cardholder',
55+
'D4458' => 'Function Not Permitted to Terminal',
56+
'D4459' => 'Suspected Fraud',
57+
'D4460' => 'Acceptor Contact Acquirer',
58+
'D4461' => 'Exceeds Withdrawal Limit',
59+
'D4462' => 'Restricted Card',
60+
'D4463' => 'Security Violation',
61+
'D4464' => 'Original Amount Incorrect',
62+
'D4466' => 'Acceptor Contact Acquirer, Security',
63+
'D4467' => 'Capture Card',
64+
'D4475' => 'PIN Tries Exceeded',
65+
'D4482' => 'CVV Validation Error',
66+
'D4490' => 'Cut off In Progress',
67+
'D4491' => 'Card Issuer Unavailable',
68+
'D4492' => 'Unable To Route Transaction',
69+
'D4493' => 'Cannot Complete, Violation Of The Law',
70+
'D4494' => 'Duplicate Transaction',
71+
'D4496' => 'System Error',
72+
'D4497' => 'MasterPass Error',
73+
'D4498' => 'PayPal Create Transaction Error',
74+
'D4499' => 'Invalid Transaction for Auth/Void',
75+
'S5000' => 'System Error',
76+
'S5011' => 'PayPal Connection Error',
77+
'S5012' => 'PayPal Settings Error',
78+
'S5085' => 'Started 3dSecure',
79+
'S5086' => 'Routed 3dSecure',
80+
'S5087' => 'Completed 3dSecure',
81+
'S5099' => 'Incomplete (Access Code in progress/incomplete)',
82+
'V6000' => 'Validation error',
83+
'V6001' => 'Invalid CustomerIP',
84+
'V6002' => 'Invalid DeviceID',
85+
'V6003' => 'Invalid PartnerID',
86+
'V6004' => 'Invalid Method',
87+
'V6010' => 'Invalid TransactionType, account not certified for eCome only MOTO or Recurring available',
88+
'V6011' => 'Invalid TotalAmount',
89+
'V6012' => 'Invalid InvoiceDescription',
90+
'V6013' => 'Invalid InvoiceNumber',
91+
'V6014' => 'Invalid InvoiceReference',
92+
'V6015' => 'Invalid CurrencyCode',
93+
'V6016' => 'Payment Required',
94+
'V6017' => 'Payment CurrencyCode Required',
95+
'V6018' => 'Unknown Payment CurrencyCode',
96+
'V6021' => 'EWAY_CARDNAME Required',
97+
'V6022' => 'EWAY_CARDNUMBER Required',
98+
'V6023' => 'EWAY_CARDCVN Required',
99+
'V6033' => 'Invalid Expiry Date',
100+
'V6034' => 'Invalid Issue Number',
101+
'V6035' => 'Invalid Valid From Date',
102+
'V6040' => 'Invalid TokenCustomerID',
103+
'V6041' => 'Customer Required',
104+
'V6042' => 'Customer First Name Required',
105+
'V6043' => 'Customer Last Name Required',
106+
'V6044' => 'Customer CountryCode Required',
107+
'V6045' => 'Customer Title Required',
108+
'V6046' => 'TokenCustomerID Required',
109+
'V6047' => 'RedirectURL Required',
110+
'V6051' => 'Invalid Customer FirstName',
111+
'V6052' => 'Invalid Customer LastName',
112+
'V6053' => 'Invalid Customer CountryCode',
113+
'V6058' => 'Invalid Customer Title',
114+
'V6059' => 'Invalid RedirectURL',
115+
'V6060' => 'Invalid TokenCustomerID',
116+
'V6061' => 'Invalid Customer Reference',
117+
'V6062' => 'Invalid Customer CompanyName',
118+
'V6063' => 'Invalid Customer JobDescription',
119+
'V6064' => 'Invalid Customer Street1',
120+
'V6065' => 'Invalid Customer Street2',
121+
'V6066' => 'Invalid Customer City',
122+
'V6067' => 'Invalid Customer State',
123+
'V6068' => 'Invalid Customer PostalCode',
124+
'V6069' => 'Invalid Customer Email',
125+
'V6070' => 'Invalid Customer Phone',
126+
'V6071' => 'Invalid Customer Mobile',
127+
'V6072' => 'Invalid Customer Comments',
128+
'V6073' => 'Invalid Customer Fax',
129+
'V6074' => 'Invalid Customer URL',
130+
'V6075' => 'Invalid ShippingAddress FirstName',
131+
'V6076' => 'Invalid ShippingAddress LastName',
132+
'V6077' => 'Invalid ShippingAddress Street1',
133+
'V6078' => 'Invalid ShippingAddress Street2',
134+
'V6079' => 'Invalid ShippingAddress City',
135+
'V6080' => 'Invalid ShippingAddress State',
136+
'V6081' => 'Invalid ShippingAddress PostalCode',
137+
'V6082' => 'Invalid ShippingAddress Email',
138+
'V6083' => 'Invalid ShippingAddress Phone',
139+
'V6084' => 'Invalid ShippingAddress Country',
140+
'V6085' => 'Invalid ShippingAddress ShippingMethod',
141+
'V6086' => 'Invalid ShippingAddress Fax',
142+
'V6091' => 'Unknown Customer CountryCode',
143+
'V6092' => 'Unknown ShippingAddress CountryCode',
144+
'V6100' => 'Invalid EWAY_CARDNAME',
145+
'V6101' => 'Invalid EWAY_CARDEXPIRYMONTH',
146+
'V6102' => 'Invalid EWAY_CARDEXPIRYYEAR',
147+
'V6103' => 'Invalid EWAY_CARDSTARTMONTH',
148+
'V6104' => 'Invalid EWAY_CARDSTARTYEAR',
149+
'V6105' => 'Invalid EWAY_CARDISSUENUMBER',
150+
'V6106' => 'Invalid EWAY_CARDCVN',
151+
'V6107' => 'Invalid EWAY_ACCESSCODE',
152+
'V6108' => 'Invalid CustomerHostAddress',
153+
'V6109' => 'Invalid UserAgent',
154+
'V6110' => 'Invalid EWAY_CARDNUMBER',
155+
'V6111' => 'Unauthorised API Access, Account Not PCI Certified',
156+
'V6112' => 'Redundant card details other than expiry year and month',
157+
'V6113' => 'Invalid transaction for refund',
158+
'V6114' => 'Gateway validation error',
159+
'V6115' => 'Invalid Refund Transaction ID',
160+
'V6116' => 'Invalid card data on original TransactionID',
161+
'V6117' => 'Invalid CreateAccessCodeSharedRequest, FooterText',
162+
'V6118' => 'Invalid CreateAccessCodeSharedRequest, HeaderText',
163+
'V6119' => 'Invalid CreateAccessCodeSharedRequest, Language',
164+
'V6120' => 'Invalid CreateAccessCodeSharedRequest, LogoUrl',
165+
'V6121' => 'Invalid TransactionSearch, Filter Match Type',
166+
'V6122' => 'Invalid TransactionSearch, Non numeric Transaction ID',
167+
'V6123' => 'Invalid TransactionSearch,no TransactionID or AccessCode specified',
168+
'V6124' => 'Invalid Line Items. The line items have been provided however the totals do not match the
169+
TotalAmount field',
170+
'V6125' => 'Selected Payment Type not enabled',
171+
'V6126' => 'Invalid encrypted card number, decryption failed',
172+
'V6127' => 'Invalid encrypted cvn, decryption failed',
173+
'V6128' => 'Invalid Method for Payment Type',
174+
'V6129' => 'Transaction has not been authorised for Capture/Cancellation',
175+
'V6130' => 'Generic customer information error',
176+
'V6131' => 'Generic shipping information error',
177+
'V6132' => 'Transaction has already been completed or voided, operation not permitted',
178+
'V6133' => 'Checkout not available for Payment Type',
179+
'V6134' => 'Invalid Auth Transaction ID for Capture/Void',
180+
'V6135' => 'PayPal Error Processing Refund',
181+
'V6140' => 'Merchant account is suspended',
182+
'V6141' => 'Invalid PayPal account details or API signature',
183+
'V6142' => 'Authorise not available for Bank/Branch',
184+
'V6150' => 'Invalid Refund Amount',
185+
'V6151' => 'Refund amount greater than original transaction',
186+
'V6152' => 'Original transaction already refunded for total amount',
187+
'V6153' => 'Card type not support by merchant',
188+
);
189+
190+
public function isSuccessful()
191+
{
192+
return isset($this->data['TransactionStatus']) && $this->data['TransactionStatus'];
193+
}
194+
195+
public function getTransactionReference()
196+
{
197+
return isset($this->data['TransactionID']) ? (string) $this->data['TransactionID'] : null;
198+
}
199+
200+
public function getMessage()
201+
{
202+
$codes = explode(',', $this->getCode());
203+
$messages = array();
204+
205+
foreach ($codes as $code) {
206+
$code = trim($code);
207+
if (isset(static::$MESSAGES[$code])) {
208+
$messages[] = static::$MESSAGES[$code];
209+
} else {
210+
$messages[] = $code;
211+
}
212+
}
213+
214+
return implode(', ', $messages) ?: null;
215+
}
216+
217+
public function getCode()
218+
{
219+
if (!empty($this->data['ResponseMessage'])) {
220+
return $this->data['ResponseMessage'];
221+
} elseif (!empty($this->data['Errors'])) {
222+
return $this->data['Errors'];
223+
}
224+
}
225+
}

src/Message/RapidPurchaseRequest.php

Lines changed: 3 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
namespace Omnipay\Eway\Message;
44

55
/**
6-
* eWAY Rapid 3.0 Purchase Request
6+
* eWAY Rapid Purchase Request
77
*
88
* Creates a payment URL using eWAY's Transparent Redirect
99
* http://api-portal.anypoint.mulesoft.com/eway/api/eway-rapid-31-api/docs/reference/transparent-redirect
@@ -15,14 +15,10 @@ public function getData()
1515
{
1616
$this->validate('amount', 'returnUrl');
1717

18-
$data = array();
18+
$data = $this->getBaseData();
1919
$data['Method'] = 'ProcessPayment';
20-
$data['DeviceID'] = 'https://github.com/adrianmacneil/omnipay';
21-
$data['CustomerIP'] = $this->getClientIp();
22-
$data['RedirectUrl'] = $this->getReturnUrl();
23-
$data['PartnerID'] = $this->getPartnerId();
2420
$data['TransactionType'] = $this->getTransactionType();
25-
$data['ShippingMethod'] = $this->getShippingMethod();
21+
$data['RedirectUrl'] = $this->getReturnUrl();
2622

2723
$data['Payment'] = array();
2824
$data['Payment']['TotalAmount'] = $this->getAmountInteger();
@@ -31,32 +27,6 @@ public function getData()
3127
$data['Payment']['CurrencyCode'] = $this->getCurrency();
3228
$data['Payment']['InvoiceReference'] = $this->getInvoiceReference();
3329

34-
$data['Customer'] = array();
35-
$card = $this->getCard();
36-
if ($card) {
37-
$data['Customer']['FirstName'] = $card->getFirstName();
38-
$data['Customer']['LastName'] = $card->getLastName();
39-
$data['Customer']['CompanyName'] = $card->getCompany();
40-
$data['Customer']['Street1'] = $card->getAddress1();
41-
$data['Customer']['Street2'] = $card->getAddress2();
42-
$data['Customer']['City'] = $card->getCity();
43-
$data['Customer']['State'] = $card->getState();
44-
$data['Customer']['PostalCode'] = $card->getPostCode();
45-
$data['Customer']['Country'] = strtolower($card->getCountry());
46-
$data['Customer']['Email'] = $card->getEmail();
47-
$data['Customer']['Phone'] = $card->getPhone();
48-
49-
$data['ShippingAddress']['FirstName'] = $card->getShippingFirstName();
50-
$data['ShippingAddress']['LastName'] = $card->getShippingLastName();
51-
$data['ShippingAddress']['Street1'] = $card->getShippingAddress1();
52-
$data['ShippingAddress']['Street2'] = $card->getShippingAddress2();
53-
$data['ShippingAddress']['City'] = $card->getShippingCity();
54-
$data['ShippingAddress']['State'] = $card->getShippingState();
55-
$data['ShippingAddress']['Country'] = strtolower($card->getShippingCountry());
56-
$data['ShippingAddress']['PostalCode'] = $card->getShippingPostcode();
57-
$data['ShippingAddress']['Phone'] = $card->getShippingPhone();
58-
}
59-
6030
if ($this->getItems()) {
6131
$data['Items'] = $this->getItemData();
6232
}

0 commit comments

Comments
 (0)