Skip to content

Commit 1fe8af0

Browse files
committed
Merge pull request #5 from incarnate/master
Improved support for eWAY specific fields, add Responsive Shared Page and some refactoring
2 parents 031236c + 6807aee commit 1fe8af0

21 files changed

+1230
-222
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: 143 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,143 @@
1+
<?php
2+
3+
namespace Omnipay\Eway\Message;
4+
5+
/**
6+
* eWAY Abstract Request
7+
*
8+
*/
9+
abstract class AbstractRequest extends \Omnipay\Common\Message\AbstractRequest
10+
{
11+
protected $liveEndpoint = 'https://api.ewaypayments.com';
12+
protected $testEndpoint = 'https://api.sandbox.ewaypayments.com';
13+
14+
public function getApiKey()
15+
{
16+
return $this->getParameter('apiKey');
17+
}
18+
19+
public function setApiKey($value)
20+
{
21+
return $this->setParameter('apiKey', $value);
22+
}
23+
24+
public function getPassword()
25+
{
26+
return $this->getParameter('password');
27+
}
28+
29+
public function setPassword($value)
30+
{
31+
return $this->setParameter('password', $value);
32+
}
33+
34+
public function getPartnerId()
35+
{
36+
return $this->getParameter('partnerId');
37+
}
38+
39+
public function setPartnerId($value)
40+
{
41+
return $this->setParameter('partnerId', $value);
42+
}
43+
44+
public function getTransactionType()
45+
{
46+
return $this->getParameter('transactionType');
47+
}
48+
49+
/**
50+
* Sets the transaction type
51+
* One of "Purchase" (default), "MOTO" or "Recurring"
52+
*/
53+
public function setTransactionType($value)
54+
{
55+
return $this->setParameter('transactionType', $value);
56+
}
57+
58+
public function getShippingMethod()
59+
{
60+
return $this->getParameter('shippingMethod');
61+
}
62+
63+
public function setShippingMethod($value)
64+
{
65+
return $this->setParameter('shippingMethod', $value);
66+
}
67+
68+
public function getInvoiceReference()
69+
{
70+
return $this->getParameter('invoiceReference');
71+
}
72+
73+
public function setInvoiceReference($value)
74+
{
75+
return $this->setParameter('invoiceReference', $value);
76+
}
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+
}
114+
115+
protected function getItemData()
116+
{
117+
$itemArray = array();
118+
$items = $this->getItems();
119+
if ($items) {
120+
foreach ($items as $item) {
121+
$data = array();
122+
$data['SKU'] = strval($item->getName());
123+
$data['Description'] = strval($item->getDescription());
124+
$data['Quantity'] = strval($item->getQuantity());
125+
$cost = $this->formatCurrency($item->getPrice());
126+
$data['UnitCost'] = strval($this->getCostInteger($cost));
127+
$itemArray[] = $data;
128+
}
129+
}
130+
131+
return $itemArray;
132+
}
133+
134+
protected function getCostInteger($amount)
135+
{
136+
return (int) round($amount * pow(10, $this->getCurrencyDecimalPlaces()));
137+
}
138+
139+
public function getEndpointBase()
140+
{
141+
return $this->getTestMode() ? $this->testEndpoint : $this->liveEndpoint;
142+
}
143+
}

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+
}

0 commit comments

Comments
 (0)