BBSNetAxept_Norway - Version 1.3.2

Version Notes

This extension uses the BBS NetAxept API.

Download this release

Release Info

Developer Magento Core Team
Extension BBSNetAxept_Norway
Version 1.3.2
Comparing to
See all releases


Version 1.3.2

Files changed (25) hide show
  1. app/code/community/Trollweb/BBSNetAxept/Block/Form.php +27 -0
  2. app/code/community/Trollweb/BBSNetAxept/Block/PaymentInfo.php +29 -0
  3. app/code/community/Trollweb/BBSNetAxept/Block/Redirect.php +62 -0
  4. app/code/community/Trollweb/BBSNetAxept/Helper/Data.php +23 -0
  5. app/code/community/Trollweb/BBSNetAxept/Model/Api/Bbs.php +317 -0
  6. app/code/community/Trollweb/BBSNetAxept/Model/Api/BbsRequest.php +62 -0
  7. app/code/community/Trollweb/BBSNetAxept/Model/Api/SoapClient.php +26 -0
  8. app/code/community/Trollweb/BBSNetAxept/Model/BBSNetterminal/Debug.php +26 -0
  9. app/code/community/Trollweb/BBSNetAxept/Model/BBSNetterminal/Language.php +31 -0
  10. app/code/community/Trollweb/BBSNetAxept/Model/BBSNetterminal/PaymentAction.php +30 -0
  11. app/code/community/Trollweb/BBSNetAxept/Model/BBSNetterminal/Request.php +23 -0
  12. app/code/community/Trollweb/BBSNetAxept/Model/BBSNetterminal/Result.php +23 -0
  13. app/code/community/Trollweb/BBSNetAxept/Model/Entity/Setup.php +22 -0
  14. app/code/community/Trollweb/BBSNetAxept/Model/WithGUI.php +355 -0
  15. app/code/community/Trollweb/BBSNetAxept/controllers/ReturnController.php +69 -0
  16. app/code/community/Trollweb/BBSNetAxept/etc/config.xml +96 -0
  17. app/code/community/Trollweb/BBSNetAxept/etc/system.xml +183 -0
  18. app/code/community/Trollweb/BBSNetAxept/sql/bbsnetaxept_setup/mysql4-install-0.1.0.php +33 -0
  19. app/code/community/Trollweb/BBSNetAxept/sql/bbsnetaxept_setup/mysql4-uninstall-0.1.0.php +29 -0
  20. app/design/adminhtml/default/default/template/bbsnetaxept/form.phtml +27 -0
  21. app/design/adminhtml/default/default/template/bbsnetaxept/paymentinfo.phtml +26 -0
  22. app/design/frontend/default/default/template/bbsnetaxept/form.phtml +27 -0
  23. app/design/frontend/default/default/template/bbsnetaxept/paymentinfo.phtml +20 -0
  24. app/etc/modules/Trollweb_BBSNetAxept.xml +29 -0
  25. package.xml +20 -0
app/code/community/Trollweb/BBSNetAxept/Block/Form.php ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * BBS NetAxept, Norge
4
+ *
5
+ * LICENSE AND USAGE INFORMATION
6
+ * It is NOT allowed to modify, copy or re-sell this file or any
7
+ * part of it. Please contact us by email at post@trollweb.no or
8
+ * visit us at www.trollweb.no/bbs if you have any questions about this.
9
+ * Trollweb is not responsible for any problems caused by this file.
10
+ *
11
+ * Visit us at http://www.trollweb.no today!
12
+ *
13
+ * @category Trollweb
14
+ * @package Trollweb_BBSNetAxept
15
+ * @copyright Copyright (c) 2009 Trollweb (http://www.trollweb.no)
16
+ * @license Single-site License
17
+ *
18
+ */
19
+
20
+ class Trollweb_BBSNetAxept_Block_Form extends Mage_Payment_Block_Form
21
+ {
22
+ protected function _construct()
23
+ {
24
+ $this->setTemplate('bbsnetaxept/form.phtml');
25
+ parent::_construct();
26
+ }
27
+ }
app/code/community/Trollweb/BBSNetAxept/Block/PaymentInfo.php ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * BBS NetAxept, Norge
4
+ *
5
+ * LICENSE AND USAGE INFORMATION
6
+ * It is NOT allowed to modify, copy or re-sell this file or any
7
+ * part of it. Please contact us by email at post@trollweb.no or
8
+ * visit us at www.trollweb.no/bbs if you have any questions about this.
9
+ * Trollweb is not responsible for any problems caused by this file.
10
+ *
11
+ * Visit us at http://www.trollweb.no today!
12
+ *
13
+ * @category Trollweb
14
+ * @package Trollweb_BBSNetAxept
15
+ * @copyright Copyright (c) 2009 Trollweb (http://www.trollweb.no)
16
+ * @license Single-site License
17
+ *
18
+ */
19
+
20
+ class Trollweb_BBSNetAxept_Block_PaymentInfo extends Mage_Payment_Block_Info
21
+ {
22
+
23
+ protected function _construct()
24
+ {
25
+ parent::_construct();
26
+ $this->setTemplate('bbsnetaxept/paymentinfo.phtml');
27
+ }
28
+
29
+ }
app/code/community/Trollweb/BBSNetAxept/Block/Redirect.php ADDED
@@ -0,0 +1,62 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * BBS NetAxept, Norge
4
+ *
5
+ * LICENSE AND USAGE INFORMATION
6
+ * It is NOT allowed to modify, copy or re-sell this file or any
7
+ * part of it. Please contact us by email at post@trollweb.no or
8
+ * visit us at www.trollweb.no/bbs if you have any questions about this.
9
+ * Trollweb is not responsible for any problems caused by this file.
10
+ *
11
+ * Visit us at http://www.trollweb.no today!
12
+ *
13
+ * @category Trollweb
14
+ * @package Trollweb_BBSNetAxept
15
+ * @copyright Copyright (c) 2009 Trollweb (http://www.trollweb.no)
16
+ * @license Single-site License
17
+ *
18
+ */
19
+
20
+ class Trollweb_BBSNetAxept_Block_Redirect extends Mage_Core_Block_Abstract
21
+ {
22
+ protected function _toHtml()
23
+ {
24
+ $standard = Mage::getModel('BBSNetAxept/withGUI');
25
+
26
+ $form = new Varien_Data_Form();
27
+ $form->setAction($standard->getBBSUrl())
28
+ ->setId('BBS_WithGUI_checkout')
29
+ ->setName('BBS_WithGUI_checkout')
30
+ ->setMethod('POST')
31
+ ->setUseContainer(true);
32
+
33
+ if ($standard->useInternalGUI()) {
34
+ $ccInfo = $standard->getCheckout()->getCardInfo();
35
+ if (!($ccInfo instanceof Varien_Object)) {
36
+ $ccInfo = new Varien_Object($ccInfo);
37
+ }
38
+
39
+ switch ($ccInfo->getCcType()) {
40
+ case 'VI': $prefix = 'v'; break;
41
+ case 'MC': $prefix = 'm'; break;
42
+ case 'AE': $prefix = 'a'; break;
43
+ case 'DI': $prefix = 'd'; break;
44
+ default: $prefix = 'v'; break;
45
+ }
46
+
47
+ $form->addField($prefix.'a','hidden', array('name' => $prefix.'a', "value" => $ccInfo->getCcNumber()));
48
+ $form->addField($prefix.'m','hidden', array('name' => $prefix.'m', "value" => sprintf("%02u",(int)$ccInfo->getCcExpMonth())));
49
+ $form->addField($prefix.'y','hidden', array('name' => $prefix.'y', "value" => substr($ccInfo->getCcExpYear(),-2)));
50
+ $form->addField($prefix.'c','hidden', array('name' => $prefix.'c', "value" => $ccInfo->getCcCid()));
51
+ }
52
+
53
+ $form->addField('BBSePay_transaction','hidden', array("name"=>'BBSePay_transaction', "value"=>$standard->getCheckout()->getBBSTransKey()));
54
+ $html = '<html><body>';
55
+ $html.= $this->__('You will be redirected to BBS NetAxept in a few seconds.');
56
+ $html.= $form->toHtml();
57
+ $html.= '<script type="text/javascript">document.getElementById("BBS_WithGUI_checkout").submit();</script>';
58
+ $html.= '</body></html>';
59
+
60
+ return $html;
61
+ }
62
+ }
app/code/community/Trollweb/BBSNetAxept/Helper/Data.php ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * BBS NetAxept, Norge
4
+ *
5
+ * LICENSE AND USAGE INFORMATION
6
+ * It is NOT allowed to modify, copy or re-sell this file or any
7
+ * part of it. Please contact us by email at post@trollweb.no or
8
+ * visit us at www.trollweb.no/bbs if you have any questions about this.
9
+ * Trollweb is not responsible for any problems caused by this file.
10
+ *
11
+ * Visit us at http://www.trollweb.no today!
12
+ *
13
+ * @category Trollweb
14
+ * @package Trollweb_BBSNetAxept
15
+ * @copyright Copyright (c) 2009 Trollweb (http://www.trollweb.no)
16
+ * @license Single-site License
17
+ *
18
+ */
19
+
20
+ class Trollweb_BBSNetAxept_Helper_Data extends Mage_Core_Helper_Abstract
21
+ {
22
+
23
+ }
app/code/community/Trollweb/BBSNetAxept/Model/Api/Bbs.php ADDED
@@ -0,0 +1,317 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * BBS NetAxept, Norge
4
+ *
5
+ * LICENSE AND USAGE INFORMATION
6
+ * It is NOT allowed to modify, copy or re-sell this file or any
7
+ * part of it. Please contact us by email at post@trollweb.no or
8
+ * visit us at www.trollweb.no/bbs if you have any questions about this.
9
+ * Trollweb is not responsible for any problems caused by this file.
10
+ *
11
+ * Visit us at http://www.trollweb.no today!
12
+ *
13
+ * @category Trollweb
14
+ * @package Trollweb_BBSNetAxept
15
+ * @copyright Copyright (c) 2009 Trollweb (http://www.trollweb.no)
16
+ * @license Single-site License
17
+ *
18
+ */
19
+
20
+
21
+ /**
22
+ * BBS Api
23
+ */
24
+ class Trollweb_BBSNetAxept_Model_Api_Bbs extends Varien_Object
25
+ {
26
+
27
+ protected $_result;
28
+
29
+ /**
30
+ * Auth with BBS and return the key.
31
+ *
32
+ * @param none
33
+ * @return array
34
+ */
35
+ public function getTransKey() {
36
+ $result = false;
37
+
38
+ $bbsClient = new Trollweb_BBSNetAxept_Model_Api_SoapClient($this->getWsdlUrl());
39
+
40
+ try {
41
+ $request = array("token" => $this->getMerchantToken(),"merchantId" => $this->getMerchantId(), "request" => $this->getRequest());
42
+ $soapResult = $bbsClient->Setup($request);
43
+ if (preg_match("/VALUE=\"([^\"]+)\"/",$soapResult->SetupResult,$match)) {
44
+ $result = $match[1];
45
+ }
46
+ else {
47
+ $this->setError(true);
48
+ $this->setErrorMessage('Error parsing soap result.');
49
+ }
50
+ }
51
+ catch (Exception $e) {
52
+ $this->setError(true);
53
+ $this->setErrorMessage($e->faultstring);
54
+ }
55
+
56
+ return $result;
57
+ }
58
+
59
+ /**
60
+ * Process the request from BBS.
61
+ *
62
+ * @param String $BBSTransKey
63
+ * @return String TransactionId
64
+ */
65
+ public function Process($BBSTransKey) {
66
+ $this->setError(false);
67
+ $result = '__';
68
+ $bbsClient = new Trollweb_BBSNetAxept_Model_Api_SoapClient($this->getWsdlUrl());
69
+
70
+ $params = array(
71
+ "merchantId" => $this->getMerchantId(),
72
+ "token" => $this->getMerchantToken(),
73
+ "transactionString" => $BBSTransKey,
74
+ );
75
+
76
+ try {
77
+ $soapResult = $bbsClient->ProcessSetup($params);
78
+
79
+ /*
80
+ * -- Result object --
81
+ object(stdClass)[58]
82
+ public 'ProcessSetupResult' =>
83
+ object(stdClass)[64]
84
+ public 'AuthenticatedStatus' => string 'N' (length=1)
85
+ public 'AuthenticatedWith' => string '3-D Secure' (length=10)
86
+ public 'AuthorizationCode' => null
87
+ public 'AuthorizationId' => null
88
+ public 'ExecutionTime' => string '2008-05-18T17:04:48.578125+02:00' (length=32)
89
+ public 'IssuerCountry' => string 'NO' (length=2)
90
+ public 'IssuerCountryCode' => string '578' (length=3)
91
+ public 'IssuerId' => string '3' (length=1)
92
+ public 'MerchantId' => string '200906' (length=6)
93
+ public 'ResponseCode' => string 'OK' (length=2)
94
+ public 'ResponseSource' => null
95
+ public 'ResponseText' => null
96
+ public 'SessionId' => string '31' (length=2)
97
+ public 'SessionNumber' => null
98
+ public 'TransactionId' => string '100000194_483046b1770f3' (length=23)
99
+ *
100
+ */
101
+
102
+ $this->Result()->setAuthenticatedStatus($soapResult->ProcessSetupResult->AuthenticatedStatus);
103
+ $this->Result()->setAuthenticatedWith($soapResult->ProcessSetupResult->AuthenticatedWith);
104
+ $this->Result()->setAuthorizationCode($soapResult->ProcessSetupResult->AuthorizationCode);
105
+ $this->Result()->setAuthorizationId($soapResult->ProcessSetupResult->AuthorizationId);
106
+ $this->Result()->setIssuerCountry($soapResult->ProcessSetupResult->IssuerCountry);
107
+ $this->Result()->setIssuerCountryCode($soapResult->ProcessSetupResult->IssuerCountryCode);
108
+ $this->Result()->setIssuerId($soapResult->ProcessSetupResult->IssuerId);
109
+ $this->Result()->setResponseCode($soapResult->ProcessSetupResult->ResponseCode);
110
+ $this->Result()->setSessionId($soapResult->ProcessSetupResult->SessionId);
111
+ $this->Result()->setTransactionId($soapResult->ProcessSetupResult->TransactionId);
112
+
113
+ $result = $soapResult->ProcessSetupResult->TransactionId;
114
+ }
115
+ catch (Exception $e) {
116
+ $this->setError(true);
117
+ $this->setErrorMessage($e->faultstring);
118
+ $this->setErrorCode(99);
119
+
120
+ if (preg_match('/Response code: ([0-9]+)/',$e->faultstring,$match)) {
121
+ $this->setErrorCode($match[1]);
122
+ }
123
+ }
124
+
125
+ return $result;
126
+ }
127
+
128
+ /**
129
+ * Process the request from BBS.
130
+ *
131
+ * @param String $TransactionId
132
+ * @return Trollweb_BBSNetAxept_Model_BBSNetterminal_Result
133
+ */
134
+ public function auth($TransactionId) {
135
+
136
+ $result = '__';
137
+ $bbsClient = new Trollweb_BBSNetAxept_Model_Api_SoapClient($this->getWsdlUrl());
138
+ $params = array(
139
+ "merchantId" => $this->getMerchantId(),
140
+ "token" => $this->getMerchantToken(),
141
+ "transactionId" => $TransactionId,
142
+ );
143
+
144
+ try {
145
+ $soapResult = $bbsClient->Auth($params);
146
+
147
+ /*
148
+ * --- Result Object --
149
+ object(stdClass)[64]
150
+ public 'AuthResult' =>
151
+ object(stdClass)[60]
152
+ public 'AuthenticatedStatus' => null
153
+ public 'AuthenticatedWith' => null
154
+ public 'AuthorizationCode' => null
155
+ public 'AuthorizationId' => string '000889' (length=6)
156
+ public 'ExecutionTime' => string '2008-05-18T17:04:48.859375+02:00' (length=32)
157
+ public 'IssuerCountry' => null
158
+ public 'IssuerCountryCode' => null
159
+ public 'IssuerId' => string '3' (length=1)
160
+ public 'MerchantId' => string '4' (length=1)
161
+ public 'ResponseCode' => string 'OK' (length=2)
162
+ public 'ResponseSource' => null
163
+ public 'ResponseText' => null
164
+ public 'SessionId' => null
165
+ public 'SessionNumber' => string '837' (length=3)
166
+ public 'TransactionId' => string '100000194_483046b1770f3' (length=23)
167
+ */
168
+
169
+ $this->Result()->setAuthorizationId($soapResult->AuthResult->AuthorizationId);
170
+ $this->Result()->setIssuerId($soapResult->AuthResult->IssuerId);
171
+ $this->Result()->setResponseCode($soapResult->AuthResult->ResponseCode);
172
+ $this->Result()->setSessionNumber($soapResult->AuthResult->SessionNumber);
173
+ $this->Result()->setTransactionId($soapResult->AuthResult->TransactionId);
174
+ $result = $soapResult->AuthResult->TransactionId;
175
+ }
176
+ catch (Exception $e) {
177
+ $this->setError(true);
178
+ $this->setErrorMessage($e->faultstring);
179
+ $this->setErrorCode(99);
180
+
181
+ if (preg_match('/Response code: ([0-9]+)/',$e->faultstring,$match)) {
182
+ $this->setErrorCode($match[1]);
183
+ }
184
+ }
185
+
186
+ return $result;
187
+ }
188
+
189
+ /**
190
+ * Capture from BBS.
191
+ *
192
+ * @param String $TransactionId, Integer $amount, [String $description]
193
+ * @return Trollweb_BBSNetAxept_Model_BBSNetterminal_Result
194
+ */
195
+ public function capture($TransactionId, $amount, $description='') {
196
+ $result = '__';
197
+ $bbsClient = new Trollweb_BBSNetAxept_Model_Api_SoapClient($this->getWsdlUrl());
198
+ $params = array(
199
+ "merchantId" => $this->getMerchantId(),
200
+ "token" => $this->getMerchantToken(),
201
+ "transactionId" => $TransactionId,
202
+ "transactionAmount" => $amount,
203
+ "description" => $description
204
+ );
205
+
206
+ try {
207
+ $soapResult = $bbsClient->Capture($params);
208
+
209
+ /*
210
+ * -- Result Object --
211
+ object(stdClass)[850]
212
+ public 'CaptureResult' =>
213
+ object(stdClass)[834]
214
+ public 'AuthenticatedStatus' => null
215
+ public 'AuthenticatedWith' => null
216
+ public 'AuthorizationCode' => null
217
+ public 'AuthorizationId' => null
218
+ public 'ExecutionTime' => string '2008-06-04T19:40:55.34375+02:00' (length=31)
219
+ public 'IssuerCountry' => null
220
+ public 'IssuerCountryCode' => null
221
+ public 'IssuerId' => string '3' (length=1)
222
+ public 'MerchantId' => string '4' (length=1)
223
+ public 'ResponseCode' => string 'OK' (length=2)
224
+ public 'ResponseSource' => null
225
+ public 'ResponseText' => null
226
+ public 'SessionId' => null
227
+ public 'SessionNumber' => string '837' (length=3)
228
+ public 'TransactionId' => string '4846d45c6ea1f' (length=13)
229
+ */
230
+
231
+ $this->Result()->setIssuerId($soapResult->CaptureResult->IssuerId);
232
+ $result = $soapResult->CaptureResult->TransactionId;
233
+ }
234
+ catch (Exception $e) {
235
+ $this->setError(true);
236
+ $this->setErrorMessage($e->faultstring);
237
+ $this->setErrorCode(99);
238
+
239
+ if (preg_match('/Response code: ([0-9]+)/',$e->faultstring,$match)) {
240
+ $this->setErrorCode($match[1]);
241
+ }
242
+ }
243
+
244
+ return $result;
245
+ }
246
+
247
+ /**
248
+ * Refund with BBS.
249
+ *
250
+ * @param String $TransactionId, Integer $amount, [String $description]
251
+ * @return Trollweb_BBSNetAxept_Model_BBSNetterminal_Result
252
+ */
253
+ public function refund($TransactionId, $amount, $description='') {
254
+
255
+ $result = '__';
256
+ $bbsClient = new Trollweb_BBSNetAxept_Model_Api_SoapClient($this->getWsdlUrl());
257
+ $params = array(
258
+ "merchantId" => $this->getMerchantId(),
259
+ "token" => $this->getMerchantToken(),
260
+ "transactionId" => $TransactionId,
261
+ "transactionAmount" => $amount,
262
+ "description" => $description
263
+ );
264
+
265
+ try {
266
+ $soapResult = $bbsClient->Credit($params);
267
+
268
+ $result = $soapResult->CreditResult->TransactionId;
269
+ }
270
+ catch (Exception $e) {
271
+ $this->setError(true);
272
+ $this->setErrorMessage($e->faultstring);
273
+ $this->setErrorCode(99);
274
+
275
+ if (preg_match('/Response code: ([0-9]+)/',$e->faultstring,$match)) {
276
+ $this->setErrorCode($match[1]);
277
+ }
278
+ }
279
+
280
+ return $result;
281
+ }
282
+
283
+ public function Result() {
284
+ if (!is_object($this->_result)) {
285
+ $this->_result = new Trollweb_BBSNetAxept_Model_BBSNetterminal_Result;
286
+ }
287
+
288
+ return $this->_result;
289
+ }
290
+
291
+ private function getRequest() {
292
+
293
+ // Set default norwegian language
294
+ if ($this->getLanguage() == false)
295
+ $this->setLanguage('no_NO');
296
+
297
+
298
+ $request = new Trollweb_BBSNetAxept_Model_Api_BbsRequest(
299
+ $this->getAmount(),
300
+ $this->getcurrencyCode(),
301
+ $this->getOrderDescription(),
302
+ $this->getOrderNumber(),
303
+ Mage::getUrl('bbsnetaxept/return/check',array('_secure' => true, '_query' => false, '_nosid' => true)),
304
+ ($this->getInternalGUI() ? 'M' : 'B'),
305
+ $this->getSessionId(),
306
+ $this->getTransactionId()
307
+ );
308
+
309
+ $request->Language = $this->getLanguage();
310
+ $request->CustomerEmail = $this->getCustomerEmail();
311
+ $request->CustomerPhoneNumber = $this->getCustomerPhoneNumber();
312
+
313
+ return $request;
314
+
315
+ }
316
+ }
317
+
app/code/community/Trollweb/BBSNetAxept/Model/Api/BbsRequest.php ADDED
@@ -0,0 +1,62 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * BBS NetAxept, Norge
4
+ *
5
+ * LICENSE AND USAGE INFORMATION
6
+ * It is NOT allowed to modify, copy or re-sell this file or any
7
+ * part of it. Please contact us by email at post@trollweb.no or
8
+ * visit us at www.trollweb.no/bbs if you have any questions about this.
9
+ * Trollweb is not responsible for any problems caused by this file.
10
+ *
11
+ * Visit us at http://www.trollweb.no today!
12
+ *
13
+ * @category Trollweb
14
+ * @package Trollweb_BBSNetAxept
15
+ * @copyright Copyright (c) 2009 Trollweb (http://www.trollweb.no)
16
+ * @license Single-site License
17
+ *
18
+ */
19
+
20
+ class Trollweb_BBSNetAxept_Model_Api_BbsRequest {
21
+
22
+ public $Amount;
23
+ public $CurrencyCode;
24
+ public $CustomerEmail;
25
+ public $CustomerPhoneNumber;
26
+ public $Description;
27
+ public $Language;
28
+ public $OrderDescription;
29
+ public $OrderNumber;
30
+ public $PanHash;
31
+ public $RecurringExpiryDate;
32
+ public $RecurringFrequency;
33
+ public $RecurringType;
34
+ public $RedirectUrl;
35
+ public $ServiceType;
36
+ public $SessionId;
37
+ public $TransactionId;
38
+
39
+ function Trollweb_BBSNetAxept_Model_Api_BbsRequest
40
+ (
41
+ $Amount,
42
+ $CurrencyCode,
43
+ $OrderDescription,
44
+ $OrderNumber,
45
+ $RedirectUrl,
46
+ $ServiceType, /* B : BBS Hosted UI ; M : Merchant Hosted UI ; C : Call Center Solution */
47
+ $SessionId,
48
+ $TransactionId
49
+ )
50
+ {
51
+ $this->Amount = $Amount;
52
+ $this->CurrencyCode = $CurrencyCode;
53
+ $this->OrderDescription = $OrderDescription;
54
+ $this->OrderNumber = $OrderNumber;
55
+ $this->RedirectUrl = $RedirectUrl;
56
+ $this->ServiceType = $ServiceType;
57
+ $this->SessionId = $SessionId;
58
+ $this->TransactionId = $TransactionId;
59
+ }
60
+
61
+ };
62
+
app/code/community/Trollweb/BBSNetAxept/Model/Api/SoapClient.php ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * BBS NetAxept, Norge
4
+ *
5
+ * LICENSE AND USAGE INFORMATION
6
+ * It is NOT allowed to modify, copy or re-sell this file or any
7
+ * part of it. Please contact us by email at post@trollweb.no or
8
+ * visit us at www.trollweb.no/bbs if you have any questions about this.
9
+ * Trollweb is not responsible for any problems caused by this file.
10
+ *
11
+ * Visit us at http://www.trollweb.no today!
12
+ *
13
+ * @category Trollweb
14
+ * @package Trollweb_BBSNetAxept
15
+ * @copyright Copyright (c) 2009 Trollweb (http://www.trollweb.no)
16
+ * @license Single-site License
17
+ *
18
+ */
19
+
20
+ /**
21
+ * BBS Soap Client
22
+ */
23
+ class Trollweb_BBSNetAxept_Model_Api_SoapClient extends SoapClient
24
+ {
25
+
26
+ }
app/code/community/Trollweb/BBSNetAxept/Model/BBSNetterminal/Debug.php ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * BBS NetAxept, Norge
4
+ *
5
+ * LICENSE AND USAGE INFORMATION
6
+ * It is NOT allowed to modify, copy or re-sell this file or any
7
+ * part of it. Please contact us by email at post@trollweb.no or
8
+ * visit us at www.trollweb.no/bbs if you have any questions about this.
9
+ * Trollweb is not responsible for any problems caused by this file.
10
+ *
11
+ * Visit us at http://www.trollweb.no today!
12
+ *
13
+ * @category Trollweb
14
+ * @package Trollweb_BBSNetAxept
15
+ * @copyright Copyright (c) 2009 Trollweb (http://www.trollweb.no)
16
+ * @license Single-site License
17
+ *
18
+ */
19
+
20
+ class Trollweb_BBSNetAxept_Model_BBSNetterminal_Debug extends Mage_Core_Model_Abstract
21
+ {
22
+ protected function _construct()
23
+ {
24
+ $this->_init('bbsnetaxept/BBSNetterminal_debug');
25
+ }
26
+ }
app/code/community/Trollweb/BBSNetAxept/Model/BBSNetterminal/Language.php ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * BBS NetAxept, Norge
4
+ *
5
+ * LICENSE AND USAGE INFORMATION
6
+ * It is NOT allowed to modify, copy or re-sell this file or any
7
+ * part of it. Please contact us by email at post@trollweb.no or
8
+ * visit us at www.trollweb.no/bbs if you have any questions about this.
9
+ * Trollweb is not responsible for any problems caused by this file.
10
+ *
11
+ * Visit us at http://www.trollweb.no today!
12
+ *
13
+ * @category Trollweb
14
+ * @package Trollweb_BBSNetAxept
15
+ * @copyright Copyright (c) 2009 Trollweb (http://www.trollweb.no)
16
+ * @license Single-site License
17
+ *
18
+ */
19
+
20
+ class Trollweb_BBSNetAxept_Model_BBSNetterminal_Language
21
+ {
22
+ public function toOptionArray()
23
+ {
24
+ return array(
25
+ array('value' => 'no_NO', 'label' => 'Norsk'),
26
+ array('value' => 'sv_SE', 'label' => 'Svenska'),
27
+ array('value' => 'en_GB', 'label' => 'English')
28
+ );
29
+ }
30
+
31
+ }
app/code/community/Trollweb/BBSNetAxept/Model/BBSNetterminal/PaymentAction.php ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * BBS NetAxept, Norge
4
+ *
5
+ * LICENSE AND USAGE INFORMATION
6
+ * It is NOT allowed to modify, copy or re-sell this file or any
7
+ * part of it. Please contact us by email at post@trollweb.no or
8
+ * visit us at www.trollweb.no/bbs if you have any questions about this.
9
+ * Trollweb is not responsible for any problems caused by this file.
10
+ *
11
+ * Visit us at http://www.trollweb.no today!
12
+ *
13
+ * @category Trollweb
14
+ * @package Trollweb_BBSNetAxept
15
+ * @copyright Copyright (c) 2009 Trollweb (http://www.trollweb.no)
16
+ * @license Single-site License
17
+ *
18
+ */
19
+
20
+ class Trollweb_BBSNetAxept_Model_BBSNetterminal_PaymentAction
21
+ {
22
+ public function toOptionArray()
23
+ {
24
+ return array(
25
+ array('value' => 'auth', 'label' => 'Authorize Only'),
26
+ array('value' => 'sale', 'label' => 'Authorize + Capture')
27
+ );
28
+ }
29
+
30
+ }
app/code/community/Trollweb/BBSNetAxept/Model/BBSNetterminal/Request.php ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * BBS NetAxept, Norge
4
+ *
5
+ * LICENSE AND USAGE INFORMATION
6
+ * It is NOT allowed to modify, copy or re-sell this file or any
7
+ * part of it. Please contact us by email at post@trollweb.no or
8
+ * visit us at www.trollweb.no/bbs if you have any questions about this.
9
+ * Trollweb is not responsible for any problems caused by this file.
10
+ *
11
+ * Visit us at http://www.trollweb.no today!
12
+ *
13
+ * @category Trollweb
14
+ * @package Trollweb_BBSNetAxept
15
+ * @copyright Copyright (c) 2009 Trollweb (http://www.trollweb.no)
16
+ * @license Single-site License
17
+ *
18
+ */
19
+
20
+ class Trollweb_BBSNetAxept_Model_BBSNetterminal_Request extends Varien_Object
21
+ {
22
+
23
+ }
app/code/community/Trollweb/BBSNetAxept/Model/BBSNetterminal/Result.php ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * BBS NetAxept, Norge
4
+ *
5
+ * LICENSE AND USAGE INFORMATION
6
+ * It is NOT allowed to modify, copy or re-sell this file or any
7
+ * part of it. Please contact us by email at post@trollweb.no or
8
+ * visit us at www.trollweb.no/bbs if you have any questions about this.
9
+ * Trollweb is not responsible for any problems caused by this file.
10
+ *
11
+ * Visit us at http://www.trollweb.no today!
12
+ *
13
+ * @category Trollweb
14
+ * @package Trollweb_BBSNetAxept
15
+ * @copyright Copyright (c) 2009 Trollweb (http://www.trollweb.no)
16
+ * @license Single-site License
17
+ *
18
+ */
19
+
20
+ class Trollweb_BBSNetAxept_Model_BBSNetterminal_Result extends Varien_Object
21
+ {
22
+
23
+ }
app/code/community/Trollweb/BBSNetAxept/Model/Entity/Setup.php ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * BBS NetAxept, Norge
4
+ *
5
+ * LICENSE AND USAGE INFORMATION
6
+ * It is NOT allowed to modify, copy or re-sell this file or any
7
+ * part of it. Please contact us by email at post@trollweb.no or
8
+ * visit us at www.trollweb.no/bbs if you have any questions about this.
9
+ * Trollweb is not responsible for any problems caused by this file.
10
+ *
11
+ * Visit us at http://www.trollweb.no today!
12
+ *
13
+ * @category Trollweb
14
+ * @package Trollweb_BBSNetAxept
15
+ * @copyright Copyright (c) 2009 Trollweb (http://www.trollweb.no)
16
+ * @license Single-site License
17
+ *
18
+ */
19
+
20
+ class Trollweb_BBSNetAxept_Model_Entity_Setup extends Mage_Eav_Model_Entity_Setup
21
+ {
22
+ }
app/code/community/Trollweb/BBSNetAxept/Model/WithGUI.php ADDED
@@ -0,0 +1,355 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * BBS NetAxept, Norge
4
+ *
5
+ * LICENSE AND USAGE INFORMATION
6
+ * It is NOT allowed to modify, copy or re-sell this file or any
7
+ * part of it. Please contact us by email at post@trollweb.no or
8
+ * visit us at www.trollweb.no/bbs if you have any questions about this.
9
+ * Trollweb is not responsible for any problems caused by this file.
10
+ *
11
+ * Visit us at http://www.trollweb.no today!
12
+ *
13
+ * @category Trollweb
14
+ * @package Trollweb_BBSNetAxept
15
+ * @copyright Copyright (c) 2009 Trollweb (http://www.trollweb.no)
16
+ * @license Single-site License
17
+ *
18
+ */
19
+
20
+
21
+ /**
22
+ * Our test CC module adapter
23
+ */
24
+ class Trollweb_BBSNetAxept_Model_WithGUI extends Mage_Payment_Model_Method_Abstract
25
+ {
26
+ protected $_code = 'bbsnetaxept_withgui';
27
+ protected $_formBlockType = 'bbsnetaxept/form';
28
+ protected $_infoBlockType = 'bbsnetaxept/paymentInfo';
29
+ protected $_allowCurrencyCode = array('NOK', 'USD', 'EUR');
30
+
31
+
32
+ //* Options *//
33
+ protected $_isGateway = true;
34
+ protected $_canAuthorize = true;
35
+ protected $_canCapture = true;
36
+ protected $_canCapturePartial = false;
37
+ protected $_canRefund = true;
38
+ protected $_canVoid = false;
39
+ protected $_canUseInternal = true;
40
+ protected $_canUseCheckout = true;
41
+ protected $_canUseForMultishipping = false;
42
+ protected $_canSaveCc = false;
43
+
44
+
45
+ /**
46
+ * Get checkout session namespace
47
+ *
48
+ * @return Mage_Checkout_Model_Session
49
+ */
50
+ public function getCheckout()
51
+ {
52
+ return Mage::getSingleton('checkout/session');
53
+ }
54
+
55
+ /**
56
+ * Get current quote
57
+ *
58
+ * @return Mage_Sales_Model_Quote
59
+ */
60
+ public function getQuote()
61
+ {
62
+ return $this->getCheckout()->getQuote();
63
+ }
64
+
65
+ /**
66
+ * Assign data to info model instance
67
+ *
68
+ * @param mixed $data
69
+ * @return Mage_Payment_Model_Info
70
+ */
71
+ public function assignData($data)
72
+ {
73
+ if (!($data instanceof Varien_Object)) {
74
+ $data = new Varien_Object($data);
75
+ }
76
+
77
+ $info = $this->getInfoInstance();
78
+ $info->setCcType($data->getCcType())
79
+ ->setCcOwner($data->getCcOwner())
80
+ ->setCcLast4(substr($data->getCcNumber(), -4))
81
+ ->setCcNumber($data->getCcNumber())
82
+ ->setCcCid($data->getCcCid())
83
+ ->setCcExpMonth($data->getCcExpMonth())
84
+ ->setCcExpYear($data->getCcExpYear());
85
+ return $this;
86
+ }
87
+
88
+
89
+ public function isAvailable($quote=null)
90
+ {
91
+ if ($this->getConfigData('use_gui') == 1) {
92
+ $this->_formBlockType = 'bbsnetaxept/form';
93
+ $this->_infoBlockType = 'bbsnetaxept/paymentInfo';
94
+
95
+ }
96
+ else {
97
+ $this->_formBlockType = 'payment/form_cc';
98
+ $this->_infoBlockType = 'payment/info_cc';
99
+
100
+ }
101
+ return true;
102
+ }
103
+
104
+
105
+ /**
106
+ * Using internal pages for input payment data
107
+ *
108
+ * @return bool
109
+ */
110
+ public function canUseInternal()
111
+ {
112
+ return true;
113
+ }
114
+
115
+ /**
116
+ * Using for multiple shipping address
117
+ *
118
+ * @return bool
119
+ */
120
+ public function canUseForMultishipping()
121
+ {
122
+ return false;
123
+ }
124
+
125
+ /*validate the currency code is avaialable to use for paypal or not*/
126
+ public function validate()
127
+ {
128
+ parent::validate();
129
+ $currency_code = $this->getQuote()->getBaseCurrencyCode();
130
+ if (!in_array($currency_code,$this->_allowCurrencyCode)) {
131
+ Mage::throwException(Mage::helper('bbsnetaxept')->__('Selected currency code ('.$currency_code.') is not compatible with BBS NetAxept'));
132
+ }
133
+ return $this;
134
+ }
135
+
136
+ public function onOrderValidate(Mage_Sales_Model_Order_Payment $payment)
137
+ {
138
+ return $this;
139
+ }
140
+
141
+ public function onInvoiceCreate(Mage_Sales_Model_Invoice_Payment $payment)
142
+ {
143
+
144
+ }
145
+
146
+ public function getOrderPlaceRedirectUrl()
147
+ {
148
+ $this->getCheckout()->setBBSTransactionId(uniqid());
149
+
150
+ $transKey = $this->getApi()->
151
+ setCurrencyCode($this->getQuote()->getBaseCurrencyCode())->
152
+ setTransactionId($this->getCheckout()->getBBSTransactionId())->
153
+ setAmount(sprintf("%0.0f",$this->getQuote()->getBaseGrandTotal()*100))->
154
+ setOrderNumber($this->getQuote()->getReservedOrderId())->
155
+ setOrderDescription(date("d.m.Y")." - Order ".$this->getQuote()->getReservedOrderId())->
156
+ setCustomerEmail($this->getQuote()->getBillingAddress()->getEmail())->
157
+ setCustomerPhoneNumber($this->getQuote()->getBillingAddress()->getTelephone())->
158
+ setSessionId($this->getCheckout()->getQuoteId())->
159
+ setInternalGUI($this->useInternalGUI())->
160
+ getTransKey();
161
+
162
+ if ($transKey == false) {
163
+ Mage::throwException(Mage::helper('bbsnetaxept')->__('Error during auth with BBS: '.$this->getApi()->getErrorMessage()));
164
+ }
165
+ else {
166
+ $this->getCheckout()->setBBSTransKey($transKey);
167
+ if ($this->useInternalGUI()) {
168
+ $info = $this->getInfoInstance();
169
+ if (!($info instanceof Varien_Object)) {
170
+ $info = new Varien_Object($info);
171
+ }
172
+ $this->getCheckout()->setCardInfo($info);
173
+ }
174
+ }
175
+ return Mage::getUrl('bbsnetaxept/return/redirect', array('_secure' => true));
176
+ }
177
+
178
+ public function getBBSUrl()
179
+ {
180
+ return $this->getConfigData('gw_url');
181
+ }
182
+
183
+ public function useInternalGUI()
184
+ {
185
+ return ($this->getConfigData('use_gui') ? false : true);
186
+ }
187
+
188
+ public function getCCDate()
189
+ {
190
+ $info = $this->getInfoInstance();
191
+ return $info;
192
+ }
193
+
194
+ /**
195
+ * Get BBS API Model
196
+ *
197
+ * @return Trollweb_BBSNetAxept_Model_Api_Bbs
198
+ */
199
+ public function getApi()
200
+ {
201
+ $bbsClient = Mage::getSingleton('bbsnetaxept/api_bbs');
202
+
203
+ // Merchant ID
204
+ $bbsClient->setMerchantId($this->getConfigData('merchant_id'))->setMerchantToken($this->getConfigData('merchant_token'))->setLanguage($this->getConfigData('gui_language'));
205
+ $bbsClient->setWsdlUrl($this->getConfigData('wsdl_url'));
206
+ return $bbsClient;
207
+ }
208
+
209
+ /**
210
+ * Check the result from the BBS NetAxept
211
+ *
212
+ * @param none
213
+ * @return bool
214
+ */
215
+ public function checkResult($bbskey) {
216
+ $isOK = false;
217
+
218
+ // Load order.
219
+ $order = Mage::getModel('sales/order');
220
+ $order->load(Mage::getSingleton('checkout/session')->getLastOrderId());
221
+
222
+ if ($this->getApi()->Process($bbskey) == $this->getCheckout()->getBBSTransactionId()) {
223
+
224
+ if ($this->getApi()->Auth($this->getApi()->Result()->getTransactionId()) == $this->getCheckout()->getBBSTransactionId()) {
225
+
226
+
227
+ $this->getCheckout()->getQuote()->setIsActive(false)->save();
228
+
229
+ /**
230
+ * send confirmation email to customer
231
+ */
232
+ if($order->getId()){
233
+ $order->sendNewOrderEmail();
234
+ }
235
+
236
+ $order->getPayment()->setBbsTransactionId($this->getCheckout()->getBBSTransactionId())->
237
+ setBbsAuthenticatedStatus($this->getApi()->Result()->getAuthenticatedStatus())->
238
+ setBbsAuthenticatedWith($this->getApi()->Result()->getAuthenticatedWith())->
239
+ setBbsIssuerCountry($this->getApi()->Result()->getIssuerCountry())->
240
+ setBbsIssuerId($this->getApi()->Result()->getIssuerId())->
241
+ setBbsAuthorizationId($this->getApi()->Result()->getAuthorizationId())->
242
+ setBbsSessionNumber($this->getApi()->Result()->getSessionNumber());
243
+
244
+ if ($this->getApi()->Result()->getResponseCode() == "OK") {
245
+ $order->getPayment()->setStatus(self::STATUS_APPROVED);
246
+ $isOK = true;
247
+ }
248
+
249
+ $order->save();
250
+ if ($this->getConfigData('payment_action') == 'sale') {
251
+ $invoice = $order->prepareInvoice();
252
+ $invoice->register()->capture();
253
+ Mage::getModel('core/resource_transaction')
254
+ ->addObject($invoice)
255
+ ->addObject($invoice->getOrder())
256
+ ->save();
257
+ }
258
+ }
259
+ else {
260
+ $order->getPayment()->setBbsAuthenticatedStatus('Error')->setBbsAuthenticatedWith($this->getApi()->getErrorMessage());
261
+ $order->cancel()->save();
262
+ $this->getCheckout()->addError($this->getErrorMessage($this->getApi()->getErrorCode()).' ('.$this->getApi()->getErrorCode().') (auth)');
263
+ }
264
+ }
265
+ else {
266
+ $order->getPayment()->setBbsAuthenticatedStatus('Error')->setBbsAuthenticatedWith($this->getApi()->getErrorMessage());
267
+ $order->cancel()->save();
268
+ $this->getCheckout()->addError($this->getErrorMessage($this->getApi()->getErrorCode()).' ('.$this->getApi()->getErrorCode().') (proc)');
269
+ }
270
+
271
+
272
+ return $isOK;
273
+ }
274
+
275
+
276
+ public function capture(Varien_Object $payment, $amount) {
277
+ $error = false;
278
+
279
+ if (!$payment->getBbsTransactionId()) {
280
+ Mage::throwException(Mage::helper('bbsnetaxept')->__('Could not find transaction id.'));
281
+ }
282
+
283
+ $order = $payment->getOrder();
284
+
285
+ $InvoiceId = ($order->getIncrementId() ? $order->getIncrementId() : 'Unknown');
286
+
287
+ $bbs_amount = sprintf("%0.0f",$amount*100);
288
+ if ($this->getApi()->capture($payment->getBbsTransactionId(),$bbs_amount,$InvoiceId) == $payment->getBbsTransactionId()) {
289
+ $payment->setStatus(self::STATUS_APPROVED);
290
+ }
291
+ else {
292
+ $error = Mage::helper('bbsnetaxept')->__('Error capturing the payment: %s', $this->getApi()->getErrorMessage());
293
+ }
294
+
295
+ if ($error !== false) {
296
+ Mage::throwException($error);
297
+ }
298
+
299
+ return $this;
300
+ }
301
+
302
+ /**
303
+ * refund the amount with transaction id
304
+ *
305
+ * @access public
306
+ * @param string $payment Varien_Object object
307
+ * @return Mage_Payment_Model_Abstract
308
+ */
309
+ public function refund(Varien_Object $payment, $amount)
310
+ {
311
+ $error = false;
312
+
313
+ if (!$payment->getBbsTransactionId()) {
314
+ Mage::throwException(Mage::helper('bbsnetaxept')->__('Could not find transaction id.'));
315
+ }
316
+
317
+
318
+ $order = $payment->getOrder();
319
+ $InvoiceId = ($order->getIncrementId() ? $order->getIncrementId() : 'Unknown');
320
+
321
+ $bbs_amount = sprintf("%0.0f",$amount*100);
322
+ if ($this->getApi()->refund($payment->getBbsTransactionId(),$bbs_amount, $InvoiceId) == $payment->getBbsTransactionId()) {
323
+ $payment->setStatus(self::STATUS_SUCCESS);
324
+
325
+ }
326
+ else {
327
+ $error = Mage::helper('bbsnetaxept')->__('Error refunding the payment: %s', $this->getApi()->getErrorMessage());
328
+ }
329
+
330
+ if ($error !== false) {
331
+ Mage::throwException($error);
332
+ }
333
+
334
+ return $this;
335
+ }
336
+
337
+
338
+ private function getErrorMessage($errorcode=99) {
339
+ switch ($errorcode) {
340
+ case '00':
341
+ $message = '';
342
+ break;
343
+ case '17':
344
+ $message = Mage::helper('bbsnetaxept')->__('Payment cancelled by user.');
345
+ break;
346
+ case '99':
347
+ default:
348
+ $message = Mage::helper('bbsnetaxept')->__('Error processing transaction from BBS. Try again or contact your bank');
349
+ break;
350
+ }
351
+
352
+ return $message;
353
+ }
354
+
355
+ }
app/code/community/Trollweb/BBSNetAxept/controllers/ReturnController.php ADDED
@@ -0,0 +1,69 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * BBS NetAxept, Norge
4
+ *
5
+ * LICENSE AND USAGE INFORMATION
6
+ * It is NOT allowed to modify, copy or re-sell this file or any
7
+ * part of it. Please contact us by email at post@trollweb.no or
8
+ * visit us at www.trollweb.no/bbs if you have any questions about this.
9
+ * Trollweb is not responsible for any problems caused by this file.
10
+ *
11
+ * Visit us at http://www.trollweb.no today!
12
+ *
13
+ * @category Trollweb
14
+ * @package Trollweb_BBSNetAxept
15
+ * @copyright Copyright (c) 2009 Trollweb (http://www.trollweb.no)
16
+ * @license Single-site License
17
+ *
18
+ */
19
+
20
+ class Trollweb_BBSNetAxept_ReturnController extends Mage_Core_Controller_Front_Action
21
+ {
22
+
23
+ protected function _expireAjax()
24
+ {
25
+ if (!Mage::getSingleton('checkout/session')->getQuote()->hasItems()) {
26
+ $this->getResponse()->setHeader('HTTP/1.1','403 Session Expired');
27
+ exit;
28
+ }
29
+ }
30
+
31
+ /**
32
+ * Get singleton with bbs strandard order transaction information
33
+ *
34
+ * @return Trollweb_BBSNetAxept_Model_WithGUI
35
+ */
36
+ public function getStandard()
37
+ {
38
+ return Mage::getSingleton('BBSNetAxept/WithGUI');
39
+ }
40
+
41
+ /**
42
+ * When a customer chooses BBS on Checkout/Payment page
43
+ *
44
+ */
45
+ public function redirectAction()
46
+ {
47
+ $session = Mage::getSingleton('checkout/session');
48
+ $session->setBBSNetterminalStandardQuoteId($session->getQuoteId());
49
+ $this->getResponse()->setBody($this->getLayout()->createBlock('BBSNetAxept/withGUI_redirect')->toHtml());
50
+ }
51
+
52
+ /**
53
+ * When a customer cancel payment from paypal.
54
+ */
55
+ public function checkAction()
56
+ {
57
+ $redirect = 'checkout/cart';
58
+
59
+ $session = Mage::getSingleton('checkout/session');
60
+ $session->setQuoteId($session->getBBSNetterminalStandardQuoteId(true));
61
+
62
+ if ($this->getStandard()->checkResult($this->getRequest()->getQuery("BBSePay_transaction"))) {
63
+ $redirect = 'checkout/onepage/success';
64
+ }
65
+
66
+ $this->_redirect($redirect, array('_secure'=>true));
67
+ }
68
+ }
69
+
app/code/community/Trollweb/BBSNetAxept/etc/config.xml ADDED
@@ -0,0 +1,96 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <Trollweb_BBSNetAxept>
5
+ <version>1.3.2</version>
6
+ <depends>
7
+ <Mage_Payment />
8
+ </depends>
9
+ </Trollweb_BBSNetAxept>
10
+ </modules>
11
+
12
+ <global>
13
+ <models>
14
+ <bbsnetaxept>
15
+ <class>Trollweb_BBSNetAxept_Model</class>
16
+ </bbsnetaxept>
17
+ </models>
18
+
19
+ <helpers>
20
+ <bbsnetaxept>
21
+ <class>Trollweb_BBSNetAxept_Helper</class>
22
+ </bbsnetaxept>
23
+ </helpers>
24
+
25
+ <resources>
26
+ <bbsnetaxept_setup>
27
+ <setup>
28
+ <module>Trollweb_BBSNetAxept</module>
29
+ <class>Trollweb_BBSNetAxept_Model_Entity_Setup</class>
30
+ </setup>
31
+ <connection>
32
+ <use>core_setup</use>
33
+ </connection>
34
+ </bbsnetaxept_setup>
35
+ <bbsnetaxept_write>
36
+ <use>core_write</use>
37
+ </bbsnetaxept_write>
38
+ <bbsnetaxept_read>
39
+ <use>core_read</use>
40
+ </bbsnetaxept_read>
41
+ </resources>
42
+
43
+ <blocks>
44
+ <bbsnetaxept><class>Trollweb_BBSNetAxept_Block</class></bbsnetaxept>
45
+ </blocks>
46
+
47
+ <payment>
48
+ <bbsnetaxept>
49
+ <authcode>
50
+ <code>authcode</code>
51
+ <name>Auth Code</name>
52
+ </authcode>
53
+ </bbsnetaxept>
54
+ </payment>
55
+ </global>
56
+
57
+ <frontend>
58
+ <secure_url>
59
+ <bbsnetaxept_withgui>/bbsnetaxept/return</bbsnetaxept_withgui>
60
+ </secure_url>
61
+ <routers>
62
+ <bbsnetaxept>
63
+ <use>standard</use>
64
+ <args>
65
+ <module>Trollweb_BBSNetAxept</module>
66
+ <frontName>bbsnetaxept</frontName>
67
+ </args>
68
+ </bbsnetaxept>
69
+ </routers>
70
+ </frontend>
71
+
72
+
73
+
74
+ <default>
75
+ <payment>
76
+ <bbsnetaxept_withgui>
77
+ <active>0</active>
78
+ <title>Kredittkort</title>
79
+ <cctypes>AE,VI,MC,DI</cctypes>
80
+ <gw_url>https://epay.bbs.no/cgi/epay.pway</gw_url>
81
+ <wsdl_url>https://epayment.bbs.no/service.svc?wsdl</wsdl_url>
82
+ <merchant_id backend_model="adminhtml/system_config_backend_encrypted" />
83
+ <merchant_token backend_model="adminhtml/system_config_backend_encrypted" />
84
+ <use_gui>1</use_gui>
85
+ <gui_language>no_NO</gui_language>
86
+ <order_status>0</order_status>
87
+ <allowspecific>0</allowspecific>
88
+ <sort_order>90</sort_order>
89
+ <payment_action>auth</payment_action>
90
+
91
+ <model>bbsnetaxept/withGUI</model>
92
+ </bbsnetaxept_withgui>
93
+ </payment>
94
+ </default>
95
+
96
+ </config>
app/code/community/Trollweb/BBSNetAxept/etc/system.xml ADDED
@@ -0,0 +1,183 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <sections>
4
+ <payment>
5
+ <groups>
6
+ <bbsnetaxept_withgui translate="label" module="bbsnetaxept">
7
+ <label>BBS NetAxept Norge, versjon 1.3.2</label>
8
+ <sort_order>670</sort_order>
9
+ <show_in_default>1</show_in_default>
10
+ <show_in_website>1</show_in_website>
11
+ <show_in_store>0</show_in_store>
12
+ <comment><![CDATA[
13
+ <div class="custom-options">
14
+ <div class="box">
15
+ <br />
16
+ <p class="grand-total">Opprett avtale med BBS og Teller<br /><b></b></p>
17
+
18
+ For å ta i bruk BBS NetAxept må du ha en avtale med BBS og en kredittkort-innløser som Teller.
19
+ Klikk på linkene nedenfor for å hente opp søknadsskjemaene til BBS og Teller.
20
+ Disse må fylles ut så godt det lar seg gjøre og returneres til BBS og Teller. <br />
21
+ <br />
22
+ <a href="http://www.trollweb.no/link.php?id=bbs"><b>Steg 1) Klikk her for å laste ned og fylle ut avtale med BBS</b></a><br />
23
+ <a href="http://www.trollweb.no/link.php?id=teller"><b>Steg 2) Klikk her for å laste ned og fylle ut avtale med Teller</b></a><br />
24
+ <br />
25
+ Kontakt oss helt gratis om du har spørsmål til søknadsskjemaene eller kostnadene rundt løsningen.<br />
26
+ <label>Epost <a href="mailto:support@trollweb.no"><b>support@trollweb.no</b></a></label><br />
27
+ Telefon <b>+47 47230804</b> (0900-1800, man-søn)<br />
28
+ <br />
29
+ <font size=1>BBS NetAxept modulen er utviklet av <a href="http://www.trollweb.no">Trollweb Solutions AS</a> i Norge og er sertifisert og godkjent av BBS Norge. Videredistribusjon av noe slag er ikke tillatt uten etter avtale med Trollweb.</font><br />
30
+ <br />
31
+ </div>
32
+ </div>
33
+ ]]></comment>
34
+ <fields>
35
+ <active translate="label">
36
+ <label>Aktiv</label>
37
+ <frontend_type>select</frontend_type>