Squiz Matrix  4.12.2
 All Data Structures Namespaces Functions Variables Pages
esec_processor.inc
1 <?php
40 {
41 
42  var $parameters;
43 
44  var $response;
45 
46  // returned response details
47  var $eps_v3plus_responses = Array(
48  'ref-id', //= referenceID
49  'auth-id', //= authorisationID
50  'message', //= message
51  'signature', //= signature
52  'eft-response', //= eftResponse
53  'txn-id', //= bank transaction ID
54  'settlement-date' //= bank settlement date
55  );
56 
57  var $card_types = Array(
58  "visa" => "visa",
59  "mastercard"=> "mastercard",
60  "amex" => "amex",
61  "dinersclub"=> "dinersclub",
62  "jcb" => "jcb"
63  );
64 
65  var $test_card_numbers = Array (
66  "testsuccess" => "Test Success",
67  "testfailure" => "Test Failure",
68  "testtimeout" => "Test Timeout"
69  );
70 
71  var $_status_codes = Array (
72  '00' => 'approved',
73  '01' => 'refer to issuer',
74  '02' => 'refer to issuer\'s special conditions',
75  '03' => 'invalid merchant',
76  '04' => 'pickup card',
77  '05' => 'do not honour',
78  '06' => 'error',
79  '07' => 'pickup card, special conditions',
80  '08' => 'approved',
81  '09' => 'request in progress',
82  '10' => 'approved for partial amount',
83  '11' => 'approved VIP',
84  '12' => 'invalid transaction',
85  '13' => 'invalid amount',
86  '14' => 'invalid card number',
87  '15' => 'no such issuer',
88  '16' => 'approved, update track 3',
89  '17' => 'customer cancellation',
90  '18' => 'customer dispute',
91  '19' => 're-enter transaction',
92  '20' => 'invalid response',
93  '21' => 'no action taken',
94  '22' => 'suspected malfunction',
95  '23' => 'unacceptable transaction fee',
96  '24' => 'file date not supported',
97  '25' => 'unable to locate record on file',
98  '26' => 'duplicate file update record, old record replaced',
99  '27' => 'file update field error',
100  '28' => 'file update file locked out',
101  '29' => 'file update not successful, contact acquirer',
102  '30' => 'format error',
103  '31' => 'bank not supported by switch',
104  '32' => 'completed partially',
105  '33' => 'expired card',
106  '34' => 'suspected fraud',
107  '35' => 'contact acquirer',
108  '36' => 'restricted card',
109  '37' => 'contact acquirer security',
110  '38' => 'allowable PIN retries exceeded',
111  '39' => 'no credit account',
112  '40' => 'request function not supported',
113  '41' => 'lost card',
114  '42' => 'no universal account',
115  '43' => 'stolen card',
116  '44' => 'no investment account',
117  '51' => 'insufficient funds',
118  '52' => 'no cheque account',
119  '53' => 'no savings account',
120  '54' => 'expired card',
121  '55' => 'incorrect PIN',
122  '56' => 'no card record',
123  '57' => 'transaction not permitted to cardholder',
124  '58' => 'transaction not permitted to terminal',
125  '59' => 'suspected fraud',
126  '60' => 'contact acquirer',
127  '61' => 'exceeds withdrawal amount limit',
128  '62' => 'restricted card',
129  '63' => 'security violation',
130  '64' => 'original amount incorrect',
131  '65' => 'exceeds withdrawal frequency limit',
132  '66' => 'contact acquirer security',
133  '67' => 'hard capture',
134  '68' => 'response received too late',
135  '75' => 'allowable number of PIN retries exceeded',
136  '90' => 'cutoff in progress',
137  '91' => 'issuer inoperative',
138  '92' => 'financial institution cannot be found',
139  '93' => 'transaction cannot be completed, violation of law',
140  '94' => 'duplicate transmission',
141  '95' => 'reconcile error',
142  '96' => 'system malfunction',
143  '97' => 'reconciliation totals have been reset',
144  '98' => 'MAC error',
145  '99' => 'reserved, will not be returned'
146  );
147 
152  function Esec_Processor()
153  {
154  $this->parameters = Array();
155  $this->response = Array();
156 
157  $this->set('EPS_CCV', '');
158  $this->set('EPS_VERSION', 3);
159  $this->set('EPS_TEST', 'false');
160  $this->set('EPS_3DSECURE', 'false');
161 
162  }//end constructor
163 
164 
174  function set($name, $value)
175  {
176  $this->parameters[$name] = $value;
177  }//end set()
178 
179 
189  function setArray($name, $value)
190  {
191  if (!is_array($this->parameters[$name])) {
192  $this->parameters[$name] = Array();
193  }
194  $this->parameters[$name][] = $value;
195  }//end setArray()
196 
197 
206  function get($name)
207  {
208  return $this->parameters[$name];
209 
210  }//end get()
211 
212 
222  function setAmount($amount, $cents=false)
223  {
224  if ($cents) {
225  $amount = floor($amount);
226  } else {
227  $amount = sprintf('%01.2f',$amount);
228  }
229  $this->set('EPS_AMOUNT', $amount);
230 
231  }//end setAmount()
232 
233 
240  function getAmount()
241  {
242  return $this->get('EPS_AMOUNT');
243 
244  }//end getAmount()
245 
246 
253  function getCardTypes()
254  {
255  return $this->card_types;
256 
257  }//end getCardTypes()
258 
259 
267  {
268  return $this->test_card_numbers;
269 
270  }//end getTestCardNumbers()
271 
272 
281  function setCardType($type)
282  {
283  $this->set('EPS_CARDTYPE', $type);
284 
285  }//end setCardType()
286 
295  function setURL($new_url)
296  {
297  $this->_url = $new_url;
298 
299  }//end setURL()
300 
301 
308  function process()
309  {
310 
311  }//end process()
312 
313 
322  function getResponse()
323  {
324  $response['REFERENCE'] = isset($this->response['ref-id']) ? $this->response['ref-id'] : '';
325  $response['AUTHORISATION'] = isset($this->response['auth-id']) ? $this->response['auth-id'] : '';
326  $response['MESSAGE_CODE'] = isset($this->response['message']) ? substr($this->response['message'], 0, 3) : '';
327  $response['MESSAGE'] = isset($this->response['message']) ? substr($this->response['message'], 4) : '';
328  $response['STATUS'] = isset($this->response['eft-response']) ? $this->response['eft-response'] : '';
329  $response['TRANSACTION'] = isset($this->response['txn-id']) ? $this->response['txn-id'] : '';
330  $response['DATE'] = isset($this->response['settlement-date']) ? $this->response['settlement-date'] : '';
331 
332  return $response;
333 
334  }//end getResponse()
335 
336 
343  function explainStatus()
344  {
345 
346  $code = $this->response['eft-response'];
347  if (isset($this->_status_codes[$code])) {
348  $result = $this->_status_codes[$code];
349  } else {
350  $result = "Unknown";
351  }
352 
353  return $result;
354 
355  }//end explainStatus()
356 
357 
366  function setMerchant($merchant_no)
367  {
368  $this->set('EPS_MERCHANT', $merchant_no);
369 
370  }//end setMerchant()
371 
372 
381  function setReference($ref_no)
382  {
383  $this->set('EPS_REFERENCEID', $ref_no);
384 
385  }//end setReference()
386 
387 
396  function setCCV($ccv_no)
397  {
398  $this->set('EPS_CCV', $ccv_no);
399 
400  }//end setCCV()
401 
402 
411  function setCardNumber($card_no)
412  {
413  $this->set('EPS_CARDNUMBER', $card_no);
414 
415  }//end setCardNumber()
416 
417 
426  function setCardExpiryMonth($month)
427  {
428  $this->set('EPS_EXPIRYMONTH', $month);
429 
430  }//end setCardExpiryMonth()
431 
432 
441  function setCardExpiryYear($year)
442  {
443  $this->set('EPS_EXPIRYYEAR', $year);
444 
445  }//end setCardExpiryYear()
446 
455  function setCardName($name)
456  {
457  $this->set('EPS_NAMEONCARD', $name);
458 
459  }//end setCardName()
460 
469  function setInfoEmail($email)
470  {
471  $this->set('EPS_INFOEMAIL', 'mailto: '.$email);
472 
473  }//end setInfoEmail()
474 
484  function setRedirectURL($value, $email=false)
485  {
486  if ($email && is_array($this->get('EPS_RESULTURL'))) {
487  // mailto is only valid if we already have an email address
488  $value = 'mailto:'.$value;
489  }
490  $this->setArray('EPS_RESULTURL', $value);
491 
492  }//end setRedirectURL()
493 
494 
504  function setTest()
505  {
506  $this->setMerchant('test');
507  $this->set('EPS_TEST', 'true');
508  $this->set('EPS_CARDTYPE', 'testcard');
509 
510  }//end setTest()
511 
512 }//end class
513 
514 /*
515 explanation of request parameters expected by the gateway
516 taken from
517 http://www.esecpayments.com.au/index.jsp?id=integdevel
518 8/10/2004
519 
520  EPS_MERCHANT
521  An unique identifier for the merchant within the Payment Gateway. This merchant identifier value is an alphanumeric string allocated to the merchant by eSec, although for testing purposes an identifier value of "test" may be used. This merchant identifier value is not the same as the merchant agreement number given to the merchant by an acquiring financial institution.
522  Examples:
523  <input type="HIDDEN" name="EPS_MERCHANT" value="test">
524  <input type="HIDDEN" name="EPS_MERCHANT" value="widgetsrus">
525 
526  EPS_REFERENCEID
527  An alphanumeric string that allows the merchant's processing system to identify an individual transaction. The format of this string is of no importance to the Payment Gateway, since the value is simply stored by the Payment Gateway as part of the transaction record and returned to the merchant's processing system in the transaction result.
528  Examples:
529  <INPUT TYPE="HIDDEN" NAME="EPS_REFERENCEID" VALUE="1234567890">
530  <INPUT TYPE="HIDDEN" NAME="EPS_REFERENCEID" VALUE="20010410-123456">
531 
532  EPS_CARDNUMBER
533  The number from the credit card to be used for the purchase. This number must be greater than 12 digits, less than 19 digits and must conform to the credit card checkdigit scheme. Spaces and hyphens included in the card number value will be removed before processing.
534  When sending transactions to the Payment Gateway test facility, and only to the test facility, the following special card "numbers" may be submitted:
535  testsuccess - Always successfully processed and authorised
536  testfailure - Always successfully processed and refused
537  testtimeout - Never responds and the transaction will time out
538  The test facility does not normally accept real credit card numbers, however additional test facilities may be made available under certain specific exceptional circumstances. The Payment Gateway live facility will not accept the test card numbers listed above under any circumstances.
539  Examples:
540  <INPUT TYPE="HIDDEN" NAME="EPS_CARDNUMBER" VALUE="testsuccess">
541  <INPUT TYPE="HIDDEN" NAME="EPS_CARDNUMBER" VALUE="1234567890123456">
542 
543  EPS_CARDTYPE
544  A string containing the name of the credit card issuer that provided the credit card. This may currently be one of the strings "visa", "mastercard", "bankcard", "amex", "dinersclub" or "jcb" in any mixture of case. If this parameter is not correctly set to one of the values listed above, the transaction will be rejected.
545  When sending transactions to the Payment Gateway test facility, and only to the test facility, the special card type "testcard" should be used to identify the special test card numbers listed above. Failure to set the card type field to "testcard" when sending test card numbers will cause the Payment Gateway to reject the transaction.
546  Examples:
547  <INPUT TYPE="HIDDEN" NAME="EPS_CARDTYPE" VALUE="testcard">
548  <INPUT TYPE="HIDDEN" NAME="EPS_CARDTYPE" VALUE="visa">
549 
550  EPS_EXPIRYMONTH
551  The month in which the credit card expires. This may only contain an integer value between 1 and 12, inclusive, corresponding to the month of the year.
552  The expiry month and expiry year together must form a date that is at least the current month. Transactions that contain an expiry date in the past will be rejected.
553  Examples:
554  <INPUT TYPE="HIDDEN" NAME="EPS_EXPIRYMONTH" VALUE="1">
555  <INPUT TYPE="HIDDEN" NAME="EPS_EXPIRYMONTH" VALUE="12">
556 
557  EPS_EXPIRYYEAR
558  The year in which the credit card expires. This should ideally be a full 4 digit year value to remove any possible ambiguity, however if a two digit year is provided, the Payment Gateway will assume that a value of "99" refers to 1999 and that any other value refers to a value of "20XX", where XX is the 2 digit value provided. The expiry month and expiry year together must form a date that is at least the current month. Transactions that contain an expiry date in the past will be rejected. It is strongly recommended that a full 4 digit year be specified as the value of this parameter since support for two digit years will be withdrawn in a future release of this interface.
559  Examples:
560  <input type="HIDDEN" name="EPS_EXPIRYYEAR" value="2001">
561  <input type="HIDDEN" name="EPS_EXPIRYYEAR" value="01">
562 
563  EPS_NAMEONCARD
564  The card holder's name as specified on the credit card. This parameter must contain a non-null alphabetic string of up to 50 characters.
565  Examples:
566  <input type="HIDDEN" name="EPS_NAMEONCARD" value="John A. Citizen">
567  <input type="HIDDEN" name="EPS_NAMEONCARD" value="Jane M. Person">
568 
569  EPS_AMOUNT
570  The total amount of the purchase transaction. This value may be specified either as a decimal dollar amount (in which case there MUST be two digits after the decimal place) or as a value in cents. If a decimal point is not included in the amount value, then the amount is assumed to be a value in cents. Please be careful to correctly specify the amount as the Payment Gateway has no way of determining whether an amount has been correctly specified. As an example, assume a transaction is being submitted for an amount of AUD$107.95. This amount may be submitted to the Payment Gateway in either of the following forms:
571  <input type="HIDDEN" name="EPS_AMOUNT" value="10795">
572  <input type="HIDDEN" name="EPS_AMOUNT" value="107.95">
573  The first form above indicates a value of 10795 cents, which is the preferred method for submitting amounts. Using the minor currency unit (i.e. cents) allows for easier expansion into future multi-currency services. Be very careful to ensure that amounts in whole dollars, i.e. with only zeros after the decimal point, are submitted *with the trailing zeros intact*. If an amount such as AUD$107.00 is simply submitted as 107, the Payment Gateway will assume that this is 107 *cents* and will process the transactions as such. The correct form for an amount such as this one is either of "10700" or "107.00".
574  Null or zero and negative amounts are not acceptable and transactions containing such amount values will be rejected.
575 
576  EPS_CCV
577  The Card Check Value (CCV) field should contain a three or four digit value that is printed on the back of the credit card itself. If the CCV value is not available, either because it is not present on the card (some cards still do not have CCV values printed on them), or because the card holder does not wish to enter it, this field should be left empty.
578  When sending transactions to the Payment Gateway test facility, and only to the test facility, CCV values of "1234" and "999" are accepted as valid fields. The CCV field may also be left empty for testing.
579  This field may be referred to elsewhere as a Card Verification Value (CVV) or a Card Verification Code (CVC), most notably in information provided by banks or credit card providers.
580  Examples:
581  <input type="HIDDEN" name="EPS_CCV" value="1234">
582  <input type="HIDDEN" name="EPS_CCV" value="999">
583 
584  EPS_VERSION
585  An integer that specifies the SSL Web Interface Specification response version that the merchant's processing system requires. This may take a value of 1, 2, 3, or 4, for a response in the required format. The differences between the response versions is described later in this document. If not set to any value, the Payment Gateway assumes a Version 1 response.
586  Examples:
587  <input type="HIDDEN" name="EPS_VERSION" value="1">
588  <input type="HIDDEN" name="EPS_VERSION" value="2">
589 
590  EPS_TEST
591  A boolean field that specifies whether the transaction should be sent to the Payment Gateway's test facility. If this element exists and contains a value of "true", the transaction will be sent to the test service, and if it contains a value of "false", the transaction will be sent to the live service. If this element does not exist, the default service will be utilised (usually the live service).
592  Examples:
593  <input type="HIDDEN" name="EPS_TEST" value="true">
594  <input type="HIDDEN" name="EPS_TEST" value="false">
595 */
596 
597 
598 ?>