Telr_TelrPayments - Version 2.0.0

Version Notes

Process transactions using the V2 hosted payment pages.

Download this release

Release Info

Developer Telr
Extension Telr_TelrPayments
Version 2.0.0
Comparing to
See all releases


Version 2.0.0

Files changed (23) hide show
  1. app/code/community/Telr/TelrPayments/Block/Cancel.php +35 -0
  2. app/code/community/Telr/TelrPayments/Block/Failure.php +35 -0
  3. app/code/community/Telr/TelrPayments/Block/Form.php +33 -0
  4. app/code/community/Telr/TelrPayments/Block/Info.php +38 -0
  5. app/code/community/Telr/TelrPayments/Block/Redirect.php +78 -0
  6. app/code/community/Telr/TelrPayments/Block/Success.php +36 -0
  7. app/code/community/Telr/TelrPayments/Helper/Data.php +26 -0
  8. app/code/community/Telr/TelrPayments/Model/Cc.php +356 -0
  9. app/code/community/Telr/TelrPayments/Model/Source/RequestType.php +29 -0
  10. app/code/community/Telr/TelrPayments/controllers/ProcessingController.php +238 -0
  11. app/code/community/Telr/TelrPayments/etc/config.xml +104 -0
  12. app/code/community/Telr/TelrPayments/etc/system.xml +108 -0
  13. app/design/adminhtml/default/default/template/telrpayments/info.phtml +27 -0
  14. app/design/adminhtml/default/default/template/telrpayments/pdf/info.phtml +21 -0
  15. app/design/frontend/base/default/layout/telrpayments.xml +39 -0
  16. app/design/frontend/base/default/template/telrpayments/blank.phtml +42 -0
  17. app/design/frontend/base/default/template/telrpayments/cancel.phtml +28 -0
  18. app/design/frontend/base/default/template/telrpayments/failure.phtml +28 -0
  19. app/design/frontend/base/default/template/telrpayments/form.phtml +27 -0
  20. app/design/frontend/base/default/template/telrpayments/info.phtml +27 -0
  21. app/design/frontend/base/default/template/telrpayments/redirect.phtml +27 -0
  22. app/etc/modules/Telr_TelrPayments.xml +28 -0
  23. package.xml +21 -0
app/code/community/Telr/TelrPayments/Block/Cancel.php ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @category Telr
16
+ * @package Telr_TelrPayments
17
+ * @copyright Copyright (c) 2015 Telr (https://telr.com/)
18
+ */
19
+
20
+ class Telr_TelrPayments_Block_Cancel extends Mage_Core_Block_Template
21
+ {
22
+ protected function _construct()
23
+ {
24
+ parent::_construct();
25
+ $this->setTemplate('telrpayments/cancel.phtml');
26
+ }
27
+
28
+ /**
29
+ * Get continue shopping url
30
+ */
31
+ public function getContinueShoppingUrl()
32
+ {
33
+ return Mage::getUrl('*/*/cancel', array('_nosid' => true));
34
+ }
35
+ }
app/code/community/Telr/TelrPayments/Block/Failure.php ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @category Telr
16
+ * @package Telr_TelrPayments
17
+ * @copyright Copyright (c) 2015 Telr (https://telr.com/)
18
+ */
19
+
20
+ class Telr_TelrPayments_Block_Failure extends Mage_Core_Block_Template
21
+ {
22
+ protected function _construct()
23
+ {
24
+ parent::_construct();
25
+ $this->setTemplate('telrpayments/failure.phtml');
26
+ }
27
+
28
+ /**
29
+ * Get continue shopping url
30
+ */
31
+ public function getContinueShoppingUrl()
32
+ {
33
+ return Mage::getUrl('checkout/cart', array('_nosid' => true));
34
+ }
35
+ }
app/code/community/Telr/TelrPayments/Block/Form.php ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @category Telr
16
+ * @package Telr_TelrPayments
17
+ * @copyright Copyright (c) 2015 Telr (https://telr.com/)
18
+ */
19
+
20
+
21
+ class Telr_TelrPayments_Block_Form extends Mage_Payment_Block_Form
22
+ {
23
+ protected function _construct()
24
+ {
25
+ parent::_construct();
26
+ $this->setTemplate('telrpayments/form.phtml');
27
+ }
28
+
29
+ protected function _getConfig()
30
+ {
31
+ return Mage::getSingleton('telrpayments/config');
32
+ }
33
+ }
app/code/community/Telr/TelrPayments/Block/Info.php ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @category Telr
16
+ * @package Telr_TelrPayments
17
+ * @copyright Copyright (c) 2015 Telr (https://telr.com/)
18
+ */
19
+
20
+ class Telr_TelrPayments_Block_Info extends Mage_Payment_Block_Info
21
+ {
22
+ protected function _construct()
23
+ {
24
+ parent::_construct();
25
+ $this->setTemplate('telrpayments/info.phtml');
26
+ }
27
+
28
+ public function getMethodCode()
29
+ {
30
+ return $this->getInfo()->getMethodInstance()->getCode();
31
+ }
32
+
33
+ public function toPdf()
34
+ {
35
+ $this->setTemplate('telrpayments/pdf/info.phtml');
36
+ return $this->toHtml();
37
+ }
38
+ }
app/code/community/Telr/TelrPayments/Block/Redirect.php ADDED
@@ -0,0 +1,78 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @category Telr
16
+ * @package Telr_TelrPayments
17
+ * @copyright Copyright (c) 2015 Telr (https://telr.com/)
18
+ */
19
+
20
+ class Telr_TelrPayments_Block_Redirect extends Mage_Core_Block_Template
21
+ {
22
+
23
+ /**
24
+ * Return checkout session instance
25
+ *
26
+ * @return Mage_Checkout_Model_Session
27
+ */
28
+ protected function _getCheckout()
29
+ {
30
+ return Mage::getSingleton('checkout/session');
31
+ }
32
+
33
+ /**
34
+ * Return order instance
35
+ *
36
+ * @return Mage_Sales_Model_Order|null
37
+ */
38
+ protected function _getOrder()
39
+ {
40
+ if ($this->getOrder()) {
41
+ return $this->getOrder();
42
+ } elseif ($orderIncrementId = $this->_getCheckout()->getLastRealOrderId()) {
43
+ return Mage::getModel('sales/order')->loadByIncrementId($orderIncrementId);
44
+ } else {
45
+ return null;
46
+ }
47
+ }
48
+
49
+ /**
50
+ * Get form data
51
+ *
52
+ * @return array
53
+ */
54
+ public function getFormData()
55
+ {
56
+ return $this->_getOrder()->getPayment()->getMethodInstance()->getFormFields();
57
+ }
58
+
59
+ /**
60
+ * Get response url
61
+ *
62
+ * @return array
63
+ */
64
+ public function createOrder()
65
+ {
66
+ return $this->_getOrder()->getPayment()->getMethodInstance()->createOrder();
67
+ }
68
+
69
+ /**
70
+ * Getting gateway url
71
+ *
72
+ * @return string
73
+ */
74
+ public function getFormAction()
75
+ {
76
+ return $this->_getOrder()->getPayment()->getMethodInstance()->getUrl();
77
+ }
78
+ }
app/code/community/Telr/TelrPayments/Block/Success.php ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @category Telr
16
+ * @package Telr_TelrPayments
17
+ * @copyright Copyright (c) 2015 Telr (https://telr.com/)
18
+ */
19
+
20
+ class Telr_TelrPayments_Block_Success extends Mage_Core_Block_Abstract
21
+ {
22
+ protected function _toHtml()
23
+ {
24
+ $successUrl = Mage::getUrl('*/*/success', array('_nosid' => true));
25
+
26
+ $html = '<html>'
27
+ . '<meta http-equiv="refresh" content="0; URL='.$successUrl.'">'
28
+ . '<body>'
29
+ . '<p>' . $this->__('Your payment has been successfully processed.') . '</p>'
30
+ . '<p>' . $this->__('Please click <a href="%s">here</a> if you are not redirected automatically.', $successUrl) . '</p>'
31
+ . '</body></html>';
32
+
33
+ return $html;
34
+ }
35
+
36
+ }
app/code/community/Telr/TelrPayments/Helper/Data.php ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @category Telr
16
+ * @package Telr_TelrPayments
17
+ * @copyright Copyright (c) 2015 Telr (https://telr.com/)
18
+ */
19
+
20
+ class Telr_TelrPayments_Helper_Data extends Mage_Payment_Helper_Data
21
+ {
22
+ public function getPendingPaymentStatus()
23
+ {
24
+ return Mage_Sales_Model_Order::STATE_PENDING_PAYMENT;
25
+ }
26
+ }
app/code/community/Telr/TelrPayments/Model/Cc.php ADDED
@@ -0,0 +1,356 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @category Telr
16
+ * @package Telr_TelrPayments
17
+ * @copyright Copyright (c) 2015 Telr (https://telr.com/)
18
+ */
19
+
20
+ class Telr_TelrPayments_Model_Cc extends Mage_Payment_Model_Method_Abstract
21
+
22
+ {
23
+ protected $_code = 'telrpayments_cc';
24
+
25
+ protected $_isGateway = true;
26
+ protected $_canAuthorize = true;
27
+ protected $_canCapture = true;
28
+ protected $_canCapturePartial = false;
29
+ protected $_canRefund = false;
30
+ protected $_canRefundInvoicePartial = false;
31
+ protected $_canVoid = false;
32
+ protected $_canUseInternal = false;
33
+ protected $_canUseCheckout = true;
34
+ protected $_canUseForMultishipping = false;
35
+ protected $_canSaveCc = false;
36
+
37
+ protected $_paymentMethod = 'cc';
38
+ protected $_defaultLocale = 'en';
39
+
40
+ protected $_testAdminUrl = 'https://secure.telr.com/gateway/order.json';
41
+ protected $_liveAdminUrl = 'https://secure.telr.com/gateway/order.json';
42
+
43
+ protected $_formBlockType = 'telrpayments/form';
44
+ protected $_infoBlockType = 'telrpayments/info';
45
+
46
+ protected $_order = NULL;
47
+ protected $_quote = false;
48
+
49
+
50
+ protected function _getCheckoutSession()
51
+ {
52
+ return Mage::getSingleton('checkout/session');
53
+ }
54
+
55
+ protected function _getQuote()
56
+ {
57
+ if (!$this->_quote) {
58
+ $this->_quote = $this->_getCheckoutSession()->getQuote();
59
+ }
60
+ return $this->_quote;
61
+ }
62
+
63
+
64
+ public function getOrder()
65
+ {
66
+ if (!$this->_order) {
67
+ $this->_order = $this->getInfoInstance()->getOrder();
68
+ }
69
+ return $this->_order;
70
+ }
71
+
72
+ public function getOrderPlaceRedirectUrl()
73
+ {
74
+ return Mage::getUrl('telrpayments/processing/redirect');
75
+ }
76
+
77
+ public function getPaymentMethodType()
78
+ {
79
+ return $this->_paymentMethod;
80
+ }
81
+
82
+ public function getUrl()
83
+ {
84
+ return $this->_liveAdminUrl;
85
+ }
86
+
87
+ public function getAdminUrl()
88
+ {
89
+ return $this->_liveAdminUrl;
90
+ }
91
+
92
+ private function _buildUrl($part) {
93
+ $url= Mage::getUrl($part,array('_nosid' => true));
94
+ $url = trim(str_replace('&amp;', '&', $url));
95
+ return $url;
96
+ }
97
+
98
+ private function _tidy($value,$remove_accents) {
99
+ if ($remove_accents>0) {
100
+ $value=Mage::helper('core')->removeAccents($value);
101
+ }
102
+ return trim($value);
103
+ }
104
+
105
+ public function createOrder()
106
+ {
107
+ $session = $this->_getCheckoutSession();
108
+ $this->_clearTransResults($session);
109
+ $securityKey = trim($this->getConfigData('security_key'));
110
+ if (empty($securityKey)) {
111
+ $message = 'Secret key not set';
112
+ Mage::throwException($message);
113
+ }
114
+ $price = number_format($this->getOrder()->getGrandTotal(),2,'.','');
115
+ $currency = $this->getOrder()->getOrderCurrencyCode();
116
+ $billing = $this->getOrder()->getBillingAddress();
117
+ $shipping = $this->getOrder()->getShippingAddress();
118
+
119
+ $locale = trim(Mage::app()->getLocale()->getLocaleCode());
120
+ if (empty($locale)) {
121
+ $locale = trim($this->getDefaultLocale());
122
+ }
123
+ $order_id = $this->getOrder()->getRealOrderId();
124
+
125
+ //$order_id = $order_id.uniqid();
126
+
127
+ $tran_desc = trim($this->getConfigData('tran_desc'));
128
+ if (empty($tran_desc)) {
129
+ $tran_desc = 'Your purchase at ' . Mage::app()->getStore()->getName();
130
+ }
131
+ $tran_desc = str_replace('{order}', $order_id, $tran_desc);
132
+ $version = Mage::getVersion();
133
+
134
+ $params = array(
135
+ 'ivp_method' => 'create',
136
+ 'ivp_store' => $this->_tidy($this->getConfigData('store_id'),0),
137
+ 'ivp_authkey' => trim($this->getConfigData('security_key')),
138
+ 'ivp_source' => $this->_tidy('Magento '.$version,0),
139
+ 'ivp_cart' => $this->_tidy($order_id,0),
140
+ 'ivp_test' => ($this->getConfigData('transaction_testmode') == '0') ? '0' : '1',
141
+ 'ivp_amount' => $this->_tidy($price,0),
142
+ 'ivp_currency' => $this->_tidy($currency,0),
143
+ 'ivp_desc' => $this->_tidy($tran_desc,0),
144
+ 'ivp_lang' => $this->_tidy($locale,0),
145
+ 'bill_title' => '',
146
+ 'bill_fname' => $this->_tidy($billing->getFirstname(),0),
147
+ 'bill_sname' => $this->_tidy($billing->getLastname(),0),
148
+ 'bill_addr1' => $this->_tidy($billing->getStreet(1),0),
149
+ 'bill_addr2' => $this->_tidy($billing->getStreet(2),0),
150
+ 'bill_addr3' => $this->_tidy($billing->getStreet(3),0),
151
+ 'bill_city' => $this->_tidy($billing->getCity(),0),
152
+ 'bill_region' => $this->_tidy($billing->getRegion(),0),
153
+ 'bill_zip' => $this->_tidy($billing->getPostcode(),0),
154
+ 'bill_country' => $this->_tidy($billing->getCountry(),0),
155
+ 'bill_email' => $this->_tidy($this->getOrder()->getCustomerEmail(),0),
156
+ 'bill_phone1' => $this->_tidy($billing->getTelephone(),0),
157
+ 'delv_title' => '',
158
+ 'delv_fname' => $this->_tidy($shipping->getFirstname(),0),
159
+ 'delv_sname' => $this->_tidy($shipping->getLastname(),0),
160
+ 'delv_addr1' => $this->_tidy($shipping->getStreet(1),0),
161
+ 'delv_addr2' => $this->_tidy($shipping->getStreet(2),0),
162
+ 'delv_city' => $this->_tidy($shipping->getCity(),0),
163
+ 'delv_region' => $this->_tidy($shipping->getRegion(),0),
164
+ 'delv_zip' => $this->_tidy($shipping->getPostcode(),0),
165
+ 'delv_country' => $this->_tidy($shipping->getCountry(),0),
166
+ 'return_auth' => $this->_buildUrl('telrpayments/processing/success'),
167
+ 'return_can' => $this->_buildUrl('telrpayments/processing/cancel'),
168
+ 'return_decl' => $this->_buildUrl('telrpayments/processing/cancel'),
169
+ );
170
+
171
+ if (Mage::app()->getStore()->isCurrentlySecure()) {
172
+ // https enabled
173
+ $customer = Mage::getSingleton('customer/session');
174
+ if ($customer->isLoggedIn()) {
175
+ // registered user
176
+ $params['bill_custref']=$customer->getCustomerId();
177
+ }
178
+ }
179
+
180
+ $ch = curl_init();
181
+ curl_setopt($ch, CURLOPT_URL,$this->_liveAdminUrl);
182
+ curl_setopt($ch, CURLOPT_POST, count($params));
183
+ curl_setopt($ch, CURLOPT_POSTFIELDS,$params);
184
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
185
+ curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
186
+ curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
187
+ curl_setopt($ch, CURLOPT_HTTPHEADER, array('Expect:'));
188
+ $results = curl_exec($ch);
189
+ curl_close($ch);
190
+ $results = json_decode($results,true);
191
+ $ref= trim($results['order']['ref']);
192
+ $url= trim($results['order']['url']);
193
+ if (empty($ref) || empty($url)) {
194
+ Mage::throwException("Order couldn't be created");
195
+ }
196
+ // Set value in session
197
+ $session->setOrderRef($ref);
198
+ $session->setTelrCheckoutPage($url);
199
+ return $url;
200
+ }
201
+
202
+ /*
203
+ public function void(Varien_Object $payment, $amount)
204
+ {
205
+ $transactionId = $payment->getLastTransId();
206
+
207
+ $params['ivp_trantype'] = 'void';
208
+ $params['ivp_amount'] = $amount;
209
+ $params['ivp_currency'] = $payment->getOrder()->getOrderCurrencyCode();
210
+ $params['tran_ref'] = $transactionId;
211
+
212
+ $response = $this->processRemoteRequest($params);
213
+ return $this;
214
+ }
215
+ */
216
+
217
+ public function capture(Varien_Object $payment, $amount)
218
+ {
219
+ if (!$this->canCapture()) {
220
+ return $this;
221
+ }
222
+ $session = $this->_getCheckoutSession();
223
+ if ($session) {
224
+ $url=$session->getTelrCheckoutPage();
225
+ if (!empty($url)) {
226
+ return $this;
227
+ }
228
+ }
229
+
230
+ $response = $this->getOrderStatus();
231
+ $payment->getOrder()->addStatusToHistory($payment->getOrder()->getStatus(), $this->_getHelper()->__('TelrPayments transaction has been captured.'));
232
+ return $this;
233
+ }
234
+
235
+ public function canEdit () {
236
+ return false;
237
+ }
238
+
239
+ public function canManageBillingAgreements () {
240
+ return false;
241
+ }
242
+
243
+ public function canManageRecurringProfiles () {
244
+ return false;
245
+ }
246
+
247
+ /*
248
+ public function canVoid ()
249
+ {
250
+ return $this->_remoteEnabled();
251
+ }
252
+ */
253
+
254
+ public function canRefund ()
255
+ {
256
+ return false;
257
+ }
258
+
259
+ public function canRefundInvoicePartial()
260
+ {
261
+ return false;
262
+ }
263
+
264
+ public function canRefundPartialPerInvoice()
265
+ {
266
+ return false;
267
+ }
268
+
269
+ public function canCapturePartial()
270
+ {
271
+ return false;
272
+ }
273
+
274
+ protected function _remoteEnabled() {
275
+ return 0;
276
+ }
277
+
278
+ protected function _setErrorResult($session) {
279
+ $session->setTelrPaymentsCart('');
280
+ $session->setTelrPaymentsTransRef('000000000000');
281
+ $session->setTelrPaymentsCode('-3');
282
+ $session->setTelrPaymentsStatus('E');
283
+ $session->setTelrPaymentsAuth('01');
284
+ $session->setTelrPaymentsMesg('Error checking order results');
285
+ }
286
+
287
+ protected function _setTransResults($session,$results) {
288
+ if (!empty($results['error']['message'])) {
289
+ $this->setErrorResults($session);
290
+ return false;
291
+ }
292
+ if (empty($results['order']['cartid'])) {
293
+ $this->setErrorResults($session);
294
+ return false;
295
+ }
296
+ $session->setTelrPaymentsCart($results['order']['cartid']);
297
+ $session->setTelrPaymentsTransRef($results['order']['transaction']['ref']);
298
+ $session->setTelrPaymentsCode($results['order']['status']['code']);
299
+ $session->setTelrPaymentsStatus($results['order']['transaction']['status']);
300
+ $session->setTelrPaymentsAuth($results['order']['transaction']['code']);
301
+ $session->setTelrPaymentsMesg($results['order']['transaction']['message']);
302
+ return true;
303
+ }
304
+
305
+ protected function _clearTransResults($session) {
306
+ $session->unsTelrPaymentsCart();
307
+ $session->unsTelrPaymentsTransRef();
308
+ $session->unsTelrPaymentsCode();
309
+ $session->unsTelrPaymentsStatus();
310
+ $session->unsTelrPaymentsAuth();
311
+ $session->unsTelrPaymentsMesg();
312
+ $session->unsTelrCheckoutPage();
313
+ }
314
+
315
+ public function getOrderStatus()
316
+ {
317
+ $session = $this->_getCheckoutSession();
318
+
319
+ if (!empty($session->getTelrPaymentsTransRef())) {
320
+ return;
321
+ }
322
+
323
+ $orderRef=trim($session->getOrderRef());
324
+ $securityKey = trim(Mage::getStoreConfig('payment/telrpayments_cc/security_key'));
325
+ $storeId = trim(Mage::getStoreConfig('payment/telrpayments_cc/store_id'));
326
+
327
+ if (empty($securityKey) || empty($storeId) || empty($orderRef)) {
328
+ $message = 'Unable to check order. Key/Store/Ref not set';
329
+ Mage::throwException($message);
330
+ }
331
+
332
+ $params = array(
333
+ 'ivp_method' => 'check',
334
+ 'ivp_store' => $storeId,
335
+ 'ivp_authkey' => $securityKey,
336
+ 'order_ref' => $orderRef
337
+ );
338
+
339
+ $ch = curl_init();
340
+ curl_setopt($ch, CURLOPT_URL,$this->_liveAdminUrl);
341
+ curl_setopt($ch, CURLOPT_POST, count($params));
342
+ curl_setopt($ch, CURLOPT_POSTFIELDS,$params);
343
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
344
+ curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
345
+ curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
346
+ curl_setopt($ch, CURLOPT_HTTPHEADER, array('Expect:'));
347
+ $results = curl_exec($ch);
348
+ curl_close($ch);
349
+ $results = json_decode($results,true);
350
+
351
+ if ($this->_setTransResults($session,$results)==false) {
352
+ Mage::throwException('Error parsing order results');
353
+ }
354
+ return;
355
+ }
356
+ }
app/code/community/Telr/TelrPayments/Model/Source/RequestType.php ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @category Telr
16
+ * @package Telr_TelrPayments
17
+ * @copyright Copyright (c) 2015 Telr (https://telr.com/)
18
+ */
19
+
20
+ class Telr_TelrPayments_Model_Source_RequestType
21
+ {
22
+ public function toOptionArray()
23
+ {
24
+ return array(
25
+ array('value' => Mage_Payment_Model_Method_Abstract::ACTION_AUTHORIZE, 'label' => Mage::helper('telrpayments')->__('PreAuthorisation')),
26
+ array('value' => Mage_Payment_Model_Method_Abstract::ACTION_AUTHORIZE_CAPTURE, 'label' => Mage::helper('telrpayments')->__('Authorisation')),
27
+ );
28
+ }
29
+ }
app/code/community/Telr/TelrPayments/controllers/ProcessingController.php ADDED
@@ -0,0 +1,238 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @category Telr
16
+ * @package Telr_TelrPayments
17
+ * @copyright Copyright (c) 2015 Telr (https://telr.com/)
18
+ */
19
+ class Telr_TelrPayments_ProcessingController extends Mage_Core_Controller_Front_Action
20
+ {
21
+
22
+ protected $_successBlockType = 'telrpayments/success';
23
+ protected $_failureBlockType = 'telrpayments/failure';
24
+ protected $_cancelBlockType = 'telrpayments/cancel';
25
+
26
+ protected $_order = NULL;
27
+ protected $_paymentInst = NULL;
28
+ protected $_quote = false;
29
+ protected $_config = null;
30
+
31
+ protected function _getCheckoutSession()
32
+ {
33
+ return Mage::getSingleton('checkout/session');
34
+ }
35
+
36
+ protected function _getQuote()
37
+ {
38
+ if (!$this->_quote) {
39
+ $this->_quote = $this->_getCheckoutSession()->getQuote();
40
+ }
41
+ return $this->_quote;
42
+ }
43
+
44
+ protected function _getModel() {
45
+ return Mage::getSingleton('telrpayments/cc');
46
+ }
47
+
48
+ /**
49
+ * when customer selects Telr payment method
50
+ */
51
+ public function redirectAction()
52
+ {
53
+ try {
54
+ $session = $this->_getCheckoutSession();
55
+ $order = Mage::getModel('sales/order');
56
+ $order->loadByIncrementId($session->getLastRealOrderId());
57
+ if (!$order->getId()) {
58
+ Mage::throwException('No order for processing found');
59
+ }
60
+ if ($order->getState() != Mage_Sales_Model_Order::STATE_PENDING_PAYMENT) {
61
+ $order->setState(
62
+ Mage_Sales_Model_Order::STATE_PENDING_PAYMENT,
63
+ Mage_Sales_Model_Order::STATE_PENDING_PAYMENT,
64
+ Mage::helper('telrpayments')->__('Customer was redirected to gateway.')
65
+ )->save();
66
+ }
67
+ if ($session->getQuoteId() && $session->getLastSuccessQuoteId()) {
68
+ $session->setTelrPaymentsQuoteId($session->getQuoteId());
69
+ $session->setTelrPaymentsSuccessQuoteId($session->getLastSuccessQuoteId());
70
+ $session->setTelrPaymentsRealOrderId($session->getLastRealOrderId());
71
+ $session->getQuote()->setIsActive(false)->save();
72
+ $session->clear();
73
+ }
74
+ $this->loadLayout();
75
+ $this->renderLayout();
76
+ return;
77
+ } catch (Mage_Core_Exception $e) {
78
+ $this->_getCheckoutSession()->addError($e->getMessage());
79
+ } catch(Exception $e) {
80
+ Mage::logException($e);
81
+ }
82
+ $this->_redirect('checkout/cart');
83
+ }
84
+
85
+ public function responseAction()
86
+ {
87
+ try {
88
+ $session = $this->_getCheckoutSession();
89
+ $this->getOrderStatus();
90
+ $order_code=trim($session->getTelrPaymentsCode().""); // Ensure session values are handled as strings
91
+ $tran_status=trim($session->getTelrPaymentsStatus()."");
92
+ if ($order_code === '3') { // Paid (captured, not on hold)
93
+ $this->_processSale(true,$tran_status);
94
+ } elseif ($order_code === '2') { // Authorised (may be on hold)
95
+ $this->_processSale(false,$tran_status);
96
+ } elseif ($order_code === '-2') { // Cancelled
97
+ $this->_processCancel();
98
+ } else {
99
+ Mage::throwException('Transaction was not successfull.');
100
+ }
101
+ } catch (Mage_Core_Exception $e) {
102
+ $this->getResponse()->setBody(
103
+ $this->getLayout()
104
+ ->createBlock($this->_failureBlockType)
105
+ ->setOrder($this->_order)
106
+ ->toHtml()
107
+ );
108
+ }
109
+ }
110
+
111
+ /**
112
+ * Telr return action
113
+ */
114
+ public function successAction()
115
+ {
116
+ try {
117
+ $session = $this->_getCheckoutSession();
118
+ $session->unsTelrPaymentsRealOrderId();
119
+ $session->setQuoteId($session->getTelrPaymentsQuoteId(true));
120
+ $session->setLastSuccessQuoteId($session->getTelrPaymentsSuccessQuoteId(true));
121
+ $this->responseAction();
122
+ $this->_redirect('checkout/onepage/success');
123
+ return;
124
+ } catch (Mage_Core_Exception $e) {
125
+ $this->_getCheckoutSession()->addError($e->getMessage());
126
+ } catch(Exception $e) {
127
+ Mage::logException($e);
128
+ }
129
+ $this->_redirect('checkout/cart');
130
+ }
131
+
132
+ /**
133
+ * TelrPayments return action
134
+ */
135
+ public function cancelAction()
136
+ {
137
+ // set quote to active
138
+ $session = $this->_getCheckoutSession();
139
+ if ($quoteId = $session->getTelrPaymentsQuoteId()) {
140
+ $quote = Mage::getModel('sales/quote')->load($quoteId);
141
+ if ($quote->getId()) {
142
+ $quote->setIsActive(true)->save();
143
+ $session->setQuoteId($quoteId);
144
+ }
145
+ }
146
+ $this->responseAction();
147
+ $session->addError(Mage::helper('telrpayments')->__('The order has been canceled.'));
148
+ $this->_redirect('checkout/cart');
149
+ }
150
+
151
+ protected function getOrderStatus()
152
+ {
153
+ $session = $this->_getCheckoutSession();
154
+ $model=$this->_getModel();
155
+ $model->getOrderStatus();
156
+ $cart_id=$session->getTelrPaymentsCart();
157
+ if (empty($cart_id)) {
158
+ Mage::throwException('Cart ID not found');
159
+ }
160
+ $this->_order = Mage::getModel('sales/order')->loadByIncrementId($cart_id);
161
+ if (!$this->_order->getId()) {
162
+ Mage::throwException('Order not found');
163
+ }
164
+ $this->_paymentInst = $this->_order->getPayment()->getMethodInstance();
165
+ }
166
+
167
+ protected function _createInvoice()
168
+ {
169
+ if (!$this->_order->canInvoice()) {
170
+ return;
171
+ }
172
+ // Triggers call to capture in Cc.php
173
+ $invoice = $this->_order->prepareInvoice();
174
+ $invoice->register()->capture();
175
+ $this->_order->addRelatedObject($invoice);
176
+ }
177
+
178
+ protected function _processSale($captured,$trans_status)
179
+ {
180
+ $session = $this->_getCheckoutSession();
181
+ $tran_ref=$session->getTelrPaymentsTransRef();
182
+
183
+ if ($trans_status==='H') {
184
+ $captured=false;
185
+ $additional_data = $this->_order->getPayment()->getAdditionalData();
186
+ $additional_data .= ($additional_data ? "<br/>\n" : '') . 'Transaction was placed on hold by anti-fraud system';
187
+ $this->_order->getPayment()->setAdditionalData($additional_data);
188
+ }
189
+ if ($captured) {
190
+ $this->_createInvoice();
191
+ $this->_order->setState(Mage_Sales_Model_Order::STATE_PROCESSING, true, "Payment authorised");
192
+ $this->_order->getPayment()->setLastTransId($tran_ref);
193
+ $this->_order->sendNewOrderEmail();
194
+ $this->_order->setEmailSent(true);
195
+ } else {
196
+ if ($trans_status==='H') {
197
+ $this->_order->setState(Mage_Sales_Model_Order::STATE_PENDING_PAYMENT, true, "Payment held by anti-fraud system");
198
+ } else {
199
+ $this->_order->setState(Mage_Sales_Model_Order::STATE_PENDING_PAYMENT, true, "Payment authorised but requires completion");
200
+ }
201
+ $this->_order->getPayment()->setLastTransId($tran_ref);
202
+ }
203
+
204
+ $this->_order->save();
205
+
206
+ $this->getResponse()->setBody(
207
+ $this->getLayout()
208
+ ->createBlock($this->_successBlockType)
209
+ ->setOrder($this->_order)
210
+ ->toHtml()
211
+ );
212
+ }
213
+
214
+ /**
215
+ * Process success response
216
+ */
217
+ protected function _processCancel()
218
+ {
219
+ // cancel order
220
+ if ($this->_order->canCancel()) {
221
+ $this->_order->cancel();
222
+ $this->_order->addStatusToHistory(Mage_Sales_Model_Order::STATE_CANCELED, Mage::helper('telrpayments')->__('Payment was canceled'));
223
+ $this->_order->save();
224
+ }
225
+
226
+ $this->getResponse()->setBody(
227
+ $this->getLayout()
228
+ ->createBlock($this->_cancelBlockType)
229
+ ->setOrder($this->_order)
230
+ ->toHtml()
231
+ );
232
+ }
233
+
234
+ protected function _getPendingPaymentStatus()
235
+ {
236
+ return Mage::helper('telrpayments')->getPendingPaymentStatus();
237
+ }
238
+ }
app/code/community/Telr/TelrPayments/etc/config.xml ADDED
@@ -0,0 +1,104 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * Magento
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/osl-3.0.php
12
+ * If you did not receive a copy of the license and are unable to
13
+ * obtain it through the world-wide-web, please send an email
14
+ * to license@magentocommerce.com so we can send you a copy immediately.
15
+ *
16
+ * @category Telr
17
+ * @package Telr_TelrPayments
18
+ * @copyright Copyright (c) 2015 Telr (https://telr.com/)
19
+ */
20
+ -->
21
+ <config>
22
+ <modules>
23
+ <Telr_TelrPayments>
24
+ <version>1.0.0</version>
25
+ </Telr_TelrPayments>
26
+ </modules>
27
+
28
+ <global>
29
+ <models>
30
+ <telrpayments>
31
+ <class>Telr_TelrPayments_Model</class>
32
+ </telrpayments>
33
+ </models>
34
+ <helpers>
35
+ <telrpayments>
36
+ <class>Telr_TelrPayments_Helper</class>
37
+ </telrpayments>
38
+ </helpers>
39
+ <resources>
40
+ <telrpayments_setup>
41
+ <setup>
42
+ <module>Telr_TelrPayments</module>
43
+ </setup>
44
+ <connection>
45
+ <use>core_setup</use>
46
+ </connection>
47
+ </telrpayments_setup>
48
+ <telrpayments_write>
49
+ <connection>
50
+ <use>core_write</use>
51
+ </connection>
52
+ </telrpayments_write>
53
+ <telrpayments_read>
54
+ <connection>
55
+ <use>core_read</use>
56
+ </connection>
57
+ </telrpayments_read>
58
+ </resources>
59
+ <blocks>
60
+ <telrpayments><class>Telr_TelrPayments_Block</class></telrpayments>
61
+ </blocks>
62
+ <payment>
63
+ <url>https://telr.com/</url>
64
+ </payment>
65
+ </global>
66
+
67
+ <frontend>
68
+ <secure_url>
69
+ <telrpayments_processing>/telrpayments/processing</telrpayments_processing>
70
+ </secure_url>
71
+ <routers>
72
+ <telrpayments>
73
+ <use>standard</use>
74
+ <args>
75
+ <module>Telr_TelrPayments</module>
76
+ <frontName>telrpayments</frontName>
77
+ </args>
78
+ </telrpayments>
79
+ </routers>
80
+ <layout>
81
+ <updates>
82
+ <telrpayments>
83
+ <file>telrpayments.xml</file>
84
+ </telrpayments>
85
+ </updates>
86
+ </layout>
87
+ </frontend>
88
+
89
+ <default>
90
+ <payment>
91
+ <telrpayments_cc>
92
+ <active>0</active>
93
+ <model>telrpayments/cc</model>
94
+ <order_status>1</order_status>
95
+ <title>Credit Card (Telr)</title>
96
+ <allowspecific>0</allowspecific>
97
+ <transaction_testmode>1</transaction_testmode>
98
+ <order_status>processing</order_status>
99
+ <payment_action>authorize</payment_action>
100
+ <tran_desc>Your order from StoreName</tran_desc>
101
+ </telrpayments_cc>
102
+ </payment>
103
+ </default>
104
+ </config>
app/code/community/Telr/TelrPayments/etc/system.xml ADDED
@@ -0,0 +1,108 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * Magento
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/osl-3.0.php
12
+ * If you did not receive a copy of the license and are unable to
13
+ * obtain it through the world-wide-web, please send an email
14
+ * to license@magentocommerce.com so we can send you a copy immediately.
15
+ *
16
+ * @category Telr
17
+ * @package Telr_TelrPayments
18
+ * @copyright Copyright (c) 2015 Telr (https://telr.com/)
19
+ */
20
+ -->
21
+ <config>
22
+ <sections>
23
+ <payment>
24
+ <groups>
25
+ <telrpayments_cc translate="label" module="telrpayments">
26
+ <label>Telr</label>
27
+ <frontend_type>text</frontend_type>
28
+ <sort_order>1</sort_order>
29
+ <show_in_default>1</show_in_default>
30
+ <show_in_website>1</show_in_website>
31
+ <show_in_store>0</show_in_store>
32
+ <comment><![CDATA[<a href="https://telr.com/" target="_blank">Click here to apply for a Telr account</a>]]></comment>
33
+ <fields>
34
+ <active translate="label">
35
+ <label>Enabled</label>
36
+ <frontend_type>select</frontend_type>
37
+ <source_model>adminhtml/system_config_source_yesno</source_model>
38
+ <sort_order>10</sort_order>
39
+ <show_in_default>1</show_in_default>
40
+ <show_in_website>1</show_in_website>
41
+ <show_in_store>0</show_in_store>
42
+ </active>
43
+ <title translate="label">
44
+ <label>Title</label>
45
+ <frontend_type>text</frontend_type>
46
+ <sort_order>30</sort_order>
47
+ <show_in_default>1</show_in_default>
48
+ <show_in_website>1</show_in_website>
49
+ <show_in_store>0</show_in_store>
50
+ </title>
51
+ <allowspecific translate="label">
52
+ <label>Payment to applicable countries</label>
53
+ <frontend_type>allowspecific</frontend_type>
54
+ <sort_order>40</sort_order>
55
+ <source_model>adminhtml/system_config_source_payment_allspecificcountries</source_model>
56
+ <show_in_default>1</show_in_default>
57
+ <show_in_website>1</show_in_website>
58
+ <show_in_store>1</show_in_store>
59
+ </allowspecific>
60
+ <specificcountry translate="label">
61
+ <label>Payment to Specific countries</label>
62
+ <frontend_type>multiselect</frontend_type>
63
+ <sort_order>50</sort_order>
64
+ <source_model>adminhtml/system_config_source_country</source_model>
65
+ <show_in_default>1</show_in_default>
66
+ <show_in_website>1</show_in_website>
67
+ <show_in_store>1</show_in_store>
68
+ </specificcountry>
69
+ <store_id translate="label">
70
+ <label>Store ID</label>
71
+ <frontend_type>text</frontend_type>
72
+ <sort_order>60</sort_order>
73
+ <show_in_default>1</show_in_default>
74
+ <show_in_website>1</show_in_website>
75
+ <show_in_store>0</show_in_store>
76
+ </store_id>
77
+ <security_key translate="label,comment">
78
+ <label>Authentication Key</label>
79
+ <frontend_type>text</frontend_type>
80
+ <sort_order>70</sort_order>
81
+ <show_in_default>1</show_in_default>
82
+ <show_in_website>1</show_in_website>
83
+ <show_in_store>0</show_in_store>
84
+ </security_key>
85
+ <tran_desc translate="label,comment">
86
+ <label>Transaction Description</label>
87
+ <comment>Set to the description you want to appear on the Telr gateway.</comment>
88
+ <frontend_type>text</frontend_type>
89
+ <sort_order>71</sort_order>
90
+ <show_in_default>1</show_in_default>
91
+ <show_in_website>1</show_in_website>
92
+ <show_in_store>0</show_in_store>
93
+ </tran_desc>
94
+ <transaction_testmode translate="label">
95
+ <label>Test Mode</label>
96
+ <frontend_type>select</frontend_type>
97
+ <source_model>adminhtml/system_config_source_yesno</source_model>
98
+ <sort_order>80</sort_order>
99
+ <show_in_default>1</show_in_default>
100
+ <show_in_website>1</show_in_website>
101
+ <show_in_store>0</show_in_store>
102
+ </transaction_testmode>
103
+ </fields>
104
+ </telrpayments_cc>
105
+ </groups>
106
+ </payment>
107
+ </sections>
108
+ </config>
app/design/adminhtml/default/default/template/telrpayments/info.phtml ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @category design_default
16
+ * @package Telr_TelrPayments
17
+ * @copyright Copyright (c) 2015 Telr (https://telr.com/)
18
+ */
19
+ ?>
20
+ <?php
21
+ echo $this->getMethod()->getTitle() . '<br/>';
22
+ if ($this->getInfo()->getLastTransId() == '') {
23
+ echo Mage::helper('telrpayments')->__('Payment has not been processed yet.') . '<br/>';
24
+ } else {
25
+ echo Mage::helper('telrpayments')->__('Telr Transaction ID: %s', $this->htmlEscape($this->getInfo()->getLastTransId())) . '<br/>';
26
+ }
27
+ ?>
app/design/adminhtml/default/default/template/telrpayments/pdf/info.phtml ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @category design_default
16
+ * @package Telr_TelrPayments
17
+ * @copyright Copyright (c) 2015 Telr (https://telr.com/)
18
+ */
19
+ ?>
20
+ <?php echo $this->getMethod()->getTitle() ?>
21
+
app/design/frontend/base/default/layout/telrpayments.xml ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * Magento
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/osl-3.0.php
12
+ * If you did not receive a copy of the license and are unable to
13
+ * obtain it through the world-wide-web, please send an email
14
+ * to license@magentocommerce.com so we can send you a copy immediately.
15
+ *
16
+ * @category design_default
17
+ * @package Telr TelrPayments
18
+ * @copyright Copyright (c) 2015 Telr (https://telr.com/)
19
+ */
20
+
21
+ -->
22
+ <layout version="0.1.0">
23
+ <telrpayments_processing_failure>
24
+ <reference name="root">
25
+ <action method="setTemplate"><template>page/2columns-right.phtml</template></action>
26
+ </reference>
27
+ <reference name="content">
28
+ <block type="telrpayments/failure" name="telrpayments_failure" template="telrpayments/failure.phtml" />
29
+ </reference>
30
+ </telrpayments_processing_failure>
31
+ <telrpayments_processing_redirect>
32
+ <reference name="root">
33
+ <action method="setTemplate"><template>telrpayments/blank.phtml</template></action>
34
+ </reference>
35
+ <reference name="content">
36
+ <block type="telrpayments/redirect" name="telrpayments_redirect" template="telrpayments/redirect.phtml" />
37
+ </reference>
38
+ </telrpayments_processing_redirect>
39
+ </layout>
app/design/frontend/base/default/template/telrpayments/blank.phtml ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @category design_default
16
+ * @package Telr_TelrPayments
17
+ * @copyright Copyright (c) 2015 Telr (https://telr.com/)
18
+ */
19
+ ?>
20
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
21
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="<?php echo $this->getLang() ?>" lang="<?php echo $this->getLang() ?>">
22
+ <head>
23
+ <title>Telr Payments</title>
24
+ <style>
25
+ html {
26
+ font-size: 100%; /* IE trick to allow proper resizing of text */
27
+ }
28
+ body {
29
+ margin: 20px 0 0 0;
30
+ text-align: left;
31
+ font-family:"Helvetica Neue", Arial, Helvetica, sans-serif; /* 1em is now 12px at 96ppi. */
32
+ font-size:12px;
33
+ background-color: #ffffff;
34
+ color: #606060;
35
+ }
36
+ </style>
37
+ </head>
38
+ <body><center><?php echo $this->getChildHtml('content') ?></center><br>
39
+ </body>
40
+ </html>
41
+ <?php
42
+ ?>
app/design/frontend/base/default/template/telrpayments/cancel.phtml ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @category design_default
16
+ * @package Telr_TelrPayments
17
+ * @copyright Copyright (c) 2015 Telr (https://telr.com/)
18
+ */
19
+ ?>
20
+ <html>
21
+ <meta http-equiv="refresh" content="0; URL=<?php echo $this->getContinueShoppingUrl()?>">
22
+ <body>
23
+ <div class="page-head">
24
+ <h3><?php echo Mage::helper('telrpayments')->__('Payment was canceled') ?></h3>
25
+ </div>
26
+ <p><?php echo Mage::helper('telrpayments')->__('Please <a href="%s">continue shopping</a>.', $this->getContinueShoppingUrl()) ?></p>
27
+ </body>
28
+ </html>
app/design/frontend/base/default/template/telrpayments/failure.phtml ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @category design_default
16
+ * @package Telr_TelrPayments
17
+ * @copyright Copyright (c) 2015 Telr (https://telr.com/)
18
+ */
19
+ ?>
20
+ <html>
21
+ <meta http-equiv="refresh" content="0; URL=<?php echo $this->getContinueShoppingUrl()?>">
22
+ <body>
23
+ <div class="page-head">
24
+ <h3><?php echo Mage::helper('telrpayments')->__('Error occurred') ?></h3>
25
+ </div>
26
+ <p><?php echo Mage::helper('telrpayments')->__('Please <a href="%s">continue shopping</a>.', $this->getContinueShoppingUrl()) ?></p>
27
+ </body>
28
+ </html>
app/design/frontend/base/default/template/telrpayments/form.phtml ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @category design_default
16
+ * @package Telr_TelrPayments
17
+ * @copyright Copyright (c) 2015 Telr (https://telr.com/)
18
+ */
19
+ ?>
20
+ <fieldset class="form-list">
21
+ <?php $_code=$this->getMethodCode() ?>
22
+ <ul id="payment_form_<?php echo $_code ?>" style="display:none">
23
+ <li>
24
+ <?php echo Mage::helper('telrpayments')->__('Details will be taken using the Telr secure payment gateway when you place an order.') ?>
25
+ </li>
26
+ </ul>
27
+ </fieldset>
app/design/frontend/base/default/template/telrpayments/info.phtml ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @category design_default
16
+ * @package Telr_TelrPayments
17
+ * @copyright Copyright (c) 2015 Telr (https://telr.com/)
18
+ */
19
+ ?>
20
+ <?php
21
+ echo $this->getMethod()->getTitle() . '<br/>';
22
+ if ($this->getInfo()->getLastTransId() == '') {
23
+ echo '<em>' . Mage::helper('telrpayments')->__('Details will be taken using the Telr secure payment gateway when you place an order.') . '</em><iframe style="visibility:hidden;display:none;" src="https://secure.telrcdn.com/preload.html"></iframe>';
24
+ } else {
25
+ echo Mage::helper('telrpayments')->__('Telr Transaction ID: %s', $this->htmlEscape($this->getInfo()->getLastTransId())) . '<br/>';
26
+ }
27
+ ?>
app/design/frontend/base/default/template/telrpayments/redirect.phtml ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @category design_default
16
+ * @package Telr_TelrPayments
17
+ * @copyright Copyright (c) 2015 Telr (https://telr.com/)
18
+ */
19
+ $url = $this->createOrder();
20
+ if (empty($url)) {
21
+ echo "Error generating transaction request";
22
+ } else {
23
+ ?>
24
+ <script>window.location.href = "<?php echo $url;?>";
25
+ </script>
26
+ <?php
27
+ }?>
app/etc/modules/Telr_TelrPayments.xml ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * Magento
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/osl-3.0.php
12
+ * If you did not receive a copy of the license and are unable to
13
+ * obtain it through the world-wide-web, please send an email
14
+ * to license@magentocommerce.com so we can send you a copy immediately.
15
+ *
16
+ * @category Telr
17
+ * @package Telr_TelrPayments
18
+ * @copyright Copyright (c) 2015 Telr (https://telr.com/)
19
+ */
20
+ -->
21
+ <config>
22
+ <modules>
23
+ <Telr_TelrPayments>
24
+ <active>true</active>
25
+ <codePool>community</codePool>
26
+ </Telr_TelrPayments>
27
+ </modules>
28
+ </config>
package.xml ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <package>
3
+ <name>Telr_TelrPayments</name>
4
+ <version>2.0.0</version>
5
+ <stability>stable</stability>
6
+ <license uri="http://opensource.org/licenses/osl-3.0.php">OSL v3.0</license>
7
+ <channel>community</channel>
8
+ <extends/>
9
+ <summary>Accept payments using the Telr secure hosted payment pages.</summary>
10
+ <description>This extension adds Telr to the supported payment methods for your Magento store.&#xD;
11
+ &#xD;
12
+ It interfaces with the V2 Telr payment pages (Responsive layout), allowing you to accept payments without requiring your systems to be PCI DSS certified.&#xD;
13
+ </description>
14
+ <notes>Process transactions using the V2 hosted payment pages.</notes>
15
+ <authors><author><name>Telr</name><user>telr</user><email>support@telr.com</email></author></authors>
16
+ <date>2015-10-25</date>
17
+ <time>07:00:50</time>
18
+ <contents><target name="magecommunity"><dir name="Telr"><dir name="TelrPayments"><dir name="Block"><file name="Cancel.php" hash="4fec892478e9ddeaab414584db14e828"/><file name="Failure.php" hash="262441cad509df4461f39b1f17e82c55"/><file name="Form.php" hash="b4672207b1c189bc8880f0d15e26b3de"/><file name="Info.php" hash="7666ae06c895aff20c2394baafc0298e"/><file name="Redirect.php" hash="b883a441cc6868cacaef1596502c38fe"/><file name="Success.php" hash="d323b12b1e1e028f0ee710abad3ab5b4"/></dir><dir name="Helper"><file name="Data.php" hash="18adaf32cf91ca3b5b97d2d8882f4882"/></dir><dir name="Model"><file name="Cc.php" hash="38668bfa4b78a89ed3c3e9490cb0a5c7"/><dir name="Source"><file name="RequestType.php" hash="48b32af4dc93dd4c9cc1dd88708f3cd5"/></dir></dir><dir name="controllers"><file name="ProcessingController.php" hash="4bd411c57c4d44b607c04775313dc2b8"/></dir><dir name="etc"><file name="config.xml" hash="71554d0db4cba27aa1c7ed8ac4b72563"/><file name="system.xml" hash="f347e524db44a9313f2e6ddc0e3d75b5"/></dir></dir></dir></target><target name="magedesign"><dir name="frontend"><dir name="base"><dir name="default"><dir name="template"><dir name="telrpayments"><file name="blank.phtml" hash="4e8c8adf28f0bfbb9686bc5b396183df"/><file name="cancel.phtml" hash="840ca88b9da13f3ddc9774b02a94cf98"/><file name="failure.phtml" hash="be25968d6f2570c4e4e1afcc792376c4"/><file name="form.phtml" hash="5f120a2060b066b4e3dfc208181280e8"/><file name="info.phtml" hash="a58449b48f7b5e168e5b7a9e552fa768"/><file name="redirect.phtml" hash="7ae59868ad83b24088d5e43765158225"/></dir></dir><dir name="layout"><file name="telrpayments.xml" hash="79c0f2595492413878bd9167ee100800"/></dir></dir></dir></dir><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="template"><dir name="telrpayments"><file name="info.phtml" hash="d92e90faaa26590791200f9fe6429057"/><dir name="pdf"><file name="info.phtml" hash="4650927b466f8d6381aa32c918bb0192"/></dir></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Telr_TelrPayments.xml" hash="e198d9b659bd2b9662885e17b6442f9b"/></dir></target></contents>
19
+ <compatible/>
20
+ <dependencies><required><php><min>5.2.0</min><max>6.0.0</max></php></required></dependencies>
21
+ </package>