BusinessKing_PaymentCharge - Version 1.0.0.1

Version Notes

Stable version release

Download this release

Release Info

Developer Business King
Extension BusinessKing_PaymentCharge
Version 1.0.0.1
Comparing to
See all releases


Version 1.0.0.1

app/code/local/BusinessKing/PaymentCharge/Block/Adminhtml/Sales/Order/Creditmemo/Totals.php ADDED
@@ -0,0 +1,54 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Adminhtml order creditmemo totals block
5
+ *
6
+ * @category BusinessKing
7
+ * @package BusinessKing_PaymentCharge
8
+ */
9
+ class BusinessKing_PaymentCharge_Block_Adminhtml_Sales_order_Creditmemo_Totals extends BusinessKing_PaymentCharge_Block_Adminhtml_Sales_Totals
10
+ {
11
+ protected $_creditmemo;
12
+
13
+ public function getCreditmemo()
14
+ {
15
+ if ($this->_creditmemo === null) {
16
+ if ($this->hasData('creditmemo')) {
17
+ $this->_creditmemo = $this->_getData('creditmemo');
18
+ } elseif (Mage::registry('current_creditmemo')) {
19
+ $this->_creditmemo = Mage::registry('current_creditmemo');
20
+ } elseif ($this->getParentBlock() && $this->getParentBlock()->getCreditmemo()) {
21
+ $this->_creditmemo = $this->getParentBlock()->getCreditmemo();
22
+ }
23
+ }
24
+ return $this->_creditmemo;
25
+ }
26
+
27
+ public function getSource()
28
+ {
29
+ return $this->getCreditmemo();
30
+ }
31
+
32
+ /**
33
+ * Initialize creditmemo totals array
34
+ *
35
+ * @return Mage_Sales_Block_Order_Totals
36
+ */
37
+ protected function _initTotals()
38
+ {
39
+ parent::_initTotals();
40
+ $this->addTotal(new Varien_Object(array(
41
+ 'code' => 'adjustment_positive',
42
+ 'value' => $this->getSource()->getAdjustmentPositive(),
43
+ 'base_value'=> $this->getSource()->getBaseAdjustmentPositive(),
44
+ 'label' => $this->helper('sales')->__('Adjustment Refund')
45
+ )));
46
+ $this->addTotal(new Varien_Object(array(
47
+ 'code' => 'adjustment_negative',
48
+ 'value' => $this->getSource()->getAdjustmentNegative(),
49
+ 'base_value'=> $this->getSource()->getBaseAdjustmentNegative(),
50
+ 'label' => $this->helper('sales')->__('Adjustment Fee')
51
+ )));
52
+ return $this;
53
+ }
54
+ }
app/code/local/BusinessKing/PaymentCharge/Block/Adminhtml/Sales/Order/Invoice/Totals.php ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Adminhtml order invoice totals block
5
+ *
6
+ * @category BusinessKing
7
+ * @package BusinessKing_PaymentCharge
8
+ */
9
+ class BusinessKing_PaymentCharge_Block_Adminhtml_Sales_order_Invoice_Totals extends BusinessKing_PaymentCharge_Block_Adminhtml_Sales_Totals
10
+ {
11
+ protected $_invoice = null;
12
+
13
+ public function getInvoice()
14
+ {
15
+ if ($this->_invoice === null) {
16
+ if ($this->hasData('invoice')) {
17
+ $this->_invoice = $this->_getData('invoice');
18
+ } elseif (Mage::registry('current_invoice')) {
19
+ $this->_invoice = Mage::registry('current_invoice');
20
+ } elseif ($this->getParentBlock()->getInvoice()) {
21
+ $this->_invoice = $this->getParentBlock()->getInvoice();
22
+ }
23
+ }
24
+ return $this->_invoice;
25
+ }
26
+
27
+ public function getSource()
28
+ {
29
+ return $this->getInvoice();
30
+ }
31
+
32
+ /**
33
+ * Initialize order totals array
34
+ *
35
+ * @return Mage_Sales_Block_Order_Totals
36
+ */
37
+ protected function _initTotals()
38
+ {
39
+ parent::_initTotals();
40
+ return $this;
41
+ }
42
+ }
app/code/local/BusinessKing/PaymentCharge/Block/Adminhtml/Sales/Order/Totals.php ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Adminhtml order totals block
5
+ *
6
+ * @category BusinessKing
7
+ * @package BusinessKing_PaymentCharge
8
+ */
9
+ class BusinessKing_PaymentCharge_Block_Adminhtml_Sales_order_Totals extends BusinessKing_PaymentCharge_Block_Adminhtml_Sales_Totals
10
+ {
11
+ /**
12
+ * Initialize order totals array
13
+ *
14
+ * @return Mage_Sales_Block_Order_Totals
15
+ */
16
+ protected function _initTotals()
17
+ {
18
+ parent::_initTotals();
19
+ $this->_totals['paid'] = new Varien_Object(array(
20
+ 'code' => 'paid',
21
+ 'strong' => true,
22
+ 'value' => $this->getSource()->getTotalPaid(),
23
+ 'base_value'=> $this->getSource()->getBaseTotalPaid(),
24
+ 'label' => $this->helper('sales')->__('Total Paid'),
25
+ 'area' => 'footer'
26
+ ));
27
+ $this->_totals['refunded'] = new Varien_Object(array(
28
+ 'code' => 'refunded',
29
+ 'strong' => true,
30
+ 'value' => $this->getSource()->getTotalRefunded(),
31
+ 'base_value'=> $this->getSource()->getBaseTotalRefunded(),
32
+ 'label' => $this->helper('sales')->__('Total Refunded'),
33
+ 'area' => 'footer'
34
+ ));
35
+ $this->_totals['due'] = new Varien_Object(array(
36
+ 'code' => 'due',
37
+ 'strong' => true,
38
+ 'value' => $this->getSource()->getTotalDue(),
39
+ 'base_value'=> $this->getSource()->getBaseTotalDue(),
40
+ 'label' => $this->helper('sales')->__('Total Due'),
41
+ 'area' => 'footer'
42
+ ));
43
+ return $this;
44
+ }
45
+ }
app/code/local/BusinessKing/PaymentCharge/Block/Adminhtml/Sales/Totals.php ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * @category BusinessKing
5
+ * @package BusinessKing_PaymentCharge
6
+ */
7
+ class BusinessKing_PaymentCharge_Block_Adminhtml_Sales_Totals extends Mage_Adminhtml_Block_Sales_Totals
8
+ {
9
+ /**
10
+ * Initialize order totals array
11
+ *
12
+ * @return Mage_Sales_Block_Order_Totals
13
+ */
14
+ protected function _initTotals()
15
+ {
16
+ parent::_initTotals();
17
+
18
+ $source = $this->getSource();
19
+
20
+ /**
21
+ * Add store rewards
22
+ */
23
+ $totals = $this->_totals;
24
+ $newTotals = array();
25
+ if (count($totals)>0) {
26
+ foreach ($totals as $index=>$arr) {
27
+ if ($index == "grand_total") {
28
+ if (((float)$this->getSource()->getPaymentCharge()) != 0) {
29
+ $label = $this->__('Payment Charge');
30
+ $newTotals['payment_charge'] = new Varien_Object(array(
31
+ 'code' => 'payment_charge',
32
+ 'field' => 'payment_charge',
33
+ 'value' => $source->getPaymentCharge(),
34
+ 'label' => $label
35
+ ));
36
+ }
37
+ }
38
+ $newTotals[$index] = $arr;
39
+ }
40
+ $this->_totals = $newTotals;
41
+ }
42
+
43
+ return $this;
44
+ }
45
+ }
app/code/local/BusinessKing/PaymentCharge/Block/Sales/Order/Creditmemo/Totals.php ADDED
@@ -0,0 +1,90 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * @category BusinessKing
5
+ * @package BusinessKing_PaymentCharge
6
+ */
7
+ class BusinessKing_PaymentCharge_Block_Sales_order_Creditmemo_Totals extends BusinessKing_PaymentCharge_Block_Sales_Order_Totals
8
+ {
9
+ protected $_creditmemo = null;
10
+
11
+ public function getCreditmemo()
12
+ {
13
+ if ($this->_creditmemo === null) {
14
+ if ($this->hasData('creditmemo')) {
15
+ $this->_creditmemo = $this->_getData('creditmemo');
16
+ } elseif (Mage::registry('current_creditmemo')) {
17
+ $this->_creditmemo = Mage::registry('current_creditmemo');
18
+ } elseif ($this->getParentBlock()->getCreditmemo()) {
19
+ $this->_creditmemo = $this->getParentBlock()->getCreditmemo();
20
+ }
21
+ }
22
+ return $this->_creditmemo;
23
+ }
24
+
25
+ public function setCreditmemo($creditmemo)
26
+ {
27
+ $this->_creditmemo = $creditmemo;
28
+ return $this;
29
+ }
30
+
31
+ /**
32
+ * Get totals source object
33
+ *
34
+ * @return Mage_Sales_Model_Order
35
+ */
36
+ public function getSource()
37
+ {
38
+ return $this->getCreditmemo();
39
+ }
40
+
41
+ /**
42
+ * Initialize order totals array
43
+ *
44
+ * @return Mage_Sales_Block_Order_Totals
45
+ */
46
+ protected function _initTotals()
47
+ {
48
+ parent::_initTotals();
49
+ $this->removeTotal('base_grandtotal');
50
+ if ((float) $this->getSource()->getAdjustmentPositive()) {
51
+ $total = new Varien_Object(array(
52
+ 'code' => 'adjustment_positive',
53
+ 'value' => $this->getSource()->getAdjustmentPositive(),
54
+ 'label' => $this->__('Adjustment Refund')
55
+ ));
56
+ $this->addTotal($total);
57
+ }
58
+ if ((float) $this->getSource()->getAdjustmentNegative()) {
59
+ $total = new Varien_Object(array(
60
+ 'code' => 'adjustment_negative',
61
+ 'value' => $this->getSource()->getAdjustmentNegative(),
62
+ 'label' => $this->__('Adjustment Fee')
63
+ ));
64
+ $this->addTotal($total);
65
+ }
66
+ /**
67
+ <?php if ($this->getCanDisplayTotalPaid()): ?>
68
+ <tr>
69
+ <td colspan="6" class="a-right"><strong><?php echo $this->__('Total Paid') ?></strong></td>
70
+ <td class="last a-right"><strong><?php echo $_order->formatPrice($_creditmemo->getTotalPaid()) ?></strong></td>
71
+ </tr>
72
+ <?php endif; ?>
73
+ <?php if ($this->getCanDisplayTotalRefunded()): ?>
74
+ <tr>
75
+ <td colspan="6" class="a-right"><strong><?php echo $this->__('Total Refunded') ?></strong></td>
76
+ <td class="last a-right"><strong><?php echo $_order->formatPrice($_creditmemo->getTotalRefunded()) ?></strong></td>
77
+ </tr>
78
+ <?php endif; ?>
79
+ <?php if ($this->getCanDisplayTotalDue()): ?>
80
+ <tr>
81
+ <td colspan="6" class="a-right"><strong><?php echo $this->__('Total Due') ?></strong></td>
82
+ <td class="last a-right"><strong><?php echo $_order->formatPrice($_creditmemo->getTotalDue()) ?></strong></td>
83
+ </tr>
84
+ <?php endif; ?>
85
+ */
86
+ return $this;
87
+ }
88
+
89
+
90
+ }
app/code/local/BusinessKing/PaymentCharge/Block/Sales/Order/Invoice/Totals.php ADDED
@@ -0,0 +1,54 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * @category BusinessKing
5
+ * @package BusinessKing_PaymentCharge
6
+ */
7
+ class BusinessKing_PaymentCharge_Block_Sales_order_Invoice_Totals extends BusinessKing_PaymentCharge_Block_Sales_Order_Totals
8
+ {
9
+ protected $_invoice = null;
10
+
11
+ public function getInvoice()
12
+ {
13
+ if ($this->_invoice === null) {
14
+ if ($this->hasData('invoice')) {
15
+ $this->_invoice = $this->_getData('invoice');
16
+ } elseif (Mage::registry('current_invoice')) {
17
+ $this->_invoice = Mage::registry('current_invoice');
18
+ } elseif ($this->getParentBlock()->getInvoice()) {
19
+ $this->_invoice = $this->getParentBlock()->getInvoice();
20
+ }
21
+ }
22
+ return $this->_invoice;
23
+ }
24
+
25
+ public function setInvoice($invoice)
26
+ {
27
+ $this->_invoice = $invoice;
28
+ return $this;
29
+ }
30
+
31
+ /**
32
+ * Get totals source object
33
+ *
34
+ * @return Mage_Sales_Model_Order
35
+ */
36
+ public function getSource()
37
+ {
38
+ return $this->getInvoice();
39
+ }
40
+
41
+ /**
42
+ * Initialize order totals array
43
+ *
44
+ * @return Mage_Sales_Block_Order_Totals
45
+ */
46
+ protected function _initTotals()
47
+ {
48
+ parent::_initTotals();
49
+ $this->removeTotal('base_grandtotal');
50
+ return $this;
51
+ }
52
+
53
+
54
+ }
app/code/local/BusinessKing/PaymentCharge/Block/Sales/Order/Totals.php ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * @category BusinessKing
5
+ * @package BusinessKing_PaymentCharge
6
+ */
7
+ class BusinessKing_PaymentCharge_Block_Sales_Order_Totals extends Mage_Sales_Block_Order_Totals
8
+ {
9
+ /**
10
+ * Initialize order totals array
11
+ *
12
+ * @return Mage_Sales_Block_Order_Totals
13
+ */
14
+ protected function _initTotals()
15
+ {
16
+ parent::_initTotals();
17
+
18
+ $source = $this->getSource();
19
+
20
+ /**
21
+ * Add store rewards
22
+ */
23
+ $totals = $this->_totals;
24
+ $newTotals = array();
25
+ if (count($totals)>0) {
26
+ foreach ($totals as $index=>$arr) {
27
+ if ($index == "grand_total") {
28
+ if (((float)$this->getSource()->getPaymentCharge()) != 0) {
29
+ $label = $this->__('Payment Charge');
30
+ $newTotals['payment_charge'] = new Varien_Object(array(
31
+ 'code' => 'payment_charge',
32
+ 'field' => 'payment_charge',
33
+ 'value' => $source->getPaymentCharge(),
34
+ 'label' => $label
35
+ ));
36
+ }
37
+ }
38
+ $newTotals[$index] = $arr;
39
+ }
40
+ $this->_totals = $newTotals;
41
+ }
42
+
43
+ return $this;
44
+ }
45
+ }
app/code/local/BusinessKing/PaymentCharge/Helper/Data.php ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class BusinessKing_PaymentCharge_Helper_Data extends Mage_Core_Helper_Abstract
4
+ {
5
+ /**
6
+ * Get payment charge
7
+ * @param string $code
8
+ * @param Mage_Sales_Model_Quote $quote
9
+ * @return float
10
+ */
11
+ public function getPaymentCharge($code, $quote=null)
12
+ {
13
+ if (is_null($quote)) {
14
+ $quote = Mage::getSingleton('checkout/session')->getQuote();
15
+ }
16
+ $amount = 0;
17
+ $address = $quote->isVirtual() ? $quote->getBillingAddress() : $quote->getShippingAddress();
18
+
19
+ if (preg_match("/paypal/i", strval($code))) {
20
+ $chargeType = Mage::getStoreConfig('paypal/account/charge_type');
21
+ $chargeValue = Mage::getStoreConfig('paypal/account/charge_value');
22
+ }
23
+ else {
24
+ $chargeType = Mage::getStoreConfig('payment/'.strval($code).'/charge_type');
25
+ $chargeValue = Mage::getStoreConfig('payment/'.strval($code).'/charge_value');
26
+ }
27
+
28
+ if ($chargeValue ) {
29
+ if ($chargeType=="percentage") {
30
+ $subTotal = $address->getSubtotal();
31
+ $amount = $subTotal * floatval($chargeValue) / 100;
32
+ }
33
+ else {
34
+ $amount = floatval($chargeValue);
35
+ }
36
+ }
37
+ //return Mage::helper('core')->formatPrice($amount);
38
+ return $amount;
39
+ }
40
+ }
app/code/local/BusinessKing/PaymentCharge/Model/Sales/Order/Creditmemo/Total/Paymentcharge.php ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class BusinessKing_PaymentCharge_Model_Sales_Order_Creditmemo_Total_Paymentcharge extends Mage_Sales_Model_Order_Creditmemo_Total_Abstract
4
+ {
5
+ public function collect(Mage_Sales_Model_Order_Creditmemo $creditmemo)
6
+ {
7
+ $creditmemo->setPaymentCharge(0);
8
+ $creditmemo->setBasePaymentCharge(0);
9
+
10
+ $amount = $creditmemo->getOrder()->getPaymentCharge();
11
+ $creditmemo->setPaymentCharge($amount);
12
+
13
+ $amount = $creditmemo->getOrder()->getBasePaymentCharge();
14
+ $creditmemo->setBasePaymentCharge($amount);
15
+
16
+ $creditmemo->setGrandTotal($creditmemo->getGrandTotal() + $creditmemo->getPaymentCharge());
17
+ $creditmemo->setBaseGrandTotal($creditmemo->getBaseGrandTotal() + $creditmemo->getBasePaymentCharge());
18
+
19
+ return $this;
20
+ }
21
+ }
app/code/local/BusinessKing/PaymentCharge/Model/Sales/Order/Invoice/Total/Paymentcharge.php ADDED
@@ -0,0 +1,43 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class BusinessKing_PaymentCharge_Model_Sales_Order_Invoice_Total_Paymentcharge extends Mage_Sales_Model_Order_Invoice_Total_Abstract
4
+ {
5
+ public function collect(Mage_Sales_Model_Order_Invoice $invoice)
6
+ {
7
+ $invoice->setPaymentCharge(0);
8
+ $invoice->setBasePaymentCharge(0);
9
+
10
+ /*$hasInvoices = $invoice->getOrder()->hasInvoices();
11
+ $paymentMethod = $invoice->getOrder()->getPayment()->getMethod();
12
+ if ($paymentMethod) { //&& !$hasInvoices
13
+ $chargeType = Mage::getStoreConfig('payment/'.strval($paymentMethod).'/charge_type');
14
+ $chargeValue = Mage::getStoreConfig('payment/'.strval($paymentMethod).'/charge_value');
15
+ if ($chargeValue) {
16
+ if ($chargeType=="percentage") {
17
+ $subTotal = $invoice->getSubtotal();
18
+ $amount = $subTotal * intval($chargeValue) / 100;
19
+ }
20
+ else {
21
+ $amount = intval($chargeValue);
22
+ }
23
+ $invoice->setPaymentCharge($amount);
24
+ $invoice->setBasePaymentCharge($amount);
25
+ }
26
+ }
27
+
28
+ $invoice->setGrandTotal($invoice->getGrandTotal() + $invoice->getPaymentCharge());
29
+ $invoice->setBaseGrandTotal($invoice->getBaseGrandTotal() + $invoice->getBasePaymentCharge());
30
+ */
31
+
32
+ $amount = $invoice->getOrder()->getPaymentCharge();
33
+ $invoice->setPaymentCharge($amount);
34
+
35
+ $amount = $invoice->getOrder()->getBasePaymentCharge();
36
+ $invoice->setBasePaymentCharge($amount);
37
+
38
+ $invoice->setGrandTotal($invoice->getGrandTotal() + $invoice->getPaymentCharge());
39
+ $invoice->setBaseGrandTotal($invoice->getBaseGrandTotal() + $invoice->getBasePaymentCharge());
40
+
41
+ return $this;
42
+ }
43
+ }
app/code/local/BusinessKing/PaymentCharge/Model/Sales/Quote/Address/Total/Paymentcharge.php ADDED
@@ -0,0 +1,49 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * @category BusinessKing
5
+ * @package BusinessKing_PaymentCharge
6
+ */
7
+ class BusinessKing_PaymentCharge_Model_Sales_Quote_Address_Total_Paymentcharge extends Mage_Sales_Model_Quote_Address_Total_Abstract
8
+ {
9
+ public function __construct()
10
+ {
11
+ $this->setCode('payment_charge');
12
+ }
13
+
14
+ public function collect(Mage_Sales_Model_Quote_Address $address)
15
+ {
16
+ $address->setPaymentCharge(0);
17
+ $address->setBasePaymentCharge(0);
18
+
19
+ $items = $address->getAllItems();
20
+ if (!count($items)) {
21
+ return $this;
22
+ }
23
+
24
+ $paymentMethod = $address->getQuote()->getPayment()->getMethod();
25
+ if ($paymentMethod) {
26
+ $amount = Mage::helper('paymentcharge')->getPaymentCharge($paymentMethod, $address->getQuote());
27
+ $address->setPaymentCharge($amount);
28
+ $address->setBasePaymentCharge($amount);
29
+ }
30
+
31
+ $address->setGrandTotal($address->getGrandTotal() + $address->getPaymentCharge());
32
+ $address->setBaseGrandTotal($address->getBaseGrandTotal() + $address->getBasePaymentCharge());
33
+ return $this;
34
+ }
35
+
36
+ public function fetch(Mage_Sales_Model_Quote_Address $address)
37
+ {
38
+ $amount = $address->getPaymentCharge();
39
+ if (($amount!=0)) {
40
+ $address->addTotal(array(
41
+ 'code' => $this->getCode(),
42
+ 'title' => Mage::helper('sales')->__('Payment Charge'),
43
+ 'full_info' => array(),
44
+ 'value' => $amount
45
+ ));
46
+ }
47
+ return $this;
48
+ }
49
+ }
app/code/local/BusinessKing/PaymentCharge/Model/System/Config/Source/Chargetype.php ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * @category BusinessKing
5
+ * @package BusinessKing_PaymentCharge
6
+ */
7
+ class BusinessKing_PaymentCharge_Model_System_Config_Source_Chargetype extends Varien_Object
8
+ {
9
+ public function toOptionArray()
10
+ {
11
+ return array(
12
+ array('value'=>'fixed', 'label'=>Mage::helper('adminhtml')->__('Fixed')),
13
+ array('value'=>'percentage', 'label'=>Mage::helper('adminhtml')->__('Percentage of subtotal')),
14
+ );
15
+ }
16
+ }
app/code/local/BusinessKing/PaymentCharge/etc/config.xml ADDED
@@ -0,0 +1,112 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <config>
3
+ <modules>
4
+ <BusinessKing_PaymentCharge>
5
+ <version>0.1.0</version>
6
+ </BusinessKing_PaymentCharge>
7
+ </modules>
8
+
9
+ <global>
10
+ <blocks>
11
+ <paymentcharge>
12
+ <class>BusinessKing_PaymentCharge_Block</class>
13
+ </paymentcharge>
14
+ <sales>
15
+ <rewrite>
16
+ <order_totals>BusinessKing_PaymentCharge_Block_Sales_Order_Totals</order_totals>
17
+ <order_invoice_totals>BusinessKing_PaymentCharge_Block_Sales_order_Invoice_Totals</order_invoice_totals>
18
+ <order_creditmemo_totals>BusinessKing_PaymentCharge_Block_Sales_order_Creditmemo_Totals</order_creditmemo_totals>
19
+ </rewrite>
20
+ </sales>
21
+ <adminhtml>
22
+ <rewrite>
23
+ <sales_totals>BusinessKing_PaymentCharge_Block_Adminhtml_Sales_Totals</sales_totals>
24
+ <sales_order_totals>BusinessKing_PaymentCharge_Block_Adminhtml_Sales_order_Totals</sales_order_totals>
25
+ <sales_order_invoice_totals>BusinessKing_PaymentCharge_Block_Adminhtml_Sales_order_Invoice_Totals</sales_order_invoice_totals>
26
+ <sales_order_creditmemo_totals>BusinessKing_PaymentCharge_Block_Adminhtml_Sales_order_Creditmemo_Totals</sales_order_creditmemo_totals>
27
+ </rewrite>
28
+ </adminhtml>
29
+ </blocks>
30
+ <fieldsets>
31
+ <sales_convert_quote_address>
32
+ <payment_charge><to_order>*</to_order></payment_charge>
33
+ <base_payment_charge><to_order>*</to_order></base_payment_charge>
34
+ </sales_convert_quote_address>
35
+ </fieldsets>
36
+ <helpers>
37
+ <paymentcharge>
38
+ <class>BusinessKing_PaymentCharge_Helper</class>
39
+ </paymentcharge>
40
+ </helpers>
41
+ <models>
42
+ <paymentcharge>
43
+ <class>BusinessKing_PaymentCharge_Model</class>
44
+ </paymentcharge>
45
+ </models>
46
+ <resources>
47
+ <paymentcharge_setup>
48
+ <setup>
49
+ <module>BusinessKing_PaymentCharge</module>
50
+ <class>Mage_Sales_Model_Mysql4_Setup</class>
51
+ </setup>
52
+ <connection>
53
+ <use>core_setup</use>
54
+ </connection>
55
+ </paymentcharge_setup>
56
+ <paymentcharge_write>
57
+ <connection>
58
+ <use>core_write</use>
59
+ </connection>
60
+ </paymentcharge_write>
61
+ <paymentcharge_read>
62
+ <connection>
63
+ <use>core_read</use>
64
+ </connection>
65
+ </paymentcharge_read>
66
+ </resources>
67
+ <sales>
68
+ <quote>
69
+ <totals>
70
+ <payment_charge>
71
+ <class>paymentcharge/sales_quote_address_total_paymentcharge</class>
72
+ <after>shipping</after>
73
+ <before>tax,grand_total</before>
74
+ </payment_charge>
75
+ </totals>
76
+ </quote>
77
+ <order_invoice>
78
+ <totals>
79
+ <payment_charge>
80
+ <class>paymentcharge/sales_order_invoice_total_paymentcharge</class>
81
+ </payment_charge>
82
+ </totals>
83
+ </order_invoice>
84
+ <order_creditmemo>
85
+ <totals>
86
+ <payment_charge>
87
+ <class>paymentcharge/sales_order_creditmemo_total_paymentcharge</class>
88
+ </payment_charge>
89
+ </totals>
90
+ </order_creditmemo>
91
+ </sales>
92
+ <pdf>
93
+ <totals>
94
+ <payment_charge translate="title">
95
+ <title>Payment Charge</title>
96
+ <source_field>payment_charge</source_field>
97
+ <amount_prefix></amount_prefix>
98
+ <font_size>7</font_size>
99
+ <display_zero>0</display_zero>
100
+ <sort_order>200</sort_order>
101
+ </payment_charge>
102
+ </totals>
103
+ </pdf>
104
+ </global>
105
+ <default>
106
+ <sales>
107
+ <totals_sort>
108
+ <payment_charge>35</payment_charge>
109
+ </totals_sort>
110
+ </sales>
111
+ </default>
112
+ </config>
app/code/local/BusinessKing/PaymentCharge/etc/system.xml ADDED
@@ -0,0 +1,220 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <sections>
4
+ <payment>
5
+ <groups>
6
+
7
+ <ccsave translate="label">
8
+ <fields>
9
+ <charge_type translate="label">
10
+ <label>Payment Charge Type</label>
11
+ <frontend_type>select</frontend_type>
12
+ <source_model>paymentcharge/system_config_source_chargetype</source_model>
13
+ <sort_order>200</sort_order>
14
+ <show_in_default>1</show_in_default>
15
+ <show_in_website>1</show_in_website>
16
+ <show_in_store>0</show_in_store>
17
+ </charge_type>
18
+ <charge_value translate="label">
19
+ <label>Payment Charge</label>
20
+ <frontend_type>text</frontend_type>
21
+ <sort_order>201</sort_order>
22
+ <show_in_default>1</show_in_default>
23
+ <show_in_website>1</show_in_website>
24
+ <show_in_store>0</show_in_store>
25
+ </charge_value>
26
+ </fields>
27
+ </ccsave>
28
+ <checkmo translate="label">
29
+ <fields>
30
+ <charge_type translate="label">
31
+ <label>Payment Charge Type</label>
32
+ <frontend_type>select</frontend_type>
33
+ <source_model>paymentcharge/system_config_source_chargetype</source_model>
34
+ <sort_order>200</sort_order>
35
+ <show_in_default>1</show_in_default>
36
+ <show_in_website>1</show_in_website>
37
+ <show_in_store>0</show_in_store>
38
+ </charge_type>
39
+ <charge_value translate="label">
40
+ <label>Payment Charge</label>
41
+ <frontend_type>text</frontend_type>
42
+ <sort_order>201</sort_order>
43
+ <show_in_default>1</show_in_default>
44
+ <show_in_website>1</show_in_website>
45
+ <show_in_store>0</show_in_store>
46
+ </charge_value>
47
+ </fields>
48
+ </checkmo>
49
+ <free translate="label">
50
+ <fields>
51
+ <charge_type translate="label">
52
+ <label>Payment Charge Type</label>
53
+ <frontend_type>select</frontend_type>
54
+ <source_model>paymentcharge/system_config_source_chargetype</source_model>
55
+ <sort_order>200</sort_order>
56
+ <show_in_default>1</show_in_default>
57
+ <show_in_website>1</show_in_website>
58
+ <show_in_store>0</show_in_store>
59
+ </charge_type>
60
+ <charge_value translate="label">
61
+ <label>Payment Charge</label>
62
+ <frontend_type>text</frontend_type>
63
+ <sort_order>201</sort_order>
64
+ <show_in_default>1</show_in_default>
65
+ <show_in_website>1</show_in_website>
66
+ <show_in_store>0</show_in_store>
67
+ </charge_value>
68
+ </fields>
69
+ </free>
70
+ <purchaseorder translate="label">
71
+ <fields>
72
+ <charge_type translate="label">
73
+ <label>Payment Charge Type</label>
74
+ <frontend_type>select</frontend_type>
75
+ <source_model>paymentcharge/system_config_source_chargetype</source_model>
76
+ <sort_order>200</sort_order>
77
+ <show_in_default>1</show_in_default>
78
+ <show_in_website>1</show_in_website>
79
+ <show_in_store>0</show_in_store>
80
+ </charge_type>
81
+ <charge_value translate="label">
82
+ <label>Payment Charge</label>
83
+ <frontend_type>text</frontend_type>
84
+ <sort_order>201</sort_order>
85
+ <show_in_default>1</show_in_default>
86
+ <show_in_website>1</show_in_website>
87
+ <show_in_store>0</show_in_store>
88
+ </charge_value>
89
+ </fields>
90
+ </purchaseorder>
91
+ <otp translate="label">
92
+ <fields>
93
+ <charge_type translate="label">
94
+ <label>Payment Charge Type</label>
95
+ <frontend_type>select</frontend_type>
96
+ <source_model>paymentcharge/system_config_source_chargetype</source_model>
97
+ <sort_order>200</sort_order>
98
+ <show_in_default>1</show_in_default>
99
+ <show_in_website>1</show_in_website>
100
+ <show_in_store>0</show_in_store>
101
+ </charge_type>
102
+ <charge_value translate="label">
103
+ <label>Payment Charge</label>
104
+ <frontend_type>text</frontend_type>
105
+ <sort_order>201</sort_order>
106
+ <show_in_default>1</show_in_default>
107
+ <show_in_website>1</show_in_website>
108
+ <show_in_store>0</show_in_store>
109
+ </charge_value>
110
+ </fields>
111
+ </otp>
112
+ <raiffeisen_ru translate="label">
113
+ <fields>
114
+ <charge_type translate="label">
115
+ <label>Payment Charge Type</label>
116
+ <frontend_type>select</frontend_type>
117
+ <source_model>paymentcharge/system_config_source_chargetype</source_model>
118
+ <sort_order>200</sort_order>
119
+ <show_in_default>1</show_in_default>
120
+ <show_in_website>1</show_in_website>
121
+ <show_in_store>0</show_in_store>
122
+ </charge_type>
123
+ <charge_value translate="label">
124
+ <label>Payment Charge</label>
125
+ <frontend_type>text</frontend_type>
126
+ <sort_order>201</sort_order>
127
+ <show_in_default>1</show_in_default>
128
+ <show_in_website>1</show_in_website>
129
+ <show_in_store>0</show_in_store>
130
+ </charge_value>
131
+ </fields>
132
+ </raiffeisen_ru>
133
+ <cashondelivery translate="label">
134
+ <fields>
135
+ <charge_type translate="label">
136
+ <label>Payment Charge Type</label>
137
+ <frontend_type>select</frontend_type>
138
+ <source_model>paymentcharge/system_config_source_chargetype</source_model>
139
+ <sort_order>200</sort_order>
140
+ <show_in_default>1</show_in_default>
141
+ <show_in_website>1</show_in_website>
142
+ <show_in_store>0</show_in_store>
143
+ </charge_type>
144
+ <charge_value translate="label">
145
+ <label>Payment Charge</label>
146
+ <frontend_type>text</frontend_type>
147
+ <sort_order>201</sort_order>
148
+ <show_in_default>1</show_in_default>
149
+ <show_in_website>1</show_in_website>
150
+ <show_in_store>0</show_in_store>
151
+ </charge_value>
152
+ </fields>
153
+ </cashondelivery>
154
+ <authorizenet translate="label">
155
+ <fields>
156
+ <charge_type translate="label">
157
+ <label>Payment Charge Type</label>
158
+ <frontend_type>select</frontend_type>
159
+ <source_model>paymentcharge/system_config_source_chargetype</source_model>
160
+ <sort_order>200</sort_order>
161
+ <show_in_default>1</show_in_default>
162
+ <show_in_website>1</show_in_website>
163
+ <show_in_store>0</show_in_store>
164
+ </charge_type>
165
+ <charge_value translate="label">
166
+ <label>Payment Charge</label>
167
+ <frontend_type>text</frontend_type>
168
+ <sort_order>201</sort_order>
169
+ <show_in_default>1</show_in_default>
170
+ <show_in_website>1</show_in_website>
171
+ <show_in_store>0</show_in_store>
172
+ </charge_value>
173
+ </fields>
174
+ </authorizenet>
175
+ </groups>
176
+ </payment>
177
+ <paypal>
178
+ <groups>
179
+ <account>
180
+ <fields>
181
+ <charge_type translate="label">
182
+ <label>Payment Charge Type</label>
183
+ <frontend_type>select</frontend_type>
184
+ <source_model>paymentcharge/system_config_source_chargetype</source_model>
185
+ <sort_order>200</sort_order>
186
+ <show_in_default>1</show_in_default>
187
+ <show_in_website>1</show_in_website>
188
+ <show_in_store>0</show_in_store>
189
+ </charge_type>
190
+ <charge_value translate="label">
191
+ <label>Payment Charge</label>
192
+ <frontend_type>text</frontend_type>
193
+ <sort_order>201</sort_order>
194
+ <show_in_default>1</show_in_default>
195
+ <show_in_website>1</show_in_website>
196
+ <show_in_store>0</show_in_store>
197
+ </charge_value>
198
+ </fields>
199
+ </account>
200
+ </groups>
201
+ </paypal>
202
+ <sales>
203
+ <groups>
204
+ <totals_sort translate="label" module="sales">
205
+ <tab>sales</tab>
206
+ <fields>
207
+ <payment_charge translate="label">
208
+ <label>Payment Charge</label>
209
+ <frontend_type>text</frontend_type>
210
+ <sort_order>3</sort_order>
211
+ <show_in_default>1</show_in_default>
212
+ <show_in_website>1</show_in_website>
213
+ <show_in_store>0</show_in_store>
214
+ </payment_charge>
215
+ </fields>
216
+ </totals_sort>
217
+ </groups>
218
+ </sales>
219
+ </sections>
220
+ </config>
app/code/local/BusinessKing/PaymentCharge/sql/paymentcharge_setup/mysql4-install-0.1.0.php ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /* @var $installer Mage_Sales_Model_Mysql4_Setup */
3
+ $installer = $this;
4
+
5
+ $installer->startSetup();
6
+
7
+ $installer->addAttribute('quote_address', 'payment_charge', array('type' => 'decimal'));
8
+ $installer->addAttribute('quote_address', 'base_payment_charge', array('type' => 'decimal'));
9
+
10
+ $installer->addAttribute('order', 'payment_charge', array('type' => 'decimal'));
11
+ $installer->addAttribute('order', 'base_payment_charge', array('type' => 'decimal'));
12
+
13
+ $installer->addAttribute('invoice', 'payment_charge', array('type' => 'decimal'));
14
+ $installer->addAttribute('invoice', 'base_payment_charge', array('type' => 'decimal'));
15
+
16
+ $installer->addAttribute('creditmemo', 'payment_charge', array('type' => 'decimal'));
17
+ $installer->addAttribute('creditmemo', 'base_payment_charge', array('type' => 'decimal'));
18
+
19
+ $installer->endSetup();
app/etc/modules/BusinessKing_PaymentCharge.xml ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <BusinessKing_PaymentCharge>
5
+ <active>true</active>
6
+ <codePool>local</codePool>
7
+ </BusinessKing_PaymentCharge>
8
+ </modules>
9
+ </config>
package.xml ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <package>
3
+ <name>BusinessKing_PaymentCharge</name>
4
+ <version>1.0.0.1</version>
5
+ <stability>stable</stability>
6
+ <license uri="http://www.opensource.org/licenses/OSL-3.0.php">OSL</license>
7
+ <channel>community</channel>
8
+ <extends/>
9
+ <summary>Payment Method Charge</summary>
10
+ <description>It allows to charge additional payment fee.</description>
11
+ <notes>Stable version release</notes>
12
+ <authors><author><name>Business King</name><user>businessking</user><email>inquiry@businessapplicationking.com</email></author></authors>
13
+ <date>2012-02-27</date>
14
+ <time>09:27:59</time>
15
+ <contents><target name="magelocal"><dir name="BusinessKing"><dir name="PaymentCharge"><dir name="Block"><dir name="Adminhtml"><dir name="Sales"><dir name="Order"><dir name="Creditmemo"><file name="Totals.php" hash="3bec4bba4acc2115f9ca3f795ebcdaaa"/></dir><dir name="Invoice"><file name="Totals.php" hash="1f2c0f6c0ce6090bf15a8898c44d7e8a"/></dir><file name="Totals.php" hash="246d7462b82d39f014d0db090c95a420"/></dir><file name="Totals.php" hash="3933e12465a2b4d989d142dc11f5465c"/></dir></dir><dir name="Sales"><dir name="Order"><dir name="Creditmemo"><file name="Totals.php" hash="4f720ef530e2c6e635abfbf915470e9f"/></dir><dir name="Invoice"><file name="Totals.php" hash="94153ced3eeeddb0858e7c50c04c4d5b"/></dir><file name="Totals.php" hash="1bdeefdf3e8bb629eeaa4a34f42c0917"/></dir></dir></dir><dir name="Helper"><file name="Data.php" hash="63d9a9edcdcbcdb74ead9aa05a87c577"/></dir><dir name="Model"><dir name="Sales"><dir name="Order"><dir name="Creditmemo"><dir name="Total"><file name="Paymentcharge.php" hash="2434def0c68ab6e5d8f1a7881a20c7c5"/></dir></dir><dir name="Invoice"><dir name="Total"><file name="Paymentcharge.php" hash="39edf882f493c759d9ecf0a53f66a543"/></dir></dir></dir><dir name="Quote"><dir name="Address"><dir name="Total"><file name="Paymentcharge.php" hash="95496f12c5b1b96d7f114e4c8fe4c735"/></dir></dir></dir></dir><dir name="System"><dir name="Config"><dir name="Source"><file name="Chargetype.php" hash="300727ef0604ce74c101edc6972f2536"/></dir></dir></dir></dir><dir name="etc"><file name="config.xml" hash="05f4fa020b960e433f94c6fb23771b59"/><file name="system.xml" hash="b6d3e68f86dace4e35fb4e1c92e86334"/></dir><dir name="sql"><dir name="paymentcharge_setup"><file name="mysql4-install-0.1.0.php" hash="8135c131114d352519c92b44b10dfb45"/></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="BusinessKing_PaymentCharge.xml" hash="148624be3bab8ab234a99f2f9d774834"/></dir></target></contents>
16
+ <compatible/>
17
+ <dependencies><required><php><min>5.1.0</min><max>6.0.0</max></php><package><name>Mage_Core_Modules</name><channel>community</channel><min>1.6.0.0</min><max>1.7</max></package></required></dependencies>
18
+ </package>