First_Data_Gateway_Integration - Version 1.0.0

Version Notes

This version is properly tested on the following Magento CE versions: 1.5, 1.6, 1.6.1, 1.6.2.0

Download this release

Release Info

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


Version 1.0.0

app/code/community/Raveinfosys/Linkpoint/Model/Linkpoint.php ADDED
@@ -0,0 +1,566 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * NOTICE OF LICENSE
4
+ *
5
+ * This source file is subject to the Open Software License (OSL 3.0)
6
+ * which is available through the world-wide-web at this URL:
7
+ * http://opensource.org/licenses/osl-3.0.php
8
+ * If you are unable to obtain it through the world-wide-web,
9
+ * please send an email to magento@raveinfosys.com
10
+ * so we can send you a copy immediately.
11
+ *
12
+ * @category Raveinfosys
13
+ * @package Raveinfosys_Linkpoint
14
+ * @author RaveInfosys, Inc.
15
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
16
+ */
17
+ class Raveinfosys_Linkpoint_Model_Linkpoint extends Mage_Payment_Model_Method_Cc {
18
+
19
+ protected $_code = 'linkpoint'; //unique internal payment method identifier
20
+
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 = false; //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('cvmvalue', 'keyfile', 'cardnumber', 'cardexpmonth', 'cardexpyear');
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
+ $info = $this->getInfoInstance();
53
+ $order_amount=0;
54
+ if ($info instanceof Mage_Sales_Model_Quote_Payment) {
55
+ $order_amount=(double)$info->getQuote()->getBaseGrandTotal();
56
+ } elseif ($info instanceof Mage_Sales_Model_Order_Payment) {
57
+ $order_amount=(double)$info->getOrder()->getQuoteBaseGrandTotal();
58
+ }
59
+
60
+ $order_min=$this->getConfigData('min_order_total');
61
+ $order_max=$this->getConfigData('max_order_total');
62
+ if(!empty($order_max) && (double)$order_max<$order_amount) {
63
+ Mage::throwException("Order amount greater than permissible Maximum order amount.");
64
+ }
65
+ if(!empty($order_min) && (double)$order_min>$order_amount) {
66
+ Mage::throwException("Order amount less than required Minimum order amount.");
67
+ }
68
+ /*
69
+ * calling parent validate function
70
+ */
71
+ parent::validate();
72
+ }
73
+
74
+ /**
75
+ * Send capture request to gateway
76
+ *
77
+ * @param Varien_Object $payment
78
+ * @param decimal $amount
79
+ * @return Mage_Paygate_Model_Authorizenet
80
+ * @throws Mage_Core_Exception
81
+ */
82
+ public function capture(Varien_Object $payment, $amount) {
83
+ if ($amount <= 0) {
84
+ Mage::throwException(Mage::helper('linkpoint')->__('Invalid amount for transaction.'));
85
+ }
86
+
87
+ $payment->setAmount($amount);
88
+
89
+ $data=$this->_prepareData();
90
+
91
+ $data['ordertype'] = "SALE";
92
+
93
+ $creditcard=array(
94
+ 'cardnumber' => $payment->getCcNumber(),
95
+ 'cardexpmonth' => $payment->getCcExpMonth(),
96
+ 'cardexpyear' => substr($payment->getCcExpYear(),-2),
97
+ );
98
+ if($this->getConfigData('useccv')==1) {
99
+ $creditcard["cvmindicator"] = "provided";
100
+ $creditcard["cvmvalue"] = $payment->getCcCid();
101
+ }
102
+
103
+ $shipping=array();
104
+ $billing=array();
105
+
106
+ $order = $payment->getOrder();
107
+
108
+ if (!empty($order)) {
109
+ $BillingAddress = $order->getBillingAddress();
110
+
111
+ $billing['name'] = $BillingAddress->getFirstname()." ".$BillingAddress->getLastname();
112
+ $billing['company'] = $BillingAddress->getCompany();
113
+ $billing['address'] = $BillingAddress->getStreet(1);
114
+ $billing['city'] = $BillingAddress->getCity();
115
+ $billing['state'] = $BillingAddress->getRegion();
116
+ $billing['zip'] = $BillingAddress->getPostcode();
117
+ $billing['country'] = $BillingAddress->getCountry();
118
+ $billing['email'] = $order->getCustomerEmail();
119
+ $billing['phone'] = $BillingAddress->getTelephone();
120
+ $billing['fax'] = $BillingAddress->getFax();
121
+
122
+ $ShippingAddress = $order->getShippingAddress();
123
+ if (!empty($shipping)) {
124
+ $shipping['sname'] = $ShippingAddress->getFirstname()." ".$ShippingAddress->getLastname();
125
+ $shipping['saddress1'] = $ShippingAddress->getStreet(1);
126
+ $shipping['scity'] = $ShippingAddress->getCity();
127
+ $shipping['sstate'] = $ShippingAddress->getRegion();
128
+ $shipping['szip'] = $ShippingAddress->getPostcode();
129
+ $shipping['scountry'] = $ShippingAddress->getCountry();
130
+ }
131
+ }
132
+ $transactiondetails=array();
133
+
134
+ $merchantinfo=array();
135
+ $merchantinfo['configfile'] = $data['storenumber'];
136
+ $merchantinfo['keyfile'] = $data['key'];
137
+
138
+ $paymentdetails=array();
139
+ $paymentdetails['chargetotal']=$payment->getAmount();
140
+
141
+ $data=array_merge($data, $creditcard, $billing, $shipping, $transactiondetails, $merchantinfo, $paymentdetails);
142
+
143
+ $result = $this->_postRequest($data);
144
+ if(is_array($result) && count($result)>0) {
145
+ if(array_key_exists("r_approved",$result)) {
146
+ if ($result["r_approved"] != "APPROVED") {
147
+ $payment->setStatus(self::STATUS_ERROR);
148
+ Mage::throwException("Gateway error : {".(string)$result["r_error"]."}");
149
+ } else {
150
+ $payment->setStatus(self::STATUS_APPROVED);
151
+ $payment->setLastTransId((string)$result["r_ordernum"]);
152
+ if (!$payment->getParentTransactionId() || (string)$result["r_ordernum"] != $payment->getParentTransactionId()) {
153
+ $payment->setTransactionId((string)$result["r_ordernum"]);
154
+ }
155
+ return $this;
156
+ }
157
+ } else {
158
+ Mage::throwException("No approval found");
159
+ }
160
+
161
+ } else {
162
+ Mage::throwException("No response found");
163
+ }
164
+ }
165
+
166
+ /**
167
+ * refund the amount with transaction id
168
+ *
169
+ * @param string $payment Varien_Object object
170
+ * @return Mage_Paygate_Model_Authorizenet
171
+ * @throws Mage_Core_Exception
172
+ */
173
+ public function refund(Varien_Object $payment, $amount) {
174
+ if ($payment->getRefundTransactionId() && $amount > 0) {
175
+ $data=$this->_prepareData();
176
+ $data['ordertype'] = "CREDIT";
177
+ $data["oid"] = $payment->getRefundTransactionId();
178
+
179
+ $merchantinfo=array();
180
+ $merchantinfo['configfile'] = $data['storenumber'];
181
+ $merchantinfo['keyfile'] = $data['key'];
182
+
183
+ $paymentdetails=array();
184
+ $paymentdetails['chargetotal']=$amount;
185
+
186
+ $data=array_merge($data, $merchantinfo, $paymentdetails);
187
+
188
+ $result = $this->_postRequest($data);
189
+
190
+ if(is_array($result) && count($result)>0) {
191
+ if(array_key_exists("r_approved",$result)) {
192
+ if ($result["r_approved"] != "APPROVED") {
193
+ Mage::throwException("Gateway error : {".(string)$result["r_error"]."}");
194
+ } else {
195
+ $payment->setStatus(self::STATUS_SUCCESS);
196
+ return $this;
197
+ }
198
+ } else {
199
+ Mage::throwException("No approval found");
200
+ }
201
+ } else {
202
+ Mage::throwException("No response found");
203
+ }
204
+
205
+ }
206
+ Mage::throwException(Mage::helper('paygate')->__('Error in refunding the payment.'));
207
+ }
208
+
209
+ /**
210
+ * Void the payment through gateway
211
+ *
212
+ * @param Varien_Object $payment
213
+ * @return Mage_Paygate_Model_Authorizenet
214
+ * @throws Mage_Core_Exception
215
+ */
216
+ public function void(Varien_Object $payment) {
217
+ if ($payment->getParentTransactionId()) {
218
+ $data=$this->_prepareData();
219
+ $data['ordertype'] = "VOID";
220
+ $data["oid"] = $payment->getParentTransactionId();
221
+
222
+ $merchantinfo=array();
223
+ $merchantinfo['configfile'] = $data['storenumber'];
224
+ $merchantinfo['keyfile'] = $data['key'];
225
+
226
+ $data=array_merge($data, $merchantinfo);
227
+
228
+ $result = $this->_postRequest($data);
229
+
230
+ if(is_array($result) && count($result)>0) {
231
+ if(array_key_exists("r_approved",$result)) {
232
+ if ($result["r_approved"] != "APPROVED") {
233
+ Mage::throwException("Gateway error : {".(string)$result["r_error"]."}");
234
+ } else {
235
+ $payment->setStatus(self::STATUS_SUCCESS );
236
+ return $this;
237
+ }
238
+ } else {
239
+ Mage::throwException("No approval found");
240
+ }
241
+ } else {
242
+ Mage::throwException("No response found");
243
+ }
244
+ }
245
+ $payment->setStatus(self::STATUS_ERROR);
246
+ Mage::throwException('Invalid transaction ID.');
247
+ }
248
+
249
+ /**
250
+ * Cancel payment
251
+ *
252
+ * @param Varien_Object $invoicePayment
253
+ * @return Mage_Payment_Model_Abstract
254
+ */
255
+ public function cancel(Varien_Object $payment) {
256
+ return $this->void($payment);
257
+ }
258
+
259
+ /**
260
+ * converts a hash of name-value pairs
261
+ * to the correct XML format for LSGS
262
+ *
263
+ * @param Array $pdata
264
+ * @return String $xml
265
+ */
266
+ protected function _buildRequest($pdata) {
267
+ $xml = "<order>";
268
+ ### ORDEROPTIONS NODE ###
269
+ $xml .= "<orderoptions>";
270
+ if (isset($pdata["ordertype"]))
271
+ $xml .= "<ordertype>" . $pdata["ordertype"] . "</ordertype>";
272
+
273
+ if (isset($pdata["result"]))
274
+ $xml .= "<result>" . $pdata["result"] . "</result>";
275
+
276
+ $xml .= "</orderoptions>";
277
+ ### ORDEROPTIONS NODE ###
278
+
279
+ ### CREDITCARD NODE ###
280
+ $xml .= "<creditcard>";
281
+
282
+ if (isset($pdata["cardnumber"]))
283
+ $xml .= "<cardnumber>" . $pdata["cardnumber"] . "</cardnumber>";
284
+
285
+ if (isset($pdata["cardexpmonth"]))
286
+ $xml .= "<cardexpmonth>" . $pdata["cardexpmonth"] . "</cardexpmonth>";
287
+
288
+ if (isset($pdata["cardexpyear"]))
289
+ $xml .= "<cardexpyear>" . $pdata["cardexpyear"] . "</cardexpyear>";
290
+
291
+ if (isset($pdata["cvmvalue"]))
292
+ $xml .= "<cvmvalue>" . $pdata["cvmvalue"] . "</cvmvalue>";
293
+
294
+ if (isset($pdata["cvmindicator"]))
295
+ $xml .= "<cvmindicator>" . $pdata["cvmindicator"] . "</cvmindicator>";
296
+
297
+ if (isset($pdata["track"]))
298
+ $xml .= "<track>" . $pdata["track"] . "</track>";
299
+
300
+ $xml .= "</creditcard>";
301
+ ### CREDITCARD NODE ###
302
+
303
+ ### BILLING NODE ###
304
+ $xml .= "<billing>";
305
+
306
+ if (isset($pdata["name"]))
307
+ $xml .= "<name>" . $pdata["name"] . "</name>";
308
+
309
+ if (isset($pdata["company"]))
310
+ $xml .= "<company>" . $pdata["company"] . "</company>";
311
+
312
+ if (isset($pdata["address1"]))
313
+ $xml .= "<address1>" . $pdata["address1"] . "</address1>";
314
+ elseif (isset($pdata["address"]))
315
+ $xml .= "<address1>" . $pdata["address"] . "</address1>";
316
+
317
+ if (isset($pdata["address2"]))
318
+ $xml .= "<address2>" . $pdata["address2"] . "</address2>";
319
+
320
+ if (isset($pdata["city"]))
321
+ $xml .= "<city>" . $pdata["city"] . "</city>";
322
+
323
+ if (isset($pdata["state"]))
324
+ $xml .= "<state>" . $pdata["state"] . "</state>";
325
+
326
+ if (isset($pdata["zip"]))
327
+ $xml .= "<zip>" . $pdata["zip"] . "</zip>";
328
+
329
+ if (isset($pdata["country"]))
330
+ $xml .= "<country>" . $pdata["country"] . "</country>";
331
+
332
+ if (isset($pdata["userid"]))
333
+ $xml .= "<userid>" . $pdata["userid"] . "</userid>";
334
+
335
+ if (isset($pdata["email"]))
336
+ $xml .= "<email>" . $pdata["email"] . "</email>";
337
+
338
+ if (isset($pdata["phone"]))
339
+ $xml .= "<phone>" . $pdata["phone"] . "</phone>";
340
+
341
+ if (isset($pdata["fax"]))
342
+ $xml .= "<fax>" . $pdata["fax"] . "</fax>";
343
+
344
+ if (isset($pdata["addrnum"]))
345
+ $xml .= "<addrnum>" . $pdata["addrnum"] . "</addrnum>";
346
+
347
+ $xml .= "</billing>";
348
+ ### BILLING NODE ###
349
+
350
+ ## SHIPPING NODE ##
351
+ $xml .= "<shipping>";
352
+
353
+ if (isset($pdata["sname"]))
354
+ $xml .= "<name>" . $pdata["sname"] . "</name>";
355
+
356
+ if (isset($pdata["saddress1"]))
357
+ $xml .= "<address1>" . $pdata["saddress1"] . "</address1>";
358
+
359
+ if (isset($pdata["saddress2"]))
360
+ $xml .= "<address2>" . $pdata["saddress2"] . "</address2>";
361
+
362
+ if (isset($pdata["scity"]))
363
+ $xml .= "<city>" . $pdata["scity"] . "</city>";
364
+
365
+ if (isset($pdata["sstate"]))
366
+ $xml .= "<state>" . $pdata["sstate"] . "</state>";
367
+
368
+ if (isset($pdata["szip"]))
369
+ $xml .= "<zip>" . $pdata["szip"] . "</zip>";
370
+
371
+ if (isset($pdata["scountry"]))
372
+ $xml .= "<country>" . $pdata["scountry"] . "</country>";
373
+
374
+ if (isset($pdata["scarrier"]))
375
+ $xml .= "<carrier>" . $pdata["scarrier"] . "</carrier>";
376
+
377
+ if (isset($pdata["sitems"]))
378
+ $xml .= "<items>" . $pdata["sitems"] . "</items>";
379
+
380
+ if (isset($pdata["sweight"]))
381
+ $xml .= "<weight>" . $pdata["sweight"] . "</weight>";
382
+
383
+ if (isset($pdata["stotal"]))
384
+ $xml .= "<total>" . $pdata["stotal"] . "</total>";
385
+
386
+ $xml .= "</shipping>";
387
+ ## SHIPPING NODE ##
388
+
389
+ ### TRANSACTIONDETAILS NODE ###
390
+ $xml .= "<transactiondetails>";
391
+
392
+ if (isset($pdata["oid"]))
393
+ $xml .= "<oid>" . $pdata["oid"] . "</oid>";
394
+
395
+ if (isset($pdata["ponumber"]))
396
+ $xml .= "<ponumber>" . $pdata["ponumber"] . "</ponumber>";
397
+
398
+ if (isset($pdata["recurring"]))
399
+ $xml .= "<recurring>" . $pdata["recurring"] . "</recurring>";
400
+
401
+ if (isset($pdata["taxexempt"]))
402
+ $xml .= "<taxexempt>" . $pdata["taxexempt"] . "</taxexempt>";
403
+
404
+ if (isset($pdata["terminaltype"]))
405
+ $xml .= "<terminaltype>" . $pdata["terminaltype"] . "</terminaltype>";
406
+
407
+ if (isset($pdata["ip"]))
408
+ $xml .= "<ip>" . $pdata["ip"] . "</ip>";
409
+
410
+ if (isset($pdata["reference_number"]))
411
+ $xml .= "<reference_number>" . $pdata["reference_number"] . "</reference_number>";
412
+
413
+ if (isset($pdata["transactionorigin"]))
414
+ $xml .= "<transactionorigin>" . $pdata["transactionorigin"] . "</transactionorigin>";
415
+
416
+ if (isset($pdata["tdate"]))
417
+ $xml .= "<tdate>" . $pdata["tdate"] . "</tdate>";
418
+
419
+ $xml .= "</transactiondetails>";
420
+ ### TRANSACTIONDETAILS NODE ###
421
+
422
+ ### MERCHANTINFO NODE ###
423
+ $xml .= "<merchantinfo>";
424
+
425
+ if (isset($pdata["configfile"]))
426
+ $xml .= "<configfile>" . $pdata["configfile"] . "</configfile>";
427
+
428
+ if (isset($pdata["keyfile"]))
429
+ $xml .= "<keyfile>" . $pdata["keyfile"] . "</keyfile>";
430
+
431
+ if (isset($pdata["host"]))
432
+ $xml .= "<host>" . $pdata["host"] . "</host>";
433
+
434
+ if (isset($pdata["port"]))
435
+ $xml .= "<port>" . $pdata["port"] . "</port>";
436
+
437
+ if (isset($pdata["appname"]))
438
+ $xml .= "<appname>" . $pdata["appname"] . "</appname>";
439
+
440
+ $xml .= "</merchantinfo>";
441
+ ### MERCHANTINFO NODE ###
442
+
443
+ ### PAYMENT NODE ###
444
+ $xml .= "<payment>";
445
+
446
+ if (isset($pdata["chargetotal"]))
447
+ $xml .= "<chargetotal>" . $pdata["chargetotal"] . "</chargetotal>";
448
+
449
+ if (isset($pdata["tax"]))
450
+ $xml .= "<tax>" . $pdata["tax"] . "</tax>";
451
+
452
+ if (isset($pdata["vattax"]))
453
+ $xml .= "<vattax>" . $pdata["vattax"] . "</vattax>";
454
+
455
+ if (isset($pdata["shipping"]))
456
+ $xml .= "<shipping>" . $pdata["shipping"] . "</shipping>";
457
+
458
+ if (isset($pdata["subtotal"]))
459
+ $xml .= "<subtotal>" . $pdata["subtotal"] . "</subtotal>";
460
+
461
+ $xml .= "</payment>";
462
+ ### PAYMENT NODE ###
463
+
464
+ $xml .= "</order>";
465
+
466
+ return $xml;
467
+ }
468
+
469
+ /**
470
+ * converts the LSGS response xml string
471
+ * to a hash of name-value pairs
472
+ *
473
+ * @param String $xml
474
+ * @return Array $retarr
475
+ */
476
+ protected function _readResponse($xml) {
477
+ preg_match_all ("/<(.*?)>(.*?)\</", $xml, $out, PREG_SET_ORDER);
478
+
479
+ $n = 0;
480
+ while (isset($out[$n])) {
481
+ $retarr[$out[$n][1]] = strip_tags($out[$n][0]);
482
+ $n++;
483
+ }
484
+
485
+ return $retarr;
486
+ }
487
+
488
+ /**
489
+ * process hash table or xml string table using cURL
490
+ *
491
+ * @param Array $data
492
+ * @return String $xml
493
+ */
494
+ protected function _postRequest($data) {
495
+ $debugData = array('request' => $data);
496
+
497
+ $xml='';
498
+
499
+ // convert incoming hash to XML string
500
+ $xml = $this->_buildRequest($data);
501
+
502
+ //get Store Number from core config table
503
+
504
+ $key = $data["keyfile"];
505
+ $host = $data["host"];
506
+ $port = $data["port"];
507
+
508
+ $host = "https://".$host.":".$port."/";
509
+
510
+ $ch = curl_init ();
511
+ curl_setopt ($ch, CURLOPT_URL,$host);
512
+ curl_setopt ($ch, CURLOPT_VERBOSE, 1);
513
+ curl_setopt ($ch, CURLOPT_POST, 1);
514
+ curl_setopt ($ch, CURLOPT_POSTFIELDS, $xml);
515
+ curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
516
+ curl_setopt ($ch, CURLOPT_SSLCERT, $key);
517
+ curl_setopt ($ch, CURLOPT_SSL_VERIFYHOST, 0);
518
+ curl_setopt ($ch, CURLOPT_SSL_VERIFYPEER, 0);
519
+
520
+ $result = curl_exec ($ch);
521
+
522
+
523
+ if (!$result) {
524
+ Mage::throwException(ucwords(curl_error($ch)));
525
+ }
526
+ $httpcode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
527
+ if ($httpcode && substr($httpcode, 0, 2) != "20") { //Unsuccessful post request...
528
+ Mage::throwException("Returned HTTP CODE: " . $httpcode . " for this URL: " . $host);
529
+ }
530
+ curl_close($ch);
531
+
532
+ #convert xml response to hash
533
+ $retarr = $this->_readResponse($result);
534
+
535
+ # log details
536
+ $debugData['response']=$retarr;
537
+ if($this->getConfigData('debug')==1) {
538
+ $this->_debug($debugData);
539
+ }
540
+
541
+ # and send it back
542
+ return ($retarr);
543
+ }
544
+
545
+ protected function _prepareData() {
546
+ $data=array(
547
+ 'key' => $this->getConfigData('pem_path_test'),
548
+ 'storenumber' => $this->getConfigData('store_number_test'),
549
+ 'host' => $this->getConfigData('host_test'),
550
+ 'port' => $this->getConfigData('port_test')
551
+ );
552
+
553
+ if($this->getConfigData('test')==0) {
554
+ $data['key'] = $this->getConfigData('pem_path_live');
555
+ $data['storenumber'] = $this->getConfigData('store_number_live');
556
+ $data['host'] = $this->getConfigData('host_live');
557
+ $data['port'] = $this->getConfigData('port_live');
558
+ }
559
+ if(empty($data['key']) || empty($data['storenumber']) || empty($data['host']) || empty($data['port'])){
560
+ Mage::throwException("Gateway Parameters Missing");
561
+ }
562
+ $data['terminaltype'] = "UNSPECIFIED";
563
+ return $data;
564
+ }
565
+ }
566
+ ?>
app/code/community/Raveinfosys/Linkpoint/Model/Observer.php ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * NOTICE OF LICENSE
4
+ *
5
+ * This source file is subject to the Open Software License (OSL 3.0)
6
+ * which is available through the world-wide-web at this URL:
7
+ * http://opensource.org/licenses/osl-3.0.php
8
+ * If you are unable to obtain it through the world-wide-web,
9
+ * please send an email to magento@raveinfosys.com
10
+ * so we can send you a copy immediately.
11
+ *
12
+ * @category Raveinfosys
13
+ * @package Raveinfosys_Linkpoint
14
+ * @author RaveInfosys, Inc.
15
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
16
+ */
17
+ class Raveinfosys_Linkpoint_Model_Observer {
18
+ public function disableMethod(Varien_Event_Observer $observer){
19
+ $moduleName="Raveinfosys_Linkpoint";
20
+ if('linkpoint'==$observer->getMethodInstance()->getCode()){
21
+ if(!Mage::getStoreConfigFlag('advanced/modules_disable_output/'.$moduleName)) {
22
+ //nothing here, as module is ENABLE
23
+ } else {
24
+ $observer->getResult()->isAvailable=false;
25
+ }
26
+
27
+ }
28
+ }
29
+ }
30
+ ?>
app/code/community/Raveinfosys/Linkpoint/etc/config.xml ADDED
@@ -0,0 +1,60 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * NOTICE OF LICENSE
5
+ *
6
+ * This source file is subject to the Open Software License (OSL 3.0)
7
+ * which is available through the world-wide-web at this URL:
8
+ * http://opensource.org/licenses/osl-3.0.php
9
+ * If you are unable to obtain it through the world-wide-web,
10
+ * please send an email to magento@raveinfosys.com
11
+ * so we can send you a copy immediately.
12
+ *
13
+ * @category Raveinfosys
14
+ * @package Raveinfosys_Linkpoint
15
+ * @author RaveInfosys, Inc.
16
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
17
+ */
18
+ -->
19
+ <config>
20
+ <modules>
21
+ <Raveinfosys_Linkpoint>
22
+ <version>1.0.0</version>
23
+ </Raveinfosys_Linkpoint>
24
+ </modules>
25
+ <frontend>
26
+ <events>
27
+ <payment_method_is_active>
28
+ <observers>
29
+ <linkpoint>
30
+ <type>singleton</type>
31
+ <class>Raveinfosys_Linkpoint_Model_Observer</class>
32
+ <method>disableMethod</method>
33
+ </linkpoint>
34
+ </observers>
35
+ </payment_method_is_active>
36
+ </events>
37
+ </frontend>
38
+ <global>
39
+ <models>
40
+ <linkpoint>
41
+ <class>Raveinfosys_Linkpoint_Model</class>
42
+ </linkpoint>
43
+ </models>
44
+ </global>
45
+ <default>
46
+ <payment>
47
+ <linkpoint>
48
+ <active>0</active>
49
+ <title>Credit Card (LinkPoint)</title>
50
+ <order_status>pending</order_status>
51
+ <cctypes>AE,VI,MC</cctypes>
52
+ <useccv>1</useccv>
53
+ <allowspecific>0</allowspecific>
54
+ <test>1</test>
55
+ <payment_action>authorize_capture</payment_action>
56
+ <model>linkpoint/linkpoint</model>
57
+ </linkpoint>
58
+ </payment>
59
+ </default>
60
+ </config>
app/code/community/Raveinfosys/Linkpoint/etc/system.xml ADDED
@@ -0,0 +1,225 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * NOTICE OF LICENSE
5
+ *
6
+ * This source file is subject to the Open Software License (OSL 3.0)
7
+ * which is available through the world-wide-web at this URL:
8
+ * http://opensource.org/licenses/osl-3.0.php
9
+ * If you are unable to obtain it through the world-wide-web,
10
+ * please send an email to magento@raveinfosys.com
11
+ * so we can send you a copy immediately.
12
+ *
13
+ * @category Raveinfosys
14
+ * @package Raveinfosys_Linkpoint
15
+ * @author RaveInfosys, Inc.
16
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
17
+ */
18
+ -->
19
+ <config>
20
+ <sections>
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>
28
+ <show_in_store>1</show_in_store>
29
+ <fields>
30
+ <active translate="label">
31
+ <label>Enabled</label>
32
+ <frontend_type>select</frontend_type>
33
+ <source_model>adminhtml/system_config_source_yesno</source_model>
34
+ <sort_order>1</sort_order>
35
+ <show_in_default>1</show_in_default>
36
+ <show_in_website>1</show_in_website>
37
+ <show_in_store>0</show_in_store>
38
+ </active>
39
+ <title translate="label">
40
+ <label>Title</label>
41
+ <frontend_type>text</frontend_type>
42
+ <sort_order>3</sort_order>
43
+ <show_in_default>1</show_in_default>
44
+ <show_in_website>1</show_in_website>
45
+ <show_in_store>1</show_in_store>
46
+ </title>
47
+ <order_status translate="label">
48
+ <label>New Order Status</label>
49
+ <frontend_type>select</frontend_type>
50
+ <source_model>adminhtml/system_config_source_order_status_newprocessing</source_model>
51
+ <sort_order>4</sort_order>
52
+ <show_in_default>1</show_in_default>
53
+ <show_in_website>1</show_in_website>
54
+ <show_in_store>0</show_in_store>
55
+ </order_status>
56
+ <cctypes translate="label">
57
+ <label>Credit Card Types</label>
58
+ <frontend_type>multiselect</frontend_type>
59
+ <source_model>adminhtml/system_config_source_payment_cctype</source_model>
60
+ <sort_order>5</sort_order>
61
+ <show_in_default>1</show_in_default>
62
+ <show_in_website>1</show_in_website>
63
+ <show_in_store>0</show_in_store>
64
+ <can_be_empty>1</can_be_empty>
65
+ </cctypes>
66
+ <useccv translate="label">
67
+ <label>Request Card Security Code</label>
68
+ <frontend_type>select</frontend_type>
69
+ <source_model>adminhtml/system_config_source_yesno</source_model>
70
+ <sort_order>6</sort_order>
71
+ <show_in_default>1</show_in_default>
72
+ <show_in_website>1</show_in_website>
73
+ <show_in_store>0</show_in_store>
74
+ </useccv>
75
+ <allowspecific translate="label">
76
+ <label>Payment from Applicable Countries</label>
77
+ <frontend_type>allowspecific</frontend_type>
78
+ <sort_order>50</sort_order>
79
+ <source_model>adminhtml/system_config_source_payment_allspecificcountries</source_model>
80
+ <show_in_default>1</show_in_default>
81
+ <show_in_website>1</show_in_website>
82
+ <show_in_store>0</show_in_store>
83
+ </allowspecific>
84
+ <specificcountry translate="label">
85
+ <label>Payment from Specific Countries</label>
86
+ <frontend_type>multiselect</frontend_type>
87
+ <sort_order>51</sort_order>
88
+ <source_model>adminhtml/system_config_source_country</source_model>
89
+ <show_in_default>1</show_in_default>
90
+ <show_in_website>1</show_in_website>
91
+ <show_in_store>0</show_in_store>
92
+ <can_be_empty>1</can_be_empty>
93
+ </specificcountry>
94
+ <min_order_total translate="label">
95
+ <label>Minimum Order Total</label>
96
+ <frontend_type>text</frontend_type>
97
+ <sort_order>98</sort_order>
98
+ <show_in_default>1</show_in_default>
99
+ <show_in_website>1</show_in_website>
100
+ <show_in_store>0</show_in_store>
101
+ </min_order_total>
102
+ <max_order_total translate="label">
103
+ <label>Maximum Order Total</label>
104
+ <frontend_type>text</frontend_type>
105
+ <sort_order>99</sort_order>
106
+ <show_in_default>1</show_in_default>
107
+ <show_in_website>1</show_in_website>
108
+ <show_in_store>0</show_in_store>
109
+ </max_order_total>
110
+ <debug translate="label">
111
+ <label>Debug</label>
112
+ <frontend_type>select</frontend_type>
113
+ <source_model>adminhtml/system_config_source_yesno</source_model>
114
+ <sort_order>55</sort_order>
115
+ <show_in_default>1</show_in_default>
116
+ <show_in_website>1</show_in_website>
117
+ <show_in_store>0</show_in_store>
118
+ </debug>
119
+ <test translate="label">
120
+ <label>Test Mode</label>
121
+ <frontend_type>select</frontend_type>
122
+ <source_model>adminhtml/system_config_source_yesno</source_model>
123
+ <sort_order>60</sort_order>
124
+ <show_in_default>1</show_in_default>
125
+ <show_in_website>1</show_in_website>
126
+ <show_in_store>0</show_in_store>
127
+ </test>
128
+ <heading_live translate="label">
129
+ <label>Live Details</label>
130
+ <frontend_model>adminhtml/system_config_form_field_heading</frontend_model>
131
+ <sort_order>61</sort_order>
132
+ <show_in_default>1</show_in_default>
133
+ <show_in_website>1</show_in_website>
134
+ </heading_live>
135
+ <store_number_live translate="label">
136
+ <label>Store Number (Live)</label>
137
+ <frontend_type>text</frontend_type>
138
+ <sort_order>62</sort_order>
139
+ <show_in_default>1</show_in_default>
140
+ <show_in_website>1</show_in_website>
141
+ <show_in_store>0</show_in_store>
142
+ </store_number_live>
143
+ <host_live translate="label">
144
+ <label>Host Name (Live)</label>
145
+ <frontend_type>text</frontend_type>
146
+ <comment>Live Host Name</comment>
147
+ <sort_order>63</sort_order>
148
+ <show_in_default>1</show_in_default>
149
+ <show_in_website>1</show_in_website>
150
+ <show_in_store>0</show_in_store>
151
+ </host_live>
152
+ <port_live translate="label">
153
+ <label>Port (Live)</label>
154
+ <frontend_type>text</frontend_type>
155
+ <comment>Port</comment>
156
+ <sort_order>64</sort_order>
157
+ <show_in_default>1</show_in_default>
158
+ <show_in_website>1</show_in_website>
159
+ <show_in_store>0</show_in_store>
160
+ </port_live>
161
+ <pem_path_live translate="label">
162
+ <label>Pem Path (Live)</label>
163
+ <frontend_type>text</frontend_type>
164
+ <comment><![CDATA[Absolute Path to .pem file.<br />For eg. "\var\site\www\" (for Linux Servers), or "c:/wamp/www/site/"(for Windows server).]]></comment>
165
+ <sort_order>65</sort_order>
166
+ <show_in_default>1</show_in_default>
167
+ <show_in_website>1</show_in_website>
168
+ <show_in_store>0</show_in_store>
169
+ </pem_path_live>
170
+ <heading_test translate="label">
171
+ <label>Test Details</label>
172
+ <frontend_model>adminhtml/system_config_form_field_heading</frontend_model>
173
+ <sort_order>66</sort_order>
174
+ <show_in_default>1</show_in_default>
175
+ <show_in_website>1</show_in_website>
176
+ </heading_test>
177
+ <store_number_test translate="label">
178
+ <label>Store Number (Test)</label>
179
+ <frontend_type>text</frontend_type>
180
+ <sort_order>67</sort_order>
181
+ <show_in_default>1</show_in_default>
182
+ <show_in_website>1</show_in_website>
183
+ <show_in_store>0</show_in_store>
184
+ </store_number_test>
185
+ <host_test translate="label">
186
+ <label>Host Name (Test)</label>
187
+ <frontend_type>text</frontend_type>
188
+ <comment>Test Host Name</comment>
189
+ <sort_order>68</sort_order>
190
+ <show_in_default>1</show_in_default>
191
+ <show_in_website>1</show_in_website>
192
+ <show_in_store>0</show_in_store>
193
+ </host_test>
194
+ <port_test translate="label">
195
+ <label>Port (Test)</label>
196
+ <frontend_type>text</frontend_type>
197
+ <comment>Port</comment>
198
+ <sort_order>69</sort_order>
199
+ <show_in_default>1</show_in_default>
200
+ <show_in_website>1</show_in_website>
201
+ <show_in_store>0</show_in_store>
202
+ </port_test>
203
+ <pem_path_test translate="label">
204
+ <label>Pem Path (Test)</label>
205
+ <frontend_type>text</frontend_type>
206
+ <comment><![CDATA[Absolute Path to .pem file. <br />For eg. "\var\site\www\" (for Linux Servers), or "c:/wamp/www/site/"(for Windows server).]]></comment>
207
+ <sort_order>70</sort_order>
208
+ <show_in_default>1</show_in_default>
209
+ <show_in_website>1</show_in_website>
210
+ <show_in_store>0</show_in_store>
211
+ </pem_path_test>
212
+ <sort_order translate="label">
213
+ <label>Sort Order</label>
214
+ <frontend_type>text</frontend_type>
215
+ <sort_order>100</sort_order>
216
+ <show_in_default>1</show_in_default>
217
+ <show_in_website>1</show_in_website>
218
+ <show_in_store>0</show_in_store>
219
+ </sort_order>
220
+ </fields>
221
+ </linkpoint>
222
+ </groups>
223
+ </payment>
224
+ </sections>
225
+ </config>
app/etc/modules/Raveinfosys_Linkpoint.xml ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * NOTICE OF LICENSE
5
+ *
6
+ * This source file is subject to the Open Software License (OSL 3.0)
7
+ * which is available through the world-wide-web at this URL:
8
+ * http://opensource.org/licenses/osl-3.0.php
9
+ * If you are unable to obtain it through the world-wide-web,
10
+ * please send an email to magento@raveinfosys.com
11
+ * so we can send you a copy immediately.
12
+ *
13
+ * @category Raveinfosys
14
+ * @package Raveinfosys_Linkpoint
15
+ * @author RaveInfosys, Inc.
16
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
17
+ */
18
+ -->
19
+ <config>
20
+ <modules>
21
+ <Raveinfosys_Linkpoint>
22
+ <active>true</active>
23
+ <codePool>community</codePool>
24
+ <depends>
25
+ <Mage_Payment />
26
+ </depends>
27
+ </Raveinfosys_Linkpoint>
28
+ </modules>
29
+ </config>
package.xml ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <package>
3
+ <name>First_Data_Gateway_Integration</name>
4
+ <version>1.0.0</version>
5
+ <stability>stable</stability>
6
+ <license uri="http://opensource.org/licenses/osl-3.0.php">Open Software License (OSL)</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.&#xD;
11
+ &#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.6.1, 1.6.2.0</notes>
14
+ <authors><author><name>Rave Infosys</name><user>raveinfo</user><email>lpext@raveinfosys.com</email></author><author><name>Mayank Sharma</name><user>mayank3008</user><email>mynk.sharma@gmail.com</email></author></authors>
15
+ <date>2012-07-12</date>
16
+ <time>06:52:57</time>
17
+ <contents><target name="magecommunity"><dir name="Raveinfosys"><dir name="Linkpoint"><dir name="Model"><file name="Linkpoint.php" hash="f8d8f6d8b90fbdee945068da741db51c"/><file name="Observer.php" hash="693ae2128bea852549c719b53aa5d3f8"/></dir><dir name="etc"><file name="config.xml" hash="8809b7589fdab005fbae48aca7d2e9d4"/><file name="system.xml" hash="d1727b5f1a15e19adc00d8c3581b3ec8"/></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.3.10</max></php><package><name>Mage_Core_Modules</name><channel>community</channel><min>1.5.0</min><max>1.6.2.0</max></package><extension><name>curl</name><min>7.21.4</min><max>7.26.0</max></extension></required></dependencies>
20
+ </package>