First_Data_Gateway_Integration - Version 1.0.7

Version Notes

This version is properly tested on the following Magento CE versions: 1.5, 1.6, 1.7,1.8,1.9.* . In this particular version we are supporting it to run on PHP V 5.5.X.

Download this release

Release Info

Developer Rave Infosys
Extension First_Data_Gateway_Integration
Version 1.0.7
Comparing to
See all releases


Code changes from version 1.0.6 to 1.0.7

app/code/community/Raveinfosys/Linkpoint/Model/Linkpoint.php CHANGED
@@ -1,4 +1,5 @@
1
  <?php
 
2
  /**
3
  * NOTICE OF LICENSE
4
  *
@@ -16,63 +17,64 @@
16
  */
17
  class Raveinfosys_Linkpoint_Model_Linkpoint extends Mage_Payment_Model_Method_Ccsave
18
  {
19
-
20
- protected $_code = 'linkpoint'; //unique internal payment method identifier
21
- protected $_isGateway = true; //Is this payment method a gateway (online auth/charge) ?
22
- protected $_canAuthorize = true; //Can authorize online?
23
- protected $_canCapture = true; //Can capture funds online?
24
- protected $_canCapturePartial = false; //Can capture partial amounts online?
25
- protected $_canRefund = true; //Can refund online?
26
- protected $_canRefundInvoicePartial = true; //Can refund invoices partially?
27
- protected $_canVoid = true; //Can void transactions online?
28
- protected $_canUseInternal = true; //Can use this payment method in administration panel?
29
- protected $_canUseCheckout = true; //Can show this payment method as an option on checkout payment page?
30
- protected $_canUseForMultishipping = false; //Is this payment method suitable for multi-shipping checkout?
31
- protected $_isInitializeNeeded = false;
32
- protected $_canFetchTransactionInfo = false;
33
- protected $_canReviewPayment = false;
34
- protected $_canCreateBillingAgreement = false;
35
- protected $_canManageRecurringProfiles = false;
36
- protected $_canSaveCc = true; //Can save credit card information for future processing?
37
-
38
- /**
 
39
  * Fields that should be replaced in debug with '***'
40
  *
41
  * @var array
42
  */
43
  protected $_debugReplacePrivateDataKeys = array('keyId', 'hmacKey', 'gatewayId', 'gatewayPass');
44
-
45
- /**
46
  * Validate payment method information object
47
  *
48
  * @param Mage_Payment_Model_Info $info
49
  * @return Mage_Payment_Model_Abstract
50
  */
51
- public function validate()
52
- {
53
- $info = $this->getInfoInstance();
54
- $order_amount = 0;
55
- if ($info instanceof Mage_Sales_Model_Quote_Payment) {
56
- $order_amount = (double)$info->getQuote()->getBaseGrandTotal();
57
  } elseif ($info instanceof Mage_Sales_Model_Order_Payment) {
58
- $order_amount = (double)$info->getOrder()->getQuoteBaseGrandTotal();
 
 
 
 
 
 
59
  }
60
-
61
- $order_min = $this->getConfigData('min_order_total');
62
- $order_max = $this->getConfigData('max_order_total');
63
- if(!empty($order_max) && (double)$order_max<$order_amount) {
64
- Mage::throwException("Order amount greater than permissible Maximum order amount.");
65
- }
66
- if(!empty($order_min) && (double)$order_min>$order_amount) {
67
- Mage::throwException("Order amount less than required Minimum order amount.");
68
- }
69
- /*
70
- * calling parent validate function
71
- */
72
  parent::validate();
73
- }
74
-
75
- /**
76
  * Send authorize request to gateway
77
  *
78
  * @param Varien_Object $payment
@@ -80,298 +82,287 @@ class Raveinfosys_Linkpoint_Model_Linkpoint extends Mage_Payment_Model_Method_Cc
80
  * @return Mage_Paygate_Model_Authorizenet
81
  * @throws Mage_Core_Exception
82
  */
83
- public function authorize(Varien_Object $payment, $amount)
84
- {
85
- if ($amount <= 0) {
86
  Mage::throwException(Mage::helper('linkpoint')->__('Invalid amount for transaction.'));
87
- }
88
- $payment->setAmount($amount);
89
- $data = $this->_prepareData();
90
- $data['trans_type'] = "01";
91
- $creditcard = array(
92
- 'cardnumber' => $payment->getCcNumber(),
93
- 'cardexpmonth' => $payment->getCcExpMonth(),
94
- 'ccname' => $payment->getCcOwner(),
95
- 'cardexpyear' => substr($payment->getCcExpYear(),-2),
96
- );
97
- if($this->getConfigData('useccv')==1) {
98
- $creditcard["cvmindicator"] = "provided";
99
- $creditcard["cvmvalue"] = $payment->getCcCid();
100
- $creditcard["cvv2indicator"]= 1;
101
- $creditcard["cvv2value"] = $payment->getCcCid();
102
- }
103
-
104
- $shipping = array();
105
- $billing = array();
106
- $order = $payment->getOrder();
107
- if (!empty($order)) {
108
- $BillingAddress = $order->getBillingAddress();
109
-
110
- $billing['name'] = $BillingAddress->getFirstname()." ".$BillingAddress->getLastname();
111
- $billing['company'] = $BillingAddress->getCompany();
112
- $billing['address'] = $BillingAddress->getStreet(1);
113
- $billing['city'] = $BillingAddress->getCity();
114
- $billing['state'] = $BillingAddress->getRegion();
115
- $billing['zip'] = $BillingAddress->getPostcode();
116
- $billing['country'] = $BillingAddress->getCountry();
117
- $billing['email'] = $order->getCustomerEmail();
118
- $billing['phone'] = $BillingAddress->getTelephone();
119
- $billing['fax'] = $BillingAddress->getFax();
120
-
121
- $ShippingAddress = $order->getShippingAddress();
122
- if (!empty($shipping)) {
123
- $shipping['sname'] = $ShippingAddress->getFirstname()." ".$ShippingAddress->getLastname();
124
- $shipping['saddress1'] = $ShippingAddress->getStreet(1);
125
- $shipping['scity'] = $ShippingAddress->getCity();
126
- $shipping['sstate'] = $ShippingAddress->getRegion();
127
- $shipping['szip'] = $ShippingAddress->getPostcode();
128
- $shipping['scountry'] = $ShippingAddress->getCountry();
129
- }
130
- }
131
-
132
- $merchantinfo = array();
133
- $merchantinfo['gatewayId'] = $data['gatewayId'];
134
- $merchantinfo['gatewayPass'] = $data['gatewayPass'];
135
- $paymentdetails = array();
136
- $paymentdetails['chargetotal'] = $payment->getAmount();
137
-
138
- $data = array_merge($data, $creditcard, $billing, $shipping, $merchantinfo, $paymentdetails);
139
-
140
- $result = $this->_postRequest($data);
141
-
142
- if(is_array($result) && count($result)>0) {
143
-
144
- if(array_key_exists("Bank_Message",$result)) {
145
- if ($result["Bank_Message"] != "Approved") {
146
- $payment->setStatus(self::STATUS_ERROR);
147
- Mage::throwException("Gateway error : {".(string)$result["EXact_Message"]."}");
148
- }
149
- elseif($trxnResult->Transaction_Error){
150
- Mage::throwException("Returned Error Message: $trxnResult->EXact_Message");
151
- }
152
- /*
153
- elseif($this->getConfigData('useccv') && $trxnResult->CVV2 != "M" ){
154
- Mage::throwException("Invalid Card Verification Number(".$trxnResult->CVV2.")");
155
- }*/
156
- else {
157
- $payment->setStatus(self::STATUS_APPROVED);
158
- $payment->setAdditionalInformation('payment_type', $this->getConfigData('payment_action'));
159
- $payment->setLastTransId((string)$result["Authorization_Num"]);
160
- $payment->setTransactionTag((string)$result["Transaction_Tag"]);
161
- if (!$payment->getParentTransactionId() || (string)$result["Authorization_Num"] != $payment->getParentTransactionId()) {
162
- $payment->setTransactionId((string)$result["Authorization_Num"]);
163
- }
164
- $this->_addTransaction(
165
- $payment,
166
- $result["Authorization_Num"],
167
- Mage_Sales_Model_Order_Payment_Transaction::TYPE_AUTH,
168
- array('is_transaction_closed' => 0));
169
- $payment->setSkipTransactionCreation(true);
170
- return $this;
171
- }
172
- }
173
- else {
174
- Mage::throwException("No approval found");
175
- }
176
- } else {
177
- Mage::throwException("No response found");
178
- }
179
- }
180
-
181
- public function capture(Varien_Object $payment, $amount)
182
- {
183
- if ($amount <= 0) {
184
  Mage::throwException(Mage::helper('linkpoint')->__('Invalid amount for transaction.'));
185
  }
186
 
187
- if($payment->getTransactionTag() != '' && Mage::app()->getStore()->isAdmin()){
188
- return $this->authorizePayment($payment, number_format($amount, 2, '.', ''));
189
- }
190
-
191
-
192
-
193
- $payment->setAmount($amount);
194
- $data = $this->_prepareData();
195
- $data['trans_type'] = "00";
196
- $creditcard = array(
197
- 'cardnumber' => $payment->getCcNumber(),
198
- 'cardexpmonth' => $payment->getCcExpMonth(),
199
- 'cardexpyear' => substr($payment->getCcExpYear(),-2),
200
- 'ccname' => $payment->getCcOwner()
201
- );
202
- if($this->getConfigData('useccv')==1) {
203
- $creditcard["cvmindicator"] = "provided";
204
- $creditcard["cvmvalue"] = $payment->getCcCid();
205
- $creditcard["cvv2indicator"]= 1;
206
- $creditcard["cvv2value"] = $payment->getCcCid();
207
- }
208
-
209
- $shipping = array();
210
- $billing = array();
211
- $order = $payment->getOrder();
212
- if (!empty($order)) {
213
- $BillingAddress = $order->getBillingAddress();
214
-
215
- $billing['name'] = $BillingAddress->getFirstname()." ".$BillingAddress->getLastname();
216
- $billing['company'] = $BillingAddress->getCompany();
217
- $billing['address'] = $BillingAddress->getStreet(1);
218
- $billing['city'] = $BillingAddress->getCity();
219
- $billing['state'] = $BillingAddress->getRegion();
220
- $billing['zip'] = $BillingAddress->getPostcode();
221
- $billing['country'] = $BillingAddress->getCountry();
222
- $billing['email'] = $order->getCustomerEmail();
223
- $billing['phone'] = $BillingAddress->getTelephone();
224
- $billing['fax'] = $BillingAddress->getFax();
225
-
226
- $ShippingAddress = $order->getShippingAddress();
227
- if (!empty($shipping)) {
228
- $shipping['sname'] = $ShippingAddress->getFirstname()." ".$ShippingAddress->getLastname();
229
- $shipping['saddress1'] = $ShippingAddress->getStreet(1);
230
- $shipping['scity'] = $ShippingAddress->getCity();
231
- $shipping['sstate'] = $ShippingAddress->getRegion();
232
- $shipping['szip'] = $ShippingAddress->getPostcode();
233
- $shipping['scountry'] = $ShippingAddress->getCountry();
234
- }
235
- }
236
-
237
- $merchantinfo = array();
238
- $merchantinfo['gatewayId'] = $data['gatewayId'];
239
- $merchantinfo['gatewayPass'] = $data['gatewayPass'];
240
- $paymentdetails = array();
241
- $paymentdetails['chargetotal'] = $payment->getAmount();
242
-
243
- $data = array_merge($data, $creditcard, $billing, $shipping, $merchantinfo, $paymentdetails);
244
-
245
- $result = $this->_postRequest($data);
246
-
247
- if(is_array($result) && count($result)>0) {
248
-
249
- if(array_key_exists("Bank_Message",$result)) {
250
- if ($result["Bank_Message"] != "Approved") {
251
- $payment->setStatus(self::STATUS_ERROR);
252
- Mage::throwException("Gateway error : {".(string)$result["EXact_Message"]."}");
253
- }
254
- elseif($trxnResult->Transaction_Error){
255
- Mage::throwException("Returned Error Message: $trxnResult->EXact_Message");
256
- }
257
- /*
258
- elseif($this->getConfigData('useccv') && $trxnResult->CVV2 != "M" ){
259
- Mage::throwException("Invalid Card Verification Number(".$trxnResult->CVV2.")");
260
- }*/
261
- else {
262
- $payment->setStatus(self::STATUS_APPROVED);
263
- $payment->setLastTransId((string)$result["Authorization_Num"]);
264
- $payment->setTransactionTag((string)$result["Transaction_Tag"]);
265
- if (!$payment->getParentTransactionId() || (string)$result["Authorization_Num"] != $payment->getParentTransactionId()) {
266
- $payment->setTransactionId((string)$result["Authorization_Num"]);
267
- }
268
- return $this;
269
- }
270
- }
271
- else {
272
- Mage::throwException("No approval found");
273
- }
274
- } else {
275
- Mage::throwException("No response found");
276
- }
277
- }
278
-
279
- public function authorizePayment(Varien_Object $payment, $amount) {
280
- $payment->setAmount($amount);
281
- $data = $this->_prepareData();
282
- $data['trans_type'] = "32";
283
- $data['transaction_tag'] = $payment->getTransactionTag();
284
-
285
- #$data['authorization_num'] = $payment->getLastTransId();
286
- $data['authorization_num'] = $payment->getParentTransactionId();
287
-
288
- $data['chargetotal'] = $amount;
289
-
290
- $result = $this->_postRequest($data);
291
-
292
- if(is_array($result) && count($result)>0) {
293
-
294
- if(array_key_exists("Bank_Message",$result)) {
295
- if ($result["Bank_Message"] != "Approved") {
296
- $payment->setStatus(self::STATUS_ERROR);
297
- Mage::throwException("Gateway error : {".(string)$result["EXact_Message"]."}");
298
- }
299
- elseif($trxnResult->Transaction_Error){
300
- Mage::throwException("Returned Error Message: $trxnResult->EXact_Message");
301
- }
302
- /*
303
- elseif($this->getConfigData('useccv') && $trxnResult->CVV2 != "M" ){
304
- Mage::throwException("Invalid Card Verification Number(".$trxnResult->CVV2.")");
305
- }*/
306
- else {
307
- $payment->setStatus(self::STATUS_APPROVED);
308
- $payment->setLastTransId((string)$result["Authorization_Num"]);
309
- $payment->setTransactionTag((string)$result["Transaction_Tag"]);
310
- if (!$payment->getParentTransactionId() || (string)$result["Authorization_Num"] != $payment->getParentTransactionId()) {
311
- $payment->setTransactionId((string)$result["Authorization_Num"]);
312
- }
313
- return $this;
314
- }
315
- }
316
- else {
317
- Mage::throwException("No approval found");
318
- }
319
- } else {
320
- Mage::throwException("No response found");
321
- }
322
- }
323
-
324
- /**
325
  * refund the amount with transaction id
326
  *
327
  * @param string $payment Varien_Object object
328
  * @return Mage_Paygate_Model_Authorizenet
329
  * @throws Mage_Core_Exception
330
  */
331
- public function refund(Varien_Object $payment, $amount) {
332
- if ($payment->getRefundTransactionId() && $amount > 0) {
 
333
  $data = $this->_prepareData();
334
- $data["trans_type"] = '34';
335
- $data["oid"] = $payment->getRefundTransactionId();
336
- $data['transaction_tag'] = $payment->getTransactionTag();
337
- $data['authorization_num'] = $payment->getParentTransactionId();
338
-
339
- $instance = $payment->getMethodInstance()->getInfoInstance();
340
- $paymentdetails = array();
341
- $paymentdetails['chargetotal'] = $amount;
342
- $paymentdetails['cardnumber'] = $instance->getCcNumber();
343
- $paymentdetails['ccname'] = $instance->getCcOwner();
344
- $paymentdetails['cardexpmonth'] = $instance->getCcExpMonth();
345
- $paymentdetails['cardexpyear'] = substr($instance->getCcExpYear(),-2);
346
- $shipping = array();
347
- $billing = array();
348
-
349
- $data = array_merge($data, $paymentdetails);
350
- $result = $this->_postRequest($data);
351
- if(is_array($result) && count($result)>0) {
352
- if(array_key_exists("Bank_Message",$result)) {
353
- if ($result["Bank_Message"] != "Approved") {
354
- Mage::throwException("Gateway error : {".(string)$result["EXact_Message"]."}");
355
- } else {
356
- $payment->setStatus(self::STATUS_SUCCESS);
357
- $payment->setLastTransId((string)$result["Authorization_Num"]);
358
- if (!$payment->getParentTransactionId() || (string)$result["Authorization_Num"] != $payment->getParentTransactionId()) {
359
- $payment->setTransactionId((string)$result["Authorization_Num"]);
360
- }
361
- return $this;
362
- }
363
- } else {
364
- Mage::throwException("No approval found");
365
- }
366
- } else {
367
- Mage::throwException("No response found");
368
- }
369
-
370
  }
371
  Mage::throwException(Mage::helper('paygate')->__('Error in refunding the payment.'));
372
- }
373
-
374
- /**
375
  * Void the payment through gateway
376
  *
377
  * @param Varien_Object $payment
@@ -379,195 +370,197 @@ class Raveinfosys_Linkpoint_Model_Linkpoint extends Mage_Payment_Model_Method_Cc
379
  * @throws Mage_Core_Exception
380
  */
381
  public function void(Varien_Object $payment)
382
- {
383
- if ($payment->getParentTransactionId()) {
384
- $data = $this->_prepareData();
385
- $data["trans_type"] = '33';
386
- $data["oid"] = $payment->getParentTransactionId();
387
- $data['transaction_tag'] = $payment->getTransactionTag();
388
- $data['authorization_num'] = $payment->getParentTransactionId();
389
- $instance = $payment->getMethodInstance()->getInfoInstance();
390
- $paymentdetails = array();
391
- $paymentdetails['cardnumber'] = $instance->getCcNumber();
392
- $data['ccname'] = $instance->getCcOwner();
393
- $paymentdetails['cardexpmonth'] = $instance->getCcExpMonth();
394
- $paymentdetails['cardexpyear'] = substr($instance->getCcExpYear(),-2);
395
- $order = $payment->getOrder();
396
- $data['chargetotal'] = $order->getGrandTotal();
397
- $data = array_merge($data, $paymentdetails);
398
- $result = $this->_postRequest($data);
399
- if(is_array($result) && count($result)>0) {
400
- if(array_key_exists("Bank_Message",$result)) {
401
- if ($result["Bank_Message"] != "Approved") {
402
- Mage::throwException("Gateway error : {".(string)$result["EXact_Message"]."}");
403
- } else {
404
- $payment->setStatus(self::STATUS_SUCCESS);
405
- return $this;
406
- }
407
- } else {
408
- Mage::throwException("No approval found");
409
- }
410
- } else {
411
- Mage::throwException("No response found");
412
- }
413
  }
414
  $payment->setStatus(self::STATUS_ERROR);
415
  Mage::throwException('Invalid transaction ID.');
416
  }
417
-
418
- /**
419
  * Cancel payment
420
  *
421
  * @param Varien_Object $invoicePayment
422
  * @return Mage_Payment_Model_Abstract
423
  */
424
- public function cancel(Varien_Object $payment) {
 
425
  return $this->void($payment);
426
  }
427
-
428
- /**
429
  * converts a hash of name-value pairs
430
  * to the correct array for new API
431
- * change on 19-feb-15
432
- *
433
  * @param Array $pdata
434
  * @return String $xml
435
  */
436
- protected function _buildRequest($req)
437
- {
438
- $request = array(
439
- "User_Name" => "",
440
- "Secure_AuthResult" => "",
441
- "Ecommerce_Flag" => "",
442
- "XID" => $req["oid"],
443
- "ExactID" => $req["gatewayId"],
444
- "CAVV" => "",
445
- "Password" => $req["gatewayPass"],
446
- "CAVV_Algorithm" => "",
447
- "Transaction_Type" => $req["trans_type"],
448
- "Reference_No" => "",
449
- "Customer_Ref" => "",
450
- "Reference_3" => "",
451
- "Client_IP" => $req["ip"],
452
- "Client_Email" => $req["email"],
453
- "Language" => "en",
454
- "Card_Number" => $req["cardnumber"],
455
- "Expiry_Date" => sprintf("%02d", $req['cardexpmonth']).$req['cardexpyear'],
456
- "CardHoldersName" => $req["ccname"],
457
- "Track1" => "",
458
- "Track2" => "",
459
- "Authorization_Num" => $req["authorization_num"],
460
- "Transaction_Tag" => $req["transaction_tag"],
461
- "DollarAmount" => $req["chargetotal"],
462
- "VerificationStr1" => "",
463
- "VerificationStr2" => $req["cvv2value"],
464
- "CVD_Presence_Ind" => $req["cvv2indicator"],
465
- "Secure_AuthRequired"=> "",
466
- "Currency" => "",
467
- "PartialRedemption" => "",
468
- "ZipCode" => $req["zip"],
469
- "Tax1Amount" => "",
470
- "Tax1Number" => "",
471
- "Tax2Amount" => "",
472
- "Tax2Number" => "",
473
- "SurchargeAmount" => "",
474
- "PAN" => ""
475
- );
476
-
477
- return $request;
478
-
479
- }
480
-
481
- /**
482
  * converts the LSGS response xml string
483
  * to a hash of name-value pairs
484
- *
485
  * @param String $xml
486
  * @return Array $retarr
487
  */
488
- protected function _readResponse($trxnResult) {
489
- foreach($trxnResult as $key=>$value){
490
- $value = nl2br($value);
491
- $retarr[$key] = $value;
492
- }
493
- return $retarr;
494
- }
495
-
496
- /**
 
497
  * chnage from: process hash table or xml string table using cURL
498
- * change to : process data using SoapClientHMAC for latest version of API
499
- * change on 19-feb-15
500
- *
501
  * @param Array $data
502
  * @return String $xml
503
  */
504
- protected function _postRequest($data) {
505
-
506
- $debugData = array('request' => $data);
507
- $trxnProperties = '';
508
- $trxnProperties = $this->_buildRequest($data);
509
- try
510
- {
511
- $client = Mage::getModel('linkpoint/soapclienthmac', array( "url" => $data["wsdlUrl"]));
512
- $response = $client->SendAndCommit($trxnProperties);
513
- }catch(Exception $e){
514
- $debugData['response'] = $e->getMessage();
515
- $this->_debug($debugData);
516
- Mage::throwException("Link point authorization failed");
517
- }
518
-
519
- if (!$response) {
520
- $debugData['response'] = $response;
521
- $this->_debug($debugData);
522
- Mage::throwException(ucwords("error in $response"));
523
- }
524
-
525
- if(@$client->fault){
526
- Mage::throwException("FAULT: Code: {$client->faultcode} <BR /> String: {$client->faultstring} </B>");
527
- $response["CTR"] = "There was an error while processing. No TRANSACTION DATA IN CTR!";
528
- }
529
-
530
- $result = $this->_readResponse($response);
531
- $debugData['response'] = $result;
532
- /* if($this->getConfigData('debug') == 1) {
533
- $this->_debug($debugData);
534
- } */
535
- $this->_debug($debugData);
536
- return $result;
537
- }
538
-
539
- protected function _prepareData()
540
- {
541
- $_coreHelper = Mage::helper('core');
542
-
543
- $data = array(
544
- 'keyId' => $_coreHelper->decrypt($this->getConfigData('key_id')),
545
- 'hmacKey' => $_coreHelper->decrypt($this->getConfigData('hmac_key')),
546
- 'wsdlUrl' => $this->getConfigData('wsdl_url'),
547
- 'gatewayId' => $_coreHelper->decrypt($this->getConfigData('gateway_id')),
548
- 'gatewayPass' => $_coreHelper->decrypt($this->getConfigData('gateway_pass')),
549
- );
550
-
551
- if($this->getConfigData('mode')) {
552
- $data['wsdlUrl'] = "https://api.demo.globalgatewaye4.firstdata.com/transaction/wsdl";
553
- }
554
-
555
- if(empty($data['keyId']) || empty($data['hmacKey']) || empty($data['wsdlUrl']) || empty($data['gatewayId']) || empty($data['gatewayPass'])){
556
- Mage::throwException("Gateway Parameters Missing");
557
- }
558
- return $data;
559
- }
560
-
561
- protected function _addTransaction(Mage_Sales_Model_Order_Payment $payment, $transactionId, $transactionType,
562
- array $transactionDetails = array(), $message = false ) {
563
-
564
  $payment->setTransactionId($transactionId);
565
  $payment->resetTransactionAdditionalInfo();
566
  foreach ($transactionDetails as $key => $value) {
567
  $payment->setData($key, $value);
568
  }
569
-
570
- $transaction = $payment->addTransaction($transactionType, null, false , $message);
571
  foreach ($transactionDetails as $key => $value) {
572
  $payment->unsetData($key);
573
  }
@@ -577,6 +570,7 @@ class Raveinfosys_Linkpoint_Model_Linkpoint extends Mage_Payment_Model_Method_Cc
577
 
578
  return $transaction;
579
  }
 
580
  }
581
 
582
  ?>
1
  <?php
2
+
3
  /**
4
  * NOTICE OF LICENSE
5
  *
17
  */
18
  class Raveinfosys_Linkpoint_Model_Linkpoint extends Mage_Payment_Model_Method_Ccsave
19
  {
20
+
21
+ protected $_code = 'linkpoint'; //unique internal payment method identifier
22
+ protected $_isGateway = true; //Is this payment method a gateway (online auth/charge) ?
23
+ protected $_canAuthorize = true; //Can authorize online?
24
+ protected $_canCapture = true; //Can capture funds online?
25
+ protected $_canCapturePartial = false; //Can capture partial amounts online?
26
+ protected $_canRefund = true; //Can refund online?
27
+ protected $_canRefundInvoicePartial = true; //Can refund invoices partially?
28
+ protected $_canVoid = true; //Can void transactions online?
29
+ protected $_canUseInternal = true; //Can use this payment method in administration panel?
30
+ protected $_canUseCheckout = true; //Can show this payment method as an option on checkout payment page?
31
+ protected $_canUseForMultishipping = false; //Is this payment method suitable for multi-shipping checkout?
32
+ protected $_isInitializeNeeded = false;
33
+ protected $_canFetchTransactionInfo = false;
34
+ protected $_canReviewPayment = false;
35
+ protected $_canCreateBillingAgreement = false;
36
+ protected $_canManageRecurringProfiles = false;
37
+ protected $_canSaveCc = false; //Can save credit card information for future processing?
38
+ protected $_infoBlockType = 'payment/info_cc';
39
+
40
+ /**
41
  * Fields that should be replaced in debug with '***'
42
  *
43
  * @var array
44
  */
45
  protected $_debugReplacePrivateDataKeys = array('keyId', 'hmacKey', 'gatewayId', 'gatewayPass');
46
+
47
+ /**
48
  * Validate payment method information object
49
  *
50
  * @param Mage_Payment_Model_Info $info
51
  * @return Mage_Payment_Model_Abstract
52
  */
53
+ public function validate()
54
+ {
55
+ $info = $this->getInfoInstance();
56
+ $order_amount = 0;
57
+ if ($info instanceof Mage_Sales_Model_Quote_Payment) {
58
+ $order_amount = (double) $info->getQuote()->getBaseGrandTotal();
59
  } elseif ($info instanceof Mage_Sales_Model_Order_Payment) {
60
+ $order_amount = (double) $info->getOrder()->getQuoteBaseGrandTotal();
61
+ }
62
+
63
+ $order_min = $this->getConfigData('min_order_total');
64
+ $order_max = $this->getConfigData('max_order_total');
65
+ if (!empty($order_max) && (double) $order_max < $order_amount) {
66
+ Mage::throwException("Order amount greater than permissible Maximum order amount.");
67
  }
68
+ if (!empty($order_min) && (double) $order_min > $order_amount) {
69
+ Mage::throwException("Order amount less than required Minimum order amount.");
70
+ }
71
+ /*
72
+ * calling parent validate function
73
+ */
 
 
 
 
 
 
74
  parent::validate();
75
+ }
76
+
77
+ /**
78
  * Send authorize request to gateway
79
  *
80
  * @param Varien_Object $payment
82
  * @return Mage_Paygate_Model_Authorizenet
83
  * @throws Mage_Core_Exception
84
  */
85
+ public function authorize(Varien_Object $payment, $amount)
86
+ {
87
+ if ($amount <= 0) {
88
  Mage::throwException(Mage::helper('linkpoint')->__('Invalid amount for transaction.'));
89
+ }
90
+ $payment->setAmount($amount);
91
+ $data = $this->_prepareData();
92
+ $data['trans_type'] = "01";
93
+ $creditcard = array(
94
+ 'cardnumber' => $payment->getCcNumber(),
95
+ 'cardexpmonth' => $payment->getCcExpMonth(),
96
+ 'ccname' => $payment->getCcOwner(),
97
+ 'cardexpyear' => substr($payment->getCcExpYear(), -2),
98
+ );
99
+ if ($this->getConfigData('useccv') == 1) {
100
+ $creditcard["cvmindicator"] = "provided";
101
+ $creditcard["cvmvalue"] = $payment->getCcCid();
102
+ $creditcard["cvv2indicator"] = 1;
103
+ $creditcard["cvv2value"] = $payment->getCcCid();
104
+ }
105
+
106
+ $shipping = array();
107
+ $billing = array();
108
+ $order = $payment->getOrder();
109
+ if (!empty($order)) {
110
+ $BillingAddress = $order->getBillingAddress();
111
+
112
+ $billing['name'] = $BillingAddress->getFirstname() . " " . $BillingAddress->getLastname();
113
+ $billing['company'] = $BillingAddress->getCompany();
114
+ $billing['address'] = $BillingAddress->getStreet(1);
115
+ $billing['city'] = $BillingAddress->getCity();
116
+ $billing['state'] = $BillingAddress->getRegion();
117
+ $billing['zip'] = $BillingAddress->getPostcode();
118
+ $billing['country'] = $BillingAddress->getCountry();
119
+ $billing['email'] = $order->getCustomerEmail();
120
+ $billing['phone'] = $BillingAddress->getTelephone();
121
+ $billing['fax'] = $BillingAddress->getFax();
122
+
123
+ $ShippingAddress = $order->getShippingAddress();
124
+ if (!empty($shipping)) {
125
+ $shipping['sname'] = $ShippingAddress->getFirstname() . " " . $ShippingAddress->getLastname();
126
+ $shipping['saddress1'] = $ShippingAddress->getStreet(1);
127
+ $shipping['scity'] = $ShippingAddress->getCity();
128
+ $shipping['sstate'] = $ShippingAddress->getRegion();
129
+ $shipping['szip'] = $ShippingAddress->getPostcode();
130
+ $shipping['scountry'] = $ShippingAddress->getCountry();
131
+ }
132
+ }
133
+
134
+ $merchantinfo = array();
135
+ $merchantinfo['gatewayId'] = $data['gatewayId'];
136
+ $merchantinfo['gatewayPass'] = $data['gatewayPass'];
137
+ $paymentdetails = array();
138
+ $paymentdetails['chargetotal'] = $payment->getAmount();
139
+
140
+ $data = array_merge($data, $creditcard, $billing, $shipping, $merchantinfo, $paymentdetails);
141
+
142
+ $result = $this->_postRequest($data);
143
+
144
+ if (is_array($result) && count($result) > 0) {
145
+
146
+ if (array_key_exists("Bank_Message", $result)) {
147
+ if ($result["Bank_Message"] != "Approved") {
148
+ $payment->setStatus(self::STATUS_ERROR);
149
+ Mage::throwException("Gateway error : {" . (string) $result["EXact_Message"] . "}");
150
+ } elseif ($result['Transaction_Error']) {
151
+ Mage::throwException("Returned Error Message: " . $result['Transaction_Error']);
152
+ }
153
+ /*
154
+ elseif($this->getConfigData('useccv') && $trxnResult->CVV2 != "M" ){
155
+ Mage::throwException("Invalid Card Verification Number(".$trxnResult->CVV2.")");
156
+ } */ else {
157
+ $payment->setStatus(self::STATUS_APPROVED);
158
+ $payment->setAdditionalInformation('payment_type', $this->getConfigData('payment_action'));
159
+ $payment->setLastTransId((string) $result["Authorization_Num"]);
160
+ $payment->setTransactionTag((string) $result["Transaction_Tag"]);
161
+ if (!$payment->getParentTransactionId() || (string) $result["Authorization_Num"] != $payment->getParentTransactionId()) {
162
+ $payment->setTransactionId((string) $result["Authorization_Num"]);
163
+ }
164
+ $this->_addTransaction(
165
+ $payment, $result["Authorization_Num"], Mage_Sales_Model_Order_Payment_Transaction::TYPE_AUTH, array('is_transaction_closed' => 0));
166
+ $payment->setSkipTransactionCreation(true);
167
+ return $this;
168
+ }
169
+ } else {
170
+ Mage::throwException("No approval found");
171
+ }
172
+ } else {
173
+ Mage::throwException("No response found");
174
+ }
175
+ }
176
+
177
+ public function capture(Varien_Object $payment, $amount)
178
+ {
179
+ if ($amount <= 0) {
 
 
 
 
 
 
180
  Mage::throwException(Mage::helper('linkpoint')->__('Invalid amount for transaction.'));
181
  }
182
 
183
+ if ($payment->getTransactionTag() != '' && Mage::app()->getStore()->isAdmin()) {
184
+ return $this->authorizePayment($payment, number_format($amount, 2, '.', ''));
185
+ }
186
+
187
+
188
+
189
+ $payment->setAmount($amount);
190
+ $data = $this->_prepareData();
191
+ $data['trans_type'] = "00";
192
+ $creditcard = array(
193
+ 'cardnumber' => $payment->getCcNumber(),
194
+ 'cardexpmonth' => $payment->getCcExpMonth(),
195
+ 'cardexpyear' => substr($payment->getCcExpYear(), -2),
196
+ 'ccname' => $payment->getCcOwner()
197
+ );
198
+ if ($this->getConfigData('useccv') == 1) {
199
+ $creditcard["cvmindicator"] = "provided";
200
+ $creditcard["cvmvalue"] = $payment->getCcCid();
201
+ $creditcard["cvv2indicator"] = 1;
202
+ $creditcard["cvv2value"] = $payment->getCcCid();
203
+ }
204
+
205
+ $shipping = array();
206
+ $billing = array();
207
+ $order = $payment->getOrder();
208
+ if (!empty($order)) {
209
+ $BillingAddress = $order->getBillingAddress();
210
+
211
+ $billing['name'] = $BillingAddress->getFirstname() . " " . $BillingAddress->getLastname();
212
+ $billing['company'] = $BillingAddress->getCompany();
213
+ $billing['address'] = $BillingAddress->getStreet(1);
214
+ $billing['city'] = $BillingAddress->getCity();
215
+ $billing['state'] = $BillingAddress->getRegion();
216
+ $billing['zip'] = $BillingAddress->getPostcode();
217
+ $billing['country'] = $BillingAddress->getCountry();
218
+ $billing['email'] = $order->getCustomerEmail();
219
+ $billing['phone'] = $BillingAddress->getTelephone();
220
+ $billing['fax'] = $BillingAddress->getFax();
221
+
222
+ $ShippingAddress = $order->getShippingAddress();
223
+ if (!empty($shipping)) {
224
+ $shipping['sname'] = $ShippingAddress->getFirstname() . " " . $ShippingAddress->getLastname();
225
+ $shipping['saddress1'] = $ShippingAddress->getStreet(1);
226
+ $shipping['scity'] = $ShippingAddress->getCity();
227
+ $shipping['sstate'] = $ShippingAddress->getRegion();
228
+ $shipping['szip'] = $ShippingAddress->getPostcode();
229
+ $shipping['scountry'] = $ShippingAddress->getCountry();
230
+ }
231
+ }
232
+
233
+ $merchantinfo = array();
234
+ $merchantinfo['gatewayId'] = $data['gatewayId'];
235
+ $merchantinfo['gatewayPass'] = $data['gatewayPass'];
236
+ $paymentdetails = array();
237
+ $paymentdetails['chargetotal'] = $payment->getAmount();
238
+
239
+ $data = array_merge($data, $creditcard, $billing, $shipping, $merchantinfo, $paymentdetails);
240
+
241
+ $result = $this->_postRequest($data);
242
+
243
+ if (is_array($result) && count($result) > 0) {
244
+
245
+ if (array_key_exists("Bank_Message", $result)) {
246
+ if ($result["Bank_Message"] != "Approved") {
247
+ $payment->setStatus(self::STATUS_ERROR);
248
+ Mage::throwException("Gateway error : {" . (string) $result["EXact_Message"] . "}");
249
+ } elseif ($result['Transaction_Error']) {
250
+ Mage::throwException("Returned Error Message: " . $result['Transaction_Error']);
251
+ }
252
+ /*
253
+ elseif($this->getConfigData('useccv') && $trxnResult->CVV2 != "M" ){
254
+ Mage::throwException("Invalid Card Verification Number(".$trxnResult->CVV2.")");
255
+ } */ else {
256
+ $payment->setStatus(self::STATUS_APPROVED);
257
+ $payment->setLastTransId((string) $result["Authorization_Num"]);
258
+ $payment->setTransactionTag((string) $result["Transaction_Tag"]);
259
+ if (!$payment->getParentTransactionId() || (string) $result["Authorization_Num"] != $payment->getParentTransactionId()) {
260
+ $payment->setTransactionId((string) $result["Authorization_Num"]);
261
+ }
262
+ return $this;
263
+ }
264
+ } else {
265
+ Mage::throwException("No approval found");
266
+ }
267
+ } else {
268
+ Mage::throwException("No response found");
269
+ }
270
+ }
271
+
272
+ public function authorizePayment(Varien_Object $payment, $amount)
273
+ {
274
+ $payment->setAmount($amount);
275
+ $data = $this->_prepareData();
276
+ $data['trans_type'] = "32";
277
+ $data['transaction_tag'] = $payment->getTransactionTag();
278
+
279
+ #$data['authorization_num'] = $payment->getLastTransId();
280
+ $data['authorization_num'] = $payment->getParentTransactionId();
281
+
282
+ $data['chargetotal'] = $amount;
283
+
284
+ $result = $this->_postRequest($data);
285
+
286
+ if (is_array($result) && count($result) > 0) {
287
+
288
+ if (array_key_exists("Bank_Message", $result)) {
289
+ if ($result["Bank_Message"] != "Approved") {
290
+ $payment->setStatus(self::STATUS_ERROR);
291
+ Mage::throwException("Gateway error : {" . (string) $result["EXact_Message"] . "}");
292
+ } elseif ($result['Transaction_Error']) {
293
+ Mage::throwException("Returned Error Message: " . $result['Transaction_Error']);
294
+ }
295
+ /*
296
+ elseif($this->getConfigData('useccv') && $trxnResult->CVV2 != "M" ){
297
+ Mage::throwException("Invalid Card Verification Number(".$trxnResult->CVV2.")");
298
+ } */ else {
299
+ $payment->setStatus(self::STATUS_APPROVED);
300
+ $payment->setLastTransId((string) $result["Authorization_Num"]);
301
+ $payment->setTransactionTag((string) $result["Transaction_Tag"]);
302
+ if (!$payment->getParentTransactionId() || (string) $result["Authorization_Num"] != $payment->getParentTransactionId()) {
303
+ $payment->setTransactionId((string) $result["Authorization_Num"]);
304
+ }
305
+ return $this;
306
+ }
307
+ } else {
308
+ Mage::throwException("No approval found");
309
+ }
310
+ } else {
311
+ Mage::throwException("No response found");
312
+ }
313
+ }
314
+
315
+ /**
 
 
 
 
 
316
  * refund the amount with transaction id
317
  *
318
  * @param string $payment Varien_Object object
319
  * @return Mage_Paygate_Model_Authorizenet
320
  * @throws Mage_Core_Exception
321
  */
322
+ public function refund(Varien_Object $payment, $amount)
323
+ {
324
+ if ($payment->getRefundTransactionId() && $amount > 0) {
325
  $data = $this->_prepareData();
326
+ $data["trans_type"] = '34';
327
+ $data["oid"] = $payment->getRefundTransactionId();
328
+ $data['transaction_tag'] = $payment->getTransactionTag();
329
+ $data['authorization_num'] = $payment->getParentTransactionId();
330
+
331
+ $instance = $payment->getMethodInstance()->getInfoInstance();
332
+ $paymentdetails = array();
333
+ $paymentdetails['chargetotal'] = $amount;
334
+ $paymentdetails['cardnumber'] = $instance->getCcNumber();
335
+ $paymentdetails['ccname'] = $instance->getCcOwner();
336
+ $paymentdetails['cardexpmonth'] = $instance->getCcExpMonth();
337
+ $paymentdetails['cardexpyear'] = substr($instance->getCcExpYear(), -2);
338
+ $shipping = array();
339
+ $billing = array();
340
+
341
+ $data = array_merge($data, $paymentdetails);
342
+ $result = $this->_postRequest($data);
343
+ if (is_array($result) && count($result) > 0) {
344
+ if (array_key_exists("Bank_Message", $result)) {
345
+ if ($result["Bank_Message"] != "Approved") {
346
+ Mage::throwException("Gateway error : {" . (string) $result["EXact_Message"] . "}");
347
+ } else {
348
+ $payment->setStatus(self::STATUS_SUCCESS);
349
+ $payment->setLastTransId((string) $result["Authorization_Num"]);
350
+ if (!$payment->getParentTransactionId() || (string) $result["Authorization_Num"] != $payment->getParentTransactionId()) {
351
+ $payment->setTransactionId((string) $result["Authorization_Num"]);
352
+ }
353
+ return $this;
354
+ }
355
+ } else {
356
+ Mage::throwException("No approval found");
357
+ }
358
+ } else {
359
+ Mage::throwException("No response found");
360
+ }
 
361
  }
362
  Mage::throwException(Mage::helper('paygate')->__('Error in refunding the payment.'));
363
+ }
364
+
365
+ /**
366
  * Void the payment through gateway
367
  *
368
  * @param Varien_Object $payment
370
  * @throws Mage_Core_Exception
371
  */
372
  public function void(Varien_Object $payment)
373
+ {
374
+ if ($payment->getParentTransactionId()) {
375
+ $data = $this->_prepareData();
376
+ $data["trans_type"] = '33';
377
+ $data["oid"] = $payment->getParentTransactionId();
378
+ $data['transaction_tag'] = $payment->getTransactionTag();
379
+ $data['authorization_num'] = $payment->getParentTransactionId();
380
+ $instance = $payment->getMethodInstance()->getInfoInstance();
381
+ $paymentdetails = array();
382
+ $paymentdetails['cardnumber'] = $instance->getCcNumber();
383
+ $data['ccname'] = $instance->getCcOwner();
384
+ $paymentdetails['cardexpmonth'] = $instance->getCcExpMonth();
385
+ $paymentdetails['cardexpyear'] = substr($instance->getCcExpYear(), -2);
386
+ $order = $payment->getOrder();
387
+ $data['chargetotal'] = $order->getGrandTotal();
388
+ $data = array_merge($data, $paymentdetails);
389
+ $result = $this->_postRequest($data);
390
+ if (is_array($result) && count($result) > 0) {
391
+ if (array_key_exists("Bank_Message", $result)) {
392
+ if ($result["Bank_Message"] != "Approved") {
393
+ Mage::throwException("Gateway error : {" . (string) $result["EXact_Message"] . "}");
394
+ } else {
395
+ $payment->setStatus(self::STATUS_SUCCESS);
396
+ return $this;
397
+ }
398
+ } else {
399
+ Mage::throwException("No approval found");
400
+ }
401
+ } else {
402
+ Mage::throwException("No response found");
403
+ }
404
  }
405
  $payment->setStatus(self::STATUS_ERROR);
406
  Mage::throwException('Invalid transaction ID.');
407
  }
408
+
409
+ /**
410
  * Cancel payment
411
  *
412
  * @param Varien_Object $invoicePayment
413
  * @return Mage_Payment_Model_Abstract
414
  */
415
+ public function cancel(Varien_Object $payment)
416
+ {
417
  return $this->void($payment);
418
  }
419
+
420
+ /**
421
  * converts a hash of name-value pairs
422
  * to the correct array for new API
423
+ * change on 19-feb-15
424
+ *
425
  * @param Array $pdata
426
  * @return String $xml
427
  */
428
+ protected function _buildRequest($req)
429
+ {
430
+
431
+ $request = array(
432
+ "User_Name" => "",
433
+ "Secure_AuthResult" => "",
434
+ "Ecommerce_Flag" => "",
435
+ "XID" => isset($req["oid"]) ? $req["oid"] : false,
436
+ "ExactID" => $req["gatewayId"],
437
+ "CAVV" => "",
438
+ "Password" => $req["gatewayPass"],
439
+ "CAVV_Algorithm" => "",
440
+ "Transaction_Type" => $req["trans_type"],
441
+ "Reference_No" => "",
442
+ "Customer_Ref" => "",
443
+ "Reference_3" => "",
444
+ "Client_IP" => isset($req["ip"]) ? $req["ip"] : false,
445
+ "Client_Email" => isset($req["email"]) ? $req["email"] : '',
446
+ "Language" => "en",
447
+ "Card_Number" => isset($req["cardnumber"]) ? $req["cardnumber"] : '',
448
+ "Expiry_Date" => isset($req['cardexpmonth']) ? sprintf("%02d", $req['cardexpmonth']) . $req['cardexpyear'] : '',
449
+ "CardHoldersName" => isset($req["ccname"]) ? $req["ccname"] : '',
450
+ "Track1" => "",
451
+ "Track2" => "",
452
+ "Authorization_Num" => isset($req["authorization_num"]) ? $req["authorization_num"] : false,
453
+ "Transaction_Tag" => isset($req["transaction_tag"]) ? $req["transaction_tag"] : false,
454
+ "DollarAmount" => $req["chargetotal"],
455
+ "VerificationStr1" => "",
456
+ "VerificationStr2" => isset($req["cvv2value"]) ? $req["cvv2value"] : '',
457
+ "CVD_Presence_Ind" => isset($req["cvv2indicator"]) ? $req["cvv2indicator"] : '',
458
+ "Secure_AuthRequired" => "",
459
+ "Currency" => "",
460
+ "PartialRedemption" => "",
461
+ "ZipCode" => isset($req["zip"]) ? $req["zip"] : '',
462
+ "Tax1Amount" => "",
463
+ "Tax1Number" => "",
464
+ "Tax2Amount" => "",
465
+ "Tax2Number" => "",
466
+ "SurchargeAmount" => "",
467
+ "PAN" => ""
468
+ );
469
+
470
+ return $request;
471
+ }
472
+
473
+ /**
474
  * converts the LSGS response xml string
475
  * to a hash of name-value pairs
476
+ *
477
  * @param String $xml
478
  * @return Array $retarr
479
  */
480
+ protected function _readResponse($trxnResult)
481
+ {
482
+ foreach ($trxnResult as $key => $value) {
483
+ $value = nl2br($value);
484
+ $retarr[$key] = $value;
485
+ }
486
+ return $retarr;
487
+ }
488
+
489
+ /**
490
  * chnage from: process hash table or xml string table using cURL
491
+ * change to : process data using SoapClientHMAC for latest version of API
492
+ * change on 19-feb-15
493
+ *
494
  * @param Array $data
495
  * @return String $xml
496
  */
497
+ protected function _postRequest($data)
498
+ {
499
+
500
+ $debugData = array('request' => $data);
501
+ $trxnProperties = '';
502
+ $trxnProperties = $this->_buildRequest($data);
503
+ try {
504
+ $client = Mage::getModel('linkpoint/soapclienthmac', array("url" => $data["wsdlUrl"]));
505
+ $response = $client->SendAndCommit($trxnProperties);
506
+ } catch (Exception $e) {
507
+ $debugData['response'] = $e->getMessage();
508
+ $this->_debug($debugData);
509
+ Mage::throwException("Link point authorization failed");
510
+ }
511
+
512
+ if (!$response) {
513
+ $debugData['response'] = $response;
514
+ $this->_debug($debugData);
515
+ Mage::throwException(ucwords("error in $response"));
516
+ }
517
+
518
+ if (@$client->fault) {
519
+ Mage::throwException("FAULT: Code: {$client->faultcode} <BR /> String: {$client->faultstring} </B>");
520
+ $response["CTR"] = "There was an error while processing. No TRANSACTION DATA IN CTR!";
521
+ }
522
+
523
+ $result = $this->_readResponse($response);
524
+ $debugData['response'] = $result;
525
+ /* if($this->getConfigData('debug') == 1) {
526
+ $this->_debug($debugData);
527
+ } */
528
+ $this->_debug($debugData);
529
+ return $result;
530
+ }
531
+
532
+ protected function _prepareData()
533
+ {
534
+ $_coreHelper = Mage::helper('core');
535
+
536
+ $data = array(
537
+ 'keyId' => $_coreHelper->decrypt($this->getConfigData('key_id')),
538
+ 'hmacKey' => $_coreHelper->decrypt($this->getConfigData('hmac_key')),
539
+ 'wsdlUrl' => $this->getConfigData('wsdl_url'),
540
+ 'gatewayId' => $_coreHelper->decrypt($this->getConfigData('gateway_id')),
541
+ 'gatewayPass' => $_coreHelper->decrypt($this->getConfigData('gateway_pass')),
542
+ );
543
+
544
+ if ($this->getConfigData('mode')) {
545
+ $data['wsdlUrl'] = "https://api.demo.globalgatewaye4.firstdata.com/transaction/wsdl";
546
+ }
547
+
548
+ if (empty($data['keyId']) || empty($data['hmacKey']) || empty($data['wsdlUrl']) || empty($data['gatewayId']) || empty($data['gatewayPass'])) {
549
+ Mage::throwException("Gateway Parameters Missing");
550
+ }
551
+ return $data;
552
+ }
553
+
554
+ protected function _addTransaction(Mage_Sales_Model_Order_Payment $payment, $transactionId, $transactionType, array $transactionDetails = array(), $message = false)
555
+ {
556
+
557
  $payment->setTransactionId($transactionId);
558
  $payment->resetTransactionAdditionalInfo();
559
  foreach ($transactionDetails as $key => $value) {
560
  $payment->setData($key, $value);
561
  }
562
+
563
+ $transaction = $payment->addTransaction($transactionType, null, false, $message);
564
  foreach ($transactionDetails as $key => $value) {
565
  $payment->unsetData($key);
566
  }
570
 
571
  return $transaction;
572
  }
573
+
574
  }
575
 
576
  ?>
app/code/community/Raveinfosys/Linkpoint/Model/Observer.php CHANGED
@@ -1,4 +1,5 @@
1
  <?php
 
2
  /**
3
  * NOTICE OF LICENSE
4
  *
@@ -16,18 +17,17 @@
16
  */
17
  class Raveinfosys_Linkpoint_Model_Observer
18
  {
19
-
20
- public function disableMethod(Varien_Event_Observer $observer)
21
- {
22
- $moduleName = "Raveinfosys_Linkpoint";
23
- if('linkpoint' == $observer->getMethodInstance()->getCode())
24
- {
25
- if(Mage::getStoreConfigFlag('advanced/modules_disable_output/'.$moduleName))
26
- {
27
- $observer->getResult()->isAvailable = false;
28
- }
29
-
30
- }
31
- }
32
  }
 
33
  ?>
1
  <?php
2
+
3
  /**
4
  * NOTICE OF LICENSE
5
  *
17
  */
18
  class Raveinfosys_Linkpoint_Model_Observer
19
  {
20
+
21
+ public function disableMethod(Varien_Event_Observer $observer)
22
+ {
23
+ $moduleName = "Raveinfosys_Linkpoint";
24
+ if ('linkpoint' == $observer->getMethodInstance()->getCode()) {
25
+ if (Mage::getStoreConfigFlag('advanced/modules_disable_output/' . $moduleName)) {
26
+ $observer->getResult()->isAvailable = false;
27
+ }
28
+ }
29
+ }
30
+
 
 
31
  }
32
+
33
  ?>
app/code/community/Raveinfosys/Linkpoint/Model/Soapclienthmac.php CHANGED
@@ -2,27 +2,29 @@
2
 
3
  class Raveinfosys_Linkpoint_Model_Soapclienthmac extends SoapClient
4
  {
5
- public function __construct($wsdl, $options = NULL) {
6
- global $context;
7
- $context = stream_context_create();
8
- $options['stream_context'] = $context;
9
- return parent::SoapClient($wsdl['url'], $options);
10
- }
11
 
12
- public function __doRequest($request, $location, $action, $version, $one_way = NULL) {
13
- global $context;
14
- $hmacKey = Mage::helper('core')->decrypt(Mage::getStoreConfig('payment/linkpoint/hmac_key'));
15
- $keyId = Mage::helper('core')->decrypt(Mage::getStoreConfig('payment/linkpoint/key_id'));
16
- $hashtime = date("c");
17
- $hashstr = "POST\ntext/xml; charset=utf-8\n" . sha1($request) . "\n" . $hashtime . "\n" . parse_url($location,PHP_URL_PATH);
18
- $authstr = base64_encode(hash_hmac("sha1", $hashstr, $hmacKey, TRUE));
19
- if (version_compare(PHP_VERSION, '5.3.11') == -1) {
20
- ini_set("user_agent", "PHP-SOAP/" . PHP_VERSION . "\r\nAuthorization: GGE4_API " . $keyId . ":" . $authstr . "\r\nx-gge4-date: " . $hashtime . "\r\nx-gge4-content-sha1: " . sha1($request));
21
- } else {
22
- stream_context_set_option($context,array("http" => array("header" => "authorization: GGE4_API " . $keyId . ":" . $authstr . "\r\nx-gge4-date: " . $hashtime . "\r\nx-gge4-content-sha1: " . sha1($request))));
23
- }
24
- return parent::__doRequest($request, $location, $action, $version, $one_way);
25
- }
26
 
27
-
28
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2
 
3
  class Raveinfosys_Linkpoint_Model_Soapclienthmac extends SoapClient
4
  {
 
 
 
 
 
 
5
 
6
+ public function __construct($wsdl, $options = NULL)
7
+ {
8
+ global $context;
9
+ $context = stream_context_create();
10
+ $options['stream_context'] = $context;
11
+ return parent::SoapClient($wsdl['url'], $options);
12
+ }
 
 
 
 
 
 
 
13
 
14
+ public function __doRequest($request, $location, $action, $version, $one_way = NULL)
15
+ {
16
+ global $context;
17
+ $hmacKey = Mage::helper('core')->decrypt(Mage::getStoreConfig('payment/linkpoint/hmac_key'));
18
+ $keyId = Mage::helper('core')->decrypt(Mage::getStoreConfig('payment/linkpoint/key_id'));
19
+ $hashtime = date("c");
20
+ $hashstr = "POST\ntext/xml; charset=utf-8\n" . sha1($request) . "\n" . $hashtime . "\n" . parse_url($location, PHP_URL_PATH);
21
+ $authstr = base64_encode(hash_hmac("sha1", $hashstr, $hmacKey, TRUE));
22
+ if (version_compare(PHP_VERSION, '5.3.11') == -1) {
23
+ ini_set("user_agent", "PHP-SOAP/" . PHP_VERSION . "\r\nAuthorization: GGE4_API " . $keyId . ":" . $authstr . "\r\nx-gge4-date: " . $hashtime . "\r\nx-gge4-content-sha1: " . sha1($request));
24
+ } else {
25
+ stream_context_set_option($context, array("http" => array("header" => "authorization: GGE4_API " . $keyId . ":" . $authstr . "\r\nx-gge4-date: " . $hashtime . "\r\nx-gge4-content-sha1: " . sha1($request))));
26
+ }
27
+ return parent::__doRequest($request, $location, $action, $version, $one_way);
28
+ }
29
+
30
+ }
app/code/community/Raveinfosys/Linkpoint/etc/config.xml CHANGED
@@ -57,7 +57,7 @@
57
  <payment>
58
  <linkpoint>
59
  <active>0</active>
60
- <title>Credit Card (LinkPoint)</title>
61
  <order_status>pending</order_status>
62
  <cctypes>AE,VI,MC</cctypes>
63
  <useccv>1</useccv>
57
  <payment>
58
  <linkpoint>
59
  <active>0</active>
60
+ <title>Credit Card (First Data)</title>
61
  <order_status>pending</order_status>
62
  <cctypes>AE,VI,MC</cctypes>
63
  <useccv>1</useccv>
app/code/community/Raveinfosys/Linkpoint/etc/system.xml CHANGED
@@ -21,7 +21,7 @@
21
  <payment>
22
  <groups>
23
  <linkpoint translate="label">
24
- <label>LinkPoint</label>
25
  <frontend_type>text</frontend_type>
26
  <show_in_default>1</show_in_default>
27
  <show_in_website>1</show_in_website>
21
  <payment>
22
  <groups>
23
  <linkpoint translate="label">
24
+ <label>First Data Global Gateway</label>
25
  <frontend_type>text</frontend_type>
26
  <show_in_default>1</show_in_default>
27
  <show_in_website>1</show_in_website>
app/code/community/Raveinfosys/Linkpoint/sql/linkpoint_setup/mysql4-install-1.0.0.php CHANGED
@@ -7,4 +7,4 @@ $installer->startSetup();
7
 
8
  $connection->addColumn($this->getTable('sales/order_payment'), 'transaction_tag', 'text null');
9
 
10
- $installer->endSetup();
7
 
8
  $connection->addColumn($this->getTable('sales/order_payment'), 'transaction_tag', 'text null');
9
 
10
+ $installer->endSetup();
package.xml CHANGED
@@ -1,21 +1,20 @@
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>First_Data_Gateway_Integration</name>
4
- <version>1.0.6</version>
5
  <stability>stable</stability>
6
- <license>GPL</license>
7
  <channel>community</channel>
8
  <extends/>
9
- <summary>This extension allows you to make payments using FirstData Global Gateway for all your online shopping needs. </summary>
10
  <description>To facilitate the payment options, this extension provides seamless integration with First Data Global Gateway. This extension allows you to make secure payments using FirstData Global Gateway for all your online shopping needs. It supports all credit cards such as Visa, MasterCard, AE, JCB etc.&amp;#xD;&#xD;
11
- &amp;#xD;&#xD;
12
- The customer is not required to leave the Magento store for making the payment. FDGG does support multiple currencies however you need to check FDGG website for latest updates.</description>
13
- <notes>This version is properly tested on the following Magento CE versions: 1.5, 1.6, 1.7,1.8,1.9.* &amp;#xD;&#xD;
14
- This version also supports for PHP V5.6.12</notes>
15
  <authors><author><name>Rave Infosys</name><user>raveinfo</user><email>magento@raveinfosys.com</email></author></authors>
16
- <date>2015-09-23</date>
17
- <time>14:07:38</time>
18
- <contents><target name="magecommunity"><dir name="Raveinfosys"><dir name="Linkpoint"><dir name="Model"><file name="Linkpoint.php" hash="649ed667cad8da2f8c67e1c84229d2cc"/><file name="Observer.php" hash="139c6944d0935ca220443b9778fb9636"/><file name="Soapclienthmac.php" hash="141d1de345fd2a50e5f1d8a02864ac71"/></dir><dir name="etc"><file name="config.xml" hash="82371b941c82e83de319823153b52822"/><file name="system.xml" hash="0239f9e631759ec0701b8a576b4aeb02"/></dir><dir name="sql"><dir name="linkpoint_setup"><file name="mysql4-install-1.0.0.php" hash="1dde8f774ac03f7b29066f45567f707e"/></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Raveinfosys_Linkpoint.xml" hash="87645041b22e2b0adf581b54991c6ee1"/></dir></target></contents>
19
  <compatible/>
20
- <dependencies><required><php><min>5.2.0</min><max>5.6.12</max></php><extension><name>curl</name><min>7.21.4</min><max>7.44.0</max></extension></required></dependencies>
21
  </package>
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>First_Data_Gateway_Integration</name>
4
+ <version>1.0.7</version>
5
  <stability>stable</stability>
6
+ <license>OSL v3.0</license>
7
  <channel>community</channel>
8
  <extends/>
9
+ <summary>This extension allows you to make payments using FirstData Global Gateway for all your online shopping needs.</summary>
10
  <description>To facilitate the payment options, this extension provides seamless integration with First Data Global Gateway. This extension allows you to make secure payments using FirstData Global Gateway for all your online shopping needs. It supports all credit cards such as Visa, MasterCard, AE, JCB etc.&amp;#xD;&#xD;
11
+ &amp;#xD;&#xD;
12
+ The customer is not required to leave the Magento store for making the payment. FDGG does support multiple currencies however you need to check FDGG website for latest updates.</description>
13
+ <notes>This version is properly tested on the following Magento CE versions: 1.5, 1.6, 1.7,1.8,1.9.* . In this particular version we are supporting it to run on PHP V 5.5.X.</notes>
 
14
  <authors><author><name>Rave Infosys</name><user>raveinfo</user><email>magento@raveinfosys.com</email></author></authors>
15
+ <date>2016-04-07</date>
16
+ <time>09:32:22</time>
17
+ <contents><target name="magecommunity"><dir name="Raveinfosys"><dir name="Linkpoint"><dir name="Model"><file name="Linkpoint.php" hash="4c781b3cb9181a3e4fc4f57c923a9015"/><file name="Observer.php" hash="0a38baf1cb0af1ce54aeecd9b59d4efe"/><file name="Soapclienthmac.php" hash="00b202168782c8137fc535b94f8c1f05"/></dir><dir name="etc"><file name="config.xml" hash="e086274f91e8feccffef407a793b2a6d"/><file name="system.xml" hash="92a7b9885924ef7362399bdce807292b"/></dir><dir name="sql"><dir name="linkpoint_setup"><file name="mysql4-install-1.0.0.php" hash="e481582777149881c86863145d541707"/></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Raveinfosys_Linkpoint.xml" hash="87645041b22e2b0adf581b54991c6ee1"/></dir></target></contents>
18
  <compatible/>
19
+ <dependencies><required><php><min>5.2.0</min><max>5.6.20</max></php><extension><name>curl</name><min>7.21.4</min><max>7.44.0</max></extension></required></dependencies>
20
  </package>