Version Notes
Add additional payment fees to payment methods
Download this release
Release Info
Developer | Fly Webservices |
Extension | flywebdesign_paypalfee |
Version | 0.1.0 |
Comparing to | |
See all releases |
Version 0.1.0
- app/code/local/FlyWebdesign/PaypalFee/Block/Adminhtml/Sales/Order/Creditmemo/Totals.php +54 -0
- app/code/local/FlyWebdesign/PaypalFee/Block/Adminhtml/Sales/Order/Invoice/Totals.php +42 -0
- app/code/local/FlyWebdesign/PaypalFee/Block/Adminhtml/Sales/Order/Totals.php +45 -0
- app/code/local/FlyWebdesign/PaypalFee/Block/Adminhtml/Sales/Totals.php +45 -0
- app/code/local/FlyWebdesign/PaypalFee/Block/Sales/Order/Creditmemo/Totals.php +90 -0
- app/code/local/FlyWebdesign/PaypalFee/Block/Sales/Order/Invoice/Totals.php +54 -0
- app/code/local/FlyWebdesign/PaypalFee/Block/Sales/Order/Totals.php +45 -0
- app/code/local/FlyWebdesign/PaypalFee/Helper/Data.php +41 -0
- app/code/local/FlyWebdesign/PaypalFee/Model/Paypal/Cart.php +108 -0
- app/code/local/FlyWebdesign/PaypalFee/Model/Sales/Order/Creditmemo/Total/Paymentcharge.php +21 -0
- app/code/local/FlyWebdesign/PaypalFee/Model/Sales/Order/Invoice/Total/Paymentcharge.php +43 -0
- app/code/local/FlyWebdesign/PaypalFee/Model/Sales/Quote/Address/Total/Paymentcharge.php +49 -0
- app/code/local/FlyWebdesign/PaypalFee/Model/System/Config/Source/Chargetype.php +16 -0
- app/code/local/FlyWebdesign/PaypalFee/etc/config.xml +117 -0
- app/code/local/FlyWebdesign/PaypalFee/etc/system.xml +220 -0
- app/code/local/FlyWebdesign/PaypalFee/sql/paymentcharge_setup/mysql4-install-0.1.0.php +19 -0
- app/etc/modules/FlyWebdesign_PaypalFee.xml +9 -0
- package.xml +22 -0
app/code/local/FlyWebdesign/PaypalFee/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 FlyWebdesign
|
7 |
+
* @package FlyWebdesign_PaypalFee
|
8 |
+
*/
|
9 |
+
class FlyWebdesign_PaypalFee_Block_Adminhtml_Sales_order_Creditmemo_Totals extends FlyWebdesign_PaypalFee_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/FlyWebdesign/PaypalFee/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 FlyWebdesign
|
7 |
+
* @package FlyWebdesign_PaypalFee
|
8 |
+
*/
|
9 |
+
class FlyWebdesign_PaypalFee_Block_Adminhtml_Sales_order_Invoice_Totals extends FlyWebdesign_PaypalFee_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/FlyWebdesign/PaypalFee/Block/Adminhtml/Sales/Order/Totals.php
ADDED
@@ -0,0 +1,45 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Adminhtml order totals block
|
5 |
+
*
|
6 |
+
* @category FlyWebdesign
|
7 |
+
* @package FlyWebdesign_PaypalFee
|
8 |
+
*/
|
9 |
+
class FlyWebdesign_PaypalFee_Block_Adminhtml_Sales_order_Totals extends FlyWebdesign_PaypalFee_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/FlyWebdesign/PaypalFee/Block/Adminhtml/Sales/Totals.php
ADDED
@@ -0,0 +1,45 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* @category FlyWebdesign
|
5 |
+
* @package FlyWebdesign_PaypalFee
|
6 |
+
*/
|
7 |
+
class FlyWebdesign_PaypalFee_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/FlyWebdesign/PaypalFee/Block/Sales/Order/Creditmemo/Totals.php
ADDED
@@ -0,0 +1,90 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* @category FlyWebdesign
|
5 |
+
* @package FlyWebdesign_PaypalFee
|
6 |
+
*/
|
7 |
+
class FlyWebdesign_PaypalFee_Block_Sales_order_Creditmemo_Totals extends FlyWebdesign_PaypalFee_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/FlyWebdesign/PaypalFee/Block/Sales/Order/Invoice/Totals.php
ADDED
@@ -0,0 +1,54 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* @category FlyWebdesign
|
5 |
+
* @package FlyWebdesign_PaypalFee
|
6 |
+
*/
|
7 |
+
class FlyWebdesign_PaypalFee_Block_Sales_order_Invoice_Totals extends FlyWebdesign_PaypalFee_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/FlyWebdesign/PaypalFee/Block/Sales/Order/Totals.php
ADDED
@@ -0,0 +1,45 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* @category FlyWebdesign
|
5 |
+
* @package FlyWebdesign_PaypalFee
|
6 |
+
*/
|
7 |
+
class FlyWebdesign_PaypalFee_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/FlyWebdesign/PaypalFee/Helper/Data.php
ADDED
@@ -0,0 +1,41 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class FlyWebdesign_PaypalFee_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 |
+
$tax = $address->getBaseTaxAmount();
|
32 |
+
$amount = ($subTotal + $tax) * floatval($chargeValue) / 100;
|
33 |
+
}
|
34 |
+
else {
|
35 |
+
$amount = floatval($chargeValue);
|
36 |
+
}
|
37 |
+
}
|
38 |
+
//return Mage::helper('core')->formatPrice($amount);
|
39 |
+
return $amount;
|
40 |
+
}
|
41 |
+
}
|
app/code/local/FlyWebdesign/PaypalFee/Model/Paypal/Cart.php
ADDED
@@ -0,0 +1,108 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class FlyWebdesign_PaypalFee_Model_Paypal_Cart extends Mage_Paypal_Model_Cart
|
4 |
+
{
|
5 |
+
protected function _render()
|
6 |
+
{
|
7 |
+
if (!$this->_shouldRender) {
|
8 |
+
return;
|
9 |
+
}
|
10 |
+
|
11 |
+
// regular items from the sales entity
|
12 |
+
$this->_items = array();
|
13 |
+
foreach ($this->_salesEntity->getAllItems() as $item) {
|
14 |
+
if (!$item->getParentItem()) {
|
15 |
+
$this->_addRegularItem($item);
|
16 |
+
}
|
17 |
+
}
|
18 |
+
end($this->_items);
|
19 |
+
$lastRegularItemKey = key($this->_items);
|
20 |
+
|
21 |
+
|
22 |
+
// Extra fee - added 21-4-12
|
23 |
+
$chargeType = Mage::getStoreConfig('paypal/account/charge_type');
|
24 |
+
$chargeValue = Mage::getStoreConfig('paypal/account/charge_value');
|
25 |
+
|
26 |
+
// regular totals
|
27 |
+
$shippingDescription = '';
|
28 |
+
if ($this->_salesEntity instanceof Mage_Sales_Model_Order) {
|
29 |
+
$shippingDescription = $this->_salesEntity->getShippingDescription();
|
30 |
+
$this->_totals = array(
|
31 |
+
self::TOTAL_SUBTOTAL => $this->_salesEntity->getBaseSubtotal(),
|
32 |
+
self::TOTAL_TAX => $this->_salesEntity->getBaseTaxAmount(),
|
33 |
+
self::TOTAL_SHIPPING => $this->_salesEntity->getBaseShippingAmount(),
|
34 |
+
self::TOTAL_DISCOUNT => abs($this->_salesEntity->getBaseDiscountAmount()),
|
35 |
+
);
|
36 |
+
if ($chargeType=="percentage") {
|
37 |
+
$this->_totals[self::TOTAL_SUBTOTAL] += ($this->_totals[self::TOTAL_SUBTOTAL]+$this->_totals[self::TOTAL_TAX]) * floatval($chargeValue) / 100;
|
38 |
+
}
|
39 |
+
else {
|
40 |
+
$this->_totals[self::TOTAL_SUBTOTAL] += floatval($chargeValue);
|
41 |
+
}
|
42 |
+
$this->_applyHiddenTaxWorkaround($this->_salesEntity);
|
43 |
+
} else {
|
44 |
+
$address = $this->_salesEntity->getIsVirtual() ?
|
45 |
+
$this->_salesEntity->getBillingAddress() : $this->_salesEntity->getShippingAddress();
|
46 |
+
$shippingDescription = $address->getShippingDescription();
|
47 |
+
$this->_totals = array (
|
48 |
+
self::TOTAL_SUBTOTAL => $this->_salesEntity->getBaseSubtotal(),
|
49 |
+
self::TOTAL_TAX => $address->getBaseTaxAmount(),
|
50 |
+
self::TOTAL_SHIPPING => $address->getBaseShippingAmount(),
|
51 |
+
self::TOTAL_DISCOUNT => abs($address->getBaseDiscountAmount()),
|
52 |
+
);
|
53 |
+
if ($chargeType=="percentage") {
|
54 |
+
$this->_totals[self::TOTAL_SUBTOTAL] += ($this->_totals[self::TOTAL_SUBTOTAL]+$this->_totals[self::TOTAL_TAX]) * floatval($chargeValue) / 100;
|
55 |
+
}
|
56 |
+
else {
|
57 |
+
$this->_totals[self::TOTAL_SUBTOTAL] += floatval($chargeValue);
|
58 |
+
}
|
59 |
+
$this->_applyHiddenTaxWorkaround($address);
|
60 |
+
}
|
61 |
+
$originalDiscount = $this->_totals[self::TOTAL_DISCOUNT];
|
62 |
+
|
63 |
+
// arbitrary items, total modifications
|
64 |
+
Mage::dispatchEvent('paypal_prepare_line_items', array('paypal_cart' => $this));
|
65 |
+
|
66 |
+
// distinguish original discount among the others
|
67 |
+
if ($originalDiscount > 0.0001 && isset($this->_totalLineItemDescriptions[self::TOTAL_DISCOUNT])) {
|
68 |
+
$this->_totalLineItemDescriptions[self::TOTAL_DISCOUNT][] = Mage::helper('sales')->__('Discount (%s)', Mage::app()->getStore()->convertPrice($originalDiscount, true, false));
|
69 |
+
}
|
70 |
+
|
71 |
+
// discount, shipping as items
|
72 |
+
if ($this->_isDiscountAsItem && $this->_totals[self::TOTAL_DISCOUNT]) {
|
73 |
+
$this->addItem(Mage::helper('paypal')->__('Discount'), 1, -1.00 * $this->_totals[self::TOTAL_DISCOUNT],
|
74 |
+
$this->_renderTotalLineItemDescriptions(self::TOTAL_DISCOUNT)
|
75 |
+
);
|
76 |
+
}
|
77 |
+
$shippingItemId = $this->_renderTotalLineItemDescriptions(self::TOTAL_SHIPPING, $shippingDescription);
|
78 |
+
if ($this->_isShippingAsItem && (float)$this->_totals[self::TOTAL_SHIPPING]) {
|
79 |
+
$this->addItem(Mage::helper('paypal')->__('Shipping'), 1, (float)$this->_totals[self::TOTAL_SHIPPING],
|
80 |
+
$shippingItemId
|
81 |
+
);
|
82 |
+
}
|
83 |
+
|
84 |
+
// compound non-regular items into subtotal
|
85 |
+
foreach ($this->_items as $key => $item) {
|
86 |
+
if ($key > $lastRegularItemKey && $item->getAmount() != 0) {
|
87 |
+
$this->_totals[self::TOTAL_SUBTOTAL] += $item->getAmount();
|
88 |
+
}
|
89 |
+
}
|
90 |
+
|
91 |
+
$this->_validate();
|
92 |
+
// if cart items are invalid, prepare cart for transfer without line items
|
93 |
+
if (!$this->_areItemsValid) {
|
94 |
+
$this->removeItem($shippingItemId);
|
95 |
+
}
|
96 |
+
|
97 |
+
$this->_shouldRender = false;
|
98 |
+
|
99 |
+
return parent::_render();
|
100 |
+
}
|
101 |
+
|
102 |
+
private function _applyHiddenTaxWorkaround($salesEntity)
|
103 |
+
{
|
104 |
+
$this->_totals[self::TOTAL_TAX] += (float)$salesEntity->getBaseHiddenTaxAmount();
|
105 |
+
$this->_totals[self::TOTAL_TAX] += (float)$salesEntity->getBaseShippingHiddenTaxAmount();
|
106 |
+
}
|
107 |
+
|
108 |
+
}
|
app/code/local/FlyWebdesign/PaypalFee/Model/Sales/Order/Creditmemo/Total/Paymentcharge.php
ADDED
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class FlyWebdesign_PaypalFee_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/FlyWebdesign/PaypalFee/Model/Sales/Order/Invoice/Total/Paymentcharge.php
ADDED
@@ -0,0 +1,43 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class FlyWebdesign_PaypalFee_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/FlyWebdesign/PaypalFee/Model/Sales/Quote/Address/Total/Paymentcharge.php
ADDED
@@ -0,0 +1,49 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* @category FlyWebdesign
|
5 |
+
* @package FlyWebdesign_PaypalFee
|
6 |
+
*/
|
7 |
+
class FlyWebdesign_PaypalFee_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/FlyWebdesign/PaypalFee/Model/System/Config/Source/Chargetype.php
ADDED
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* @category FlyWebdesign
|
5 |
+
* @package FlyWebdesign_PaypalFee
|
6 |
+
*/
|
7 |
+
class FlyWebdesign_PaypalFee_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/FlyWebdesign/PaypalFee/etc/config.xml
ADDED
@@ -0,0 +1,117 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0" encoding="UTF-8"?>
|
2 |
+
<config>
|
3 |
+
<modules>
|
4 |
+
<FlyWebdesign_PaypalFee>
|
5 |
+
<version>0.1.0</version>
|
6 |
+
</FlyWebdesign_PaypalFee>
|
7 |
+
</modules>
|
8 |
+
|
9 |
+
<global>
|
10 |
+
<blocks>
|
11 |
+
<paymentcharge>
|
12 |
+
<class>FlyWebdesign_PaypalFee_Block</class>
|
13 |
+
</paymentcharge>
|
14 |
+
<sales>
|
15 |
+
<rewrite>
|
16 |
+
<order_totals>FlyWebdesign_PaypalFee_Block_Sales_Order_Totals</order_totals>
|
17 |
+
<order_invoice_totals>FlyWebdesign_PaypalFee_Block_Sales_order_Invoice_Totals</order_invoice_totals>
|
18 |
+
<order_creditmemo_totals>FlyWebdesign_PaypalFee_Block_Sales_order_Creditmemo_Totals</order_creditmemo_totals>
|
19 |
+
</rewrite>
|
20 |
+
</sales>
|
21 |
+
<adminhtml>
|
22 |
+
<rewrite>
|
23 |
+
<sales_totals>FlyWebdesign_PaypalFee_Block_Adminhtml_Sales_Totals</sales_totals>
|
24 |
+
<sales_order_totals>FlyWebdesign_PaypalFee_Block_Adminhtml_Sales_order_Totals</sales_order_totals>
|
25 |
+
<sales_order_invoice_totals>FlyWebdesign_PaypalFee_Block_Adminhtml_Sales_order_Invoice_Totals</sales_order_invoice_totals>
|
26 |
+
<sales_order_creditmemo_totals>FlyWebdesign_PaypalFee_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>FlyWebdesign_PaypalFee_Helper</class>
|
39 |
+
</paymentcharge>
|
40 |
+
</helpers>
|
41 |
+
<models>
|
42 |
+
<paymentcharge>
|
43 |
+
<class>FlyWebdesign_PaypalFee_Model</class>
|
44 |
+
</paymentcharge>
|
45 |
+
<paypal>
|
46 |
+
<rewrite>
|
47 |
+
<cart>FlyWebdesign_PaypalFee_Model_Paypal_Cart</cart>
|
48 |
+
</rewrite>
|
49 |
+
</paypal>
|
50 |
+
</models>
|
51 |
+
<resources>
|
52 |
+
<paymentcharge_setup>
|
53 |
+
<setup>
|
54 |
+
<module>FlyWebdesign_PaypalFee</module>
|
55 |
+
<class>Mage_Sales_Model_Mysql4_Setup</class>
|
56 |
+
</setup>
|
57 |
+
<connection>
|
58 |
+
<use>core_setup</use>
|
59 |
+
</connection>
|
60 |
+
</paymentcharge_setup>
|
61 |
+
<paymentcharge_write>
|
62 |
+
<connection>
|
63 |
+
<use>core_write</use>
|
64 |
+
</connection>
|
65 |
+
</paymentcharge_write>
|
66 |
+
<paymentcharge_read>
|
67 |
+
<connection>
|
68 |
+
<use>core_read</use>
|
69 |
+
</connection>
|
70 |
+
</paymentcharge_read>
|
71 |
+
</resources>
|
72 |
+
<sales>
|
73 |
+
<quote>
|
74 |
+
<totals>
|
75 |
+
<payment_charge>
|
76 |
+
<class>paymentcharge/sales_quote_address_total_paymentcharge</class>
|
77 |
+
<after>shipping</after>
|
78 |
+
<before>tax,grand_total</before>
|
79 |
+
</payment_charge>
|
80 |
+
</totals>
|
81 |
+
</quote>
|
82 |
+
<order_invoice>
|
83 |
+
<totals>
|
84 |
+
<payment_charge>
|
85 |
+
<class>paymentcharge/sales_order_invoice_total_paymentcharge</class>
|
86 |
+
</payment_charge>
|
87 |
+
</totals>
|
88 |
+
</order_invoice>
|
89 |
+
<order_creditmemo>
|
90 |
+
<totals>
|
91 |
+
<payment_charge>
|
92 |
+
<class>paymentcharge/sales_order_creditmemo_total_paymentcharge</class>
|
93 |
+
</payment_charge>
|
94 |
+
</totals>
|
95 |
+
</order_creditmemo>
|
96 |
+
</sales>
|
97 |
+
<pdf>
|
98 |
+
<totals>
|
99 |
+
<payment_charge translate="title">
|
100 |
+
<title>Payment Charge</title>
|
101 |
+
<source_field>payment_charge</source_field>
|
102 |
+
<amount_prefix></amount_prefix>
|
103 |
+
<font_size>7</font_size>
|
104 |
+
<display_zero>0</display_zero>
|
105 |
+
<sort_order>200</sort_order>
|
106 |
+
</payment_charge>
|
107 |
+
</totals>
|
108 |
+
</pdf>
|
109 |
+
</global>
|
110 |
+
<default>
|
111 |
+
<sales>
|
112 |
+
<totals_sort>
|
113 |
+
<payment_charge>35</payment_charge>
|
114 |
+
</totals_sort>
|
115 |
+
</sales>
|
116 |
+
</default>
|
117 |
+
</config>
|
app/code/local/FlyWebdesign/PaypalFee/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/FlyWebdesign/PaypalFee/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/FlyWebdesign_PaypalFee.xml
ADDED
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<modules>
|
4 |
+
<FlyWebdesign_PaypalFee>
|
5 |
+
<active>true</active>
|
6 |
+
<codePool>local</codePool>
|
7 |
+
</FlyWebdesign_PaypalFee>
|
8 |
+
</modules>
|
9 |
+
</config>
|
package.xml
ADDED
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<package>
|
3 |
+
<name>flywebdesign_paypalfee</name>
|
4 |
+
<version>0.1.0</version>
|
5 |
+
<stability>stable</stability>
|
6 |
+
<license uri="http://opensource.org/licenses/osl-3.0.php">Open Software License (OSL)</license>
|
7 |
+
<channel>community</channel>
|
8 |
+
<extends/>
|
9 |
+
<summary>Add a customer fee to payment methods, like PayPal.</summary>
|
10 |
+
<description>When we couldn't find an affordable and open source extension for adding a fee to PayPal payments, we developed one ourselves.
|
11 |
+

|
12 |
+
It provides the functionality to set different payment fee/charge for all payment methods. If you want to charge additional fee depending on the selected payment method (and don't want to add additional charge in your product cost or don't want to increase any other cost) at your Magento store then this extension would be very helpful.
|
13 |
+

|
14 |
+
In the backend you can fill in a fixed price or percentage of the subtotal to add to the amount the customer has to pay.</description>
|
15 |
+
<notes>Add additional payment fees to payment methods</notes>
|
16 |
+
<authors><author><name>Fly Webdesign</name><user>flyweb</user><email>info@flywebdesign.nl</email></author></authors>
|
17 |
+
<date>2012-05-30</date>
|
18 |
+
<time>09:06:22</time>
|
19 |
+
<contents><target name="mageetc"><dir name="modules"><file name="FlyWebdesign_PaypalFee.xml" hash="c07031f7f9da066befc127abc8c766f8"/></dir></target><target name="magelocal"><dir name="FlyWebdesign"><dir name="PaypalFee"><dir name="Block"><dir name="Adminhtml"><dir name="Sales"><dir name="Order"><dir name="Creditmemo"><file name="Totals.php" hash="99ccd5759d9070540bfba617f637b2d8"/></dir><dir name="Invoice"><file name="Totals.php" hash="2b0e3ee138df4503062e3a6645cd8bc1"/></dir><file name="Totals.php" hash="3bbb080ce185a4102345bca3e73c1583"/></dir><file name="Totals.php" hash="2a91e0feadf1e7f25ba2f8d01cbb8b4d"/></dir></dir><dir name="Sales"><dir name="Order"><dir name="Creditmemo"><file name="Totals.php" hash="e37228644674a2f0950b34bd61dcc675"/></dir><dir name="Invoice"><file name="Totals.php" hash="4d81572c4b68ba0b7ee1c4f38e59022e"/></dir><file name="Totals.php" hash="f2a13692a95ca921af9cd1f090731835"/></dir></dir></dir><dir name="etc"><file name="config.xml" hash="b33e0d07880993c95c3457115943fe5c"/><file name="system.xml" hash="b6d3e68f86dace4e35fb4e1c92e86334"/></dir><dir name="Helper"><file name="Data.php" hash="402eeba9fb50cd4f3464e361eb258407"/></dir><dir name="Model"><dir name="Paypal"><file name="Cart.php" hash="853d4f2b6dad6c2fe4bf3fe1770ca0f9"/></dir><dir name="Sales"><dir name="Order"><dir name="Creditmemo"><dir name="Total"><file name="Paymentcharge.php" hash="5e8be36c3c91891dd5b9d3a4ebeef1c8"/></dir></dir><dir name="Invoice"><dir name="Total"><file name="Paymentcharge.php" hash="dce4cb36f08cb7e1146d25d9dcb5f7f5"/></dir></dir></dir><dir name="Quote"><dir name="Address"><dir name="Total"><file name="Paymentcharge.php" hash="517eee927f1ac8ca4f082f14e52e46f4"/></dir></dir></dir></dir><dir name="System"><dir name="Config"><dir name="Source"><file name="Chargetype.php" hash="4c281a3c37d64567946829cbadf1d905"/></dir></dir></dir></dir><dir name="sql"><dir name="paymentcharge_setup"><file name="mysql4-install-0.1.0.php" hash="8135c131114d352519c92b44b10dfb45"/></dir></dir></dir></dir></target></contents>
|
20 |
+
<compatible/>
|
21 |
+
<dependencies><required><php><min>5.1.0</min><max>6.0.0</max></php></required></dependencies>
|
22 |
+
</package>
|