|
| 1 | +<?php |
| 2 | + |
| 3 | +namespace Omnipay\Eway\Message; |
| 4 | + |
| 5 | +use Omnipay\Common\Message\AbstractResponse; |
| 6 | +use Omnipay\Common\Message\RedirectResponseInterface; |
| 7 | + |
| 8 | +/** |
| 9 | + * eWAY Rapid 3.0 Purchase Response |
| 10 | + */ |
| 11 | +class RapidResponse extends AbstractResponse implements RedirectResponseInterface |
| 12 | +{ |
| 13 | + public static $MESSAGES = array( |
| 14 | + 'A2000' => 'Transaction Approved', |
| 15 | + 'A2008' => 'Honour With Identification', |
| 16 | + 'A2010' => 'Approved For Partial Amount', |
| 17 | + 'A2011' => 'Approved, VIP', |
| 18 | + 'A2016' => 'Approved, Update Track 3', |
| 19 | + 'D4401' => 'Refer to Issuer', |
| 20 | + 'D4402' => 'Refer to Issuer, special', |
| 21 | + 'D4403' => 'No Merchant', |
| 22 | + 'D4404' => 'Pick Up Card', |
| 23 | + 'D4405' => 'Do Not Honour', |
| 24 | + 'D4406' => 'Error', |
| 25 | + 'D4407' => 'Pick Up Card, Special', |
| 26 | + 'D4409' => 'Request In Progress', |
| 27 | + 'D4412' => 'Invalid Transaction', |
| 28 | + 'D4413' => 'Invalid Amount', |
| 29 | + 'D4414' => 'Invalid Card Number', |
| 30 | + 'D4415' => 'No Issuer', |
| 31 | + 'D4419' => 'Re-enter Last Transaction', |
| 32 | + 'D4421' => 'No Action Taken', |
| 33 | + 'D4422' => 'Suspected Malfunction', |
| 34 | + 'D4423' => 'Unacceptable Transaction Fee', |
| 35 | + 'D4425' => 'Unable to Locate Record On File', |
| 36 | + 'D4430' => 'Format Error', |
| 37 | + 'D4431' => 'Bank Not Supported By Switch', |
| 38 | + 'D4433' => 'Expired Card, Capture', |
| 39 | + 'D4434' => 'Suspected Fraud, Retain Card', |
| 40 | + 'D4435' => 'Card Acceptor, Contact Acquirer, Retain Card', |
| 41 | + 'D4436' => 'Restricted Card, Retain Card', |
| 42 | + 'D4437' => 'Contact Acquirer Security Department, Retain Card', |
| 43 | + 'D4438' => 'PIN Tries Exceeded, Capture', |
| 44 | + 'D4439' => 'No Credit Account', |
| 45 | + 'D4440' => 'Function Not Supported', |
| 46 | + 'D4441' => 'Lost Card', |
| 47 | + 'D4442' => 'No Universal Account', |
| 48 | + 'D4443' => 'Stolen Card', |
| 49 | + 'D4444' => 'No Investment Account', |
| 50 | + 'D4451' => 'Insufficient Funds', |
| 51 | + 'D4452' => 'No Cheque Account', |
| 52 | + 'D4453' => 'No Savings Account', |
| 53 | + 'D4454' => 'Expired Card', |
| 54 | + 'D4455' => 'Incorrect PIN', |
| 55 | + 'D4456' => 'No Card Record', |
| 56 | + 'D4457' => 'Function Not Permitted to Cardholder', |
| 57 | + 'D4458' => 'Function Not Permitted to Terminal', |
| 58 | + 'D4459' => 'Suspected Fraud', |
| 59 | + 'D4460' => 'Acceptor Contact Acquirer', |
| 60 | + 'D4461' => 'Exceeds Withdrawal Limit', |
| 61 | + 'D4462' => 'Restricted Card', |
| 62 | + 'D4463' => 'Security Violation', |
| 63 | + 'D4464' => 'Original Amount Incorrect', |
| 64 | + 'D4466' => 'Acceptor Contact Acquirer, Security', |
| 65 | + 'D4467' => 'Capture Card', |
| 66 | + 'D4475' => 'PIN Tries Exceeded', |
| 67 | + 'D4482' => 'CVV Validation Error', |
| 68 | + 'D4490' => 'Cut off In Progress', |
| 69 | + 'D4491' => 'Card Issuer Unavailable', |
| 70 | + 'D4492' => 'Unable To Route Transaction', |
| 71 | + 'D4493' => 'Cannot Complete, Violation Of The Law', |
| 72 | + 'D4494' => 'Duplicate Transaction', |
| 73 | + 'D4496' => 'System Error', |
| 74 | + 'S5000' => 'System Error', |
| 75 | + 'S5085' => 'Started 3dSecure', |
| 76 | + 'S5086' => 'Routed 3dSecure', |
| 77 | + 'S5087' => 'Completed 3dSecure', |
| 78 | + 'S5099' => 'Incomplete (Access Code in progress/incomplete)', |
| 79 | + 'V6000' => 'Validation error', |
| 80 | + 'V6001' => 'Invalid CustomerIP', |
| 81 | + 'V6002' => 'Invalid DeviceID', |
| 82 | + 'V6011' => 'Invalid Payment TotalAmount', |
| 83 | + 'V6012' => 'Invalid Payment InvoiceDescription', |
| 84 | + 'V6013' => 'Invalid Payment InvoiceNumber', |
| 85 | + 'V6014' => 'Invalid Payment InvoiceReference', |
| 86 | + 'V6015' => 'Invalid Payment CurrencyCode', |
| 87 | + 'V6016' => 'Payment Required', |
| 88 | + 'V6017' => 'Payment CurrencyCode Required', |
| 89 | + 'V6018' => 'Unknown Payment CurrencyCode', |
| 90 | + 'V6021' => 'EWAY_CARDNAME Required', |
| 91 | + 'V6022' => 'EWAY_CARDNUMBER Required', |
| 92 | + 'V6023' => 'EWAY_CARDCVN Required', |
| 93 | + 'V6033' => 'Invalid Expiry Date', |
| 94 | + 'V6034' => 'Invalid Issue Number', |
| 95 | + 'V6035' => 'Invalid Valid From Date', |
| 96 | + 'V6040' => 'Invalid TokenCustomerID', |
| 97 | + 'V6041' => 'Customer Required', |
| 98 | + 'V6042' => 'Customer FirstName Required', |
| 99 | + 'V6043' => 'Customer LastName Required', |
| 100 | + 'V6044' => 'Customer CountryCode Required', |
| 101 | + 'V6045' => 'Customer Title Required', |
| 102 | + 'V6046' => 'TokenCustomerID Required', |
| 103 | + 'V6047' => 'RedirectURL Required', |
| 104 | + 'V6051' => 'Invalid Customer FirstName', |
| 105 | + 'V6052' => 'Invalid Customer LastName', |
| 106 | + 'V6053' => 'Invalid Customer CountryCode', |
| 107 | + 'V6058' => 'Invalid Customer Title', |
| 108 | + 'V6059' => 'Invalid RedirectURL', |
| 109 | + 'V6060' => 'Invalid TokenCustomerID', |
| 110 | + 'V6061' => 'Invalid Customer Reference', |
| 111 | + 'V6062' => 'Invalid Customer CompanyName', |
| 112 | + 'V6063' => 'Invalid Customer JobDescription', |
| 113 | + 'V6064' => 'Invalid Customer Street1', |
| 114 | + 'V6065' => 'Invalid Customer Street2', |
| 115 | + 'V6066' => 'Invalid Customer City', |
| 116 | + 'V6067' => 'Invalid Customer State', |
| 117 | + 'V6068' => 'Invalid Customer PostalCode', |
| 118 | + 'V6069' => 'Invalid Customer Email', |
| 119 | + 'V6070' => 'Invalid Customer Phone', |
| 120 | + 'V6071' => 'Invalid Customer Mobile', |
| 121 | + 'V6072' => 'Invalid Customer Comments', |
| 122 | + 'V6073' => 'Invalid Customer Fax', |
| 123 | + 'V6074' => 'Invalid Customer URL', |
| 124 | + 'V6075' => 'Invalid ShippingAddress FirstName', |
| 125 | + 'V6076' => 'Invalid ShippingAddress LastName', |
| 126 | + 'V6077' => 'Invalid ShippingAddress Street1', |
| 127 | + 'V6078' => 'Invalid ShippingAddress Street2', |
| 128 | + 'V6079' => 'Invalid ShippingAddress City', |
| 129 | + 'V6080' => 'Invalid ShippingAddress State', |
| 130 | + 'V6081' => 'Invalid ShippingAddress PostalCode', |
| 131 | + 'V6082' => 'Invalid ShippingAddress Email', |
| 132 | + 'V6083' => 'Invalid ShippingAddress Phone', |
| 133 | + 'V6084' => 'Invalid ShippingAddress Country', |
| 134 | + 'V6085' => 'Invalid ShippingAddress ShippingMethod', |
| 135 | + 'V6086' => 'Invalid ShippingAddress Fax', |
| 136 | + 'V6091' => 'Unknown Customer CountryCode', |
| 137 | + 'V6092' => 'Unknown ShippingAddress CountryCode', |
| 138 | + 'V6100' => 'Invalid EWAY_CARDNAME', |
| 139 | + 'V6101' => 'Invalid EWAY_CARDEXPIRYMONTH', |
| 140 | + 'V6102' => 'Invalid EWAY_CARDEXPIRYYEAR', |
| 141 | + 'V6103' => 'Invalid EWAY_CARDSTARTMONTH', |
| 142 | + 'V6104' => 'Invalid EWAY_CARDSTARTYEAR', |
| 143 | + 'V6105' => 'Invalid EWAY_CARDISSUENUMBER', |
| 144 | + 'V6106' => 'Invalid EWAY_CARDCVN', |
| 145 | + 'V6107' => 'Invalid EWAY_ACCESSCODE', |
| 146 | + 'V6108' => 'Invalid CustomerHostAddress', |
| 147 | + 'V6109' => 'Invalid UserAgent', |
| 148 | + 'V6110' => 'Invalid EWAY_CARDNUMBER', |
| 149 | + ); |
| 150 | + |
| 151 | + public function isSuccessful() |
| 152 | + { |
| 153 | + return isset($this->data['TransactionStatus']) && $this->data['TransactionStatus']; |
| 154 | + } |
| 155 | + |
| 156 | + public function isRedirect() |
| 157 | + { |
| 158 | + return isset($this->data['FormActionURL']); |
| 159 | + } |
| 160 | + |
| 161 | + public function getRedirectUrl() |
| 162 | + { |
| 163 | + return isset($this->data['FormActionURL']) ? $this->data['FormActionURL'] : null; |
| 164 | + } |
| 165 | + |
| 166 | + public function getRedirectMethod() |
| 167 | + { |
| 168 | + return 'POST'; |
| 169 | + } |
| 170 | + |
| 171 | + public function getRedirectData() |
| 172 | + { |
| 173 | + if ($this->isRedirect()) { |
| 174 | + return array( |
| 175 | + 'EWAY_ACCESSCODE' => $this->data['AccessCode'], |
| 176 | + ); |
| 177 | + } |
| 178 | + } |
| 179 | + |
| 180 | + public function getTransactionReference() |
| 181 | + { |
| 182 | + return isset($this->data['TransactionID']) ? (string) $this->data['TransactionID'] : null; |
| 183 | + } |
| 184 | + |
| 185 | + public function getMessage() |
| 186 | + { |
| 187 | + $codes = explode(',', $this->getCode()); |
| 188 | + $messages = array(); |
| 189 | + |
| 190 | + foreach ($codes as $code) { |
| 191 | + if (isset(static::$MESSAGES[$code])) { |
| 192 | + $messages[] = static::$MESSAGES[$code]; |
| 193 | + } else { |
| 194 | + $messages[] = $code; |
| 195 | + } |
| 196 | + } |
| 197 | + |
| 198 | + return implode(', ', $messages) ?: null; |
| 199 | + } |
| 200 | + |
| 201 | + public function getCode() |
| 202 | + { |
| 203 | + if (!empty($this->data['ResponseMessage'])) { |
| 204 | + return $this->data['ResponseMessage']; |
| 205 | + } elseif (!empty($this->data['Errors'])) { |
| 206 | + return $this->data['Errors']; |
| 207 | + } |
| 208 | + } |
| 209 | +} |
0 commit comments