Version Notes
Improved the calculation of order items
Now adds configuration values to descriptions (ex. size, color etc)
Some code cleaning
It is now possible to set which payment methods to offer the customer (bank, credit card or bank & creditcard)
Better check for showing invoice or not in checkout
Download this release
Release Info
Developer | Oscar Villegas |
Extension | Payson |
Version | 1.2.0 |
Comparing to | |
See all releases |
Code changes from version 1.0.1 to 1.2.0
- app/code/community/Payson/Payson/Block/Form.php +11 -11
- app/code/community/Payson/Payson/Block/Invoice/Form.php +11 -11
- app/code/community/Payson/Payson/Block/Order/Totals/Fee.php +22 -22
- app/code/community/Payson/Payson/Block/Standard/Form.php +11 -11
- app/code/community/Payson/Payson/Helper/Api.php +127 -142
- app/code/community/Payson/Payson/Helper/Api/Response/Interface.php +20 -20
- app/code/community/Payson/Payson/Helper/Api/Response/Standard.php +131 -131
- app/code/community/Payson/Payson/Helper/Api/Response/Standard/Parameters.php +66 -66
- app/code/community/Payson/Payson/Helper/Api/Response/Validate.php +46 -46
- app/code/community/Payson/Payson/Helper/Data.php +6 -6
- app/code/community/Payson/Payson/Model/Config.php +221 -221
- app/code/community/Payson/Payson/Model/Method/Abstract.php +1 -1
- app/code/community/Payson/Payson/Model/Method/Invoice.php +2 -2
- app/code/community/Payson/Payson/Model/Method/Standard.php +39 -39
- app/code/community/Payson/Payson/Model/Mysql4/Setup.php +6 -6
- app/code/community/Payson/Payson/Model/Order/Creditmemo/Total/Invoice.php +44 -44
- app/code/community/Payson/Payson/Model/Order/Invoice/Total/Invoice.php +43 -43
- app/code/community/Payson/Payson/Model/Quote/Address/Total/Invoice.php +64 -64
- app/code/community/Payson/Payson/Model/Standard.php +118 -118
- app/code/community/Payson/Payson/Model/System/Config/Source/Paysondirectmethod.php +25 -0
- app/code/community/Payson/Payson/controllers/Adminhtml/Sales/Order/ShipmentController.php +26 -26
- app/code/community/Payson/Payson/controllers/CheckoutController.php +62 -31
- app/code/community/Payson/Payson/controllers/IpnController.php +25 -25
- app/code/community/Payson/Payson/etc/config.xml +1 -17
- app/code/community/Payson/Payson/etc/system.xml +11 -0
- app/code/community/Payson/Payson/sql/payson_setup/mysql4-install-0.1.0.php +32 -32
- app/code/community/Payson/Payson/sql/payson_setup/mysql4-upgrade-0.1.0-0.1.2.php +8 -8
- app/design/adminhtml/default/default/Payson/Payson/total.phtml +5 -5
- app/design/adminhtml/default/default/layout/Payson.xml +24 -24
- app/design/frontend/base/default/layout/Payson.xml +45 -45
- app/design/frontend/base/default/template/Payson/Payson/invoice_form.phtml +15 -15
- app/design/frontend/base/default/template/Payson/Payson/standard_form.phtml +9 -9
- app/etc/modules/Payson_Payson.xml +1 -1
- app/locale/sv_SE/Payson_Payson.csv +50 -50
- package.xml +9 -6
app/code/community/Payson/Payson/Block/Form.php
CHANGED
@@ -1,11 +1,11 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
class Payson_Payson_Block_Form extends Mage_Payment_Block_Form {
|
4 |
-
|
5 |
-
protected function _construct() {
|
6 |
-
$this->setTemplate('Payson/Payson/form.phtml');
|
7 |
-
parent::_construct();
|
8 |
-
}
|
9 |
-
|
10 |
-
}
|
11 |
-
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Payson_Payson_Block_Form extends Mage_Payment_Block_Form {
|
4 |
+
|
5 |
+
protected function _construct() {
|
6 |
+
$this->setTemplate('Payson/Payson/form.phtml');
|
7 |
+
parent::_construct();
|
8 |
+
}
|
9 |
+
|
10 |
+
}
|
11 |
+
|
app/code/community/Payson/Payson/Block/Invoice/Form.php
CHANGED
@@ -1,11 +1,11 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
class Payson_Payson_Block_Invoice_Form extends Mage_Payment_Block_Form {
|
4 |
-
|
5 |
-
protected function _construct() {
|
6 |
-
$this->setTemplate('Payson/Payson/invoice_form.phtml');
|
7 |
-
parent::_construct();
|
8 |
-
}
|
9 |
-
|
10 |
-
}
|
11 |
-
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Payson_Payson_Block_Invoice_Form extends Mage_Payment_Block_Form {
|
4 |
+
|
5 |
+
protected function _construct() {
|
6 |
+
$this->setTemplate('Payson/Payson/invoice_form.phtml');
|
7 |
+
parent::_construct();
|
8 |
+
}
|
9 |
+
|
10 |
+
}
|
11 |
+
|
app/code/community/Payson/Payson/Block/Order/Totals/Fee.php
CHANGED
@@ -1,22 +1,22 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
class Payson_Payson_Block_Order_Totals_Fee extends Mage_Core_Block_Abstract {
|
4 |
-
|
5 |
-
public function initTotals() {
|
6 |
-
$parent = $this->getParentBlock();
|
7 |
-
$this->_order = $parent->getOrder();
|
8 |
-
|
9 |
-
if ($this->_order->getPayment()->getMethod() === 'payson_invoice') {
|
10 |
-
$parent->addTotalBefore(new Varien_Object(array
|
11 |
-
(
|
12 |
-
'code' => 'payson_invoice',
|
13 |
-
'label' => Mage::helper('payson')->__('Invoice fee'),
|
14 |
-
'value' => $this->_order->getPaysonInvoiceFee()
|
15 |
-
)), 'tax');
|
16 |
-
}
|
17 |
-
|
18 |
-
return $this;
|
19 |
-
}
|
20 |
-
|
21 |
-
}
|
22 |
-
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Payson_Payson_Block_Order_Totals_Fee extends Mage_Core_Block_Abstract {
|
4 |
+
|
5 |
+
public function initTotals() {
|
6 |
+
$parent = $this->getParentBlock();
|
7 |
+
$this->_order = $parent->getOrder();
|
8 |
+
|
9 |
+
if ($this->_order->getPayment()->getMethod() === 'payson_invoice') {
|
10 |
+
$parent->addTotalBefore(new Varien_Object(array
|
11 |
+
(
|
12 |
+
'code' => 'payson_invoice',
|
13 |
+
'label' => Mage::helper('payson')->__('Invoice fee'),
|
14 |
+
'value' => $this->_order->getPaysonInvoiceFee()
|
15 |
+
)), 'tax');
|
16 |
+
}
|
17 |
+
|
18 |
+
return $this;
|
19 |
+
}
|
20 |
+
|
21 |
+
}
|
22 |
+
|
app/code/community/Payson/Payson/Block/Standard/Form.php
CHANGED
@@ -1,11 +1,11 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
class Payson_Payson_Block_Standard_Form extends Mage_Payment_Block_Form {
|
4 |
-
|
5 |
-
protected function _construct() {
|
6 |
-
$this->setTemplate('Payson/Payson/standard_form.phtml');
|
7 |
-
parent::_construct();
|
8 |
-
}
|
9 |
-
|
10 |
-
}
|
11 |
-
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Payson_Payson_Block_Standard_Form extends Mage_Payment_Block_Form {
|
4 |
+
|
5 |
+
protected function _construct() {
|
6 |
+
$this->setTemplate('Payson/Payson/standard_form.phtml');
|
7 |
+
parent::_construct();
|
8 |
+
}
|
9 |
+
|
10 |
+
}
|
11 |
+
|
app/code/community/Payson/Payson/Helper/Api.php
CHANGED
@@ -11,9 +11,9 @@ class Payson_Payson_Helper_Api {
|
|
11 |
const API_CALL_PAYMENT_DETAILS = '%s://%sapi.payson.%s/%s/%sDetails/';
|
12 |
const API_CALL_PAYMENT_UPDATE = '%s://%sapi.payson.%s/%s/%sUpdate/';
|
13 |
const PAY_FORWARD_URL = '%s://%s%s.payson.%s/paySecure/';
|
14 |
-
const APPLICATION_ID = 'Magento
|
15 |
const MODULE_NAME = 'payson_magento';
|
16 |
-
const MODULE_VERSION = '1.
|
17 |
const DEBUG_MODE_MAIL = 'testagent-1@payson.se';
|
18 |
const DEBUG_MODE_AGENT_ID = '1';
|
19 |
const DEBUG_MODE_MD5 = 'fddb19ac-7470-42b6-a91d-072cb1495f0a';
|
@@ -57,21 +57,31 @@ class Payson_Payson_Helper_Api {
|
|
57 |
|
58 |
private $response;
|
59 |
private $order_discount_item = 0.0;
|
|
|
|
|
|
|
|
|
|
|
60 |
|
61 |
/*
|
62 |
* Private methods
|
63 |
*/
|
64 |
|
65 |
-
|
66 |
-
$
|
|
|
|
|
|
|
|
|
|
|
67 |
|
68 |
$http_client = new Zend_Http_Client($url);
|
69 |
|
70 |
$http_client->setMethod(Zend_Http_Client::POST)
|
71 |
->setHeaders(array
|
72 |
(
|
73 |
-
'PAYSON-SECURITY-USERID' => $
|
74 |
-
'PAYSON-SECURITY-PASSWORD' => $
|
75 |
'PAYSON-APPLICATION-ID' => self::APPLICATION_ID,
|
76 |
'PAYSON-MODULE-INFO' => self::MODULE_NAME . '|' . self::MODULE_VERSION . '|' . Mage::getVersion()
|
77 |
));
|
@@ -79,79 +89,96 @@ class Payson_Payson_Helper_Api {
|
|
79 |
return $http_client->resetParameters();
|
80 |
}
|
81 |
|
82 |
-
private function
|
83 |
Payson_Payson_Helper_Api_Response_Interface $response) {
|
84 |
$this->response = $response;
|
85 |
|
86 |
return $this;
|
87 |
}
|
88 |
|
89 |
-
private function
|
90 |
-
$total -= $item->
|
91 |
-
$this->order_discount_item += $item->
|
92 |
}
|
93 |
|
94 |
/**
|
95 |
* Helper for Pay()
|
96 |
*
|
97 |
-
* @param
|
98 |
-
* @param int $i
|
99 |
* @param int $total
|
100 |
* @return array
|
101 |
*/
|
102 |
-
private function
|
|
|
103 |
$product = Mage::getModel('catalog/product')
|
104 |
->load($item->getProductId());
|
105 |
-
$children = $item->getChildrenItems();
|
106 |
|
107 |
-
|
108 |
-
|
|
|
109 |
$args = array();
|
|
|
110 |
foreach ($children as $child) {
|
111 |
-
$
|
112 |
}
|
113 |
-
return
|
114 |
}
|
115 |
|
116 |
-
|
117 |
-
|
118 |
-
$
|
119 |
-
} else {
|
120 |
-
$name = $product->getData('name');
|
121 |
-
$sku = $item->getData('sku');
|
122 |
}
|
123 |
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
$
|
|
|
|
|
|
|
129 |
$tax_mod /= 100;
|
130 |
$tax_mod = round($tax_mod, 5);
|
131 |
|
132 |
-
$qty = (float) $item->
|
133 |
$qty = round($qty, 2);
|
134 |
|
135 |
-
$price = (float) $item->
|
136 |
|
137 |
$base_price = (($price / (1 + $tax_mod)) / $qty);
|
138 |
$base_price = round($base_price, 3);
|
139 |
|
140 |
$total += (($base_price * (1 + $tax_mod)) * $qty);
|
141 |
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
155 |
}
|
156 |
|
157 |
/**
|
@@ -162,44 +189,29 @@ class Payson_Payson_Helper_Api {
|
|
162 |
* @param object $store
|
163 |
* @param int $i
|
164 |
* @param int $total
|
165 |
-
* @return array
|
166 |
*/
|
167 |
-
private function
|
168 |
$tax_calc = Mage::getSingleton('tax/calculation');
|
169 |
|
170 |
$tax_rate_req = $tax_calc->getRateRequest(
|
171 |
$order->getShippingAddress(), $order->getBillingAddress(), $customer->getTaxClassId(), $store);
|
172 |
|
173 |
-
$args = array();
|
174 |
|
175 |
-
if (($price = (float) $order->
|
176 |
$tax_mod = $tax_calc->getRate($tax_rate_req->setProductClassId(
|
177 |
Mage::getStoreConfig('tax/classes/shipping_tax_class')));
|
178 |
$tax_mod /= 100;
|
179 |
$tax_mod = round($tax_mod, 5);
|
180 |
|
181 |
-
$price -= (float) $order->
|
182 |
|
183 |
$base_price = ($price / (1 + $tax_mod));
|
184 |
$base_price = round($base_price, 3);
|
185 |
|
186 |
$total += ($base_price * (1 + $tax_mod));
|
187 |
|
188 |
-
$
|
189 |
-
(
|
190 |
-
'orderItemList.orderItem(' . $i . ').description' =>
|
191 |
-
$order->getData('shipping_description'),
|
192 |
-
'orderItemList.orderItem(' . $i . ').sku' =>
|
193 |
-
$order->getData('shipping_method'),
|
194 |
-
'orderItemList.orderItem(' . $i . ').quantity' =>
|
195 |
-
1,
|
196 |
-
'orderItemList.orderItem(' . $i . ').unitPrice' =>
|
197 |
-
$base_price,
|
198 |
-
'orderItemList.orderItem(' . $i . ').taxPercentage' =>
|
199 |
-
$tax_mod
|
200 |
-
);
|
201 |
}
|
202 |
-
return $args;
|
203 |
}
|
204 |
|
205 |
/*
|
@@ -221,7 +233,7 @@ class Payson_Payson_Helper_Api {
|
|
221 |
* @return string
|
222 |
*/
|
223 |
public function GetPayForwardUrl() {
|
224 |
-
$url = vsprintf(self::PAY_FORWARD_URL . '?token=' . $this->GetResponse()->TOKEN, $this->
|
225 |
return $url;
|
226 |
}
|
227 |
|
@@ -233,8 +245,8 @@ class Payson_Payson_Helper_Api {
|
|
233 |
*/
|
234 |
public function Pay(Mage_Sales_Model_Order $order) {
|
235 |
$payment_method = $order->getPayment()->getMethod();
|
236 |
-
|
237 |
-
$
|
238 |
$store = Mage::app()->getStore($order->getStoreId());
|
239 |
$customer = Mage::getModel('customer/customer')
|
240 |
->load($order->getCustomerId());
|
@@ -273,7 +285,7 @@ class Payson_Payson_Helper_Api {
|
|
273 |
//$order->getBaseCurrencyCode(),
|
274 |
strtoupper(substr($order->getOrderCurrency()->getCode(), 0, 3)),
|
275 |
'memo' =>
|
276 |
-
sprintf($
|
277 |
'senderEmail' =>
|
278 |
$order->getCustomerEmail(),
|
279 |
'senderFirstName' =>
|
@@ -281,89 +293,70 @@ class Payson_Payson_Helper_Api {
|
|
281 |
'senderLastName' =>
|
282 |
$billing_address->getLastname(),
|
283 |
'receiverList.receiver(0).email' =>
|
284 |
-
$
|
285 |
'trackingId' => $order->getRealOrderId()
|
286 |
);
|
287 |
|
288 |
-
if (!$
|
289 |
$args['guaranteeOffered'] = self::GUARANTEE_NO;
|
290 |
}
|
291 |
|
292 |
if (($payment_method === 'payson_invoice')) {
|
293 |
-
if (!$
|
294 |
Mage::throwException('Invoice payment is disabled');
|
295 |
}
|
296 |
|
297 |
-
$args['fundingList.fundingConstraint(0).constraint'] =
|
298 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
299 |
}
|
300 |
|
301 |
-
|
302 |
$total = 0;
|
303 |
|
304 |
// Calculate price of each item in the order
|
305 |
foreach ($order->getAllVisibleItems() as $item) {
|
306 |
-
$
|
307 |
}
|
308 |
|
309 |
foreach ($order->getAllVisibleItems() as $item) {
|
310 |
-
$this->
|
311 |
}
|
312 |
-
if ($this->order_discount_item
|
313 |
-
$
|
314 |
-
(
|
315 |
-
'orderItemList.orderItem(' . $i . ').description' =>
|
316 |
-
'discount',
|
317 |
-
'orderItemList.orderItem(' . $i . ').sku' =>
|
318 |
-
'discount',
|
319 |
-
'orderItemList.orderItem(' . $i . ').quantity' =>
|
320 |
-
1,
|
321 |
-
'orderItemList.orderItem(' . $i . ').unitPrice' =>
|
322 |
-
-$this->order_discount_item,
|
323 |
-
'orderItemList.orderItem(' . $i . ').taxPercentage' =>
|
324 |
-
0.0
|
325 |
-
);
|
326 |
}
|
327 |
// Calculate price for shipping
|
328 |
-
$
|
329 |
-
|
330 |
-
print_r($args);
|
331 |
-
echo '</pre>';exit; */
|
332 |
if ($order->getPaysonInvoiceFee() > 0) {
|
333 |
$fee = $order->getPaysonInvoiceFee();
|
334 |
-
/* $args += array
|
335 |
-
(
|
336 |
-
'orderItemList.orderItem(' . $i . ').description' =>
|
337 |
-
$helper->__('Invoice fee'),
|
338 |
-
'orderItemList.orderItem(' . $i . ').sku' =>
|
339 |
-
'invoice_fee',
|
340 |
-
'orderItemList.orderItem(' . $i . ').quantity' =>
|
341 |
-
1,
|
342 |
-
'orderItemList.orderItem(' . $i . ').unitPrice' =>
|
343 |
-
$config->GetInvoiceFee($order),
|
344 |
-
'orderItemList.orderItem(' . $i . ').taxPercentage' =>
|
345 |
-
$config->GetInvoiceFeeTaxMod($order)
|
346 |
-
);
|
347 |
-
|
348 |
-
$total += $config->GetInvoiceFeeInclTax($order); */
|
349 |
-
|
350 |
$args['invoiceFee'] = round((float) $fee, 3);
|
351 |
$total += $fee;
|
352 |
}
|
353 |
|
354 |
-
$
|
|
|
|
|
355 |
|
356 |
-
$args['receiverList.receiver(0).amount'] = $
|
357 |
|
358 |
-
|
359 |
-
$
|
360 |
-
$client = $this->GetHttpClient($url)
|
361 |
->setParameterPost($args);
|
362 |
|
363 |
$response = Payson_Payson_Helper_Api_Response_Standard
|
364 |
::FromHttpBody($client->request()->getBody());
|
365 |
|
366 |
-
$this->
|
367 |
|
368 |
$resource = Mage::getSingleton('core/resource');
|
369 |
$db = $resource->getConnection('core_write');
|
@@ -395,7 +388,7 @@ class Payson_Payson_Helper_Api {
|
|
395 |
|
396 |
if (!$response->IsValid()) {
|
397 |
|
398 |
-
throw new Mage_Core_Exception(sprintf($
|
399 |
'Failed to initialize payment. Payson replied: %s'), $response->GetError()), $response->GetErrorId());
|
400 |
}
|
401 |
|
@@ -412,8 +405,7 @@ class Payson_Payson_Helper_Api {
|
|
412 |
* @return object $this
|
413 |
*/
|
414 |
public function Validate($http_body, $content_type) {
|
415 |
-
|
416 |
-
$config = Mage::getModel('payson/config');
|
417 |
// Parse request done by Payson to our IPN controller
|
418 |
$ipn_response = Payson_Payson_Helper_Api_Response_Standard
|
419 |
::FromHttpBody($http_body);
|
@@ -470,13 +462,13 @@ LIMIT
|
|
470 |
}
|
471 |
|
472 |
// Do the validate API call
|
473 |
-
$client = $this->
|
474 |
->setRawData($http_body, $content_type);
|
475 |
|
476 |
$response = Payson_Payson_Helper_Api_Response_Validate
|
477 |
::FromHttpBody($client->request()->getBody());
|
478 |
|
479 |
-
$this->
|
480 |
|
481 |
if (!$response->IsValid()) {
|
482 |
Mage::throwException('Validate call was unsuccessful');
|
@@ -524,9 +516,7 @@ LIMIT
|
|
524 |
case self::STATUS_COMPLETED: {
|
525 |
//Changes the status of the order from pending_payment to processing
|
526 |
$order->setState(
|
527 |
-
Mage_Sales_Model_Order::STATE_PROCESSING, Mage_Sales_Model_Order::STATE_PROCESSING,
|
528 |
-
//$helper->__('Payson completed the order payment XXXXXXX'));
|
529 |
-
$config->get('test_mode') ? $helper->__('Payson test completed the order payment') : $helper->__('Payson completed the order payment'));
|
530 |
|
531 |
//It creates the invoice to the order
|
532 |
$invoice = Mage::getModel('sales/service_order', $order)->prepareInvoice();
|
@@ -549,9 +539,7 @@ LIMIT
|
|
549 |
self::INVOICE_STATUS_ORDERCREATED)) {
|
550 |
//Changes the status of the order from pending to processing
|
551 |
$order->setState(
|
552 |
-
Mage_Sales_Model_Order::STATE_PROCESSING, Mage_Sales_Model_Order::STATE_PROCESSING,
|
553 |
-
//$helper->__('Payson created an invoice'));
|
554 |
-
$config->get('test_mode') ? $helper->__('Payson test created an invoice') : $helper->__('Payson created an invoice'));
|
555 |
|
556 |
|
557 |
|
@@ -834,12 +822,12 @@ LIMIT
|
|
834 |
}
|
835 |
|
836 |
$address->save();
|
837 |
-
$order->addStatusHistoryComment(sprintf($
|
838 |
'Payson updated the shipping address')));
|
839 |
}
|
840 |
} else {
|
841 |
$order->addStatusHistoryComment(sprintf(
|
842 |
-
$
|
843 |
}
|
844 |
|
845 |
break;
|
@@ -849,7 +837,7 @@ LIMIT
|
|
849 |
|
850 |
$order->cancel();
|
851 |
|
852 |
-
$order->addStatusHistoryComment($
|
853 |
|
854 |
break;
|
855 |
|
@@ -890,7 +878,6 @@ LIMIT
|
|
890 |
* @return object $this
|
891 |
*/
|
892 |
public function PaymentDetails($order_id) {
|
893 |
-
$helper = Mage::helper('payson');
|
894 |
|
895 |
// Get the database connection
|
896 |
$resource = Mage::getSingleton('core/resource');
|
@@ -929,15 +916,15 @@ LIMIT
|
|
929 |
(
|
930 |
'token' => $payson_order->token
|
931 |
);
|
932 |
-
$url = vsprintf(self::API_CALL_PAYMENT_DETAILS, $this->
|
933 |
|
934 |
-
$client = $this->
|
935 |
->setParameterPost($args);
|
936 |
|
937 |
$response = Payson_Payson_Helper_Api_Response_Standard
|
938 |
::FromHttpBody($client->request()->getBody());
|
939 |
|
940 |
-
$this->
|
941 |
|
942 |
$db->insert($order_log_table, array
|
943 |
(
|
@@ -949,7 +936,7 @@ LIMIT
|
|
949 |
));
|
950 |
|
951 |
if (!$response->IsValid()) {
|
952 |
-
throw new Mage_Core_Exception(sprintf($
|
953 |
'Failed to retrieve payment details. Payson replied: %s'), $response->GetError()), $response->GetErrorId());
|
954 |
}
|
955 |
|
@@ -964,7 +951,6 @@ LIMIT
|
|
964 |
* @return object $this
|
965 |
*/
|
966 |
public function PaymentUpdate($order_id, $action) {
|
967 |
-
$helper = Mage::helper('payson');
|
968 |
|
969 |
// Get the database connection
|
970 |
$resource = Mage::getSingleton('core/resource');
|
@@ -1005,13 +991,13 @@ LIMIT
|
|
1005 |
'action' => $action
|
1006 |
);
|
1007 |
|
1008 |
-
$client = $this->
|
1009 |
->setParameterPost($args);
|
1010 |
|
1011 |
$response = Payson_Payson_Helper_Api_Response_Standard
|
1012 |
::FromHttpBody($client->request()->getBody());
|
1013 |
|
1014 |
-
$this->
|
1015 |
|
1016 |
$db->insert($order_log_table, array
|
1017 |
(
|
@@ -1025,7 +1011,7 @@ LIMIT
|
|
1025 |
/* if(!$response->IsValid())
|
1026 |
{
|
1027 |
// TODO: don't seem to return an errorList
|
1028 |
-
throw new Mage_Core_Exception(sprintf($
|
1029 |
'Failed to update payment. Payson replied: %s'),
|
1030 |
$response->GetError()), $response->GetErrorId());
|
1031 |
} */
|
@@ -1033,11 +1019,11 @@ LIMIT
|
|
1033 |
return $this;
|
1034 |
}
|
1035 |
|
1036 |
-
private function
|
1037 |
-
|
1038 |
$stack = array();
|
1039 |
/* @var $isTest bool */
|
1040 |
-
$isTest = ($
|
1041 |
|
1042 |
array_push($stack, self::DEBUG_MODE ? "http" : "https");
|
1043 |
array_push($stack, $isTest && !self::DEBUG_MODE ? "test-" : (self::DEBUG_MODE && !$isForwardURL ? "mvc" : ""));
|
@@ -1077,4 +1063,3 @@ LIMIT
|
|
1077 |
}
|
1078 |
|
1079 |
}
|
1080 |
-
|
11 |
const API_CALL_PAYMENT_DETAILS = '%s://%sapi.payson.%s/%s/%sDetails/';
|
12 |
const API_CALL_PAYMENT_UPDATE = '%s://%sapi.payson.%s/%s/%sUpdate/';
|
13 |
const PAY_FORWARD_URL = '%s://%s%s.payson.%s/paySecure/';
|
14 |
+
const APPLICATION_ID = 'Magento';
|
15 |
const MODULE_NAME = 'payson_magento';
|
16 |
+
const MODULE_VERSION = '1.2';
|
17 |
const DEBUG_MODE_MAIL = 'testagent-1@payson.se';
|
18 |
const DEBUG_MODE_AGENT_ID = '1';
|
19 |
const DEBUG_MODE_MD5 = 'fddb19ac-7470-42b6-a91d-072cb1495f0a';
|
57 |
|
58 |
private $response;
|
59 |
private $order_discount_item = 0.0;
|
60 |
+
/* @var $_config Payson_Payson_Model_Config */
|
61 |
+
private $_config;
|
62 |
+
/* @var $_helper Payson_Payson_Helper_Data */
|
63 |
+
private $_helper;
|
64 |
+
private $_products = array();
|
65 |
|
66 |
/*
|
67 |
* Private methods
|
68 |
*/
|
69 |
|
70 |
+
public function __construct() {
|
71 |
+
$this->_config = Mage::getModel('payson/config');
|
72 |
+
$this->_helper = Mage::helper('payson');
|
73 |
+
}
|
74 |
+
|
75 |
+
private function getHttpClient($url) {
|
76 |
+
|
77 |
|
78 |
$http_client = new Zend_Http_Client($url);
|
79 |
|
80 |
$http_client->setMethod(Zend_Http_Client::POST)
|
81 |
->setHeaders(array
|
82 |
(
|
83 |
+
'PAYSON-SECURITY-USERID' => $this->_config->get('test_mode') ? self::DEBUG_MODE_AGENT_ID : $this->_config->Get('agent_id'),
|
84 |
+
'PAYSON-SECURITY-PASSWORD' => $this->_config->get('test_mode') ? self::DEBUG_MODE_MD5 : $this->_config->Get('md5_key'),
|
85 |
'PAYSON-APPLICATION-ID' => self::APPLICATION_ID,
|
86 |
'PAYSON-MODULE-INFO' => self::MODULE_NAME . '|' . self::MODULE_VERSION . '|' . Mage::getVersion()
|
87 |
));
|
89 |
return $http_client->resetParameters();
|
90 |
}
|
91 |
|
92 |
+
private function setResponse(
|
93 |
Payson_Payson_Helper_Api_Response_Interface $response) {
|
94 |
$this->response = $response;
|
95 |
|
96 |
return $this;
|
97 |
}
|
98 |
|
99 |
+
private function setOrderDiscountItem($item, &$total) {
|
100 |
+
$total -= $item->getDiscountAmount();
|
101 |
+
$this->order_discount_item += $item->getDiscountAmount();
|
102 |
}
|
103 |
|
104 |
/**
|
105 |
* Helper for Pay()
|
106 |
*
|
107 |
+
* @param Mage_Sales_Model_Order_Item $item
|
|
|
108 |
* @param int $total
|
109 |
* @return array
|
110 |
*/
|
111 |
+
private function prepareOrderItemData($item, &$total) {
|
112 |
+
/* @var $product Mage_Catalog_Model_Product */
|
113 |
$product = Mage::getModel('catalog/product')
|
114 |
->load($item->getProductId());
|
|
|
115 |
|
116 |
+
$attributesString = "";
|
117 |
+
|
118 |
+
if (($children = $item->getChildrenItems()) != null && !$product->isConfigurable()) {
|
119 |
$args = array();
|
120 |
+
$this->prepareProductData($item->getName(), $item->getSku(), $item->getQtyOrdered(), 0, 0);
|
121 |
foreach ($children as $child) {
|
122 |
+
$this->prepareOrderItemData($child, $total);
|
123 |
}
|
124 |
+
return;
|
125 |
}
|
126 |
|
127 |
+
$productOptions = $item->getProductOptions();
|
128 |
+
foreach ($productOptions['attributes_info'] as $attribute) {
|
129 |
+
$attributesString .= $attribute['label'] . ": " . $attribute['value'] . ", ";
|
|
|
|
|
|
|
130 |
}
|
131 |
|
132 |
+
if ($attributesString != "") {
|
133 |
+
$attributesString = substr($attributesString, 0, strlen($attributesString) - 2);
|
134 |
+
}
|
135 |
+
|
136 |
+
$name = $item->getName() . ($attributesString != "" ? " - " . $attributesString : "");
|
137 |
+
$sku = $item->getSku();
|
138 |
+
|
139 |
+
$tax_mod = (float) $item->getTaxPercent();
|
140 |
$tax_mod /= 100;
|
141 |
$tax_mod = round($tax_mod, 5);
|
142 |
|
143 |
+
$qty = (float) $item->getQtyOrdered();
|
144 |
$qty = round($qty, 2);
|
145 |
|
146 |
+
$price = (float) $item->getRowTotalInclTax();
|
147 |
|
148 |
$base_price = (($price / (1 + $tax_mod)) / $qty);
|
149 |
$base_price = round($base_price, 3);
|
150 |
|
151 |
$total += (($base_price * (1 + $tax_mod)) * $qty);
|
152 |
|
153 |
+
$this->prepareProductData($name, $sku, $qty, $base_price, $tax_mod);
|
154 |
+
}
|
155 |
+
|
156 |
+
private function generateProductDataForPayson(array $args) {
|
157 |
+
$productData = array();
|
158 |
+
for ($i = 0; $i < sizeof($this->_products); $i++) {
|
159 |
+
$productData += array
|
160 |
+
(
|
161 |
+
'orderItemList.orderItem(' . $i . ').description' =>
|
162 |
+
$this->_products[$i]['Description'],
|
163 |
+
'orderItemList.orderItem(' . $i . ').sku' =>
|
164 |
+
$this->_products[$i]['Sku'],
|
165 |
+
'orderItemList.orderItem(' . $i . ').quantity' =>
|
166 |
+
$this->_products[$i]['Quantity'],
|
167 |
+
'orderItemList.orderItem(' . $i . ').unitPrice' =>
|
168 |
+
$this->_products[$i]['Price'],
|
169 |
+
'orderItemList.orderItem(' . $i . ').taxPercentage' =>
|
170 |
+
$this->_products[$i]['Tax']
|
171 |
+
);
|
172 |
+
$args += $productData;
|
173 |
+
}
|
174 |
+
return $args;
|
175 |
+
}
|
176 |
+
|
177 |
+
private function prepareProductData($description, $sku, $qty, $base_price, $tax_mod) {
|
178 |
+
$description = strlen($description) <= 128 ? $description : substr($description, 128);
|
179 |
+
$sku = strlen($sku) <= 128 ? $sku : substr($sku, 128);
|
180 |
+
$this->_products[] = array("Description" => $description, "Sku" => $sku,
|
181 |
+
"Quantity" => $qty, "Price" => $base_price, "Tax" => $tax_mod);
|
182 |
}
|
183 |
|
184 |
/**
|
189 |
* @param object $store
|
190 |
* @param int $i
|
191 |
* @param int $total
|
|
|
192 |
*/
|
193 |
+
private function prepareOrderShippingData($order, $customer, $store, &$total) {
|
194 |
$tax_calc = Mage::getSingleton('tax/calculation');
|
195 |
|
196 |
$tax_rate_req = $tax_calc->getRateRequest(
|
197 |
$order->getShippingAddress(), $order->getBillingAddress(), $customer->getTaxClassId(), $store);
|
198 |
|
|
|
199 |
|
200 |
+
if (($price = (float) $order->getShippingInclTax()) > 0) {
|
201 |
$tax_mod = $tax_calc->getRate($tax_rate_req->setProductClassId(
|
202 |
Mage::getStoreConfig('tax/classes/shipping_tax_class')));
|
203 |
$tax_mod /= 100;
|
204 |
$tax_mod = round($tax_mod, 5);
|
205 |
|
206 |
+
$price -= (float) $order->getShippingDiscountAmount();
|
207 |
|
208 |
$base_price = ($price / (1 + $tax_mod));
|
209 |
$base_price = round($base_price, 3);
|
210 |
|
211 |
$total += ($base_price * (1 + $tax_mod));
|
212 |
|
213 |
+
$this->prepareProductData($order->getShippingDescription(), $order->getShippingMethod(), 1, $base_price, $tax_mod);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
214 |
}
|
|
|
215 |
}
|
216 |
|
217 |
/*
|
233 |
* @return string
|
234 |
*/
|
235 |
public function GetPayForwardUrl() {
|
236 |
+
$url = vsprintf(self::PAY_FORWARD_URL . '?token=' . $this->GetResponse()->TOKEN, $this->getFormatIfTest(null, true));
|
237 |
return $url;
|
238 |
}
|
239 |
|
245 |
*/
|
246 |
public function Pay(Mage_Sales_Model_Order $order) {
|
247 |
$payment_method = $order->getPayment()->getMethod();
|
248 |
+
|
249 |
+
/* @var $store Mage_Core_Model_Store */
|
250 |
$store = Mage::app()->getStore($order->getStoreId());
|
251 |
$customer = Mage::getModel('customer/customer')
|
252 |
->load($order->getCustomerId());
|
285 |
//$order->getBaseCurrencyCode(),
|
286 |
strtoupper(substr($order->getOrderCurrency()->getCode(), 0, 3)),
|
287 |
'memo' =>
|
288 |
+
sprintf($this->_helper->__('Order from %s'), $store->getName()),
|
289 |
'senderEmail' =>
|
290 |
$order->getCustomerEmail(),
|
291 |
'senderFirstName' =>
|
293 |
'senderLastName' =>
|
294 |
$billing_address->getLastname(),
|
295 |
'receiverList.receiver(0).email' =>
|
296 |
+
$this->_config->get('test_mode') ? self::DEBUG_MODE_MAIL : $this->_config->Get('email'),
|
297 |
'trackingId' => $order->getRealOrderId()
|
298 |
);
|
299 |
|
300 |
+
if (!$this->_config->CanPaymentGuarantee()) {
|
301 |
$args['guaranteeOffered'] = self::GUARANTEE_NO;
|
302 |
}
|
303 |
|
304 |
if (($payment_method === 'payson_invoice')) {
|
305 |
+
if (!$this->_config->CanInvoicePayment()) {
|
306 |
Mage::throwException('Invoice payment is disabled');
|
307 |
}
|
308 |
|
309 |
+
$args['fundingList.fundingConstraint(0).constraint'] = self::PAYMENT_METHOD_INVOICE;
|
310 |
+
} else {
|
311 |
+
switch ($this->_config->get('paysondirect_method')) {
|
312 |
+
case 1:
|
313 |
+
$args['fundingList.fundingConstraint(0).constraint'] = 'CREDITCARD';
|
314 |
+
break;
|
315 |
+
case 2:
|
316 |
+
$args['fundingList.fundingConstraint(0).constraint'] = 'BANK';
|
317 |
+
break;
|
318 |
+
default:
|
319 |
+
break;
|
320 |
+
}
|
321 |
}
|
322 |
|
323 |
+
|
324 |
$total = 0;
|
325 |
|
326 |
// Calculate price of each item in the order
|
327 |
foreach ($order->getAllVisibleItems() as $item) {
|
328 |
+
$this->prepareOrderItemData($item, $total);
|
329 |
}
|
330 |
|
331 |
foreach ($order->getAllVisibleItems() as $item) {
|
332 |
+
$this->setOrderDiscountItem($item, $total);
|
333 |
}
|
334 |
+
if ($this->order_discount_item > 0) {
|
335 |
+
$this->prepareProductData('discount', 'discount', 1, -$this->order_discount_item, 0.0);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
336 |
}
|
337 |
// Calculate price for shipping
|
338 |
+
$this->prepareOrderShippingData($order, $customer, $store, $total);
|
339 |
+
|
|
|
|
|
340 |
if ($order->getPaysonInvoiceFee() > 0) {
|
341 |
$fee = $order->getPaysonInvoiceFee();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
342 |
$args['invoiceFee'] = round((float) $fee, 3);
|
343 |
$total += $fee;
|
344 |
}
|
345 |
|
346 |
+
$args = $this->generateProductDataForPayson($args);
|
347 |
+
|
348 |
+
$roundedTotal = round($total, 2);
|
349 |
|
350 |
+
$args['receiverList.receiver(0).amount'] = $roundedTotal;
|
351 |
|
352 |
+
$url = vsprintf(self::API_CALL_PAY, $this->getFormatIfTest($order->getStoreId()));
|
353 |
+
$client = $this->getHttpClient($url)
|
|
|
354 |
->setParameterPost($args);
|
355 |
|
356 |
$response = Payson_Payson_Helper_Api_Response_Standard
|
357 |
::FromHttpBody($client->request()->getBody());
|
358 |
|
359 |
+
$this->setResponse($response);
|
360 |
|
361 |
$resource = Mage::getSingleton('core/resource');
|
362 |
$db = $resource->getConnection('core_write');
|
388 |
|
389 |
if (!$response->IsValid()) {
|
390 |
|
391 |
+
throw new Mage_Core_Exception(sprintf($this->_helper->__(
|
392 |
'Failed to initialize payment. Payson replied: %s'), $response->GetError()), $response->GetErrorId());
|
393 |
}
|
394 |
|
405 |
* @return object $this
|
406 |
*/
|
407 |
public function Validate($http_body, $content_type) {
|
408 |
+
|
|
|
409 |
// Parse request done by Payson to our IPN controller
|
410 |
$ipn_response = Payson_Payson_Helper_Api_Response_Standard
|
411 |
::FromHttpBody($http_body);
|
462 |
}
|
463 |
|
464 |
// Do the validate API call
|
465 |
+
$client = $this->getHttpClient(vsprintf(self::API_CALL_VALIDATE, $this->getFormatIfTest($payson_order->store_id)))
|
466 |
->setRawData($http_body, $content_type);
|
467 |
|
468 |
$response = Payson_Payson_Helper_Api_Response_Validate
|
469 |
::FromHttpBody($client->request()->getBody());
|
470 |
|
471 |
+
$this->setResponse($response);
|
472 |
|
473 |
if (!$response->IsValid()) {
|
474 |
Mage::throwException('Validate call was unsuccessful');
|
516 |
case self::STATUS_COMPLETED: {
|
517 |
//Changes the status of the order from pending_payment to processing
|
518 |
$order->setState(
|
519 |
+
Mage_Sales_Model_Order::STATE_PROCESSING, Mage_Sales_Model_Order::STATE_PROCESSING, $this->_config->get('test_mode') ? $this->_helper->__('Payson test completed the order payment') : $this->_helper->__('Payson completed the order payment'));
|
|
|
|
|
520 |
|
521 |
//It creates the invoice to the order
|
522 |
$invoice = Mage::getModel('sales/service_order', $order)->prepareInvoice();
|
539 |
self::INVOICE_STATUS_ORDERCREATED)) {
|
540 |
//Changes the status of the order from pending to processing
|
541 |
$order->setState(
|
542 |
+
Mage_Sales_Model_Order::STATE_PROCESSING, Mage_Sales_Model_Order::STATE_PROCESSING, $this->_config->get('test_mode') ? $this->_helper->__('Payson test created an invoice') : $this->_helper->__('Payson created an invoice'));
|
|
|
|
|
543 |
|
544 |
|
545 |
|
822 |
}
|
823 |
|
824 |
$address->save();
|
825 |
+
$order->addStatusHistoryComment(sprintf($this->_helper->__(
|
826 |
'Payson updated the shipping address')));
|
827 |
}
|
828 |
} else {
|
829 |
$order->addStatusHistoryComment(sprintf(
|
830 |
+
$this->_helper->__('Payson pinged the order with status %s'), $ipn_response->status));
|
831 |
}
|
832 |
|
833 |
break;
|
837 |
|
838 |
$order->cancel();
|
839 |
|
840 |
+
$order->addStatusHistoryComment($this->_helper->__('The order was denied by Payson.'));
|
841 |
|
842 |
break;
|
843 |
|
878 |
* @return object $this
|
879 |
*/
|
880 |
public function PaymentDetails($order_id) {
|
|
|
881 |
|
882 |
// Get the database connection
|
883 |
$resource = Mage::getSingleton('core/resource');
|
916 |
(
|
917 |
'token' => $payson_order->token
|
918 |
);
|
919 |
+
$url = vsprintf(self::API_CALL_PAYMENT_DETAILS, $this->getFormatIfTest($payson_order->store_id));
|
920 |
|
921 |
+
$client = $this->getHttpClient($url)
|
922 |
->setParameterPost($args);
|
923 |
|
924 |
$response = Payson_Payson_Helper_Api_Response_Standard
|
925 |
::FromHttpBody($client->request()->getBody());
|
926 |
|
927 |
+
$this->setResponse($response);
|
928 |
|
929 |
$db->insert($order_log_table, array
|
930 |
(
|
936 |
));
|
937 |
|
938 |
if (!$response->IsValid()) {
|
939 |
+
throw new Mage_Core_Exception(sprintf($this->_helper->__(
|
940 |
'Failed to retrieve payment details. Payson replied: %s'), $response->GetError()), $response->GetErrorId());
|
941 |
}
|
942 |
|
951 |
* @return object $this
|
952 |
*/
|
953 |
public function PaymentUpdate($order_id, $action) {
|
|
|
954 |
|
955 |
// Get the database connection
|
956 |
$resource = Mage::getSingleton('core/resource');
|
991 |
'action' => $action
|
992 |
);
|
993 |
|
994 |
+
$client = $this->getHttpClient(vsprintf(self::API_CALL_PAYMENT_UPDATE, $this->getFormatIfTest($payson_order->store_id)))
|
995 |
->setParameterPost($args);
|
996 |
|
997 |
$response = Payson_Payson_Helper_Api_Response_Standard
|
998 |
::FromHttpBody($client->request()->getBody());
|
999 |
|
1000 |
+
$this->setResponse($response);
|
1001 |
|
1002 |
$db->insert($order_log_table, array
|
1003 |
(
|
1011 |
/* if(!$response->IsValid())
|
1012 |
{
|
1013 |
// TODO: don't seem to return an errorList
|
1014 |
+
throw new Mage_Core_Exception(sprintf($this->_helper->__(
|
1015 |
'Failed to update payment. Payson replied: %s'),
|
1016 |
$response->GetError()), $response->GetErrorId());
|
1017 |
} */
|
1019 |
return $this;
|
1020 |
}
|
1021 |
|
1022 |
+
private function getFormatIfTest($storeID = null, $isForwardURL = FALSE) {
|
1023 |
+
|
1024 |
$stack = array();
|
1025 |
/* @var $isTest bool */
|
1026 |
+
$isTest = ($this->_config->get('test_mode', $storeID) == "1");
|
1027 |
|
1028 |
array_push($stack, self::DEBUG_MODE ? "http" : "https");
|
1029 |
array_push($stack, $isTest && !self::DEBUG_MODE ? "test-" : (self::DEBUG_MODE && !$isForwardURL ? "mvc" : ""));
|
1063 |
}
|
1064 |
|
1065 |
}
|
|
app/code/community/Payson/Payson/Helper/Api/Response/Interface.php
CHANGED
@@ -1,20 +1,20 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
interface Payson_Payson_Helper_Api_Response_Interface {
|
4 |
-
|
5 |
-
/**
|
6 |
-
* Construct a response object from a string
|
7 |
-
*
|
8 |
-
* @param string $body
|
9 |
-
* @return object
|
10 |
-
*/
|
11 |
-
public static function FromHttpBody($body);
|
12 |
-
|
13 |
-
/**
|
14 |
-
* Whether this response is valid
|
15 |
-
*
|
16 |
-
* @return bool
|
17 |
-
*/
|
18 |
-
public function IsValid();
|
19 |
-
}
|
20 |
-
|
1 |
+
<?php
|
2 |
+
|
3 |
+
interface Payson_Payson_Helper_Api_Response_Interface {
|
4 |
+
|
5 |
+
/**
|
6 |
+
* Construct a response object from a string
|
7 |
+
*
|
8 |
+
* @param string $body
|
9 |
+
* @return object
|
10 |
+
*/
|
11 |
+
public static function FromHttpBody($body);
|
12 |
+
|
13 |
+
/**
|
14 |
+
* Whether this response is valid
|
15 |
+
*
|
16 |
+
* @return bool
|
17 |
+
*/
|
18 |
+
public function IsValid();
|
19 |
+
}
|
20 |
+
|
app/code/community/Payson/Payson/Helper/Api/Response/Standard.php
CHANGED
@@ -1,131 +1,131 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
class Payson_Payson_Helper_Api_Response_Standard extends Payson_Payson_Helper_Api_Response_Standard_Parameters implements Payson_Payson_Helper_Api_Response_Interface {
|
4 |
-
/*
|
5 |
-
* Constants
|
6 |
-
*/
|
7 |
-
|
8 |
-
const ACK_SUCCESS = 'SUCCESS';
|
9 |
-
const ACK_FAILURE = 'FAILURE';
|
10 |
-
|
11 |
-
/*
|
12 |
-
* Public methods
|
13 |
-
*/
|
14 |
-
|
15 |
-
/**
|
16 |
-
* Parse response object and instantiate
|
17 |
-
*
|
18 |
-
* @param string $response
|
19 |
-
* @return object
|
20 |
-
*/
|
21 |
-
static public function FromHttpBody($body) {
|
22 |
-
$params = array();
|
23 |
-
parse_str($body, $params);
|
24 |
-
|
25 |
-
foreach ($params as $key => $value) {
|
26 |
-
$sub_key = strtok($key, '_');
|
27 |
-
|
28 |
-
if ($sub_key === $key) {
|
29 |
-
continue;
|
30 |
-
}
|
31 |
-
|
32 |
-
$current = &$params;
|
33 |
-
|
34 |
-
do {
|
35 |
-
$matches = array();
|
36 |
-
|
37 |
-
if (preg_match('/\((\d)\)$/', $sub_key, $matches) === 1) {
|
38 |
-
$sub_key = substr($sub_key, 0, -3);
|
39 |
-
|
40 |
-
if (!strlen($sub_key)) {
|
41 |
-
continue;
|
42 |
-
}
|
43 |
-
}
|
44 |
-
|
45 |
-
if (!isset($current[$sub_key]) || !is_array($current[$sub_key])) {
|
46 |
-
$current[$sub_key] = array();
|
47 |
-
}
|
48 |
-
|
49 |
-
$current = &$current[$sub_key];
|
50 |
-
|
51 |
-
if (isset($matches[1])) {
|
52 |
-
if (!isset($current[$matches[1]]) ||
|
53 |
-
!is_array($current[$matches[1]])) {
|
54 |
-
$current[$matches[1]] = array();
|
55 |
-
}
|
56 |
-
|
57 |
-
$current = &$current[$matches[1]];
|
58 |
-
}
|
59 |
-
} while (($sub_key = strtok('_')) !== false);
|
60 |
-
|
61 |
-
$current = $value;
|
62 |
-
|
63 |
-
unset($params[$key]);
|
64 |
-
}
|
65 |
-
|
66 |
-
return new self($params);
|
67 |
-
}
|
68 |
-
|
69 |
-
/**
|
70 |
-
* Populate parameters
|
71 |
-
*
|
72 |
-
* @param array $params
|
73 |
-
* @return void
|
74 |
-
*/
|
75 |
-
public function __construct(array $params) {
|
76 |
-
if (empty($params)) {
|
77 |
-
Mage::throwException('Invalid response');
|
78 |
-
}
|
79 |
-
|
80 |
-
parent::__construct($params);
|
81 |
-
}
|
82 |
-
|
83 |
-
/**
|
84 |
-
* @inheritDoc
|
85 |
-
*/
|
86 |
-
public function IsValid() {
|
87 |
-
return (isset($this->responseEnvelope->ack) &&
|
88 |
-
($this->responseEnvelope->ack === self::ACK_SUCCESS));
|
89 |
-
}
|
90 |
-
|
91 |
-
/**
|
92 |
-
* Compile all errors into a string
|
93 |
-
*
|
94 |
-
* @return string
|
95 |
-
*/
|
96 |
-
public function GetError() {
|
97 |
-
$ret = '';
|
98 |
-
|
99 |
-
if (isset($this->errorList->error)) {
|
100 |
-
foreach ($this->errorList->error->ToArray() as $error) {
|
101 |
-
if (isset($error['parameter'])) {
|
102 |
-
$ret .= $error['parameter'] . ' ';
|
103 |
-
}
|
104 |
-
|
105 |
-
$ret .= '(' . $error['errorId'] . ') ' .
|
106 |
-
$error['message'] . ' ';
|
107 |
-
}
|
108 |
-
}
|
109 |
-
|
110 |
-
return rtrim($ret);
|
111 |
-
}
|
112 |
-
|
113 |
-
/**
|
114 |
-
* Get first error id
|
115 |
-
*
|
116 |
-
* @return int|null
|
117 |
-
*/
|
118 |
-
public function GetErrorId() {
|
119 |
-
if (isset($this->errorList->error)) {
|
120 |
-
foreach ($this->errorList->error->ToArray() as $error) {
|
121 |
-
if (isset($error['errorId'])) {
|
122 |
-
return (int) $error['errorId'];
|
123 |
-
}
|
124 |
-
}
|
125 |
-
}
|
126 |
-
|
127 |
-
return null;
|
128 |
-
}
|
129 |
-
|
130 |
-
}
|
131 |
-
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Payson_Payson_Helper_Api_Response_Standard extends Payson_Payson_Helper_Api_Response_Standard_Parameters implements Payson_Payson_Helper_Api_Response_Interface {
|
4 |
+
/*
|
5 |
+
* Constants
|
6 |
+
*/
|
7 |
+
|
8 |
+
const ACK_SUCCESS = 'SUCCESS';
|
9 |
+
const ACK_FAILURE = 'FAILURE';
|
10 |
+
|
11 |
+
/*
|
12 |
+
* Public methods
|
13 |
+
*/
|
14 |
+
|
15 |
+
/**
|
16 |
+
* Parse response object and instantiate
|
17 |
+
*
|
18 |
+
* @param string $response
|
19 |
+
* @return object
|
20 |
+
*/
|
21 |
+
static public function FromHttpBody($body) {
|
22 |
+
$params = array();
|
23 |
+
parse_str($body, $params);
|
24 |
+
|
25 |
+
foreach ($params as $key => $value) {
|
26 |
+
$sub_key = strtok($key, '_');
|
27 |
+
|
28 |
+
if ($sub_key === $key) {
|
29 |
+
continue;
|
30 |
+
}
|
31 |
+
|
32 |
+
$current = &$params;
|
33 |
+
|
34 |
+
do {
|
35 |
+
$matches = array();
|
36 |
+
|
37 |
+
if (preg_match('/\((\d)\)$/', $sub_key, $matches) === 1) {
|
38 |
+
$sub_key = substr($sub_key, 0, -3);
|
39 |
+
|
40 |
+
if (!strlen($sub_key)) {
|
41 |
+
continue;
|
42 |
+
}
|
43 |
+
}
|
44 |
+
|
45 |
+
if (!isset($current[$sub_key]) || !is_array($current[$sub_key])) {
|
46 |
+
$current[$sub_key] = array();
|
47 |
+
}
|
48 |
+
|
49 |
+
$current = &$current[$sub_key];
|
50 |
+
|
51 |
+
if (isset($matches[1])) {
|
52 |
+
if (!isset($current[$matches[1]]) ||
|
53 |
+
!is_array($current[$matches[1]])) {
|
54 |
+
$current[$matches[1]] = array();
|
55 |
+
}
|
56 |
+
|
57 |
+
$current = &$current[$matches[1]];
|
58 |
+
}
|
59 |
+
} while (($sub_key = strtok('_')) !== false);
|
60 |
+
|
61 |
+
$current = $value;
|
62 |
+
|
63 |
+
unset($params[$key]);
|
64 |
+
}
|
65 |
+
|
66 |
+
return new self($params);
|
67 |
+
}
|
68 |
+
|
69 |
+
/**
|
70 |
+
* Populate parameters
|
71 |
+
*
|
72 |
+
* @param array $params
|
73 |
+
* @return void
|
74 |
+
*/
|
75 |
+
public function __construct(array $params) {
|
76 |
+
if (empty($params)) {
|
77 |
+
Mage::throwException('Invalid response');
|
78 |
+
}
|
79 |
+
|
80 |
+
parent::__construct($params);
|
81 |
+
}
|
82 |
+
|
83 |
+
/**
|
84 |
+
* @inheritDoc
|
85 |
+
*/
|
86 |
+
public function IsValid() {
|
87 |
+
return (isset($this->responseEnvelope->ack) &&
|
88 |
+
($this->responseEnvelope->ack === self::ACK_SUCCESS));
|
89 |
+
}
|
90 |
+
|
91 |
+
/**
|
92 |
+
* Compile all errors into a string
|
93 |
+
*
|
94 |
+
* @return string
|
95 |
+
*/
|
96 |
+
public function GetError() {
|
97 |
+
$ret = '';
|
98 |
+
|
99 |
+
if (isset($this->errorList->error)) {
|
100 |
+
foreach ($this->errorList->error->ToArray() as $error) {
|
101 |
+
if (isset($error['parameter'])) {
|
102 |
+
$ret .= $error['parameter'] . ' ';
|
103 |
+
}
|
104 |
+
|
105 |
+
$ret .= '(' . $error['errorId'] . ') ' .
|
106 |
+
$error['message'] . ' ';
|
107 |
+
}
|
108 |
+
}
|
109 |
+
|
110 |
+
return rtrim($ret);
|
111 |
+
}
|
112 |
+
|
113 |
+
/**
|
114 |
+
* Get first error id
|
115 |
+
*
|
116 |
+
* @return int|null
|
117 |
+
*/
|
118 |
+
public function GetErrorId() {
|
119 |
+
if (isset($this->errorList->error)) {
|
120 |
+
foreach ($this->errorList->error->ToArray() as $error) {
|
121 |
+
if (isset($error['errorId'])) {
|
122 |
+
return (int) $error['errorId'];
|
123 |
+
}
|
124 |
+
}
|
125 |
+
}
|
126 |
+
|
127 |
+
return null;
|
128 |
+
}
|
129 |
+
|
130 |
+
}
|
131 |
+
|
app/code/community/Payson/Payson/Helper/Api/Response/Standard/Parameters.php
CHANGED
@@ -1,66 +1,66 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
class Payson_Payson_Helper_Api_Response_Standard_Parameters {
|
4 |
-
/*
|
5 |
-
* Protected properties
|
6 |
-
*/
|
7 |
-
|
8 |
-
/**
|
9 |
-
* Multi-dimensional array containing parameters from the response
|
10 |
-
*
|
11 |
-
* @var array
|
12 |
-
*/
|
13 |
-
protected $params = array();
|
14 |
-
|
15 |
-
/*
|
16 |
-
* Public methods
|
17 |
-
*/
|
18 |
-
|
19 |
-
/**
|
20 |
-
* Constructor!
|
21 |
-
*
|
22 |
-
* @param arary $params
|
23 |
-
* @return void
|
24 |
-
*/
|
25 |
-
public function __construct(array $params) {
|
26 |
-
foreach ($params as $key => $value) {
|
27 |
-
if (is_array($value)) {
|
28 |
-
$this->params[$key] = new self($value);
|
29 |
-
} else {
|
30 |
-
$this->params[$key] = $value;
|
31 |
-
}
|
32 |
-
}
|
33 |
-
}
|
34 |
-
|
35 |
-
public function __get($name) {
|
36 |
-
return (isset($this->params[$name]) ? $this->params[$name] : null);
|
37 |
-
}
|
38 |
-
|
39 |
-
public function __set($name, $value) {
|
40 |
-
$this->params[$name] = $value;
|
41 |
-
}
|
42 |
-
|
43 |
-
public function __isset($name) {
|
44 |
-
return isset($this->params[$name]);
|
45 |
-
}
|
46 |
-
|
47 |
-
/**
|
48 |
-
* Compile the parameters into an array
|
49 |
-
*
|
50 |
-
* @return array
|
51 |
-
*/
|
52 |
-
public function ToArray() {
|
53 |
-
foreach ($this->params as $key => $value) {
|
54 |
-
if ($value instanceof
|
55 |
-
Payson_Payson_Helper_Api_Response_Standard_Parameters) {
|
56 |
-
$arr[$key] = $value->ToArray();
|
57 |
-
} else {
|
58 |
-
$arr[$key] = $value;
|
59 |
-
}
|
60 |
-
}
|
61 |
-
|
62 |
-
return $arr;
|
63 |
-
}
|
64 |
-
|
65 |
-
}
|
66 |
-
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Payson_Payson_Helper_Api_Response_Standard_Parameters {
|
4 |
+
/*
|
5 |
+
* Protected properties
|
6 |
+
*/
|
7 |
+
|
8 |
+
/**
|
9 |
+
* Multi-dimensional array containing parameters from the response
|
10 |
+
*
|
11 |
+
* @var array
|
12 |
+
*/
|
13 |
+
protected $params = array();
|
14 |
+
|
15 |
+
/*
|
16 |
+
* Public methods
|
17 |
+
*/
|
18 |
+
|
19 |
+
/**
|
20 |
+
* Constructor!
|
21 |
+
*
|
22 |
+
* @param arary $params
|
23 |
+
* @return void
|
24 |
+
*/
|
25 |
+
public function __construct(array $params) {
|
26 |
+
foreach ($params as $key => $value) {
|
27 |
+
if (is_array($value)) {
|
28 |
+
$this->params[$key] = new self($value);
|
29 |
+
} else {
|
30 |
+
$this->params[$key] = $value;
|
31 |
+
}
|
32 |
+
}
|
33 |
+
}
|
34 |
+
|
35 |
+
public function __get($name) {
|
36 |
+
return (isset($this->params[$name]) ? $this->params[$name] : null);
|
37 |
+
}
|
38 |
+
|
39 |
+
public function __set($name, $value) {
|
40 |
+
$this->params[$name] = $value;
|
41 |
+
}
|
42 |
+
|
43 |
+
public function __isset($name) {
|
44 |
+
return isset($this->params[$name]);
|
45 |
+
}
|
46 |
+
|
47 |
+
/**
|
48 |
+
* Compile the parameters into an array
|
49 |
+
*
|
50 |
+
* @return array
|
51 |
+
*/
|
52 |
+
public function ToArray() {
|
53 |
+
foreach ($this->params as $key => $value) {
|
54 |
+
if ($value instanceof
|
55 |
+
Payson_Payson_Helper_Api_Response_Standard_Parameters) {
|
56 |
+
$arr[$key] = $value->ToArray();
|
57 |
+
} else {
|
58 |
+
$arr[$key] = $value;
|
59 |
+
}
|
60 |
+
}
|
61 |
+
|
62 |
+
return $arr;
|
63 |
+
}
|
64 |
+
|
65 |
+
}
|
66 |
+
|
app/code/community/Payson/Payson/Helper/Api/Response/Validate.php
CHANGED
@@ -1,46 +1,46 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
class Payson_Payson_Helper_Api_Response_Validate implements Payson_Payson_Helper_Api_Response_Interface {
|
4 |
-
/*
|
5 |
-
* Constants
|
6 |
-
*/
|
7 |
-
|
8 |
-
const VERIFIED = 'VERIFIED';
|
9 |
-
const INVALID = 'INVALID';
|
10 |
-
|
11 |
-
/*
|
12 |
-
* Private properties
|
13 |
-
*/
|
14 |
-
|
15 |
-
private $data;
|
16 |
-
|
17 |
-
/*
|
18 |
-
* Public methods
|
19 |
-
*/
|
20 |
-
|
21 |
-
/**
|
22 |
-
* @inheritDoc
|
23 |
-
*/
|
24 |
-
static public function FromHttpBody($data) {
|
25 |
-
return new self($data);
|
26 |
-
}
|
27 |
-
|
28 |
-
/**
|
29 |
-
* Constructor!
|
30 |
-
*
|
31 |
-
* @param string $data
|
32 |
-
* @return void
|
33 |
-
*/
|
34 |
-
public function __construct($data) {
|
35 |
-
$this->data = $data;
|
36 |
-
}
|
37 |
-
|
38 |
-
/**
|
39 |
-
* @inheritDoc
|
40 |
-
*/
|
41 |
-
public function IsValid() {
|
42 |
-
return ($this->data === self::VERIFIED);
|
43 |
-
}
|
44 |
-
|
45 |
-
}
|
46 |
-
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Payson_Payson_Helper_Api_Response_Validate implements Payson_Payson_Helper_Api_Response_Interface {
|
4 |
+
/*
|
5 |
+
* Constants
|
6 |
+
*/
|
7 |
+
|
8 |
+
const VERIFIED = 'VERIFIED';
|
9 |
+
const INVALID = 'INVALID';
|
10 |
+
|
11 |
+
/*
|
12 |
+
* Private properties
|
13 |
+
*/
|
14 |
+
|
15 |
+
private $data;
|
16 |
+
|
17 |
+
/*
|
18 |
+
* Public methods
|
19 |
+
*/
|
20 |
+
|
21 |
+
/**
|
22 |
+
* @inheritDoc
|
23 |
+
*/
|
24 |
+
static public function FromHttpBody($data) {
|
25 |
+
return new self($data);
|
26 |
+
}
|
27 |
+
|
28 |
+
/**
|
29 |
+
* Constructor!
|
30 |
+
*
|
31 |
+
* @param string $data
|
32 |
+
* @return void
|
33 |
+
*/
|
34 |
+
public function __construct($data) {
|
35 |
+
$this->data = $data;
|
36 |
+
}
|
37 |
+
|
38 |
+
/**
|
39 |
+
* @inheritDoc
|
40 |
+
*/
|
41 |
+
public function IsValid() {
|
42 |
+
return ($this->data === self::VERIFIED);
|
43 |
+
}
|
44 |
+
|
45 |
+
}
|
46 |
+
|
app/code/community/Payson/Payson/Helper/Data.php
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
class Payson_Payson_Helper_Data extends Mage_Core_Helper_Abstract {
|
4 |
-
|
5 |
-
}
|
6 |
-
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Payson_Payson_Helper_Data extends Mage_Core_Helper_Abstract {
|
4 |
+
|
5 |
+
}
|
6 |
+
|
app/code/community/Payson/Payson/Model/Config.php
CHANGED
@@ -1,221 +1,221 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
class Payson_Payson_Model_Config {
|
4 |
-
/*
|
5 |
-
* Constants
|
6 |
-
*/
|
7 |
-
|
8 |
-
//const PAYMENT_GUARANTEE = 'payment_guarantee';
|
9 |
-
|
10 |
-
const PAYMENT_GUARANTEE = 'NO';
|
11 |
-
const DIRECT_PAYMENT = 'direct_payment';
|
12 |
-
const CREDIT_CARD_PAYMENT = 'credit_card_payment';
|
13 |
-
const INVOICE_PAYMENT = 'invoice_payment';
|
14 |
-
|
15 |
-
/*
|
16 |
-
* Private properties
|
17 |
-
*/
|
18 |
-
|
19 |
-
/**
|
20 |
-
* Default store id used in GetConfig()
|
21 |
-
*
|
22 |
-
* @var int
|
23 |
-
*/
|
24 |
-
private $default_store_id;
|
25 |
-
|
26 |
-
/**
|
27 |
-
* Supported currency codes
|
28 |
-
*
|
29 |
-
* @var array
|
30 |
-
*/
|
31 |
-
private $supported_currencies = array
|
32 |
-
(
|
33 |
-
'SEK', 'EUR'
|
34 |
-
);
|
35 |
-
|
36 |
-
/*
|
37 |
-
* Public methods
|
38 |
-
*/
|
39 |
-
|
40 |
-
/**
|
41 |
-
* Constructor!
|
42 |
-
*
|
43 |
-
* @return void
|
44 |
-
*/
|
45 |
-
public function __construct() {
|
46 |
-
$this->SetDefaultStoreId(Mage::app()->getStore()->getId());
|
47 |
-
}
|
48 |
-
|
49 |
-
/**
|
50 |
-
* Set default store id
|
51 |
-
*
|
52 |
-
* @param int $store
|
53 |
-
* @return object $this
|
54 |
-
*/
|
55 |
-
public function SetDefaultStoreId($store) {
|
56 |
-
$this->default_store_id = $store;
|
57 |
-
|
58 |
-
return $this;
|
59 |
-
}
|
60 |
-
|
61 |
-
/**
|
62 |
-
* Get default store id
|
63 |
-
*
|
64 |
-
* @return int
|
65 |
-
*/
|
66 |
-
public function GetDefaultStoreId() {
|
67 |
-
return $this->default_store_id;
|
68 |
-
}
|
69 |
-
|
70 |
-
/**
|
71 |
-
* Whether $currency is supported
|
72 |
-
*
|
73 |
-
* @param string $currency
|
74 |
-
* @return bool
|
75 |
-
*/
|
76 |
-
public function IsCurrencySupported($currency) {
|
77 |
-
return in_array(strtoupper($currency), $this->supported_currencies);
|
78 |
-
}
|
79 |
-
|
80 |
-
/**
|
81 |
-
* Get configuration value
|
82 |
-
*
|
83 |
-
* @param mixed $name
|
84 |
-
* @param int|null $store [optional]
|
85 |
-
* @param mixed $default [optional]
|
86 |
-
* @param string $prefix [optional]
|
87 |
-
*/
|
88 |
-
public function GetConfig($name, $store = null, $default = null, $prefix = 'payment/payson_standard/') {
|
89 |
-
if (!isset($store)) {
|
90 |
-
$store = $this->GetDefaultStoreId();
|
91 |
-
}
|
92 |
-
|
93 |
-
$name = $prefix . $name;
|
94 |
-
// Mage::getStoreConfigFlag
|
95 |
-
$value = Mage::getStoreConfig($name, $store);
|
96 |
-
|
97 |
-
return (isset($value) ? $value : $default);
|
98 |
-
}
|
99 |
-
|
100 |
-
/**
|
101 |
-
* @see GetConfig
|
102 |
-
*/
|
103 |
-
public function Get($name, $store = null, $default = null, $prefix = 'payment/payson_standard/') {
|
104 |
-
return $this->GetConfig($name, $store, $default, $prefix);
|
105 |
-
}
|
106 |
-
|
107 |
-
/**
|
108 |
-
* Get Payson specific invoice fee excluding tax
|
109 |
-
*
|
110 |
-
* @param object $order
|
111 |
-
* @return float
|
112 |
-
*/
|
113 |
-
public function GetInvoiceFee($order) {
|
114 |
-
$currency = $order->getBaseCurrencyCode();
|
115 |
-
$currency = strtolower($currency);
|
116 |
-
|
117 |
-
if (!$this->IsCurrencySupported($currency)) {
|
118 |
-
return 0;
|
119 |
-
}
|
120 |
-
|
121 |
-
$store = Mage::app()->getStore($order->getStoreId());
|
122 |
-
|
123 |
-
$fee = $this->GetConfig('invoice_fee_' . $currency, $store->getId(), 0, 'payment/payson_invoice/');
|
124 |
-
$fee = round((float) $fee, 3);
|
125 |
-
|
126 |
-
return $fee;
|
127 |
-
}
|
128 |
-
|
129 |
-
/**
|
130 |
-
* Get Payson specific invoice fee including tax
|
131 |
-
*
|
132 |
-
* @param object $order
|
133 |
-
* @return float
|
134 |
-
*/
|
135 |
-
public function GetInvoiceFeeInclTax($order) {
|
136 |
-
$fee = $this->GetInvoiceFee($order);
|
137 |
-
$fee *= (1 + $this->GetInvoiceFeeTaxMod($order));
|
138 |
-
$fee = round($fee, 3);
|
139 |
-
|
140 |
-
return $fee;
|
141 |
-
}
|
142 |
-
|
143 |
-
/**
|
144 |
-
* Get Payson specific invoice fee tax modifier
|
145 |
-
*
|
146 |
-
* @param object $order
|
147 |
-
* @return float
|
148 |
-
*/
|
149 |
-
public function GetInvoiceFeeTaxMod($order) {
|
150 |
-
$store = Mage::app()->getStore($order->getStoreId());
|
151 |
-
|
152 |
-
$tax_calc = Mage::getSingleton('tax/calculation');
|
153 |
-
$customer = Mage::getModel('customer/customer')
|
154 |
-
->load($order->getCustomerId());
|
155 |
-
|
156 |
-
$tax_class = $this->GetConfig('invoice_fee_tax', $store->getId(), 0, 'payment/payson_invoice/');
|
157 |
-
|
158 |
-
$tax_rate_req = $tax_calc->getRateRequest(
|
159 |
-
$order->getShippingAddress(), $order->getBillingAddress(), $customer->getTaxClassId(), $store)
|
160 |
-
->setProductClassId($tax_class);
|
161 |
-
|
162 |
-
$tax_mod = (float) $tax_calc->getRate($tax_rate_req);
|
163 |
-
$tax_mod /= 100;
|
164 |
-
$tax_mod = round($tax_mod, 5);
|
165 |
-
|
166 |
-
return $tax_mod;
|
167 |
-
}
|
168 |
-
|
169 |
-
/**
|
170 |
-
* Does this store support payment guarantee?
|
171 |
-
*
|
172 |
-
* @param int|null $store [optional]
|
173 |
-
* @return bool
|
174 |
-
*/
|
175 |
-
public function CanPaymentGuarantee($store = null) {
|
176 |
-
return (bool) $this->GetConfig(self::PAYMENT_GUARANTEE, $store, false);
|
177 |
-
}
|
178 |
-
|
179 |
-
/**
|
180 |
-
* Is standard payment enabled?
|
181 |
-
*
|
182 |
-
* @param int|null $store [optional]
|
183 |
-
* @return bool
|
184 |
-
*/
|
185 |
-
public function CanStandardPayment($store = null) {
|
186 |
-
return $this->GetConfig('active', $store, false, 'payment/payson_standard/');
|
187 |
-
}
|
188 |
-
|
189 |
-
/**
|
190 |
-
* Is invoice payment enabled?
|
191 |
-
*
|
192 |
-
* @param int|null $store [optional]
|
193 |
-
* @return bool
|
194 |
-
*/
|
195 |
-
public function CanInvoicePayment($store = null) {
|
196 |
-
/* if(!$this->CanStandardPayment($store))
|
197 |
-
{
|
198 |
-
return false;
|
199 |
-
} */
|
200 |
-
|
201 |
-
return $this->GetConfig('active', $store, false, 'payment/payson_invoice/');
|
202 |
-
}
|
203 |
-
|
204 |
-
public function restoreCartOnCancel($store = null) {
|
205 |
-
if (!$store)
|
206 |
-
$store = Mage::app()->getStore()->getId();
|
207 |
-
$configValue = $this->GetConfig("restore_on_cancel", $store);
|
208 |
-
|
209 |
-
return $configValue == 1;
|
210 |
-
}
|
211 |
-
|
212 |
-
public function restoreCartOnError($store = null) {
|
213 |
-
if (!$store)
|
214 |
-
$store = Mage::app()->getStore()->getId();
|
215 |
-
$configValue = $this->GetConfig("restore_on_error", $store);
|
216 |
-
|
217 |
-
return $configValue == 1;
|
218 |
-
}
|
219 |
-
|
220 |
-
}
|
221 |
-
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Payson_Payson_Model_Config {
|
4 |
+
/*
|
5 |
+
* Constants
|
6 |
+
*/
|
7 |
+
|
8 |
+
//const PAYMENT_GUARANTEE = 'payment_guarantee';
|
9 |
+
|
10 |
+
const PAYMENT_GUARANTEE = 'NO';
|
11 |
+
const DIRECT_PAYMENT = 'direct_payment';
|
12 |
+
const CREDIT_CARD_PAYMENT = 'credit_card_payment';
|
13 |
+
const INVOICE_PAYMENT = 'invoice_payment';
|
14 |
+
|
15 |
+
/*
|
16 |
+
* Private properties
|
17 |
+
*/
|
18 |
+
|
19 |
+
/**
|
20 |
+
* Default store id used in GetConfig()
|
21 |
+
*
|
22 |
+
* @var int
|
23 |
+
*/
|
24 |
+
private $default_store_id;
|
25 |
+
|
26 |
+
/**
|
27 |
+
* Supported currency codes
|
28 |
+
*
|
29 |
+
* @var array
|
30 |
+
*/
|
31 |
+
private $supported_currencies = array
|
32 |
+
(
|
33 |
+
'SEK', 'EUR'
|
34 |
+
);
|
35 |
+
|
36 |
+
/*
|
37 |
+
* Public methods
|
38 |
+
*/
|
39 |
+
|
40 |
+
/**
|
41 |
+
* Constructor!
|
42 |
+
*
|
43 |
+
* @return void
|
44 |
+
*/
|
45 |
+
public function __construct() {
|
46 |
+
$this->SetDefaultStoreId(Mage::app()->getStore()->getId());
|
47 |
+
}
|
48 |
+
|
49 |
+
/**
|
50 |
+
* Set default store id
|
51 |
+
*
|
52 |
+
* @param int $store
|
53 |
+
* @return object $this
|
54 |
+
*/
|
55 |
+
public function SetDefaultStoreId($store) {
|
56 |
+
$this->default_store_id = $store;
|
57 |
+
|
58 |
+
return $this;
|
59 |
+
}
|
60 |
+
|
61 |
+
/**
|
62 |
+
* Get default store id
|
63 |
+
*
|
64 |
+
* @return int
|
65 |
+
*/
|
66 |
+
public function GetDefaultStoreId() {
|
67 |
+
return $this->default_store_id;
|
68 |
+
}
|
69 |
+
|
70 |
+
/**
|
71 |
+
* Whether $currency is supported
|
72 |
+
*
|
73 |
+
* @param string $currency
|
74 |
+
* @return bool
|
75 |
+
*/
|
76 |
+
public function IsCurrencySupported($currency) {
|
77 |
+
return in_array(strtoupper($currency), $this->supported_currencies);
|
78 |
+
}
|
79 |
+
|
80 |
+
/**
|
81 |
+
* Get configuration value
|
82 |
+
*
|
83 |
+
* @param mixed $name
|
84 |
+
* @param int|null $store [optional]
|
85 |
+
* @param mixed $default [optional]
|
86 |
+
* @param string $prefix [optional]
|
87 |
+
*/
|
88 |
+
public function GetConfig($name, $store = null, $default = null, $prefix = 'payment/payson_standard/') {
|
89 |
+
if (!isset($store)) {
|
90 |
+
$store = $this->GetDefaultStoreId();
|
91 |
+
}
|
92 |
+
|
93 |
+
$name = $prefix . $name;
|
94 |
+
// Mage::getStoreConfigFlag
|
95 |
+
$value = Mage::getStoreConfig($name, $store);
|
96 |
+
|
97 |
+
return (isset($value) ? $value : $default);
|
98 |
+
}
|
99 |
+
|
100 |
+
/**
|
101 |
+
* @see GetConfig
|
102 |
+
*/
|
103 |
+
public function Get($name, $store = null, $default = null, $prefix = 'payment/payson_standard/') {
|
104 |
+
return $this->GetConfig($name, $store, $default, $prefix);
|
105 |
+
}
|
106 |
+
|
107 |
+
/**
|
108 |
+
* Get Payson specific invoice fee excluding tax
|
109 |
+
*
|
110 |
+
* @param object $order
|
111 |
+
* @return float
|
112 |
+
*/
|
113 |
+
public function GetInvoiceFee($order) {
|
114 |
+
$currency = $order->getBaseCurrencyCode();
|
115 |
+
$currency = strtolower($currency);
|
116 |
+
|
117 |
+
if (!$this->IsCurrencySupported($currency)) {
|
118 |
+
return 0;
|
119 |
+
}
|
120 |
+
|
121 |
+
$store = Mage::app()->getStore($order->getStoreId());
|
122 |
+
|
123 |
+
$fee = $this->GetConfig('invoice_fee_' . $currency, $store->getId(), 0, 'payment/payson_invoice/');
|
124 |
+
$fee = round((float) $fee, 3);
|
125 |
+
|
126 |
+
return $fee;
|
127 |
+
}
|
128 |
+
|
129 |
+
/**
|
130 |
+
* Get Payson specific invoice fee including tax
|
131 |
+
*
|
132 |
+
* @param object $order
|
133 |
+
* @return float
|
134 |
+
*/
|
135 |
+
public function GetInvoiceFeeInclTax($order) {
|
136 |
+
$fee = $this->GetInvoiceFee($order);
|
137 |
+
$fee *= (1 + $this->GetInvoiceFeeTaxMod($order));
|
138 |
+
$fee = round($fee, 3);
|
139 |
+
|
140 |
+
return $fee;
|
141 |
+
}
|
142 |
+
|
143 |
+
/**
|
144 |
+
* Get Payson specific invoice fee tax modifier
|
145 |
+
*
|
146 |
+
* @param object $order
|
147 |
+
* @return float
|
148 |
+
*/
|
149 |
+
public function GetInvoiceFeeTaxMod($order) {
|
150 |
+
$store = Mage::app()->getStore($order->getStoreId());
|
151 |
+
|
152 |
+
$tax_calc = Mage::getSingleton('tax/calculation');
|
153 |
+
$customer = Mage::getModel('customer/customer')
|
154 |
+
->load($order->getCustomerId());
|
155 |
+
|
156 |
+
$tax_class = $this->GetConfig('invoice_fee_tax', $store->getId(), 0, 'payment/payson_invoice/');
|
157 |
+
|
158 |
+
$tax_rate_req = $tax_calc->getRateRequest(
|
159 |
+
$order->getShippingAddress(), $order->getBillingAddress(), $customer->getTaxClassId(), $store)
|
160 |
+
->setProductClassId($tax_class);
|
161 |
+
|
162 |
+
$tax_mod = (float) $tax_calc->getRate($tax_rate_req);
|
163 |
+
$tax_mod /= 100;
|
164 |
+
$tax_mod = round($tax_mod, 5);
|
165 |
+
|
166 |
+
return $tax_mod;
|
167 |
+
}
|
168 |
+
|
169 |
+
/**
|
170 |
+
* Does this store support payment guarantee?
|
171 |
+
*
|
172 |
+
* @param int|null $store [optional]
|
173 |
+
* @return bool
|
174 |
+
*/
|
175 |
+
public function CanPaymentGuarantee($store = null) {
|
176 |
+
return (bool) $this->GetConfig(self::PAYMENT_GUARANTEE, $store, false);
|
177 |
+
}
|
178 |
+
|
179 |
+
/**
|
180 |
+
* Is standard payment enabled?
|
181 |
+
*
|
182 |
+
* @param int|null $store [optional]
|
183 |
+
* @return bool
|
184 |
+
*/
|
185 |
+
public function CanStandardPayment($store = null) {
|
186 |
+
return $this->GetConfig('active', $store, false, 'payment/payson_standard/');
|
187 |
+
}
|
188 |
+
|
189 |
+
/**
|
190 |
+
* Is invoice payment enabled?
|
191 |
+
*
|
192 |
+
* @param int|null $store [optional]
|
193 |
+
* @return bool
|
194 |
+
*/
|
195 |
+
public function CanInvoicePayment($store = null) {
|
196 |
+
/* if(!$this->CanStandardPayment($store))
|
197 |
+
{
|
198 |
+
return false;
|
199 |
+
} */
|
200 |
+
|
201 |
+
return $this->GetConfig('active', $store, false, 'payment/payson_invoice/');
|
202 |
+
}
|
203 |
+
|
204 |
+
public function restoreCartOnCancel($store = null) {
|
205 |
+
if (!$store)
|
206 |
+
$store = Mage::app()->getStore()->getId();
|
207 |
+
$configValue = $this->GetConfig("restore_on_cancel", $store);
|
208 |
+
|
209 |
+
return $configValue == 1;
|
210 |
+
}
|
211 |
+
|
212 |
+
public function restoreCartOnError($store = null) {
|
213 |
+
if (!$store)
|
214 |
+
$store = Mage::app()->getStore()->getId();
|
215 |
+
$configValue = $this->GetConfig("restore_on_error", $store);
|
216 |
+
|
217 |
+
return $configValue == 1;
|
218 |
+
}
|
219 |
+
|
220 |
+
}
|
221 |
+
|
app/code/community/Payson/Payson/Model/Method/Abstract.php
CHANGED
@@ -70,7 +70,7 @@ abstract class Payson_Payson_Model_Method_Abstract extends Mage_Payment_Model_Me
|
|
70 |
* @return bool
|
71 |
*/
|
72 |
public function canUseForCurrency($currency) {
|
73 |
-
return Mage::getModel('payson/config')->IsCurrencySupported(
|
74 |
}
|
75 |
|
76 |
/**
|
70 |
* @return bool
|
71 |
*/
|
72 |
public function canUseForCurrency($currency) {
|
73 |
+
return Mage::getModel('payson/config')->IsCurrencySupported(Mage::app()->getStore()->getCurrentCurrencyCode());
|
74 |
}
|
75 |
|
76 |
/**
|
app/code/community/Payson/Payson/Model/Method/Invoice.php
CHANGED
@@ -96,6 +96,8 @@ class Payson_Payson_Model_Method_Invoice extends Payson_Payson_Model_Method_Abst
|
|
96 |
|
97 |
public function canUseCheckout() {
|
98 |
if ($this->isSweden()) {
|
|
|
|
|
99 |
if (Mage::getSingleton('checkout/cart')->getQuote()->getGrandTotal() < $this->invoiceAmountMinLimit)
|
100 |
return false;
|
101 |
else
|
@@ -107,7 +109,6 @@ class Payson_Payson_Model_Method_Invoice extends Payson_Payson_Model_Method_Abst
|
|
107 |
public function isSweden() {
|
108 |
$checkout = Mage::getSingleton('checkout/session')->getQuote();
|
109 |
$billing = $checkout->getBillingAddress();
|
110 |
-
//$shipping = $checkout->getShippingAddress();
|
111 |
if (strtoupper($billing->getCountry()) != 'SE')
|
112 |
return false;
|
113 |
else
|
@@ -115,4 +116,3 @@ class Payson_Payson_Model_Method_Invoice extends Payson_Payson_Model_Method_Abst
|
|
115 |
}
|
116 |
|
117 |
}
|
118 |
-
|
96 |
|
97 |
public function canUseCheckout() {
|
98 |
if ($this->isSweden()) {
|
99 |
+
if (strtoupper(Mage::app()->getStore()->getCurrentCurrencyCode()) != 'SEK')
|
100 |
+
return false;
|
101 |
if (Mage::getSingleton('checkout/cart')->getQuote()->getGrandTotal() < $this->invoiceAmountMinLimit)
|
102 |
return false;
|
103 |
else
|
109 |
public function isSweden() {
|
110 |
$checkout = Mage::getSingleton('checkout/session')->getQuote();
|
111 |
$billing = $checkout->getBillingAddress();
|
|
|
112 |
if (strtoupper($billing->getCountry()) != 'SE')
|
113 |
return false;
|
114 |
else
|
116 |
}
|
117 |
|
118 |
}
|
|
app/code/community/Payson/Payson/Model/Method/Standard.php
CHANGED
@@ -1,39 +1,39 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
class Payson_Payson_Model_Method_Standard extends Payson_Payson_Model_Method_Abstract {
|
4 |
-
/*
|
5 |
-
* Protected properties
|
6 |
-
*/
|
7 |
-
|
8 |
-
protected $_canCapture = true;
|
9 |
-
protected $_canRefund = true;
|
10 |
-
protected $_canVoid = true;
|
11 |
-
|
12 |
-
/**
|
13 |
-
* @inheritDoc
|
14 |
-
*/
|
15 |
-
protected $_code = 'payson_standard';
|
16 |
-
protected $_formBlockType = 'payson/standard_form';
|
17 |
-
|
18 |
-
/*
|
19 |
-
* Public methods
|
20 |
-
*/
|
21 |
-
|
22 |
-
/**
|
23 |
-
* @inheritDoc
|
24 |
-
*/
|
25 |
-
public function getTitle() {
|
26 |
-
return Mage::helper('payson')->__('Checkout with Payson');
|
27 |
-
}
|
28 |
-
|
29 |
-
/**
|
30 |
-
* @inheritDoc
|
31 |
-
*/
|
32 |
-
public function authorize(Varien_Object $payment, $amount) {
|
33 |
-
$payment->setTransactionId('auth')->setIsTransactionClosed(0);
|
34 |
-
|
35 |
-
return $this;
|
36 |
-
}
|
37 |
-
|
38 |
-
}
|
39 |
-
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Payson_Payson_Model_Method_Standard extends Payson_Payson_Model_Method_Abstract {
|
4 |
+
/*
|
5 |
+
* Protected properties
|
6 |
+
*/
|
7 |
+
|
8 |
+
protected $_canCapture = true;
|
9 |
+
protected $_canRefund = true;
|
10 |
+
protected $_canVoid = true;
|
11 |
+
|
12 |
+
/**
|
13 |
+
* @inheritDoc
|
14 |
+
*/
|
15 |
+
protected $_code = 'payson_standard';
|
16 |
+
protected $_formBlockType = 'payson/standard_form';
|
17 |
+
|
18 |
+
/*
|
19 |
+
* Public methods
|
20 |
+
*/
|
21 |
+
|
22 |
+
/**
|
23 |
+
* @inheritDoc
|
24 |
+
*/
|
25 |
+
public function getTitle() {
|
26 |
+
return Mage::helper('payson')->__('Checkout with Payson');
|
27 |
+
}
|
28 |
+
|
29 |
+
/**
|
30 |
+
* @inheritDoc
|
31 |
+
*/
|
32 |
+
public function authorize(Varien_Object $payment, $amount) {
|
33 |
+
$payment->setTransactionId('auth')->setIsTransactionClosed(0);
|
34 |
+
|
35 |
+
return $this;
|
36 |
+
}
|
37 |
+
|
38 |
+
}
|
39 |
+
|
app/code/community/Payson/Payson/Model/Mysql4/Setup.php
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
class Payson_Payson_Model_Mysql4_Setup extends Mage_Sales_Model_Mysql4_Setup {
|
4 |
-
|
5 |
-
}
|
6 |
-
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Payson_Payson_Model_Mysql4_Setup extends Mage_Sales_Model_Mysql4_Setup {
|
4 |
+
|
5 |
+
}
|
6 |
+
|
app/code/community/Payson/Payson/Model/Order/Creditmemo/Total/Invoice.php
CHANGED
@@ -1,44 +1,44 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
class Payson_Payson_Model_Order_Creditmemo_Total_Invoice extends
|
4 |
-
Mage_Sales_Model_Order_Creditmemo_Total_Abstract {
|
5 |
-
|
6 |
-
protected $_code = 'payson_invoice';
|
7 |
-
|
8 |
-
public function collect(Mage_Sales_Model_Order_Creditmemo $invoice) {
|
9 |
-
$order = $invoice->getOrder();
|
10 |
-
|
11 |
-
$method = $order->getPayment()->getMethodInstance()->getCode(); /* Should be getMethod() */
|
12 |
-
|
13 |
-
if ($method !== 'payson_invoice') {
|
14 |
-
return $this;
|
15 |
-
}
|
16 |
-
|
17 |
-
/* if($order->hasInvoices() !== 0)
|
18 |
-
{
|
19 |
-
return $this;
|
20 |
-
} */
|
21 |
-
|
22 |
-
$base_fee = $order->getBasePaysonInvoiceFee();
|
23 |
-
$fee = $order->getPaysonInvoiceFee();
|
24 |
-
|
25 |
-
if (!$base_fee || !$fee) {
|
26 |
-
return $this;
|
27 |
-
}
|
28 |
-
|
29 |
-
$base_grand_total = $invoice->getBaseGrandTotal();
|
30 |
-
$base_grand_total += $base_fee;
|
31 |
-
$grand_total = $invoice->getGrandTotal();
|
32 |
-
$grand_total += $fee;
|
33 |
-
|
34 |
-
$invoice->setBasePaysonInvoiceFee($base_fee);
|
35 |
-
$invoice->setPaysonInvoiceFee($fee);
|
36 |
-
|
37 |
-
$invoice->setBaseGrandTotal($base_grand_total);
|
38 |
-
$invoice->setGrandTotal($grand_total);
|
39 |
-
|
40 |
-
return $this;
|
41 |
-
}
|
42 |
-
|
43 |
-
}
|
44 |
-
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Payson_Payson_Model_Order_Creditmemo_Total_Invoice extends
|
4 |
+
Mage_Sales_Model_Order_Creditmemo_Total_Abstract {
|
5 |
+
|
6 |
+
protected $_code = 'payson_invoice';
|
7 |
+
|
8 |
+
public function collect(Mage_Sales_Model_Order_Creditmemo $invoice) {
|
9 |
+
$order = $invoice->getOrder();
|
10 |
+
|
11 |
+
$method = $order->getPayment()->getMethodInstance()->getCode(); /* Should be getMethod() */
|
12 |
+
|
13 |
+
if ($method !== 'payson_invoice') {
|
14 |
+
return $this;
|
15 |
+
}
|
16 |
+
|
17 |
+
/* if($order->hasInvoices() !== 0)
|
18 |
+
{
|
19 |
+
return $this;
|
20 |
+
} */
|
21 |
+
|
22 |
+
$base_fee = $order->getBasePaysonInvoiceFee();
|
23 |
+
$fee = $order->getPaysonInvoiceFee();
|
24 |
+
|
25 |
+
if (!$base_fee || !$fee) {
|
26 |
+
return $this;
|
27 |
+
}
|
28 |
+
|
29 |
+
$base_grand_total = $invoice->getBaseGrandTotal();
|
30 |
+
$base_grand_total += $base_fee;
|
31 |
+
$grand_total = $invoice->getGrandTotal();
|
32 |
+
$grand_total += $fee;
|
33 |
+
|
34 |
+
$invoice->setBasePaysonInvoiceFee($base_fee);
|
35 |
+
$invoice->setPaysonInvoiceFee($fee);
|
36 |
+
|
37 |
+
$invoice->setBaseGrandTotal($base_grand_total);
|
38 |
+
$invoice->setGrandTotal($grand_total);
|
39 |
+
|
40 |
+
return $this;
|
41 |
+
}
|
42 |
+
|
43 |
+
}
|
44 |
+
|
app/code/community/Payson/Payson/Model/Order/Invoice/Total/Invoice.php
CHANGED
@@ -1,43 +1,43 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
class Payson_Payson_Model_Order_Invoice_Total_Invoice extends
|
4 |
-
Mage_Sales_Model_Order_Invoice_Total_Abstract {
|
5 |
-
|
6 |
-
protected $_code = 'payson_invoice';
|
7 |
-
|
8 |
-
public function collect(Mage_Sales_Model_Order_Invoice $invoice) {
|
9 |
-
$order = $invoice->getOrder();
|
10 |
-
|
11 |
-
$method = $order->getPayment()->getMethodInstance()->getCode(); /* Should be getMethod() */
|
12 |
-
|
13 |
-
if ($method !== 'payson_invoice') {
|
14 |
-
return $this;
|
15 |
-
}
|
16 |
-
|
17 |
-
if ($order->hasInvoices() == 0) {
|
18 |
-
return $this;
|
19 |
-
}
|
20 |
-
|
21 |
-
$base_fee = $order->getBasePaysonInvoiceFee();
|
22 |
-
$fee = $order->getPaysonInvoiceFee();
|
23 |
-
|
24 |
-
if (!$base_fee || !$fee) {
|
25 |
-
return $this;
|
26 |
-
}
|
27 |
-
|
28 |
-
$base_grand_total = $invoice->getBaseGrandTotal();
|
29 |
-
$base_grand_total += $base_fee;
|
30 |
-
$grand_total = $invoice->getGrandTotal();
|
31 |
-
$grand_total += $fee;
|
32 |
-
|
33 |
-
$invoice->setBasePaysonInvoiceFee($base_fee);
|
34 |
-
$invoice->setPaysonInvoiceFee($fee);
|
35 |
-
|
36 |
-
$invoice->setBaseGrandTotal($base_grand_total);
|
37 |
-
$invoice->setGrandTotal($grand_total);
|
38 |
-
|
39 |
-
return $this;
|
40 |
-
}
|
41 |
-
|
42 |
-
}
|
43 |
-
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Payson_Payson_Model_Order_Invoice_Total_Invoice extends
|
4 |
+
Mage_Sales_Model_Order_Invoice_Total_Abstract {
|
5 |
+
|
6 |
+
protected $_code = 'payson_invoice';
|
7 |
+
|
8 |
+
public function collect(Mage_Sales_Model_Order_Invoice $invoice) {
|
9 |
+
$order = $invoice->getOrder();
|
10 |
+
|
11 |
+
$method = $order->getPayment()->getMethodInstance()->getCode(); /* Should be getMethod() */
|
12 |
+
|
13 |
+
if ($method !== 'payson_invoice') {
|
14 |
+
return $this;
|
15 |
+
}
|
16 |
+
|
17 |
+
if ($order->hasInvoices() == 0) {
|
18 |
+
return $this;
|
19 |
+
}
|
20 |
+
|
21 |
+
$base_fee = $order->getBasePaysonInvoiceFee();
|
22 |
+
$fee = $order->getPaysonInvoiceFee();
|
23 |
+
|
24 |
+
if (!$base_fee || !$fee) {
|
25 |
+
return $this;
|
26 |
+
}
|
27 |
+
|
28 |
+
$base_grand_total = $invoice->getBaseGrandTotal();
|
29 |
+
$base_grand_total += $base_fee;
|
30 |
+
$grand_total = $invoice->getGrandTotal();
|
31 |
+
$grand_total += $fee;
|
32 |
+
|
33 |
+
$invoice->setBasePaysonInvoiceFee($base_fee);
|
34 |
+
$invoice->setPaysonInvoiceFee($fee);
|
35 |
+
|
36 |
+
$invoice->setBaseGrandTotal($base_grand_total);
|
37 |
+
$invoice->setGrandTotal($grand_total);
|
38 |
+
|
39 |
+
return $this;
|
40 |
+
}
|
41 |
+
|
42 |
+
}
|
43 |
+
|
app/code/community/Payson/Payson/Model/Quote/Address/Total/Invoice.php
CHANGED
@@ -1,64 +1,64 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
class Payson_Payson_Model_Quote_Address_Total_Invoice extends
|
4 |
-
Mage_Sales_Model_Quote_Address_Total_Abstract {
|
5 |
-
|
6 |
-
protected $_code = 'payson_invoice';
|
7 |
-
|
8 |
-
public function collect(Mage_Sales_Model_Quote_Address $address) {
|
9 |
-
if ($address->getAddressType() !== 'shipping') {
|
10 |
-
return $this;
|
11 |
-
}
|
12 |
-
|
13 |
-
$address->setBasePaysonInvoiceFee(0);
|
14 |
-
$address->setPaysonInvoiceFee(0);
|
15 |
-
|
16 |
-
$quote = $address->getQuote();
|
17 |
-
|
18 |
-
if (is_null($quote->getId())) {
|
19 |
-
return $this;
|
20 |
-
}
|
21 |
-
|
22 |
-
$method = $address->getQuote()->getPayment()->getMethod();
|
23 |
-
|
24 |
-
if ($method !== 'payson_invoice') {
|
25 |
-
return $this;
|
26 |
-
}
|
27 |
-
|
28 |
-
$store = $quote->getStore();
|
29 |
-
$config = Mage::getModel('payson/config');
|
30 |
-
|
31 |
-
$fee = $config->GetInvoiceFeeInclTax($quote);
|
32 |
-
|
33 |
-
$base_grand_total = $address->getBaseGrandTotal();
|
34 |
-
$base_grand_total += $fee;
|
35 |
-
|
36 |
-
// TODO: update tax in another model?
|
37 |
-
|
38 |
-
$address->setBasePaysonInvoiceFee($fee);
|
39 |
-
$address->setPaysonInvoiceFee($store->convertPrice($fee, false));
|
40 |
-
|
41 |
-
$address->setBaseGrandTotal($base_grand_total);
|
42 |
-
$address->setGrandTotal($store->convertPrice($base_grand_total, false));
|
43 |
-
|
44 |
-
//$this->_addBaseAmount($fee);
|
45 |
-
//$this->_addAmount($fee);
|
46 |
-
|
47 |
-
return $this;
|
48 |
-
}
|
49 |
-
|
50 |
-
public function fetch(Mage_Sales_Model_Quote_Address $address) {
|
51 |
-
if (($fee = $address->getPaysonInvoiceFee()) > 0) {
|
52 |
-
$address->addTotal(array
|
53 |
-
(
|
54 |
-
'code' => $this->getCode(),
|
55 |
-
'title' => Mage::helper('payson')->__('Invoice fee'),
|
56 |
-
'value' => $fee
|
57 |
-
));
|
58 |
-
}
|
59 |
-
|
60 |
-
return $this;
|
61 |
-
}
|
62 |
-
|
63 |
-
}
|
64 |
-
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Payson_Payson_Model_Quote_Address_Total_Invoice extends
|
4 |
+
Mage_Sales_Model_Quote_Address_Total_Abstract {
|
5 |
+
|
6 |
+
protected $_code = 'payson_invoice';
|
7 |
+
|
8 |
+
public function collect(Mage_Sales_Model_Quote_Address $address) {
|
9 |
+
if ($address->getAddressType() !== 'shipping') {
|
10 |
+
return $this;
|
11 |
+
}
|
12 |
+
|
13 |
+
$address->setBasePaysonInvoiceFee(0);
|
14 |
+
$address->setPaysonInvoiceFee(0);
|
15 |
+
|
16 |
+
$quote = $address->getQuote();
|
17 |
+
|
18 |
+
if (is_null($quote->getId())) {
|
19 |
+
return $this;
|
20 |
+
}
|
21 |
+
|
22 |
+
$method = $address->getQuote()->getPayment()->getMethod();
|
23 |
+
|
24 |
+
if ($method !== 'payson_invoice') {
|
25 |
+
return $this;
|
26 |
+
}
|
27 |
+
|
28 |
+
$store = $quote->getStore();
|
29 |
+
$config = Mage::getModel('payson/config');
|
30 |
+
|
31 |
+
$fee = $config->GetInvoiceFeeInclTax($quote);
|
32 |
+
|
33 |
+
$base_grand_total = $address->getBaseGrandTotal();
|
34 |
+
$base_grand_total += $fee;
|
35 |
+
|
36 |
+
// TODO: update tax in another model?
|
37 |
+
|
38 |
+
$address->setBasePaysonInvoiceFee($fee);
|
39 |
+
$address->setPaysonInvoiceFee($store->convertPrice($fee, false));
|
40 |
+
|
41 |
+
$address->setBaseGrandTotal($base_grand_total);
|
42 |
+
$address->setGrandTotal($store->convertPrice($base_grand_total, false));
|
43 |
+
|
44 |
+
//$this->_addBaseAmount($fee);
|
45 |
+
//$this->_addAmount($fee);
|
46 |
+
|
47 |
+
return $this;
|
48 |
+
}
|
49 |
+
|
50 |
+
public function fetch(Mage_Sales_Model_Quote_Address $address) {
|
51 |
+
if (($fee = $address->getPaysonInvoiceFee()) > 0) {
|
52 |
+
$address->addTotal(array
|
53 |
+
(
|
54 |
+
'code' => $this->getCode(),
|
55 |
+
'title' => Mage::helper('payson')->__('Invoice fee'),
|
56 |
+
'value' => $fee
|
57 |
+
));
|
58 |
+
}
|
59 |
+
|
60 |
+
return $this;
|
61 |
+
}
|
62 |
+
|
63 |
+
}
|
64 |
+
|
app/code/community/Payson/Payson/Model/Standard.php
CHANGED
@@ -1,118 +1,118 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
class Payson_Payson_Model_Standard extends Mage_Payment_Model_Method_Abstract {
|
4 |
-
/*
|
5 |
-
* Protected properties
|
6 |
-
*/
|
7 |
-
|
8 |
-
/**
|
9 |
-
* @inheritDoc
|
10 |
-
*/
|
11 |
-
protected $_code = 'payson';
|
12 |
-
protected $_formBlockType = 'payson/form';
|
13 |
-
//protected $_infoBlockType = 'payson/info';
|
14 |
-
|
15 |
-
/**
|
16 |
-
* @inheritDoc
|
17 |
-
*/
|
18 |
-
protected $_isGateway = false;
|
19 |
-
protected $_canAuthorize = false;
|
20 |
-
protected $_canCapture = true;
|
21 |
-
protected $_canCapturePartial = false;
|
22 |
-
protected $_canRefund = false;
|
23 |
-
protected $_canRefundInvoicePartial = false;
|
24 |
-
protected $_canVoid = false;
|
25 |
-
protected $_canUseInternal = true;
|
26 |
-
protected $_canUseCheckout = true;
|
27 |
-
protected $_canUseForMultishipping = false;
|
28 |
-
protected $_isInitializeNeeded = false;
|
29 |
-
protected $_canFetchTransactionInfo = false;
|
30 |
-
protected $_canReviewPayment = false;
|
31 |
-
protected $_canCreateBillingAgreement = false;
|
32 |
-
protected $_canManageRecurringProfiles = false;
|
33 |
-
|
34 |
-
/**
|
35 |
-
* @inheritDoc
|
36 |
-
*/
|
37 |
-
protected $_canCancelInvoice = false;
|
38 |
-
|
39 |
-
/*
|
40 |
-
* Public methods
|
41 |
-
*/
|
42 |
-
|
43 |
-
/**
|
44 |
-
* @inheritDoc
|
45 |
-
*/
|
46 |
-
public function initialize($payment_action, $state_object) {
|
47 |
-
$state_object->setState(Mage_Sales_Model_Order::STATE_PENDING_PAYMENT);
|
48 |
-
$state_object->setStatus(Mage_Sales_Model_Order::STATE_PENDING_PAYMENT);
|
49 |
-
$state_object->setIsNotified(false);
|
50 |
-
|
51 |
-
return $this;
|
52 |
-
}
|
53 |
-
|
54 |
-
/**
|
55 |
-
* @inheritDoc
|
56 |
-
*/
|
57 |
-
public function capture(Varien_Object $payment, $amount) {
|
58 |
-
$order = $payment->getOrder();
|
59 |
-
$order_id = $order->getData('increment_id');
|
60 |
-
|
61 |
-
$api = Mage::helper('payson/api');
|
62 |
-
|
63 |
-
$api->PaymentDetails($order_id);
|
64 |
-
$details = $api->GetResponse();
|
65 |
-
|
66 |
-
if (($details->type ===
|
67 |
-
Payson_Payson_Helper_Api::PAYMENT_METHOD_INVOICE) ||
|
68 |
-
($details->invoiceStatus ===
|
69 |
-
Payson_Payson_Helper_Api::INVOICE_STATUS_ORDERCREATED)) {
|
70 |
-
$api->PaymentUpdate($order_id, Payson_Payson_Helper_Api::UPDATE_ACTION_SHIPORDER);
|
71 |
-
}
|
72 |
-
|
73 |
-
return $this;
|
74 |
-
}
|
75 |
-
|
76 |
-
/**
|
77 |
-
* Redirect url when user place order
|
78 |
-
*
|
79 |
-
* @return string
|
80 |
-
*/
|
81 |
-
public function getOrderPlaceRedirectUrl() {
|
82 |
-
return Mage::getUrl('payson/checkout/redirect', array('_secure' => true));
|
83 |
-
}
|
84 |
-
|
85 |
-
/**
|
86 |
-
* Whether this paymend method is available for specified currency
|
87 |
-
*
|
88 |
-
* @param string $currency
|
89 |
-
* @return bool
|
90 |
-
*/
|
91 |
-
public function canUseForCurrency($currency) {
|
92 |
-
return Mage::getModel('payson/config')->IsCurrencySupported($currency);
|
93 |
-
}
|
94 |
-
|
95 |
-
/**
|
96 |
-
* Is run when payment method is selected
|
97 |
-
*
|
98 |
-
* @return void
|
99 |
-
*/
|
100 |
-
public function validate() {
|
101 |
-
$session = Mage::getSingleton('checkout/session');
|
102 |
-
|
103 |
-
if (isset($_POST['payment']['payson_payment_method'])) {
|
104 |
-
$session->setData('payson_payment_method', $_POST['payment']['payson_payment_method']);
|
105 |
-
} else {
|
106 |
-
$session->unsetData('payson_payment_method');
|
107 |
-
}
|
108 |
-
}
|
109 |
-
|
110 |
-
/**
|
111 |
-
* @inheritDoc
|
112 |
-
*/
|
113 |
-
public function getTitle() {
|
114 |
-
return Mage::Helper('payson')->__('Checkout with Payson');
|
115 |
-
}
|
116 |
-
|
117 |
-
}
|
118 |
-
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Payson_Payson_Model_Standard extends Mage_Payment_Model_Method_Abstract {
|
4 |
+
/*
|
5 |
+
* Protected properties
|
6 |
+
*/
|
7 |
+
|
8 |
+
/**
|
9 |
+
* @inheritDoc
|
10 |
+
*/
|
11 |
+
protected $_code = 'payson';
|
12 |
+
protected $_formBlockType = 'payson/form';
|
13 |
+
//protected $_infoBlockType = 'payson/info';
|
14 |
+
|
15 |
+
/**
|
16 |
+
* @inheritDoc
|
17 |
+
*/
|
18 |
+
protected $_isGateway = false;
|
19 |
+
protected $_canAuthorize = false;
|
20 |
+
protected $_canCapture = true;
|
21 |
+
protected $_canCapturePartial = false;
|
22 |
+
protected $_canRefund = false;
|
23 |
+
protected $_canRefundInvoicePartial = false;
|
24 |
+
protected $_canVoid = false;
|
25 |
+
protected $_canUseInternal = true;
|
26 |
+
protected $_canUseCheckout = true;
|
27 |
+
protected $_canUseForMultishipping = false;
|
28 |
+
protected $_isInitializeNeeded = false;
|
29 |
+
protected $_canFetchTransactionInfo = false;
|
30 |
+
protected $_canReviewPayment = false;
|
31 |
+
protected $_canCreateBillingAgreement = false;
|
32 |
+
protected $_canManageRecurringProfiles = false;
|
33 |
+
|
34 |
+
/**
|
35 |
+
* @inheritDoc
|
36 |
+
*/
|
37 |
+
protected $_canCancelInvoice = false;
|
38 |
+
|
39 |
+
/*
|
40 |
+
* Public methods
|
41 |
+
*/
|
42 |
+
|
43 |
+
/**
|
44 |
+
* @inheritDoc
|
45 |
+
*/
|
46 |
+
public function initialize($payment_action, $state_object) {
|
47 |
+
$state_object->setState(Mage_Sales_Model_Order::STATE_PENDING_PAYMENT);
|
48 |
+
$state_object->setStatus(Mage_Sales_Model_Order::STATE_PENDING_PAYMENT);
|
49 |
+
$state_object->setIsNotified(false);
|
50 |
+
|
51 |
+
return $this;
|
52 |
+
}
|
53 |
+
|
54 |
+
/**
|
55 |
+
* @inheritDoc
|
56 |
+
*/
|
57 |
+
public function capture(Varien_Object $payment, $amount) {
|
58 |
+
$order = $payment->getOrder();
|
59 |
+
$order_id = $order->getData('increment_id');
|
60 |
+
|
61 |
+
$api = Mage::helper('payson/api');
|
62 |
+
|
63 |
+
$api->PaymentDetails($order_id);
|
64 |
+
$details = $api->GetResponse();
|
65 |
+
|
66 |
+
if (($details->type ===
|
67 |
+
Payson_Payson_Helper_Api::PAYMENT_METHOD_INVOICE) ||
|
68 |
+
($details->invoiceStatus ===
|
69 |
+
Payson_Payson_Helper_Api::INVOICE_STATUS_ORDERCREATED)) {
|
70 |
+
$api->PaymentUpdate($order_id, Payson_Payson_Helper_Api::UPDATE_ACTION_SHIPORDER);
|
71 |
+
}
|
72 |
+
|
73 |
+
return $this;
|
74 |
+
}
|
75 |
+
|
76 |
+
/**
|
77 |
+
* Redirect url when user place order
|
78 |
+
*
|
79 |
+
* @return string
|
80 |
+
*/
|
81 |
+
public function getOrderPlaceRedirectUrl() {
|
82 |
+
return Mage::getUrl('payson/checkout/redirect', array('_secure' => true));
|
83 |
+
}
|
84 |
+
|
85 |
+
/**
|
86 |
+
* Whether this paymend method is available for specified currency
|
87 |
+
*
|
88 |
+
* @param string $currency
|
89 |
+
* @return bool
|
90 |
+
*/
|
91 |
+
public function canUseForCurrency($currency) {
|
92 |
+
return Mage::getModel('payson/config')->IsCurrencySupported($currency);
|
93 |
+
}
|
94 |
+
|
95 |
+
/**
|
96 |
+
* Is run when payment method is selected
|
97 |
+
*
|
98 |
+
* @return void
|
99 |
+
*/
|
100 |
+
public function validate() {
|
101 |
+
$session = Mage::getSingleton('checkout/session');
|
102 |
+
|
103 |
+
if (isset($_POST['payment']['payson_payment_method'])) {
|
104 |
+
$session->setData('payson_payment_method', $_POST['payment']['payson_payment_method']);
|
105 |
+
} else {
|
106 |
+
$session->unsetData('payson_payment_method');
|
107 |
+
}
|
108 |
+
}
|
109 |
+
|
110 |
+
/**
|
111 |
+
* @inheritDoc
|
112 |
+
*/
|
113 |
+
public function getTitle() {
|
114 |
+
return Mage::Helper('payson')->__('Checkout with Payson');
|
115 |
+
}
|
116 |
+
|
117 |
+
}
|
118 |
+
|
app/code/community/Payson/Payson/Model/System/Config/Source/Paysondirectmethod.php
ADDED
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* My own options
|
4 |
+
*
|
5 |
+
*/
|
6 |
+
class Payson_Payson_Model_System_Config_Source_Paysondirectmethod
|
7 |
+
{
|
8 |
+
|
9 |
+
/**
|
10 |
+
* Options getter
|
11 |
+
*
|
12 |
+
* @return array
|
13 |
+
*/
|
14 |
+
public function toOptionArray()
|
15 |
+
{
|
16 |
+
return array(
|
17 |
+
array('value' => 0, 'label'=>Mage::helper('adminhtml')->__('CREDITCARD / BANK')),
|
18 |
+
array('value' => 1, 'label'=>Mage::helper('adminhtml')->__('CREDITCARD')),
|
19 |
+
array('value' => 2, 'label'=>Mage::helper('adminhtml')->__('BANK')),
|
20 |
+
);
|
21 |
+
}
|
22 |
+
|
23 |
+
}
|
24 |
+
|
25 |
+
|
app/code/community/Payson/Payson/controllers/Adminhtml/Sales/Order/ShipmentController.php
CHANGED
@@ -1,26 +1,26 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
require_once 'Mage/Adminhtml/controllers/Sales/Order/ShipmentController.php';
|
4 |
-
|
5 |
-
class Payson_Payson_Adminhtml_Sales_Order_ShipmentController extends Mage_Adminhtml_Sales_Order_ShipmentController {
|
6 |
-
|
7 |
-
public function saveAction() {
|
8 |
-
|
9 |
-
$order = Mage::getModel('sales/order')->load($this->getRequest()->getParam('order_id'));
|
10 |
-
|
11 |
-
if ($order->getPayment()->getMethodInstance()->getCode() == "payson_invoice") {
|
12 |
-
$invoice = Mage::getModel('sales/service_order', $order)->prepareInvoice();
|
13 |
-
$invoice->setRequestedCaptureCase(Mage_Sales_Model_Order_Invoice::CAPTURE_ONLINE);
|
14 |
-
$invoice->register();
|
15 |
-
$transactionSave = Mage::getModel('core/resource_transaction')
|
16 |
-
->addObject($invoice)
|
17 |
-
->addObject($invoice->getOrder());
|
18 |
-
$transactionSave->save();
|
19 |
-
}
|
20 |
-
|
21 |
-
parent::saveAction();
|
22 |
-
}
|
23 |
-
|
24 |
-
}
|
25 |
-
|
26 |
-
?>
|
1 |
+
<?php
|
2 |
+
|
3 |
+
require_once 'Mage/Adminhtml/controllers/Sales/Order/ShipmentController.php';
|
4 |
+
|
5 |
+
class Payson_Payson_Adminhtml_Sales_Order_ShipmentController extends Mage_Adminhtml_Sales_Order_ShipmentController {
|
6 |
+
|
7 |
+
public function saveAction() {
|
8 |
+
|
9 |
+
$order = Mage::getModel('sales/order')->load($this->getRequest()->getParam('order_id'));
|
10 |
+
|
11 |
+
if ($order->getPayment()->getMethodInstance()->getCode() == "payson_invoice") {
|
12 |
+
$invoice = Mage::getModel('sales/service_order', $order)->prepareInvoice();
|
13 |
+
$invoice->setRequestedCaptureCase(Mage_Sales_Model_Order_Invoice::CAPTURE_ONLINE);
|
14 |
+
$invoice->register();
|
15 |
+
$transactionSave = Mage::getModel('core/resource_transaction')
|
16 |
+
->addObject($invoice)
|
17 |
+
->addObject($invoice->getOrder());
|
18 |
+
$transactionSave->save();
|
19 |
+
}
|
20 |
+
|
21 |
+
parent::saveAction();
|
22 |
+
}
|
23 |
+
|
24 |
+
}
|
25 |
+
|
26 |
+
?>
|
app/code/community/Payson/Payson/controllers/CheckoutController.php
CHANGED
@@ -5,46 +5,60 @@ class Payson_Payson_CheckoutController extends Mage_Core_Controller_Front_Action
|
|
5 |
* Private properties
|
6 |
*/
|
7 |
|
8 |
-
private $
|
9 |
-
private $
|
|
|
|
|
|
|
|
|
10 |
|
11 |
/*
|
12 |
* Private methods
|
13 |
*/
|
14 |
|
15 |
-
|
16 |
-
|
17 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
18 |
}
|
19 |
|
20 |
-
return $this->
|
21 |
}
|
22 |
|
23 |
/**
|
24 |
*
|
25 |
* @return Mage_Sales_Model_Order
|
26 |
*/
|
27 |
-
private function
|
28 |
-
if (!isset($this->
|
29 |
-
$increment_id = $this->
|
30 |
|
31 |
if ($increment_id) {
|
32 |
-
$this->
|
33 |
->loadByIncrementId($increment_id);
|
34 |
|
35 |
-
if (is_null($this->
|
36 |
-
$this->
|
37 |
}
|
38 |
}
|
39 |
}
|
40 |
|
41 |
-
return $this->
|
42 |
}
|
43 |
|
44 |
-
private function
|
45 |
-
|
|
|
46 |
|
47 |
-
if (!is_null($order = $this->
|
48 |
$order->cancel();
|
49 |
|
50 |
if ($message != '')
|
@@ -60,7 +74,8 @@ class Payson_Payson_CheckoutController extends Mage_Core_Controller_Front_Action
|
|
60 |
*/
|
61 |
|
62 |
public function redirectAction() {
|
63 |
-
|
|
|
64 |
|
65 |
if (is_null($order)) {
|
66 |
$this->_redirect('checkout/cart');
|
@@ -77,7 +92,11 @@ class Payson_Payson_CheckoutController extends Mage_Core_Controller_Front_Action
|
|
77 |
|
78 |
$this->GetResponse()->setRedirect($api->GetPayForwardUrl());
|
79 |
} catch (Exception $e) {
|
80 |
-
$this->
|
|
|
|
|
|
|
|
|
81 |
|
82 |
Mage::logException($e);
|
83 |
|
@@ -87,7 +106,7 @@ class Payson_Payson_CheckoutController extends Mage_Core_Controller_Front_Action
|
|
87 |
}
|
88 |
|
89 |
public function returnAction() {
|
90 |
-
|
91 |
$paymentDetailsResponse = Mage::helper('payson/api')->PaymentDetails(Mage::getSingleton('checkout/session')->getLastRealOrderId())->getResponse();
|
92 |
$paymentStatus = $paymentDetailsResponse->status;
|
93 |
switch ($paymentStatus) {
|
@@ -95,16 +114,26 @@ class Payson_Payson_CheckoutController extends Mage_Core_Controller_Front_Action
|
|
95 |
case 'PENDING':
|
96 |
case 'PROCESSING':
|
97 |
case 'CREDITED': {
|
98 |
-
$
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
99 |
$this->_redirect('checkout/onepage/success');
|
100 |
break;
|
101 |
}
|
102 |
case 'ERROR': {
|
103 |
$errorMessage = Mage::helper('payson')->__('The payment was denied by Payson. Please, try a different payment method');
|
104 |
Mage::getSingleton('core/session')->addError($errorMessage);
|
105 |
-
$this->
|
106 |
-
if ($config->restoreCartOnError())
|
107 |
-
$this->restoreCart();
|
108 |
|
109 |
$this->_redirect('checkout');
|
110 |
break;
|
@@ -118,21 +147,23 @@ class Payson_Payson_CheckoutController extends Mage_Core_Controller_Front_Action
|
|
118 |
}
|
119 |
|
120 |
public function cancelAction() {
|
121 |
-
$config = Mage::getModel('payson/config');
|
122 |
-
$cancelMessage = Mage::helper('payson')->__('Something went wrong with the payment. Please, try a different payment method');
|
123 |
-
Mage::getSingleton('core/session')->addError($cancelMessage);
|
124 |
-
$this->CancelOrder($cancelMessage);
|
125 |
-
if ($config->restoreCartOnCancel())
|
126 |
-
$this->restoreCart();
|
127 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
128 |
|
129 |
$this->_redirect('checkout');
|
130 |
}
|
131 |
|
132 |
private function restoreCart() {
|
133 |
-
|
|
|
134 |
$quote = Mage::getModel('sales/quote')->load($quoteId);
|
135 |
$quote->setIsActive(true)->save();
|
136 |
}
|
137 |
|
138 |
-
}
|
5 |
* Private properties
|
6 |
*/
|
7 |
|
8 |
+
private $_session;
|
9 |
+
private $_order = null;
|
10 |
+
/* @var $_config Payson_Payson_Model_Config */
|
11 |
+
private $_config;
|
12 |
+
/* @var $_helper Payson_Payson_Helper_Data */
|
13 |
+
private $_helper;
|
14 |
|
15 |
/*
|
16 |
* Private methods
|
17 |
*/
|
18 |
|
19 |
+
public function _construct() {
|
20 |
+
$this->_config = Mage::getModel('payson/config');
|
21 |
+
$this->_helper = Mage::helper('payson');
|
22 |
+
}
|
23 |
+
|
24 |
+
/*
|
25 |
+
* Private methods
|
26 |
+
*/
|
27 |
+
|
28 |
+
private function getSession() {
|
29 |
+
if (!isset($this->_session)) {
|
30 |
+
$this->_session = Mage::getSingleton('checkout/session');
|
31 |
}
|
32 |
|
33 |
+
return $this->_session;
|
34 |
}
|
35 |
|
36 |
/**
|
37 |
*
|
38 |
* @return Mage_Sales_Model_Order
|
39 |
*/
|
40 |
+
private function getOrder() {
|
41 |
+
if (!isset($this->_order)) {
|
42 |
+
$increment_id = $this->getSession()->getData('last_real_order_id');
|
43 |
|
44 |
if ($increment_id) {
|
45 |
+
$this->_order = Mage::getModel('sales/order')
|
46 |
->loadByIncrementId($increment_id);
|
47 |
|
48 |
+
if (is_null($this->_order->getId())) {
|
49 |
+
$this->_order = null;
|
50 |
}
|
51 |
}
|
52 |
}
|
53 |
|
54 |
+
return $this->_order;
|
55 |
}
|
56 |
|
57 |
+
private function cancelOrder($message = '') {
|
58 |
+
|
59 |
+
$order = $this->getOrder();
|
60 |
|
61 |
+
if (!is_null($order = $this->getOrder())) {
|
62 |
$order->cancel();
|
63 |
|
64 |
if ($message != '')
|
74 |
*/
|
75 |
|
76 |
public function redirectAction() {
|
77 |
+
|
78 |
+
$order = $this->getOrder();
|
79 |
|
80 |
if (is_null($order)) {
|
81 |
$this->_redirect('checkout/cart');
|
92 |
|
93 |
$this->GetResponse()->setRedirect($api->GetPayForwardUrl());
|
94 |
} catch (Exception $e) {
|
95 |
+
$this->cancelOrder($e->getMessage());
|
96 |
+
|
97 |
+
if ($this->_config->restoreCartOnError()) {
|
98 |
+
$this->_config->restoreCart();
|
99 |
+
}
|
100 |
|
101 |
Mage::logException($e);
|
102 |
|
106 |
}
|
107 |
|
108 |
public function returnAction() {
|
109 |
+
|
110 |
$paymentDetailsResponse = Mage::helper('payson/api')->PaymentDetails(Mage::getSingleton('checkout/session')->getLastRealOrderId())->getResponse();
|
111 |
$paymentStatus = $paymentDetailsResponse->status;
|
112 |
switch ($paymentStatus) {
|
114 |
case 'PENDING':
|
115 |
case 'PROCESSING':
|
116 |
case 'CREDITED': {
|
117 |
+
$order->setState(Mage_Sales_Model_Order::STATE_PROCESSING, true);
|
118 |
+
$order->sendNewOrderEmail()->save();
|
119 |
+
|
120 |
+
//It creates the invoice to the order
|
121 |
+
if ($paymentDetailsResponse->type != 'INVOICE' && $paymentDetailsResponse->status == 'COMPLETED') {
|
122 |
+
$invoice = Mage::getModel('sales/service_order', $order)->prepareInvoice();
|
123 |
+
$invoice->setRequestedCaptureCase(Mage_Sales_Model_Order_Invoice::CAPTURE_ONLINE);
|
124 |
+
$invoice->register();
|
125 |
+
$transactionSave = Mage::getModel('core/resource_transaction')
|
126 |
+
->addObject($invoice)
|
127 |
+
->addObject($invoice->getOrder());
|
128 |
+
$transactionSave->save();
|
129 |
+
}
|
130 |
$this->_redirect('checkout/onepage/success');
|
131 |
break;
|
132 |
}
|
133 |
case 'ERROR': {
|
134 |
$errorMessage = Mage::helper('payson')->__('The payment was denied by Payson. Please, try a different payment method');
|
135 |
Mage::getSingleton('core/session')->addError($errorMessage);
|
136 |
+
$this->cancelOrder($errorMessage);
|
|
|
|
|
137 |
|
138 |
$this->_redirect('checkout');
|
139 |
break;
|
147 |
}
|
148 |
|
149 |
public function cancelAction() {
|
|
|
|
|
|
|
|
|
|
|
|
|
150 |
|
151 |
+
$cancelMessage = Mage::helper('payson')->__('Order was canceled at Payson');
|
152 |
+
|
153 |
+
$this->cancelOrder($cancelMessage);
|
154 |
+
|
155 |
+
if ($this->_config->restoreCartOnCancel()) {
|
156 |
+
$this->restoreCart();
|
157 |
+
}
|
158 |
|
159 |
$this->_redirect('checkout');
|
160 |
}
|
161 |
|
162 |
private function restoreCart() {
|
163 |
+
|
164 |
+
$quoteId = $this->getOrder()->getQuoteId();
|
165 |
$quote = Mage::getModel('sales/quote')->load($quoteId);
|
166 |
$quote->setIsActive(true)->save();
|
167 |
}
|
168 |
|
169 |
+
}
|
app/code/community/Payson/Payson/controllers/IpnController.php
CHANGED
@@ -1,25 +1,25 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
class Payson_Payson_IpnController extends Mage_Core_Controller_Front_Action {
|
4 |
-
|
5 |
-
public function notifyAction() {
|
6 |
-
$request = $this->getRequest();
|
7 |
-
$response = $this->getResponse();
|
8 |
-
|
9 |
-
if (!$request->isPost()) {
|
10 |
-
$response->setHttpResponseCode(503)->setBody('No!');
|
11 |
-
|
12 |
-
return;
|
13 |
-
}
|
14 |
-
|
15 |
-
try {
|
16 |
-
$api = Mage::helper('payson/api')->Validate($request->getRawBody(), $request->getHeader('Content-Type'));
|
17 |
-
} catch (Exception $e) {
|
18 |
-
$response->setHttpResponseCode(503)->setBody($e->getMessage());
|
19 |
-
|
20 |
-
return;
|
21 |
-
}
|
22 |
-
}
|
23 |
-
|
24 |
-
}
|
25 |
-
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Payson_Payson_IpnController extends Mage_Core_Controller_Front_Action {
|
4 |
+
|
5 |
+
public function notifyAction() {
|
6 |
+
$request = $this->getRequest();
|
7 |
+
$response = $this->getResponse();
|
8 |
+
|
9 |
+
if (!$request->isPost()) {
|
10 |
+
$response->setHttpResponseCode(503)->setBody('No!');
|
11 |
+
|
12 |
+
return;
|
13 |
+
}
|
14 |
+
|
15 |
+
try {
|
16 |
+
$api = Mage::helper('payson/api')->Validate($request->getRawBody(), $request->getHeader('Content-Type'));
|
17 |
+
} catch (Exception $e) {
|
18 |
+
$response->setHttpResponseCode(503)->setBody($e->getMessage());
|
19 |
+
|
20 |
+
return;
|
21 |
+
}
|
22 |
+
}
|
23 |
+
|
24 |
+
}
|
25 |
+
|
app/code/community/Payson/Payson/etc/config.xml
CHANGED
@@ -2,7 +2,7 @@
|
|
2 |
<config>
|
3 |
<modules>
|
4 |
<Payson_Payson>
|
5 |
-
<version>1.
|
6 |
</Payson_Payson>
|
7 |
</modules>
|
8 |
<admin>
|
@@ -91,22 +91,6 @@
|
|
91 |
<to_order>*</to_order>
|
92 |
</payson_invoice_fee>
|
93 |
</sales_convert_quote_address>
|
94 |
-
<!--<sales_convert_order>
|
95 |
-
<base_payson_invoice_fee>
|
96 |
-
<to_quote>*</to_quote>
|
97 |
-
</base_payson_invoice_fee>
|
98 |
-
<payson_invoice_fee>
|
99 |
-
<to_quote>*</to_quote>
|
100 |
-
</payson_invoice_fee>
|
101 |
-
</sales_convert_order>
|
102 |
-
<sales_convert_quote>
|
103 |
-
<base_payson_invoice_fee>
|
104 |
-
<to_order>*</to_order>
|
105 |
-
</base_payson_invoice_fee>
|
106 |
-
<payson_invoice_fee>
|
107 |
-
<to_order>*</to_order>
|
108 |
-
</payson_invoice_fee>
|
109 |
-
</sales_convert_quote>-->
|
110 |
</fieldsets>
|
111 |
</global>
|
112 |
<frontend>
|
2 |
<config>
|
3 |
<modules>
|
4 |
<Payson_Payson>
|
5 |
+
<version>1.2</version>
|
6 |
</Payson_Payson>
|
7 |
</modules>
|
8 |
<admin>
|
91 |
<to_order>*</to_order>
|
92 |
</payson_invoice_fee>
|
93 |
</sales_convert_quote_address>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
94 |
</fieldsets>
|
95 |
</global>
|
96 |
<frontend>
|
app/code/community/Payson/Payson/etc/system.xml
CHANGED
@@ -58,6 +58,16 @@
|
|
58 |
<show_in_website>0</show_in_website>
|
59 |
<show_in_store>0</show_in_store>
|
60 |
</md5_key>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
61 |
<payment_guarantee translate="label,comment">
|
62 |
<label>Enable payment guarantee</label>
|
63 |
<comment>Enable/disable payment guarantee.</comment>
|
@@ -96,6 +106,7 @@
|
|
96 |
<show_in_default>1</show_in_default>
|
97 |
<show_in_website>1</show_in_website>
|
98 |
<show_in_store>1</show_in_store>
|
|
|
99 |
<fields>
|
100 |
<active translate="label,comment">
|
101 |
<label>Enabled</label>
|
58 |
<show_in_website>0</show_in_website>
|
59 |
<show_in_store>0</show_in_store>
|
60 |
</md5_key>
|
61 |
+
<paysondirect_method translate="label">
|
62 |
+
<label>Please select the payment method</label>
|
63 |
+
<comment>Pay with Payson (Visa, Mastercard or Internetbank)</comment>
|
64 |
+
<frontend_type>select</frontend_type>
|
65 |
+
<source_model>payson/system_config_source_paysondirectmethod</source_model>
|
66 |
+
<sort_order>45</sort_order>
|
67 |
+
<show_in_default>1</show_in_default>
|
68 |
+
<show_in_website>1</show_in_website>
|
69 |
+
<show_in_store>1</show_in_store>
|
70 |
+
</paysondirect_method>
|
71 |
<payment_guarantee translate="label,comment">
|
72 |
<label>Enable payment guarantee</label>
|
73 |
<comment>Enable/disable payment guarantee.</comment>
|
106 |
<show_in_default>1</show_in_default>
|
107 |
<show_in_website>1</show_in_website>
|
108 |
<show_in_store>1</show_in_store>
|
109 |
+
<comment><![CDATA[Payson Invoice requires a separate contract. Please contact Payson for more information<a href="http://payson.se" target="_blank">Click here</a>]]></comment>
|
110 |
<fields>
|
111 |
<active translate="label,comment">
|
112 |
<label>Enabled</label>
|
app/code/community/Payson/Payson/sql/payson_setup/mysql4-install-0.1.0.php
CHANGED
@@ -1,32 +1,32 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
$this->startSetup();
|
4 |
-
$this->run('
|
5 |
-
CREATE TABLE IF NOT EXISTS `' . $this->getTable('payson_order') . '`
|
6 |
-
(
|
7 |
-
`id` INT NOT NULL AUTO_INCREMENT,
|
8 |
-
`order_id` INT NOT NULL,
|
9 |
-
`added` DATETIME DEFAULT NULL,
|
10 |
-
`updated` DATETIME DEFAULT NULL,
|
11 |
-
`valid` TINYINT(1) NOT NULL,
|
12 |
-
`ipn_status` VARCHAR(32) DEFAULT NULL,
|
13 |
-
`token` VARCHAR(255) DEFAULT NULL,
|
14 |
-
PRIMARY KEY (`id`)
|
15 |
-
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
16 |
-
|
17 |
-
CREATE TABLE IF NOT EXISTS `' . $this->getTable('payson_order_log') . '`
|
18 |
-
(
|
19 |
-
`id` INT NOT NULL AUTO_INCREMENT,
|
20 |
-
`payson_order_id` INT DEFAULT NULL,
|
21 |
-
`added` DATETIME DEFAULT NULL,
|
22 |
-
`api_call` VARCHAR(32) NOT NULL,
|
23 |
-
`valid` TINYINT(1) NOT NULL,
|
24 |
-
`response` TEXT NOT NULL,
|
25 |
-
PRIMARY KEY (`id`)
|
26 |
-
) ENGINE=InnoDB DEFAULT CHARSET=utf8;');
|
27 |
-
|
28 |
-
$this->addAttribute('order', 'payson_invoice_fee', array('type' => 'decimal', 'grid' => false));
|
29 |
-
$this->addAttribute('order', 'base_payson_invoice_fee', array('type' => 'decimal', 'grid' => false));
|
30 |
-
|
31 |
-
$this->endSetup();
|
32 |
-
|
1 |
+
<?php
|
2 |
+
|
3 |
+
$this->startSetup();
|
4 |
+
$this->run('
|
5 |
+
CREATE TABLE IF NOT EXISTS `' . $this->getTable('payson_order') . '`
|
6 |
+
(
|
7 |
+
`id` INT NOT NULL AUTO_INCREMENT,
|
8 |
+
`order_id` INT NOT NULL,
|
9 |
+
`added` DATETIME DEFAULT NULL,
|
10 |
+
`updated` DATETIME DEFAULT NULL,
|
11 |
+
`valid` TINYINT(1) NOT NULL,
|
12 |
+
`ipn_status` VARCHAR(32) DEFAULT NULL,
|
13 |
+
`token` VARCHAR(255) DEFAULT NULL,
|
14 |
+
PRIMARY KEY (`id`)
|
15 |
+
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
16 |
+
|
17 |
+
CREATE TABLE IF NOT EXISTS `' . $this->getTable('payson_order_log') . '`
|
18 |
+
(
|
19 |
+
`id` INT NOT NULL AUTO_INCREMENT,
|
20 |
+
`payson_order_id` INT DEFAULT NULL,
|
21 |
+
`added` DATETIME DEFAULT NULL,
|
22 |
+
`api_call` VARCHAR(32) NOT NULL,
|
23 |
+
`valid` TINYINT(1) NOT NULL,
|
24 |
+
`response` TEXT NOT NULL,
|
25 |
+
PRIMARY KEY (`id`)
|
26 |
+
) ENGINE=InnoDB DEFAULT CHARSET=utf8;');
|
27 |
+
|
28 |
+
$this->addAttribute('order', 'payson_invoice_fee', array('type' => 'decimal', 'grid' => false));
|
29 |
+
$this->addAttribute('order', 'base_payson_invoice_fee', array('type' => 'decimal', 'grid' => false));
|
30 |
+
|
31 |
+
$this->endSetup();
|
32 |
+
|
app/code/community/Payson/Payson/sql/payson_setup/mysql4-upgrade-0.1.0-0.1.2.php
CHANGED
@@ -1,8 +1,8 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
$this->startSetup();
|
4 |
-
$this->run('alter table `' . $this->getTable('payson_order') . '` add store_id int;
|
5 |
-
');
|
6 |
-
|
7 |
-
$this->endSetup();
|
8 |
-
|
1 |
+
<?php
|
2 |
+
|
3 |
+
$this->startSetup();
|
4 |
+
$this->run('alter table `' . $this->getTable('payson_order') . '` add store_id int;
|
5 |
+
');
|
6 |
+
|
7 |
+
$this->endSetup();
|
8 |
+
|
app/design/adminhtml/default/default/Payson/Payson/total.phtml
CHANGED
@@ -1,5 +1,5 @@
|
|
1 |
-
<tr>
|
2 |
-
<td class="label"><?php echo($this->__('Invoice Fee')); ?></td>
|
3 |
-
<td><?php echo($this->displayPriceAttribute('payson_invoice_fee')); ?></td>
|
4 |
-
</tr>
|
5 |
-
|
1 |
+
<tr>
|
2 |
+
<td class="label"><?php echo($this->__('Invoice Fee')); ?></td>
|
3 |
+
<td><?php echo($this->displayPriceAttribute('payson_invoice_fee')); ?></td>
|
4 |
+
</tr>
|
5 |
+
|
app/design/adminhtml/default/default/layout/Payson.xml
CHANGED
@@ -1,24 +1,24 @@
|
|
1 |
-
<?xml version="1.0" encoding="UTF-8"?>
|
2 |
-
<layout>
|
3 |
-
<adminhtml_sales_order_view>
|
4 |
-
<reference name="order_totals">
|
5 |
-
<block type="adminhtml/sales_order_totals_item" name="payson_invoice_fee" template="Payson/Payson/total.phtml" />
|
6 |
-
</reference>
|
7 |
-
</adminhtml_sales_order_view>
|
8 |
-
<adminhtml_sales_order_invoice_new>
|
9 |
-
<reference name="invoice_totals">
|
10 |
-
<block type="adminhtml/sales_order_totals_item" name="payson_invoice_fee" template="Payson/Payson/total.phtml" />
|
11 |
-
</reference>
|
12 |
-
</adminhtml_sales_order_invoice_new>
|
13 |
-
<adminhtml_sales_order_invoice_view>
|
14 |
-
<reference name="invoice_totals">
|
15 |
-
<block type="adminhtml/sales_order_totals_item" name="payson_invoice_fee" template="Payson/Payson/total.phtml" />
|
16 |
-
</reference>
|
17 |
-
</adminhtml_sales_order_invoice_view>
|
18 |
-
<adminhtml_sales_order_creditmemo_new>
|
19 |
-
<reference name="creditmemo_totals">
|
20 |
-
<block type="adminhtml/sales_order_totals_item" name="payson_invoice_fee" template="Payson/Payson/total.phtml" />
|
21 |
-
</reference>
|
22 |
-
</adminhtml_sales_order_creditmemo_new>
|
23 |
-
</layout>
|
24 |
-
|
1 |
+
<?xml version="1.0" encoding="UTF-8"?>
|
2 |
+
<layout>
|
3 |
+
<adminhtml_sales_order_view>
|
4 |
+
<reference name="order_totals">
|
5 |
+
<block type="adminhtml/sales_order_totals_item" name="payson_invoice_fee" template="Payson/Payson/total.phtml" />
|
6 |
+
</reference>
|
7 |
+
</adminhtml_sales_order_view>
|
8 |
+
<adminhtml_sales_order_invoice_new>
|
9 |
+
<reference name="invoice_totals">
|
10 |
+
<block type="adminhtml/sales_order_totals_item" name="payson_invoice_fee" template="Payson/Payson/total.phtml" />
|
11 |
+
</reference>
|
12 |
+
</adminhtml_sales_order_invoice_new>
|
13 |
+
<adminhtml_sales_order_invoice_view>
|
14 |
+
<reference name="invoice_totals">
|
15 |
+
<block type="adminhtml/sales_order_totals_item" name="payson_invoice_fee" template="Payson/Payson/total.phtml" />
|
16 |
+
</reference>
|
17 |
+
</adminhtml_sales_order_invoice_view>
|
18 |
+
<adminhtml_sales_order_creditmemo_new>
|
19 |
+
<reference name="creditmemo_totals">
|
20 |
+
<block type="adminhtml/sales_order_totals_item" name="payson_invoice_fee" template="Payson/Payson/total.phtml" />
|
21 |
+
</reference>
|
22 |
+
</adminhtml_sales_order_creditmemo_new>
|
23 |
+
</layout>
|
24 |
+
|
app/design/frontend/base/default/layout/Payson.xml
CHANGED
@@ -1,45 +1,45 @@
|
|
1 |
-
<?xml version="1.0" encoding="UTF-8"?>
|
2 |
-
<layout version="0.1.0">
|
3 |
-
<sales_order_print>
|
4 |
-
<reference name="order_totals">
|
5 |
-
<block type="payson/order_totals_fee" name="payson_invoice_fee" />
|
6 |
-
</reference>
|
7 |
-
</sales_order_print>
|
8 |
-
<sales_order_view>
|
9 |
-
<reference name="order_totals">
|
10 |
-
<block type="payson/order_totals_fee" name="payson_invoice_fee" />
|
11 |
-
</reference>
|
12 |
-
</sales_order_view>
|
13 |
-
<sales_order_invoice>
|
14 |
-
<reference name="invoice_totals">
|
15 |
-
<block type="payson/order_totals_fee" name="payson_invoice_fee" />
|
16 |
-
</reference>
|
17 |
-
</sales_order_invoice>
|
18 |
-
<sales_order_printinvoice>
|
19 |
-
<reference name="invoice_totals">
|
20 |
-
<block type="payson/order_totals_fee" name="payson_invoice_fee" />
|
21 |
-
</reference>
|
22 |
-
</sales_order_printinvoice>
|
23 |
-
<sales_order_creditmemo>
|
24 |
-
<reference name="creditmemo_totals">
|
25 |
-
<block type="payson/order_totals_fee" name="payson_invoice_fee" />
|
26 |
-
</reference>
|
27 |
-
</sales_order_creditmemo>
|
28 |
-
<sales_order_printcreditmemo>
|
29 |
-
<reference name="creditmemo_totals">
|
30 |
-
<block type="payson/order_totals_fee" name="payson_invoice_fee" />
|
31 |
-
</reference>
|
32 |
-
</sales_order_printcreditmemo>
|
33 |
-
<sales_email_order_items>
|
34 |
-
<reference name="order_totals">
|
35 |
-
<block type="payson/order_totals_fee" name="payson_invoice_fee" />
|
36 |
-
</reference>
|
37 |
-
</sales_email_order_items>
|
38 |
-
<sales_email_order_invoice_items>
|
39 |
-
<reference name="invoice_totals">
|
40 |
-
<block type="payson/order_totals_fee" name="payson_invoice_fee" />
|
41 |
-
</reference>
|
42 |
-
</sales_email_order_invoice_items>
|
43 |
-
<!-- sales_email_order_shipment_items sales_email_order_creditmemo_items -->
|
44 |
-
</layout>
|
45 |
-
|
1 |
+
<?xml version="1.0" encoding="UTF-8"?>
|
2 |
+
<layout version="0.1.0">
|
3 |
+
<sales_order_print>
|
4 |
+
<reference name="order_totals">
|
5 |
+
<block type="payson/order_totals_fee" name="payson_invoice_fee" />
|
6 |
+
</reference>
|
7 |
+
</sales_order_print>
|
8 |
+
<sales_order_view>
|
9 |
+
<reference name="order_totals">
|
10 |
+
<block type="payson/order_totals_fee" name="payson_invoice_fee" />
|
11 |
+
</reference>
|
12 |
+
</sales_order_view>
|
13 |
+
<sales_order_invoice>
|
14 |
+
<reference name="invoice_totals">
|
15 |
+
<block type="payson/order_totals_fee" name="payson_invoice_fee" />
|
16 |
+
</reference>
|
17 |
+
</sales_order_invoice>
|
18 |
+
<sales_order_printinvoice>
|
19 |
+
<reference name="invoice_totals">
|
20 |
+
<block type="payson/order_totals_fee" name="payson_invoice_fee" />
|
21 |
+
</reference>
|
22 |
+
</sales_order_printinvoice>
|
23 |
+
<sales_order_creditmemo>
|
24 |
+
<reference name="creditmemo_totals">
|
25 |
+
<block type="payson/order_totals_fee" name="payson_invoice_fee" />
|
26 |
+
</reference>
|
27 |
+
</sales_order_creditmemo>
|
28 |
+
<sales_order_printcreditmemo>
|
29 |
+
<reference name="creditmemo_totals">
|
30 |
+
<block type="payson/order_totals_fee" name="payson_invoice_fee" />
|
31 |
+
</reference>
|
32 |
+
</sales_order_printcreditmemo>
|
33 |
+
<sales_email_order_items>
|
34 |
+
<reference name="order_totals">
|
35 |
+
<block type="payson/order_totals_fee" name="payson_invoice_fee" />
|
36 |
+
</reference>
|
37 |
+
</sales_email_order_items>
|
38 |
+
<sales_email_order_invoice_items>
|
39 |
+
<reference name="invoice_totals">
|
40 |
+
<block type="payson/order_totals_fee" name="payson_invoice_fee" />
|
41 |
+
</reference>
|
42 |
+
</sales_email_order_invoice_items>
|
43 |
+
<!-- sales_email_order_shipment_items sales_email_order_creditmemo_items -->
|
44 |
+
</layout>
|
45 |
+
|
app/design/frontend/base/default/template/Payson/Payson/invoice_form.phtml
CHANGED
@@ -1,15 +1,15 @@
|
|
1 |
-
<?php
|
2 |
-
$helper = Mage::Helper('payson');
|
3 |
-
$code = $this->getMethodCode();
|
4 |
-
?>
|
5 |
-
<fieldset class="form-list">
|
6 |
-
<label for="p_method_<?php echo($code); ?>" style="float: none"><img src="<?php echo(Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_SKIN)); ?>frontend/base/default/Payson/Payson/payson_faktura.png" alt="Payson" style="margin: 10px 0; display: block" /></label>
|
7 |
-
<p id="payment_form_<?php echo($code); ?>" style="display: none">
|
8 |
-
<?php
|
9 |
-
echo($helper->__('You will be redirected to Payson\'s website.'));
|
10 |
-
echo '<br /><br />';
|
11 |
-
echo($helper->__('If you choose to pay by Paysoninvoice so there is a fee. Payment terms are 10 days and the invoice will be sent separately by email to the email address you specify. To pay by Paysoninvoice You must be 18 years old and be registered in Sweden as well as authorized in the credit assessment carried out at purchase.'));
|
12 |
-
?>
|
13 |
-
</p>
|
14 |
-
</fieldset>
|
15 |
-
|
1 |
+
<?php
|
2 |
+
$helper = Mage::Helper('payson');
|
3 |
+
$code = $this->getMethodCode();
|
4 |
+
?>
|
5 |
+
<fieldset class="form-list">
|
6 |
+
<label for="p_method_<?php echo($code); ?>" style="float: none"><img src="<?php echo(Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_SKIN)); ?>frontend/base/default/Payson/Payson/payson_faktura.png" alt="Payson" style="margin: 10px 0; display: block" /></label>
|
7 |
+
<p id="payment_form_<?php echo($code); ?>" style="display: none">
|
8 |
+
<?php
|
9 |
+
echo($helper->__('You will be redirected to Payson\'s website.'));
|
10 |
+
echo '<br /><br />';
|
11 |
+
echo($helper->__('If you choose to pay by Paysoninvoice so there is a fee. Payment terms are 10 days and the invoice will be sent separately by email to the email address you specify. To pay by Paysoninvoice You must be 18 years old and be registered in Sweden as well as authorized in the credit assessment carried out at purchase.'));
|
12 |
+
?>
|
13 |
+
</p>
|
14 |
+
</fieldset>
|
15 |
+
|
app/design/frontend/base/default/template/Payson/Payson/standard_form.phtml
CHANGED
@@ -1,9 +1,9 @@
|
|
1 |
-
<?php
|
2 |
-
$helper = Mage::Helper('payson');
|
3 |
-
$code = $this->getMethodCode();
|
4 |
-
?>
|
5 |
-
<fieldset class="form-list">
|
6 |
-
<label for="p_method_<?php echo($code); ?>" style="float: none"><img src="<?php echo(Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_SKIN)); ?>frontend/base/default/Payson/Payson/payson.png" alt="Payson" style="margin: 10px 0; display: block" /></label>
|
7 |
-
<p id="payment_form_<?php echo($code); ?>" style="display: none"><?php echo($helper->__('You will be redirected to Payson\'s website.')); ?></p>
|
8 |
-
</fieldset>
|
9 |
-
|
1 |
+
<?php
|
2 |
+
$helper = Mage::Helper('payson');
|
3 |
+
$code = $this->getMethodCode();
|
4 |
+
?>
|
5 |
+
<fieldset class="form-list">
|
6 |
+
<label for="p_method_<?php echo($code); ?>" style="float: none"><img src="<?php echo(Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_SKIN)); ?>frontend/base/default/Payson/Payson/payson.png" alt="Payson" style="margin: 10px 0; display: block" /></label>
|
7 |
+
<p id="payment_form_<?php echo($code); ?>" style="display: none"><?php echo($helper->__('You will be redirected to Payson\'s website.')); ?></p>
|
8 |
+
</fieldset>
|
9 |
+
|
app/etc/modules/Payson_Payson.xml
CHANGED
@@ -4,7 +4,7 @@
|
|
4 |
<Payson_Payson>
|
5 |
<active>true</active>
|
6 |
<codePool>community</codePool>
|
7 |
-
<version>1.
|
8 |
<depends>
|
9 |
<Mage_Payment />
|
10 |
</depends>
|
4 |
<Payson_Payson>
|
5 |
<active>true</active>
|
6 |
<codePool>community</codePool>
|
7 |
+
<version>1.2</version>
|
8 |
<depends>
|
9 |
<Mage_Payment />
|
10 |
</depends>
|
app/locale/sv_SE/Payson_Payson.csv
CHANGED
@@ -1,50 +1,50 @@
|
|
1 |
-
"Checkout with Payson","Betala med Payson"
|
2 |
-
"You will be redirected to Payson's website.","Du kommer att skickas vidare till Paysons webbplats"
|
3 |
-
|
4 |
-
"Checkout with Payson invoice %s invoice fee","Betala med Payson faktura %s fakturaavgift"
|
5 |
-
"Invoice fee","Fakturaavgift"
|
6 |
-
"If you choose to pay by Paysoninvoice so there is a fee. Payment terms are 10 days and the invoice will be sent separately by email to the email address you specify. To pay by Paysoninvoice You must be 18 years old and be registered in Sweden as well as authorized in the credit assessment carried out at purchase.", "Om du väljer att betala med Paysonfaktura så tillkommer ovanstående avgift. Betalningsvillkor är 10 dagar och fakturan kommer att sändas separat med e-post till den e-postadress Du anger. För att betala mot Paysonfaktura måste Du ha fyllt 18 år och vara folkbokförd i Sverige samt godkännas i den kreditprövning som genomförs vid köpet."
|
7 |
-
"The payment was denied by Payson. Please, try a different payment method", "Betalningen blev nekad. Vänligen, försök med en annan betalningsmetod."
|
8 |
-
"Something went wrong with the payment. Please, try a different payment method", "Något gick fel med betalningen. Vänligen, försök en annan betalningsmetod."
|
9 |
-
|
10 |
-
"Order was activated at Payson","Order aktiverades hos Payson"
|
11 |
-
"Payment was credited at Payson","Betalningen krediterades hos Payson"
|
12 |
-
"Order was canceled at Payson","Beställningen avbröts hos Payson"
|
13 |
-
|
14 |
-
"Payson is not ready to create an invoice. Please try again later.","Payson är inte redo att skapa en faktura. Försök igen senare."
|
15 |
-
"Payson is not ready to cancel the order. Please try again later.","Payson är inte redo att avbryta beställningen. Försök igen senare."
|
16 |
-
|
17 |
-
"Order from %s","Order från %s"
|
18 |
-
"No description","Ingen beskrivning"
|
19 |
-
"Failed to initialize payment. Payson replied: %s","Misslyckades med att initiera betalning. Payson svarade med: %s"
|
20 |
-
"Failed to retrieve payment details. Payson replied: %s","Misslyckades med att hämta betalningsdetaljer. Payson svarade med: %s"
|
21 |
-
"Failed to update payment. Payson replied: %s","Misslyckades med att uppdatera betalning. Payson svarade med: %s"
|
22 |
-
"The customer was redirected to Payson","Kunden omdirigerades till Payson"
|
23 |
-
"Payson completed the order payment","Payson färdigställde betalningen"
|
24 |
-
"Payson created an invoice","Payson skapade en faktura"
|
25 |
-
"Payson updated the shipping address","Payson uppdaterade leveransadressen"
|
26 |
-
"Payson pinged the order with status %s","Payson pingade ordern med status: %s"
|
27 |
-
"Payson cancelled the order with status %s","Payson avbröt ordern med status: %s"
|
28 |
-
|
29 |
-
"Enabled","Aktiverad"
|
30 |
-
"Enable/disable payment with Payson.","Aktivera eller inaktivera betalning med Payson."
|
31 |
-
"Email","E-post"
|
32 |
-
"Email address bound to your Payson account.","E-postadress för ditt Paysonkonto."
|
33 |
-
"Agent ID","Agent ID"
|
34 |
-
"Agent ID is found on your Payson profile page.","Logga in på Paysons webbplats för att hämta ditt Agent ID."
|
35 |
-
"MD5 key","MD5-nyckel"
|
36 |
-
"MD5 key is found on your Payson profile page.","Logga in på Paysons webbplats för att hämta din MD5-nyckel."
|
37 |
-
"Enable payment guarantee","Aktivera Paysongaranti"
|
38 |
-
"Enable/disable payment guarantee.","Aktivera eller inaktivera Paysongaranti."
|
39 |
-
|
40 |
-
"Payson invoice","Payson faktura"
|
41 |
-
"Enable/disable invoice payment with Payson.","Aktivera eller inaktivera faktura med Payson."
|
42 |
-
"Invoice fee tax","Momsklass för fakturaavgift"
|
43 |
-
"Tax class for invoice fees.","Momsklass för fakturaavgift."
|
44 |
-
"Invoice fee (SEK)","Fakturaavgift (SEK)"
|
45 |
-
"Invoice fee for SEK excluding tax.","Fakturaavgift för SEK utan moms."
|
46 |
-
"Invoice fee (EUR)","Fakturaavgift (EUR)"
|
47 |
-
"Invoice fee for EUR excluding tax.","Fakturaavgift för EUR utan moms."
|
48 |
-
"Enable/disable test mode.","Slå på/av testläge"
|
49 |
-
"Enable this to send Payson invoice to customer instantly after purchase. Disabling this means you have to mark the goods as Shipped in Admin to activate the invoice","Aktivera detta för att skicka Payson-fakturan direkt när ett köp accepterats. Stängs denna funktion av måste ordern markeras som Skickad i Magento Admin eller Payson Admin"
|
50 |
-
|
1 |
+
"Checkout with Payson","Betala med Payson"
|
2 |
+
"You will be redirected to Payson's website.","Du kommer att skickas vidare till Paysons webbplats"
|
3 |
+
|
4 |
+
"Checkout with Payson invoice %s invoice fee","Betala med Payson faktura %s fakturaavgift"
|
5 |
+
"Invoice fee","Fakturaavgift"
|
6 |
+
"If you choose to pay by Paysoninvoice so there is a fee. Payment terms are 10 days and the invoice will be sent separately by email to the email address you specify. To pay by Paysoninvoice You must be 18 years old and be registered in Sweden as well as authorized in the credit assessment carried out at purchase.", "Om du väljer att betala med Paysonfaktura så tillkommer ovanstående avgift. Betalningsvillkor är 10 dagar och fakturan kommer att sändas separat med e-post till den e-postadress Du anger. För att betala mot Paysonfaktura måste Du ha fyllt 18 år och vara folkbokförd i Sverige samt godkännas i den kreditprövning som genomförs vid köpet."
|
7 |
+
"The payment was denied by Payson. Please, try a different payment method", "Betalningen blev nekad. Vänligen, försök med en annan betalningsmetod."
|
8 |
+
"Something went wrong with the payment. Please, try a different payment method", "Något gick fel med betalningen. Vänligen, försök en annan betalningsmetod."
|
9 |
+
|
10 |
+
"Order was activated at Payson","Order aktiverades hos Payson"
|
11 |
+
"Payment was credited at Payson","Betalningen krediterades hos Payson"
|
12 |
+
"Order was canceled at Payson","Beställningen avbröts hos Payson"
|
13 |
+
|
14 |
+
"Payson is not ready to create an invoice. Please try again later.","Payson är inte redo att skapa en faktura. Försök igen senare."
|
15 |
+
"Payson is not ready to cancel the order. Please try again later.","Payson är inte redo att avbryta beställningen. Försök igen senare."
|
16 |
+
|
17 |
+
"Order from %s","Order från %s"
|
18 |
+
"No description","Ingen beskrivning"
|
19 |
+
"Failed to initialize payment. Payson replied: %s","Misslyckades med att initiera betalning. Payson svarade med: %s"
|
20 |
+
"Failed to retrieve payment details. Payson replied: %s","Misslyckades med att hämta betalningsdetaljer. Payson svarade med: %s"
|
21 |
+
"Failed to update payment. Payson replied: %s","Misslyckades med att uppdatera betalning. Payson svarade med: %s"
|
22 |
+
"The customer was redirected to Payson","Kunden omdirigerades till Payson"
|
23 |
+
"Payson completed the order payment","Payson färdigställde betalningen"
|
24 |
+
"Payson created an invoice","Payson skapade en faktura"
|
25 |
+
"Payson updated the shipping address","Payson uppdaterade leveransadressen"
|
26 |
+
"Payson pinged the order with status %s","Payson pingade ordern med status: %s"
|
27 |
+
"Payson cancelled the order with status %s","Payson avbröt ordern med status: %s"
|
28 |
+
|
29 |
+
"Enabled","Aktiverad"
|
30 |
+
"Enable/disable payment with Payson.","Aktivera eller inaktivera betalning med Payson."
|
31 |
+
"Email","E-post"
|
32 |
+
"Email address bound to your Payson account.","E-postadress för ditt Paysonkonto."
|
33 |
+
"Agent ID","Agent ID"
|
34 |
+
"Agent ID is found on your Payson profile page.","Logga in på Paysons webbplats för att hämta ditt Agent ID."
|
35 |
+
"MD5 key","MD5-nyckel"
|
36 |
+
"MD5 key is found on your Payson profile page.","Logga in på Paysons webbplats för att hämta din MD5-nyckel."
|
37 |
+
"Enable payment guarantee","Aktivera Paysongaranti"
|
38 |
+
"Enable/disable payment guarantee.","Aktivera eller inaktivera Paysongaranti."
|
39 |
+
|
40 |
+
"Payson invoice","Payson faktura"
|
41 |
+
"Enable/disable invoice payment with Payson.","Aktivera eller inaktivera faktura med Payson."
|
42 |
+
"Invoice fee tax","Momsklass för fakturaavgift"
|
43 |
+
"Tax class for invoice fees.","Momsklass för fakturaavgift."
|
44 |
+
"Invoice fee (SEK)","Fakturaavgift (SEK)"
|
45 |
+
"Invoice fee for SEK excluding tax.","Fakturaavgift för SEK utan moms."
|
46 |
+
"Invoice fee (EUR)","Fakturaavgift (EUR)"
|
47 |
+
"Invoice fee for EUR excluding tax.","Fakturaavgift för EUR utan moms."
|
48 |
+
"Enable/disable test mode.","Slå på/av testläge"
|
49 |
+
"Enable this to send Payson invoice to customer instantly after purchase. Disabling this means you have to mark the goods as Shipped in Admin to activate the invoice","Aktivera detta för att skicka Payson-fakturan direkt när ett köp accepterats. Stängs denna funktion av måste ordern markeras som Skickad i Magento Admin eller Payson Admin"
|
50 |
+
|
package.xml
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>Payson</name>
|
4 |
-
<version>1.0
|
5 |
<stability>stable</stability>
|
6 |
<license>BSD</license>
|
7 |
<channel>community</channel>
|
@@ -12,12 +12,15 @@
|
|
12 |
<description>Make it easy to charge your customers. Chose Payson.
|
13 |

|
14 |
This module integrates with Payson and allows you to charge your customers via Invoice, Card and direct bank transfers.</description>
|
15 |
-
<notes
|
16 |
-
|
|
|
|
|
|
|
17 |
<authors><author><name>Daniel Hansen</name><user>PaysonAB</user><email>integration@payson.se</email></author></authors>
|
18 |
-
<date>2013-
|
19 |
-
<time>
|
20 |
-
<contents><target name="mage"><dir name="app"><dir name="code"><dir name="community"><dir name="Payson"><dir name="Payson"><dir name="Block"><file name="Form.php" hash="
|
21 |
<compatible/>
|
22 |
<dependencies><required><php><min>5.2.0</min><max>6.0.0</max></php></required></dependencies>
|
23 |
</package>
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>Payson</name>
|
4 |
+
<version>1.2.0</version>
|
5 |
<stability>stable</stability>
|
6 |
<license>BSD</license>
|
7 |
<channel>community</channel>
|
12 |
<description>Make it easy to charge your customers. Chose Payson.
|
13 |

|
14 |
This module integrates with Payson and allows you to charge your customers via Invoice, Card and direct bank transfers.</description>
|
15 |
+
<notes>Improved the calculation of order items
|
16 |
+
Now adds configuration values to descriptions (ex. size, color etc)
|
17 |
+
Some code cleaning
|
18 |
+
It is now possible to set which payment methods to offer the customer (bank, credit card or bank & creditcard)
|
19 |
+
Better check for showing invoice or not in checkout</notes>
|
20 |
<authors><author><name>Daniel Hansen</name><user>PaysonAB</user><email>integration@payson.se</email></author></authors>
|
21 |
+
<date>2013-10-25</date>
|
22 |
+
<time>08:00:16</time>
|
23 |
+
<contents><target name="mage"><dir name="app"><dir name="code"><dir name="community"><dir name="Payson"><dir name="Payson"><dir name="Block"><file name="Form.php" hash="74a8967879fbb6af999f0e513bc91323"/><dir name="Invoice"><file name="Form.php" hash="0d16d91e26b31691267c0a7bdc2a516d"/></dir><dir name="Order"><dir name="Totals"><file name="Fee.php" hash="3e8566e634d68d8df9bb70f597916980"/></dir></dir><dir name="Standard"><file name="Form.php" hash="c715cbec95494a9a26d261992429dff0"/></dir></dir><dir name="Helper"><dir name="Api"><dir name="Response"><file name="Interface.php" hash="51d0ffe7eefaa12eb9b4f2551e9f4259"/><dir name="Standard"><file name="Parameters.php" hash="6965b8259867c23a5e1e682e14491eb2"/></dir><file name="Standard.php" hash="cef827896629364fee49671af879adc3"/><file name="Validate.php" hash="34fb6626af3a6ac06e987c9e10a95796"/></dir></dir><file name="Api.php" hash="4e617360a4c0239d9ad2785a51ef8fdb"/><file name="Data.php" hash="83ff59b1588c0b0ff8d2f7341589ea59"/></dir><dir name="Model"><file name="Config.php" hash="2886124eac6b444fce7944e06ebf9faf"/><dir name="Method"><file name="Abstract.php" hash="6ea3385160ce437933da158b5d3e0d65"/><file name="Invoice.php" hash="ecfd2883a9f2dc24a6e43f04b6f098e8"/><file name="Standard.php" hash="e79bc4044be332dba6b1bcb28ffd6654"/></dir><dir name="Mysql4"><file name="Setup.php" hash="3075fa047af3d56d6eac609004e6e1cc"/></dir><dir name="Order"><dir name="Creditmemo"><dir name="Total"><file name="Invoice.php" hash="0073a5e3617542107713e4155faa07fe"/></dir></dir><dir name="Invoice"><dir name="Total"><file name="Invoice.php" hash="2a2bb0752543535b27c29668113b67e0"/></dir></dir></dir><dir name="Quote"><dir name="Address"><dir name="Total"><file name="Invoice.php" hash="d85f0abf040163920659d18e16d84a9e"/></dir></dir></dir><file name="Standard.php" hash="2e7fa64c2e561d2fbbd3735935edad43"/><dir name="System"><dir name="Config"><dir name="Source"><file name="Paysondirectmethod.php" hash="23549b49797c4ef2ee312fc4fc5f5000"/></dir></dir></dir></dir><dir name="controllers"><dir name="Adminhtml"><dir name="Sales"><dir name="Order"><file name="ShipmentController.php" hash="18d1c17c341f97c233b8ad63f8c321cb"/></dir></dir></dir><file name="CheckoutController.php" hash="683e8c3f2f72430c7004486ca7f164b0"/><file name="IpnController.php" hash="e7b092cdd0011a3a1359a084bbaf14ad"/></dir><dir name="etc"><file name="config.xml" hash="9c2aebf87efc52ada8fe4cc141377594"/><file name="system.xml" hash="2d95d66bdf13e8b056425a002279fb3b"/></dir><dir name="sql"><dir name="payson_setup"><file name="mysql4-install-0.1.0.php" hash="21cd9fd3436ba1eb2fc20eaaadb42106"/><file name="mysql4-upgrade-0.1.0-0.1.2.php" hash="5bbcb930748e3a87a220c0e9f8448a15"/></dir></dir></dir></dir></dir></dir><dir name="design"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="Payson"><dir name="Payson"><file name="total.phtml" hash="e35a3824cd0f3127e8cf7d03a229fb1a"/></dir></dir><dir name="layout"><file name="Payson.xml" hash=""/></dir></dir></dir></dir><dir name="frontend"><dir name="base"><dir name="default"><dir name="template"><dir name="Payson"><dir name="Payson"><file name="invoice_form.phtml" hash="e492d82844ce8b9dc289ae676e391ca7"/><file name="standard_form.phtml" hash="781286055d322d532496af6c5e320034"/></dir></dir></dir><dir name="layout"><file name="Payson.xml" hash=""/></dir></dir></dir></dir></dir><dir name="etc"><dir name="modules"><file name="Payson_Payson.xml" hash=""/></dir></dir><dir name="locale"><dir name="sv_SE"><file name="Payson_Payson.csv" hash=""/></dir></dir></dir><dir name="skin"><dir name="frontend"><dir name="base"><dir name="default"><dir name="Payson"><dir name="Payson"><file name="payson.gif" hash="638d0055cbc1a4bdc32e9fa1156b722a"/><file name="payson.png" hash="308916345711a4520313c94218c5bda7"/><file name="payson_faktura.png" hash="fa218c9949c05c6f3452d9f4c541da2c"/></dir></dir></dir></dir></dir></dir></target></contents>
|
24 |
<compatible/>
|
25 |
<dependencies><required><php><min>5.2.0</min><max>6.0.0</max></php></required></dependencies>
|
26 |
</package>
|