Version Notes
Add option for merchant to include Yellow transaction fees in amount invoiced to customer.
Download this release
Release Info
Developer | Tawfek Daghistani |
Extension | Yellow_Pay |
Version | 1.0.3 |
Comparing to | |
See all releases |
Code changes from version 1.0.2 to 1.0.3
- app/code/local/Yellow/Bitcoin/Block/Adminhtml/Sales/Order/Total/Fee.php +10 -0
- app/code/local/Yellow/Bitcoin/Block/Sales/Order/Fee.php +94 -0
- app/code/local/Yellow/Bitcoin/Model/Bitcoin.php +63 -2
- app/code/local/Yellow/Bitcoin/Model/Observer.php +67 -0
- app/code/local/Yellow/Bitcoin/Model/Sales/Order/Total/Creditmemo/Fee.php +42 -0
- app/code/local/Yellow/Bitcoin/Model/Sales/Order/Total/Invoice/Fee.php +49 -0
- app/code/local/Yellow/Bitcoin/Model/Sales/Quote/Address/Total/Fee.php +83 -0
- app/code/local/Yellow/Bitcoin/etc/config.xml +83 -1
- app/code/local/Yellow/Bitcoin/etc/system.xml +11 -1
- app/code/local/Yellow/Bitcoin/sql/bitcoin_setup/mysql4-upgrade-0.1.3-1.0.2.php +1 -0
- app/code/local/Yellow/Bitcoin/sql/bitcoin_setup/mysql4-upgrade-1.0.2-1.0.3.php +46 -0
- app/design/adminhtml/default/default/layout/bitcoin.xml +53 -0
- app/design/adminhtml/default/default/template/bitcoin/sales/order/refunded.phtml +16 -0
- app/design/adminhtml/default/default/template/bitcoin/sales/order/total.phtml +9 -0
- app/design/frontend/base/default/layout/bitcoin.xml +47 -0
- app/design/frontend/base/default/template/bitcoin/checkout/total/fee.phtml +15 -0
- app/etc/modules/Yellow_Bitcoin.xml +1 -1
- package.xml +5 -6
app/code/local/Yellow/Bitcoin/Block/Adminhtml/Sales/Order/Total/Fee.php
ADDED
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Yellow_Bitcoin_Block_Adminhtml_Sales_Order_Total_Fee extends Mage_Adminhtml_Block_Sales_Order_Create_Totals_Default
|
4 |
+
{
|
5 |
+
/**
|
6 |
+
* Use your own template if necessary
|
7 |
+
* See "sales/order/create/totals/default.phtml" for model
|
8 |
+
*/
|
9 |
+
//protected $_template = 'bitcoin/sales/order/total/fee.phtml';
|
10 |
+
}
|
app/code/local/Yellow/Bitcoin/Block/Sales/Order/Fee.php
ADDED
@@ -0,0 +1,94 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
*
|
4 |
+
* The MIT License (MIT)
|
5 |
+
*
|
6 |
+
* Copyright (c) 2014 YellowPay.co
|
7 |
+
*
|
8 |
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
9 |
+
* of this software and associated documentation files (the "Software"), to deal
|
10 |
+
* in the Software without restriction, including without limitation the rights
|
11 |
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
12 |
+
* copies of the Software, and to permit persons to whom the Software is
|
13 |
+
* furnished to do so, subject to the following conditions:
|
14 |
+
*
|
15 |
+
* The above copyright notice and this permission notice shall be included in all
|
16 |
+
* copies or substantial portions of the Software.
|
17 |
+
*
|
18 |
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
19 |
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
20 |
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
21 |
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
22 |
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
23 |
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
24 |
+
* SOFTWARE.
|
25 |
+
*
|
26 |
+
* */
|
27 |
+
class Yellow_Bitcoin_Block_Sales_Order_Fee extends Mage_Core_Block_Template
|
28 |
+
{
|
29 |
+
|
30 |
+
protected $_template = 'bitcoin/checkout/total/fee.phtml';
|
31 |
+
|
32 |
+
/**
|
33 |
+
* Get label cell tag properties
|
34 |
+
*
|
35 |
+
* @return string
|
36 |
+
*/
|
37 |
+
public function getLabelProperties()
|
38 |
+
{
|
39 |
+
return $this->getParentBlock()->getLabelProperties();
|
40 |
+
}
|
41 |
+
|
42 |
+
/**
|
43 |
+
* Get order store object
|
44 |
+
*
|
45 |
+
* @return Mage_Sales_Model_Order
|
46 |
+
*/
|
47 |
+
public function getOrder()
|
48 |
+
{
|
49 |
+
return $this->getParentBlock()->getOrder();
|
50 |
+
}
|
51 |
+
|
52 |
+
/**
|
53 |
+
* Get totals source object
|
54 |
+
*
|
55 |
+
* @return Mage_Sales_Model_Order
|
56 |
+
*/
|
57 |
+
public function getSource()
|
58 |
+
{
|
59 |
+
return $this->getParentBlock()->getSource();
|
60 |
+
}
|
61 |
+
|
62 |
+
/**
|
63 |
+
* Get value cell tag properties
|
64 |
+
*
|
65 |
+
* @return string
|
66 |
+
*/
|
67 |
+
public function getValueProperties()
|
68 |
+
{
|
69 |
+
return $this->getParentBlock()->getValueProperties();
|
70 |
+
}
|
71 |
+
|
72 |
+
/**
|
73 |
+
*
|
74 |
+
* @return Yellow_Bitcoin_Block_Sales_Order_Total
|
75 |
+
*/
|
76 |
+
public function initTotals()
|
77 |
+
{
|
78 |
+
if ((float) $this->getOrder()->getYellowFee()) {
|
79 |
+
$source = $this->getSource();
|
80 |
+
$value = $source->getYellowFee();
|
81 |
+
$label = "Transaction Fee" ;
|
82 |
+
|
83 |
+
$this->getParentBlock()->addTotal(new Varien_Object(array(
|
84 |
+
'code' => 'yellow_fee',
|
85 |
+
'strong' => false,
|
86 |
+
'label' => Mage::helper('bitcoin')->__($label),
|
87 |
+
'value' => $source instanceof Mage_Sales_Model_Order_Creditmemo ? - $value : $value
|
88 |
+
)));
|
89 |
+
}
|
90 |
+
|
91 |
+
return $this;
|
92 |
+
}
|
93 |
+
|
94 |
+
}
|
app/code/local/Yellow/Bitcoin/Model/Bitcoin.php
CHANGED
@@ -88,6 +88,14 @@ Class Yellow_Bitcoin_Model_Bitcoin extends Mage_Payment_Model_Method_Abstract
|
|
88 |
*/
|
89 |
private $api_uri_check_payment = "invoice/[id]/";
|
90 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
91 |
/**
|
92 |
* @type Mage_Sales_Model_Order
|
93 |
**/
|
@@ -360,8 +368,8 @@ Class Yellow_Bitcoin_Model_Bitcoin extends Mage_Payment_Model_Method_Abstract
|
|
360 |
$http_client = $this->getHTTPClient();
|
361 |
$yellow_payment_data = array(
|
362 |
"base_price" => $base_price, /// Set to 0.30 for testing
|
363 |
-
"base_ccy"
|
364 |
-
"callback"
|
365 |
);
|
366 |
$post_body = json_encode($yellow_payment_data);
|
367 |
$nonce = round(microtime(true) * 1000);
|
@@ -704,4 +712,57 @@ Class Yellow_Bitcoin_Model_Bitcoin extends Mage_Payment_Model_Method_Abstract
|
|
704 |
return $this->server_root;
|
705 |
}
|
706 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
707 |
}
|
88 |
*/
|
89 |
private $api_uri_check_payment = "invoice/[id]/";
|
90 |
|
91 |
+
/**
|
92 |
+
* check profile data
|
93 |
+
*
|
94 |
+
* @var String
|
95 |
+
*/
|
96 |
+
private $api_profile = "profile/";
|
97 |
+
|
98 |
+
|
99 |
/**
|
100 |
* @type Mage_Sales_Model_Order
|
101 |
**/
|
368 |
$http_client = $this->getHTTPClient();
|
369 |
$yellow_payment_data = array(
|
370 |
"base_price" => $base_price, /// Set to 0.30 for testing
|
371 |
+
"base_ccy" => $base_ccy, /// Set to "USD" for testing
|
372 |
+
"callback" => $ipnUrl
|
373 |
);
|
374 |
$post_body = json_encode($yellow_payment_data);
|
375 |
$nonce = round(microtime(true) * 1000);
|
712 |
return $this->server_root;
|
713 |
}
|
714 |
|
715 |
+
/**
|
716 |
+
* @param Mage_Sales_Model_Quote_Address $address
|
717 |
+
* @return bool
|
718 |
+
*/
|
719 |
+
public function canApplyFee(Mage_Sales_Model_Quote_Address $address)
|
720 |
+
{
|
721 |
+
$isEnabled = (bool) $this->getConfiguration("transaction_fee");
|
722 |
+
if(!$isEnabled)
|
723 |
+
{
|
724 |
+
return false;
|
725 |
+
}
|
726 |
+
//// check if the user select yellow as his selected payment method
|
727 |
+
if($address->getQuote()->getPayment()->getMethod() !== self::getCode())
|
728 |
+
{
|
729 |
+
return false;
|
730 |
+
}
|
731 |
+
|
732 |
+
return true;
|
733 |
+
}
|
734 |
+
|
735 |
+
/**
|
736 |
+
*
|
737 |
+
* @return float
|
738 |
+
* @throws Mage_Core_Exception
|
739 |
+
* @throws Zend_Http_Client_Exception
|
740 |
+
*/
|
741 |
+
public function getYellowFee()
|
742 |
+
{
|
743 |
+
$url = $this->server_root . $this->api_profile;
|
744 |
+
$nonce = round(microtime(true) * 1000);
|
745 |
+
$message = $nonce . $url;
|
746 |
+
$private_key = Mage::helper('core')->decrypt($this->getConfiguration("private_key"));
|
747 |
+
$hash = hash_hmac("sha256", $message, $private_key, false);
|
748 |
+
$http_client = $this->getHTTPClient();
|
749 |
+
$http_client->setHeaders($this->getHeaders($nonce, $hash));
|
750 |
+
$http_client->setMethod("GET")->setUri($url);
|
751 |
+
try {
|
752 |
+
$body = $http_client->request()->getBody();
|
753 |
+
$data = json_decode($body, true);
|
754 |
+
if(!isset($data["fee"])){
|
755 |
+
throw new \Exception("expected fee amount and got : " . json_encode($data) , "500");
|
756 |
+
}
|
757 |
+
return (float) $data["fee"];
|
758 |
+
} catch (\Exception $e) {
|
759 |
+
$this->log($e->getMessage());
|
760 |
+
$this->log("EXCEPTION:" . json_encode($e));
|
761 |
+
Mage::throwException(
|
762 |
+
Mage::helper('bitcoin')->__(
|
763 |
+
"We're sorry, an error has occurred while completing your `/profile` request. Please refresh the page to try again. If the error persists, please send us an email at support@yellowpay.co"
|
764 |
+
)
|
765 |
+
);
|
766 |
+
}
|
767 |
+
}
|
768 |
}
|
app/code/local/Yellow/Bitcoin/Model/Observer.php
ADDED
@@ -0,0 +1,67 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
*
|
4 |
+
* The MIT License (MIT)
|
5 |
+
*
|
6 |
+
* Copyright (c) 2014 YellowPay.co
|
7 |
+
*
|
8 |
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
9 |
+
* of this software and associated documentation files (the "Software"), to deal
|
10 |
+
* in the Software without restriction, including without limitation the rights
|
11 |
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
12 |
+
* copies of the Software, and to permit persons to whom the Software is
|
13 |
+
* furnished to do so, subject to the following conditions:
|
14 |
+
*
|
15 |
+
* The above copyright notice and this permission notice shall be included in all
|
16 |
+
* copies or substantial portions of the Software.
|
17 |
+
*
|
18 |
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
19 |
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
20 |
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
21 |
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
22 |
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
23 |
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
24 |
+
* SOFTWARE.
|
25 |
+
*
|
26 |
+
* */
|
27 |
+
class Yellow_Bitcoin_Model_Observer
|
28 |
+
{
|
29 |
+
|
30 |
+
/**
|
31 |
+
* Set fee amount invoiced to the order
|
32 |
+
*
|
33 |
+
* @param Varien_Event_Observer $observer
|
34 |
+
* @return Yellow_Bitcoin_Model_Observer
|
35 |
+
*/
|
36 |
+
public function invoiceSaveAfter(Varien_Event_Observer $observer)
|
37 |
+
{
|
38 |
+
$invoice = $observer->getEvent()->getInvoice();
|
39 |
+
|
40 |
+
if ($invoice->getBaseYellowFeeAmount()) {
|
41 |
+
$order = $invoice->getOrder();
|
42 |
+
$order->setYellowFeeAmountInvoiced($order->getYellowFeeAmountInvoiced() + $invoice->getYellowFeeAmount());
|
43 |
+
$order->setBaseYellowFeeAmountInvoiced($order->getBaseYellowFeeAmountInvoiced() + $invoice->getBaseYellowFeeAmount());
|
44 |
+
}
|
45 |
+
|
46 |
+
return $this;
|
47 |
+
}
|
48 |
+
|
49 |
+
/**
|
50 |
+
* Set fee amount refunded to the order
|
51 |
+
*
|
52 |
+
* @param Varien_Event_Observer $observer
|
53 |
+
* @return Yellow_Bitcoin_Model_Observer
|
54 |
+
*/
|
55 |
+
public function creditmemoSaveAfter(Varien_Event_Observer $observer)
|
56 |
+
{
|
57 |
+
$creditmemo = $observer->getEvent()->getCreditmemo();
|
58 |
+
|
59 |
+
if ($creditmemo->getYellowFeeAmount()) {
|
60 |
+
$order = $creditmemo->getOrder();
|
61 |
+
$order->setYellowFeeAmountRefunded($order->getYellowFeeAmountRefunded() + $creditmemo->getYellowFeeAmount());
|
62 |
+
$order->setBaseYellowFeeAmountRefunded($order->getBaseYellowFeeAmountRefunded() + $creditmemo->getBaseYellowFeeAmount());
|
63 |
+
}
|
64 |
+
|
65 |
+
return $this;
|
66 |
+
}
|
67 |
+
}
|
app/code/local/Yellow/Bitcoin/Model/Sales/Order/Total/Creditmemo/Fee.php
ADDED
@@ -0,0 +1,42 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
*
|
4 |
+
* The MIT License (MIT)
|
5 |
+
*
|
6 |
+
* Copyright (c) 2014 YellowPay.co
|
7 |
+
*
|
8 |
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
9 |
+
* of this software and associated documentation files (the "Software"), to deal
|
10 |
+
* in the Software without restriction, including without limitation the rights
|
11 |
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
12 |
+
* copies of the Software, and to permit persons to whom the Software is
|
13 |
+
* furnished to do so, subject to the following conditions:
|
14 |
+
*
|
15 |
+
* The above copyright notice and this permission notice shall be included in all
|
16 |
+
* copies or substantial portions of the Software.
|
17 |
+
*
|
18 |
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
19 |
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
20 |
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
21 |
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
22 |
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
23 |
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
24 |
+
* SOFTWARE.
|
25 |
+
*
|
26 |
+
* */
|
27 |
+
class Yellow_Bitcoin_Model_Sales_Order_Total_Creditmemo_Fee extends Mage_Sales_Model_Order_Creditmemo_Total_Abstract
|
28 |
+
{
|
29 |
+
public function collect(Mage_Sales_Model_Order_Creditmemo $creditmemo)
|
30 |
+
{
|
31 |
+
$order = $creditmemo->getOrder();
|
32 |
+
$yellowFeeLeft = $order->getYellowFeeInvoiced() - $order->getYellowFeeRefunded();
|
33 |
+
$baseYellowFeeLeft = $order->getBaseYellowFeeInvoiced() - $order->getYellowBaseFeeRefunded();
|
34 |
+
if ($baseYellowFeeLeft > 0) {
|
35 |
+
$creditmemo->setGrandTotal($creditmemo->getGrandTotal() + $yellowFeeLeft);
|
36 |
+
$creditmemo->setBaseGrandTotal($creditmemo->getBaseGrandTotal() + $baseYellowFeeLeft);
|
37 |
+
$creditmemo->setYellowFee($yellowFeeLeft);
|
38 |
+
$creditmemo->setBaseYellowFee($baseYellowFeeLeft);
|
39 |
+
}
|
40 |
+
return $this;
|
41 |
+
}
|
42 |
+
}
|
app/code/local/Yellow/Bitcoin/Model/Sales/Order/Total/Invoice/Fee.php
ADDED
@@ -0,0 +1,49 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
*
|
4 |
+
* The MIT License (MIT)
|
5 |
+
*
|
6 |
+
* Copyright (c) 2014 YellowPay.co
|
7 |
+
*
|
8 |
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
9 |
+
* of this software and associated documentation files (the "Software"), to deal
|
10 |
+
* in the Software without restriction, including without limitation the rights
|
11 |
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
12 |
+
* copies of the Software, and to permit persons to whom the Software is
|
13 |
+
* furnished to do so, subject to the following conditions:
|
14 |
+
*
|
15 |
+
* The above copyright notice and this permission notice shall be included in all
|
16 |
+
* copies or substantial portions of the Software.
|
17 |
+
*
|
18 |
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
19 |
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
20 |
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
21 |
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
22 |
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
23 |
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
24 |
+
* SOFTWARE.
|
25 |
+
*
|
26 |
+
* */
|
27 |
+
class Yellow_Bitcoin_Model_Sales_Order_Total_Invoice_Fee extends Mage_Sales_Model_Order_Invoice_Total_Abstract
|
28 |
+
{
|
29 |
+
public function collect(Mage_Sales_Model_Order_Invoice $invoice)
|
30 |
+
{
|
31 |
+
$order = $invoice->getOrder();
|
32 |
+
$yellowFeeLeft = $order->getYellowFee() - $order->getYellowFeeInvoiced();
|
33 |
+
$baseYellowFeeLeft = $order->getBaseYellowFee() - $order->getBaseYellowFeeInvoiced();
|
34 |
+
if (abs($baseYellowFeeLeft) < $invoice->getBaseGrandTotal()) {
|
35 |
+
$invoice->setGrandTotal($invoice->getGrandTotal() + $yellowFeeLeft);
|
36 |
+
$invoice->setBaseGrandTotal($invoice->getBaseGrandTotal() + $baseYellowFeeLeft);
|
37 |
+
} else {
|
38 |
+
$yellowFeeLeft = $invoice->getGrandTotal() * -1;
|
39 |
+
$baseYellowFeeLeft = $invoice->getBaseGrandTotal() * -1;
|
40 |
+
|
41 |
+
$invoice->setGrandTotal(0);
|
42 |
+
$invoice->setBaseGrandTotal(0);
|
43 |
+
}
|
44 |
+
|
45 |
+
$invoice->setYellowFee($yellowFeeLeft);
|
46 |
+
$invoice->setBaseYellowFee($baseYellowFeeLeft);
|
47 |
+
return $this;
|
48 |
+
}
|
49 |
+
}
|
app/code/local/Yellow/Bitcoin/Model/Sales/Quote/Address/Total/Fee.php
ADDED
@@ -0,0 +1,83 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
*
|
4 |
+
* The MIT License (MIT)
|
5 |
+
*
|
6 |
+
* Copyright (c) 2014 YellowPay.co
|
7 |
+
*
|
8 |
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
9 |
+
* of this software and associated documentation files (the "Software"), to deal
|
10 |
+
* in the Software without restriction, including without limitation the rights
|
11 |
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
12 |
+
* copies of the Software, and to permit persons to whom the Software is
|
13 |
+
* furnished to do so, subject to the following conditions:
|
14 |
+
*
|
15 |
+
* The above copyright notice and this permission notice shall be included in all
|
16 |
+
* copies or substantial portions of the Software.
|
17 |
+
*
|
18 |
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
19 |
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
20 |
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
21 |
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
22 |
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
23 |
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
24 |
+
* SOFTWARE.
|
25 |
+
*
|
26 |
+
* */
|
27 |
+
class Yellow_Bitcoin_Model_Sales_Quote_Address_Total_Fee extends Mage_Sales_Model_Quote_Address_Total_Abstract{
|
28 |
+
|
29 |
+
protected $_code = 'yellow_fee';
|
30 |
+
|
31 |
+
public function collect(Mage_Sales_Model_Quote_Address $address)
|
32 |
+
{
|
33 |
+
|
34 |
+
parent::collect($address);
|
35 |
+
|
36 |
+
/// reset values
|
37 |
+
$this->_setAmount(0);
|
38 |
+
$this->_setBaseAmount(0);
|
39 |
+
|
40 |
+
$address->setYellowFee(0);
|
41 |
+
$address->setBaseYellowFee(0);
|
42 |
+
|
43 |
+
$quote = $address->getQuote();
|
44 |
+
$quote->setYellowFee(0);
|
45 |
+
$quote->setBaseYellowFee(0);
|
46 |
+
|
47 |
+
$items = $this->_getAddressItems($address);
|
48 |
+
if (!count($items)) {
|
49 |
+
return $this; //this makes only address type shipping to come through
|
50 |
+
}
|
51 |
+
|
52 |
+
|
53 |
+
$model = Mage::getModel("bitcoin/bitcoin");
|
54 |
+
if($model->canApplyFee($address)){
|
55 |
+
$fee = $model->getYellowFee();
|
56 |
+
$totals = array_sum($address->getAllTotalAmounts());
|
57 |
+
//$baseTotals = array_sum($address->getAllBaseTotalAmounts());
|
58 |
+
$fee = round(($totals * $fee) / (1 - $fee) , 2, PHP_ROUND_HALF_UP );
|
59 |
+
if( $fee > 0 ){
|
60 |
+
$baseFee = $address->getQuote()->getStore()->convertPrice($fee, false);
|
61 |
+
$address->setYellowFee($fee);
|
62 |
+
$address->setBaseYellowFee($baseFee);
|
63 |
+
$quote->setYellowFee($fee);
|
64 |
+
$quote->setBaseYellowFee($baseFee);
|
65 |
+
$address->setGrandTotal($address->getGrandTotal() + $address->getYellowFee());
|
66 |
+
$address->setBaseGrandTotal($address->getBaseGrandTotal() + $address->getBaseYellowFee());
|
67 |
+
}
|
68 |
+
|
69 |
+
}
|
70 |
+
return $this;
|
71 |
+
}
|
72 |
+
|
73 |
+
public function fetch(Mage_Sales_Model_Quote_Address $address)
|
74 |
+
{
|
75 |
+
$fee = $address->getYellowFee();
|
76 |
+
$address->addTotal(array(
|
77 |
+
'code'=>$this->getCode(),
|
78 |
+
'title'=>Mage::helper('bitcoin')->__('Transaction Fee'),
|
79 |
+
'value'=> $fee
|
80 |
+
));
|
81 |
+
return $this;
|
82 |
+
}
|
83 |
+
}
|
app/code/local/Yellow/Bitcoin/etc/config.xml
CHANGED
@@ -27,13 +27,94 @@ SOFTWARE.
|
|
27 |
<config>
|
28 |
<modules>
|
29 |
<Yellow_Bitcoin>
|
30 |
-
<version>1.0.
|
31 |
<depends>
|
32 |
<Mage_Payment/>
|
33 |
</depends>
|
34 |
</Yellow_Bitcoin>
|
35 |
</modules>
|
36 |
<global>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
37 |
<helpers>
|
38 |
<bitcoin>
|
39 |
<class>Yellow_Bitcoin_Helper</class>
|
@@ -183,6 +264,7 @@ SOFTWARE.
|
|
183 |
<private_key></private_key>
|
184 |
<payment_action>authorize</payment_action>
|
185 |
<db_log>0</db_log>
|
|
|
186 |
</bitcoin>
|
187 |
</payment>
|
188 |
</default>
|
27 |
<config>
|
28 |
<modules>
|
29 |
<Yellow_Bitcoin>
|
30 |
+
<version>1.0.3</version>
|
31 |
<depends>
|
32 |
<Mage_Payment/>
|
33 |
</depends>
|
34 |
</Yellow_Bitcoin>
|
35 |
</modules>
|
36 |
<global>
|
37 |
+
<sales>
|
38 |
+
<quote>
|
39 |
+
<totals>
|
40 |
+
<yellow_fee>
|
41 |
+
<class>bitcoin/sales_quote_address_total_fee</class>
|
42 |
+
<renderer>bitcoin/sales_order_fee</renderer>
|
43 |
+
<admin_renderer>fee/adminhtml_sales_order_total_fee</admin_renderer>
|
44 |
+
<after>subtotal,discount,tax</after>
|
45 |
+
<before>grand_total</before>
|
46 |
+
</yellow_fee>
|
47 |
+
</totals>
|
48 |
+
</quote>
|
49 |
+
<order_invoice>
|
50 |
+
<totals>
|
51 |
+
<yellow_fee>
|
52 |
+
<class>bitcoin/sales_order_total_invoice_fee</class>
|
53 |
+
<renderer>bitcoin/sales_order_fee</renderer>
|
54 |
+
<after>subtotal,discount,tax</after>
|
55 |
+
<before>grand_total</before>
|
56 |
+
</yellow_fee>
|
57 |
+
</totals>
|
58 |
+
</order_invoice>
|
59 |
+
<order_creditmemo>
|
60 |
+
<totals>
|
61 |
+
<yellow_fee>
|
62 |
+
<class>bitcoin/sales_order_total_creditmemo_fee</class>
|
63 |
+
<renderer>bitcoin/sales_order_fee</renderer>
|
64 |
+
<after>subtotal,discount,tax</after>
|
65 |
+
<before>grand_total</before>
|
66 |
+
</yellow_fee>
|
67 |
+
</totals>
|
68 |
+
</order_creditmemo>
|
69 |
+
</sales>
|
70 |
+
<events>
|
71 |
+
<sales_order_invoice_save_after>
|
72 |
+
<observers>
|
73 |
+
<sales_order_invoice_save_after>
|
74 |
+
<class>bitcoin/observer</class>
|
75 |
+
<method>invoiceSaveAfter</method>
|
76 |
+
</sales_order_invoice_save_after>
|
77 |
+
</observers>
|
78 |
+
</sales_order_invoice_save_after>
|
79 |
+
<sales_order_creditmemo_save_after>
|
80 |
+
<observers>
|
81 |
+
<sales_order_creditmemo_save_after>
|
82 |
+
<class>bitcoin/observer</class>
|
83 |
+
<method>creditmemoSaveAfter</method>
|
84 |
+
</sales_order_creditmemo_save_after>
|
85 |
+
</observers>
|
86 |
+
</sales_order_creditmemo_save_after>
|
87 |
+
</events>
|
88 |
+
<fieldsets>
|
89 |
+
<sales_convert_quote_address>
|
90 |
+
<yellow_fee>
|
91 |
+
<to_order>*</to_order>
|
92 |
+
</yellow_fee>
|
93 |
+
<base_yellow_fee>
|
94 |
+
<to_order>*</to_order>
|
95 |
+
</base_yellow_fee>
|
96 |
+
</sales_convert_quote_address>
|
97 |
+
<sales_convert_quote_item>
|
98 |
+
<yellow_fee>
|
99 |
+
<to_order>*</to_order>
|
100 |
+
</yellow_fee>
|
101 |
+
<base_yellow_fee>
|
102 |
+
<to_order>*</to_order>
|
103 |
+
</base_yellow_fee>
|
104 |
+
</sales_convert_quote_item>
|
105 |
+
</fieldsets>
|
106 |
+
<pdf>
|
107 |
+
<totals>
|
108 |
+
<yellow_fee translate="title">
|
109 |
+
<title>Transaction Fee</title>
|
110 |
+
<source_field>yellow_fee</source_field>
|
111 |
+
<font_size>7</font_size>
|
112 |
+
<display_zero>0</display_zero>
|
113 |
+
<sort_order>650</sort_order>
|
114 |
+
<amount_prefix></amount_prefix>
|
115 |
+
</yellow_fee>
|
116 |
+
</totals>
|
117 |
+
</pdf>
|
118 |
<helpers>
|
119 |
<bitcoin>
|
120 |
<class>Yellow_Bitcoin_Helper</class>
|
264 |
<private_key></private_key>
|
265 |
<payment_action>authorize</payment_action>
|
266 |
<db_log>0</db_log>
|
267 |
+
<transaction_fee>0</transaction_fee>
|
268 |
</bitcoin>
|
269 |
</payment>
|
270 |
</default>
|
app/code/local/Yellow/Bitcoin/etc/system.xml
CHANGED
@@ -33,7 +33,7 @@ SOFTWARE.
|
|
33 |
<label>Yellow Bitcoin</label>
|
34 |
<comment>
|
35 |
<![CDATA[
|
36 |
-
<div class="
|
37 |
<a href="http://yellowpay.co/" target="_blank"><img src="https://avatars2.githubusercontent.com/u/8528793?v=2&s=100" alt= "YellowPay" width='100px' height='100px'/></a>
|
38 |
<p>This extension by <a href="http://www.yellowpay.co/" title="Applications for Ecommerce" style="color: #EA7601">Yellow</a> | <a href="http://yellowpay.co" title="Get support for this extension" style="color: #EA7601">Get Support</a></p>
|
39 |
</div>
|
@@ -154,6 +154,16 @@ SOFTWARE.
|
|
154 |
<sort_order>13</sort_order>
|
155 |
<show_in_default>1</show_in_default>
|
156 |
</show_logo>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
157 |
<sort_order translate="label">
|
158 |
<label>Sort Order</label>
|
159 |
<frontend_type>text</frontend_type>
|
33 |
<label>Yellow Bitcoin</label>
|
34 |
<comment>
|
35 |
<![CDATA[
|
36 |
+
<div class="v1.0.3">
|
37 |
<a href="http://yellowpay.co/" target="_blank"><img src="https://avatars2.githubusercontent.com/u/8528793?v=2&s=100" alt= "YellowPay" width='100px' height='100px'/></a>
|
38 |
<p>This extension by <a href="http://www.yellowpay.co/" title="Applications for Ecommerce" style="color: #EA7601">Yellow</a> | <a href="http://yellowpay.co" title="Get support for this extension" style="color: #EA7601">Get Support</a></p>
|
39 |
</div>
|
154 |
<sort_order>13</sort_order>
|
155 |
<show_in_default>1</show_in_default>
|
156 |
</show_logo>
|
157 |
+
<transaction_fee>
|
158 |
+
<label>Add Yellow fees to order total</label>
|
159 |
+
<frontend_type>select</frontend_type>
|
160 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
161 |
+
<sort_order>14</sort_order>
|
162 |
+
<show_in_default>1</show_in_default>
|
163 |
+
<comment>
|
164 |
+
Select Yes to have the customer pay the transaction fees
|
165 |
+
</comment>
|
166 |
+
</transaction_fee>
|
167 |
<sort_order translate="label">
|
168 |
<label>Sort Order</label>
|
169 |
<frontend_type>text</frontend_type>
|
app/code/local/Yellow/Bitcoin/sql/bitcoin_setup/mysql4-upgrade-0.1.3-1.0.2.php
ADDED
@@ -0,0 +1 @@
|
|
|
1 |
+
<?php
|
app/code/local/Yellow/Bitcoin/sql/bitcoin_setup/mysql4-upgrade-1.0.2-1.0.3.php
ADDED
@@ -0,0 +1,46 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
*
|
4 |
+
* The MIT License (MIT)
|
5 |
+
*
|
6 |
+
* Copyright (c) 2014 YellowPay.co
|
7 |
+
*
|
8 |
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
9 |
+
* of this software and associated documentation files (the "Software"), to deal
|
10 |
+
* in the Software without restriction, including without limitation the rights
|
11 |
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
12 |
+
* copies of the Software, and to permit persons to whom the Software is
|
13 |
+
* furnished to do so, subject to the following conditions:
|
14 |
+
*
|
15 |
+
* The above copyright notice and this permission notice shall be included in all
|
16 |
+
* copies or substantial portions of the Software.
|
17 |
+
*
|
18 |
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
19 |
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
20 |
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
21 |
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
22 |
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
23 |
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
24 |
+
* SOFTWARE.
|
25 |
+
*
|
26 |
+
* */
|
27 |
+
|
28 |
+
$installer = $this;
|
29 |
+
$installer->startSetup();
|
30 |
+
$installer->run("
|
31 |
+
ALTER TABLE `".$this->getTable('sales/quote')."` ADD `yellow_fee` DECIMAL( 10, 2 ) NOT NULL;
|
32 |
+
ALTER TABLE `".$this->getTable('sales/quote')."` ADD `base_yellow_fee` DECIMAL( 10, 2 ) NOT NULL;
|
33 |
+
ALTER TABLE `".$this->getTable('sales/order')."` ADD `yellow_fee` DECIMAL( 10, 2 ) NOT NULL;
|
34 |
+
ALTER TABLE `".$this->getTable('sales/order')."` ADD `base_yellow_fee` DECIMAL( 10, 2 ) NOT NULL;
|
35 |
+
ALTER TABLE `".$this->getTable('sales/order')."` ADD `yellow_fee_invoiced` DECIMAL( 10, 2 ) NOT NULL;
|
36 |
+
ALTER TABLE `".$this->getTable('sales/order')."` ADD `base_yellow_fee_invoiced` DECIMAL( 10, 2 ) NOT NULL;
|
37 |
+
ALTER TABLE `".$this->getTable('sales/order')."` ADD `yellow_fee_refunded` DECIMAL( 10, 2 ) NOT NULL;
|
38 |
+
ALTER TABLE `".$this->getTable('sales/order')."` ADD `base_yellow_fee_refunded` DECIMAL( 10, 2 ) NOT NULL;
|
39 |
+
ALTER TABLE `".$this->getTable('sales/quote_address')."` ADD `yellow_fee` DECIMAL( 10, 2 ) NOT NULL;
|
40 |
+
ALTER TABLE `".$this->getTable('sales/quote_address')."` ADD `base_yellow_fee` DECIMAL( 10, 2 ) NOT NULL;
|
41 |
+
ALTER TABLE `".$this->getTable('sales/invoice')."` ADD `yellow_fee` DECIMAL( 10, 2 ) NOT NULL;
|
42 |
+
ALTER TABLE `".$this->getTable('sales/invoice')."` ADD `base_yellow_fee` DECIMAL( 10, 2 ) NOT NULL;
|
43 |
+
ALTER TABLE `".$this->getTable('sales/creditmemo')."` ADD `yellow_fee` DECIMAL( 10, 2 ) NOT NULL;
|
44 |
+
ALTER TABLE `".$this->getTable('sales/creditmemo')."` ADD `base_yellow_fee` DECIMAL( 10, 2 ) NOT NULL;
|
45 |
+
");
|
46 |
+
$installer->endSetup();
|
app/design/adminhtml/default/default/layout/bitcoin.xml
CHANGED
@@ -10,4 +10,57 @@
|
|
10 |
<block type="bitcoin/adminhtml_ipn" name="btcoin_ipn"/>
|
11 |
</reference>
|
12 |
</bitcoin_adminhtml_ipn_index>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
13 |
</layout>
|
10 |
<block type="bitcoin/adminhtml_ipn" name="btcoin_ipn"/>
|
11 |
</reference>
|
12 |
</bitcoin_adminhtml_ipn_index>
|
13 |
+
<adminhtml_sales_order_view>
|
14 |
+
<reference name="order_totals">
|
15 |
+
<block type="adminhtml/sales_order_totals_item" name="yellow.fee" template="bitcoin/sales/order/total.phtml"/>
|
16 |
+
|
17 |
+
<block type="adminhtml/sales_order_totals_item" name="fee.refunded" template="bitcoin/sales/order/refunded.phtml">
|
18 |
+
<action method="setDisplayArea"><area>footer</area></action>
|
19 |
+
<action method="setAfterCondition"><condition>last</condition></action>
|
20 |
+
</block>
|
21 |
+
</reference>
|
22 |
+
</adminhtml_sales_order_view>
|
23 |
+
|
24 |
+
<adminhtml_sales_order_invoice_new>
|
25 |
+
<reference name="invoice_totals">
|
26 |
+
<block type="adminhtml/sales_order_totals_item" name="yellow.fee" template="bitcoin/sales/order/total.phtml">
|
27 |
+
</block>
|
28 |
+
</reference>
|
29 |
+
</adminhtml_sales_order_invoice_new>
|
30 |
+
|
31 |
+
<adminhtml_sales_order_invoice_updateqty>
|
32 |
+
<reference name="invoice_totals">
|
33 |
+
<block type="adminhtml/sales_order_totals_item" name="yellow.fee" template="bitcoin/sales/order/total.phtml">
|
34 |
+
</block>
|
35 |
+
</reference>
|
36 |
+
</adminhtml_sales_order_invoice_updateqty>
|
37 |
+
|
38 |
+
<adminhtml_sales_order_invoice_view>
|
39 |
+
<reference name="invoice_totals">
|
40 |
+
<block type="adminhtml/sales_order_totals_item" name="yellow.fee" template="bitcoin/sales/order/total.phtml">
|
41 |
+
</block>
|
42 |
+
</reference>
|
43 |
+
</adminhtml_sales_order_invoice_view>
|
44 |
+
|
45 |
+
<adminhtml_sales_order_creditmemo_new>
|
46 |
+
<reference name="creditmemo_totals">
|
47 |
+
<block type="adminhtml/sales_order_totals_item" name="yellow.fee" template="bitcoin/sales/order/total.phtml">
|
48 |
+
</block>
|
49 |
+
</reference>
|
50 |
+
</adminhtml_sales_order_creditmemo_new>
|
51 |
+
|
52 |
+
<adminhtml_sales_order_creditmemo_updateqty>
|
53 |
+
<reference name="creditmemo_totals">
|
54 |
+
<block type="adminhtml/sales_order_totals_item" name="yellow.fee" template="bitcoin/sales/order/total.phtml">
|
55 |
+
</block>
|
56 |
+
</reference>
|
57 |
+
</adminhtml_sales_order_creditmemo_updateqty>
|
58 |
+
|
59 |
+
<adminhtml_sales_order_creditmemo_view>
|
60 |
+
<reference name="creditmemo_totals">
|
61 |
+
<block type="adminhtml/sales_order_totals_item" name="fee.refunded" template="bitcoin/sales/order/refunded.phtml">
|
62 |
+
<action method="setDisplayArea"><area>footer</area></action>
|
63 |
+
</block>
|
64 |
+
</reference>
|
65 |
+
</adminhtml_sales_order_creditmemo_view>
|
66 |
</layout>
|
app/design/adminhtml/default/default/template/bitcoin/sales/order/refunded.phtml
ADDED
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php if($this->getSource() instanceof Mage_Sales_Model_Order){ ?>
|
2 |
+
<?php if ((float) $this->getSource()->getYellowFeeRefunded()): ?>
|
3 |
+
<tr>
|
4 |
+
<td class="label"><strong><?php echo Mage::helper('bitcoin')->__('Transaction fee refunded to customer') ?></strong></td>
|
5 |
+
<td><strong><?php echo $this->getSource()->getYellowFeeRefunded(); ?></strong></td>
|
6 |
+
</tr>
|
7 |
+
<?php endif; ?>
|
8 |
+
<?php } else { ?>
|
9 |
+
<?php if ((float) $this->getSource()->getYellowFee()): ?>
|
10 |
+
<tr>
|
11 |
+
<td class="label"><strong><?php echo Mage::helper('bitcoin')->__('Transaction fee Refunded') ?></strong></td>
|
12 |
+
<td><strong><?php echo $this->getSource()->getYellowFee(); ?></strong></td>
|
13 |
+
</tr>
|
14 |
+
<?php endif;
|
15 |
+
}?>
|
16 |
+
|
app/design/adminhtml/default/default/template/bitcoin/sales/order/total.phtml
ADDED
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php $this->setPriceDataObject($this->getSource()) ?>
|
2 |
+
<?php if ((float) $this->getSource()->getYellowFee()): ?>
|
3 |
+
<tr>
|
4 |
+
<td class="label"><?php echo Mage::helper('bitcoin')->__("Transaction Fee") ?></td>
|
5 |
+
<td>
|
6 |
+
<?php echo $this->displayPrices($this->getSource()->getBaseYellowFee(), $this->getSource()->getYellowFee()); ?>
|
7 |
+
</td>
|
8 |
+
</tr>
|
9 |
+
<?php endif; ?>
|
app/design/frontend/base/default/layout/bitcoin.xml
CHANGED
@@ -55,5 +55,52 @@
|
|
55 |
</action>
|
56 |
</reference>
|
57 |
</bitcoin_index_status>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
58 |
</layout>
|
59 |
|
55 |
</action>
|
56 |
</reference>
|
57 |
</bitcoin_index_status>
|
58 |
+
<sales_order_view>
|
59 |
+
<reference name="order_totals">
|
60 |
+
<block type="bitcoin/sales_order_fee" name="bitcoin.sales.order.total" template="bitcoin/checkout/total/fee.phtml" />
|
61 |
+
</reference>
|
62 |
+
</sales_order_view>
|
63 |
+
<sales_order_print>
|
64 |
+
<reference name="order_totals">
|
65 |
+
<block type="bitcoin/sales_order_fee" name="bitcoin.sales.order.total" template="bitcoin/checkout/total/fee.phtml"/>
|
66 |
+
</reference>
|
67 |
+
</sales_order_print>
|
68 |
+
<sales_email_order_items>
|
69 |
+
<reference name="order_totals">
|
70 |
+
<block type="bitcoin/sales_order_fee" name="bitcoin.sales.order.total" template="bitcoin/checkout/total/fee.phtml"/>
|
71 |
+
</reference>
|
72 |
+
</sales_email_order_items>
|
73 |
+
|
74 |
+
<sales_order_invoice>
|
75 |
+
<reference name="invoice_totals">
|
76 |
+
<block type="bitcoin/sales_order_fee" name="bitcoin.sales.order.total" template="bitcoin/checkout/total/fee.phtml"/>
|
77 |
+
</reference>
|
78 |
+
</sales_order_invoice>
|
79 |
+
<sales_order_printinvoice>
|
80 |
+
<reference name="invoice_totals">
|
81 |
+
<block type="bitcoin/sales_order_fee" name="bitcoin.sales.order.total" template="bitcoin/checkout/total/fee.phtml"/>
|
82 |
+
</reference>
|
83 |
+
</sales_order_printinvoice>
|
84 |
+
<sales_email_order_invoice_items>
|
85 |
+
<reference name="invoice_totals">
|
86 |
+
<block type="bitcoin/sales_order_fee" name="bitcoin.sales.order.total" template="bitcoin/checkout/total/fee.phtml"/>
|
87 |
+
</reference>
|
88 |
+
</sales_email_order_invoice_items>
|
89 |
+
|
90 |
+
<sales_order_creditmemo>
|
91 |
+
<reference name="creditmemo_totals">
|
92 |
+
<block type="bitcoin/sales_order_fee" name="bitcoin.sales.order.total" template="bitcoin/checkout/total/fee.phtml"/>
|
93 |
+
</reference>
|
94 |
+
</sales_order_creditmemo>
|
95 |
+
<sales_order_printcreditmemo>
|
96 |
+
<reference name="creditmemo_totals">
|
97 |
+
<block type="bitcoin/sales_order_fee" name="bitcoin.sales.order.total" template="bitcoin/checkout/total/fee.phtml"/>
|
98 |
+
</reference>
|
99 |
+
</sales_order_printcreditmemo>
|
100 |
+
<sales_email_order_creditmemo_items>
|
101 |
+
<reference name="creditmemo_totals">
|
102 |
+
<block type="bitcoin/sales_order_fee" name="bitcoin.sales.order.total" template="bitcoin/checkout/total/fee.phtml"/>
|
103 |
+
</reference>
|
104 |
+
</sales_email_order_creditmemo_items>
|
105 |
</layout>
|
106 |
|
app/design/frontend/base/default/template/bitcoin/checkout/total/fee.phtml
ADDED
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php $fee = $this->getTotal()->getValue(); ?>
|
2 |
+
<?php if($fee > 0 ): ?>
|
3 |
+
<tr>
|
4 |
+
<td colspan="<?php echo $this->getColspan(); ?>" style="<?php echo $this->getTotal()->getStyle() ?>" class="a-right">
|
5 |
+
<?php if ($this->getRenderingArea() == $this->getTotal()->getArea()): ?><strong><?php endif; ?>
|
6 |
+
<?php echo $this->escapeHtml($this->getTotal()->getTitle()); ?>
|
7 |
+
<?php if ($this->getRenderingArea() == $this->getTotal()->getArea()): ?></strong><?php endif; ?>
|
8 |
+
</td>
|
9 |
+
<td style="<?php echo $this->getTotal()->getStyle() ?>" class="a-right">
|
10 |
+
<?php if ($this->getRenderingArea() == $this->getTotal()->getArea()): ?><strong><?php endif; ?>
|
11 |
+
<?php echo $this->helper('checkout')->formatPrice($fee) ?>
|
12 |
+
<?php if ($this->getRenderingArea() == $this->getTotal()->getArea()): ?></strong><?php endif; ?>
|
13 |
+
</td>
|
14 |
+
</tr>
|
15 |
+
<?php endif;?>
|
app/etc/modules/Yellow_Bitcoin.xml
CHANGED
@@ -33,7 +33,7 @@ SOFTWARE.
|
|
33 |
<depends>
|
34 |
<Mage_Payment/>
|
35 |
</depends>
|
36 |
-
<version>1.0.
|
37 |
</Yellow_Bitcoin>
|
38 |
</modules>
|
39 |
</config>
|
33 |
<depends>
|
34 |
<Mage_Payment/>
|
35 |
</depends>
|
36 |
+
<version>1.0.3</version>
|
37 |
</Yellow_Bitcoin>
|
38 |
</modules>
|
39 |
</config>
|
package.xml
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>Yellow_Pay</name>
|
4 |
-
<version>1.0.
|
5 |
<stability>stable</stability>
|
6 |
<license uri="https://github.com/YellowPay/yellow-magento/blob/master/LICENSE.md">MITL</license>
|
7 |
<channel>community</channel>
|
@@ -30,12 +30,11 @@ Bitcoin payment is received and the customer is redirected to an order confirmat
|
|
30 |

|
31 |
6.
|
32 |
Yellow converts the received Bitcoin payment into a national currency (like AED) and transfers it to the merchant's bank account</description>
|
33 |
-
<notes>
|
34 |
-
UI fixes</notes>
|
35 |
<authors><author><name>Tawfek Daghistani</name><user>tawfekov</user><email>tawfekov@gmail.com</email></author><author><name>James Piechota</name><user>YellowPay</user><email>james@yellowpay.co</email></author></authors>
|
36 |
-
<date>2015-
|
37 |
-
<time>
|
38 |
-
<contents><target name="magelocal"><dir name="Yellow"><dir name="Bitcoin"><dir name="Block"><dir name="Adminhtml"><dir name="Ipn"><dir name="Edit"><file name="Form.php" hash="7f80eace317f9fe82d4f76c1964c1130"/><dir name="Tab"><file name="Form.php" hash="6a89244929f6cb68dfee02e8559cafb2"/></dir><file name="Tabs.php" hash="238c2dc91e560ea5b71964c8257d52a1"/></dir><file name="Edit.php" hash="025d0b4b35397890207a7ea8af97ee0e"/><file name="Grid.php" hash="84bf9234f25b8b27bbb1032442fc26ba"/></dir><file name="Ipn.php" hash="5fe044c4cb3fffcdab958c481a83e864"/><dir name="Log"><dir name="Edit"><file name="Form.php" hash="27fa08c710def8bf91ba212882c74e83"/><dir name="Tab"><file name="Form.php" hash="d9a427fd3e1011188f0214c128d3bb4e"/></dir><file name="Tabs.php" hash="275d186945a3cfc9d73ab2b7a606ca18"/></dir><file name="Edit.php" hash="6a4763b0d2427ce58ae46adef581d2f6"/><file name="Grid.php" hash="7eea4350f39da7956abfd60dec08e512"/></dir><file name="Log.php" hash="bca0901efdb1f99e5103fce583774967"/></dir><dir name="Form"><file name="Bitcoin.php" hash="ac5bd0bc5d4cdd1f1a3f5cd1be68359e"/></dir><dir name="Fullscreen"><dir name="Widget"><file name="Content.php" hash="f97e2a8a3ef850272fb5d3a7e2dd750d"/><file name="Footer.php" hash="d10cd8c519422fd4de3defcd88569239"/><file name="Header.php" hash="ba790b89254447b7d4a9362d02d2b4f3"/></dir></dir><file name="Info.php" hash="1d2052d6dcf46c18dd846d1072f259ef"/><file name="Status.php" hash="dd26ce7879dc006f19b8528b4cfe6dd4"/><file name="Widget.php" hash="6d640b82fae0c83cce79aed368a05044"/></dir><dir name="Helper"><file name="Data.php" hash="b96124f0753fdaa49644b8fdac5f95ce"/></dir><dir name="Model"><file name="Bitcoin.php" hash="
|
39 |
<compatible/>
|
40 |
<dependencies><required><php><min>5.3.0</min><max>6.0.0</max></php></required></dependencies>
|
41 |
</package>
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>Yellow_Pay</name>
|
4 |
+
<version>1.0.3</version>
|
5 |
<stability>stable</stability>
|
6 |
<license uri="https://github.com/YellowPay/yellow-magento/blob/master/LICENSE.md">MITL</license>
|
7 |
<channel>community</channel>
|
30 |

|
31 |
6.
|
32 |
Yellow converts the received Bitcoin payment into a national currency (like AED) and transfers it to the merchant's bank account</description>
|
33 |
+
<notes>Add option for merchant to include Yellow transaction fees in amount invoiced to customer.</notes>
|
|
|
34 |
<authors><author><name>Tawfek Daghistani</name><user>tawfekov</user><email>tawfekov@gmail.com</email></author><author><name>James Piechota</name><user>YellowPay</user><email>james@yellowpay.co</email></author></authors>
|
35 |
+
<date>2015-07-16</date>
|
36 |
+
<time>19:29:37</time>
|
37 |
+
<contents><target name="magelocal"><dir name="Yellow"><dir name="Bitcoin"><dir name="Block"><dir name="Adminhtml"><dir name="Ipn"><dir name="Edit"><file name="Form.php" hash="7f80eace317f9fe82d4f76c1964c1130"/><dir name="Tab"><file name="Form.php" hash="6a89244929f6cb68dfee02e8559cafb2"/></dir><file name="Tabs.php" hash="238c2dc91e560ea5b71964c8257d52a1"/></dir><file name="Edit.php" hash="025d0b4b35397890207a7ea8af97ee0e"/><file name="Grid.php" hash="84bf9234f25b8b27bbb1032442fc26ba"/></dir><file name="Ipn.php" hash="5fe044c4cb3fffcdab958c481a83e864"/><dir name="Log"><dir name="Edit"><file name="Form.php" hash="27fa08c710def8bf91ba212882c74e83"/><dir name="Tab"><file name="Form.php" hash="d9a427fd3e1011188f0214c128d3bb4e"/></dir><file name="Tabs.php" hash="275d186945a3cfc9d73ab2b7a606ca18"/></dir><file name="Edit.php" hash="6a4763b0d2427ce58ae46adef581d2f6"/><file name="Grid.php" hash="7eea4350f39da7956abfd60dec08e512"/></dir><file name="Log.php" hash="bca0901efdb1f99e5103fce583774967"/><dir name="Sales"><dir name="Order"><dir name="Total"><file name="Fee.php" hash="d4d196496234cbe95a74900a29b2490e"/></dir></dir></dir></dir><dir name="Form"><file name="Bitcoin.php" hash="ac5bd0bc5d4cdd1f1a3f5cd1be68359e"/></dir><dir name="Fullscreen"><dir name="Widget"><file name="Content.php" hash="f97e2a8a3ef850272fb5d3a7e2dd750d"/><file name="Footer.php" hash="d10cd8c519422fd4de3defcd88569239"/><file name="Header.php" hash="ba790b89254447b7d4a9362d02d2b4f3"/></dir></dir><file name="Info.php" hash="1d2052d6dcf46c18dd846d1072f259ef"/><dir name="Sales"><dir name="Order"><file name="Fee.php" hash="16bca8499e7c0be2f3c05f9850f3cb45"/></dir></dir><file name="Status.php" hash="dd26ce7879dc006f19b8528b4cfe6dd4"/><file name="Widget.php" hash="6d640b82fae0c83cce79aed368a05044"/></dir><dir name="Helper"><file name="Data.php" hash="b96124f0753fdaa49644b8fdac5f95ce"/></dir><dir name="Model"><file name="Bitcoin.php" hash="8128869421a8a883a36877f6463bad70"/><file name="Http.php" hash="8cd7ca764944940130a54b7ed2927fdd"/><file name="Ipn.php" hash="cd66beab4f6bea576c6997bff68e0de2"/><file name="Log.php" hash="67d5fbbc997e57cefdbc1c8b28a94d93"/><file name="Observer.php" hash="97b36e04bcd4659d8fad2ff5857c01ce"/><dir name="Resource"><dir name="Ipn"><file name="Collection.php" hash="74285c584012f2b9d079ba258bc30ac9"/></dir><file name="Ipn.php" hash="a81ef4ed09a444a61c11ad1e92965438"/><dir name="Log"><file name="Collection.php" hash="fe97d78a654f856ea4eb005728b683e3"/></dir><file name="Log.php" hash="70de1ff87111d0ef4961c89810a1d8a0"/></dir><dir name="Sales"><dir name="Order"><dir name="Total"><dir name="Creditmemo"><file name="Fee.php" hash="6e323f0859668fff73ca4b24c209b2a2"/></dir><dir name="Invoice"><file name="Fee.php" hash="46a3506d561a2560848209741d11a6b4"/></dir></dir></dir><dir name="Quote"><dir name="Address"><dir name="Total"><file name="Fee.php" hash="8ec58093c5f2b4c543cef1ca6c124ba3"/></dir></dir></dir></dir></dir><dir name="controllers"><dir name="Adminhtml"><file name="IpnController.php" hash="fcd760bd4f54eab247544dcd70cfa3e2"/><file name="LogController.php" hash="dbe296b63e4d3f6b7cc3b231fae8bf72"/></dir><file name="IndexController.php" hash="314d06d1fc10c37a171c07d23dc694f4"/></dir><dir name="etc"><file name="config.xml" hash="a64682cd1af6a2723bdddd1774618712"/><file name="system.xml" hash="672d9f4b38300a8f222b41c29ebcae99"/></dir><dir name="sql"><dir name="bitcoin_setup"><file name="mysql4-install-0.1.0.php" hash="2cd90bb78e7befc41e7b3c74d602db86"/><file name="mysql4-upgrade-0.1.0-0.1.1.php" hash="029263662ecc7b7dfe8e76cfa907b38b"/><file name="mysql4-upgrade-0.1.1-0.1.2.php" hash="afa8d749b6f82519964f9fe2aa4ff4a1"/><file name="mysql4-upgrade-0.1.2-0.1.3.php" hash="1872837133e08ed077cfa52eafd91a3a"/><file name="mysql4-upgrade-0.1.3-1.0.2.php" hash="ce407ff5715c837d02b1aba7975bf512"/><file name="mysql4-upgrade-1.0.2-1.0.3.php" hash="b083a9abd77f5b54149ce98da333d65e"/></dir></dir></dir></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="bitcoin.xml" hash="6d989db92d00f02d1cad418d63e7c9ea"/></dir><dir name="template"><dir name="bitcoin"><dir name="info"><file name="invoice.phtml" hash="61aa4bdffb8c22cc8601087cd1219057"/></dir><dir name="sales"><dir name="order"><file name="refunded.phtml" hash="6b61736471913d8634bafb88d54d98ef"/><file name="total.phtml" hash="197a5e092a86a4ac340005a47b9d8479"/></dir></dir></dir></dir></dir></dir></dir><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="bitcoin.xml" hash="93caa647d4e50921db114b00598c4f4b"/></dir><dir name="template"><dir name="bitcoin"><dir name="checkout"><dir name="total"><file name="fee.phtml" hash="1e74b813a919480a6c49f3ffe9e4c0b1"/></dir></dir><dir name="form"><file name="bitcoin.phtml" hash="d41d8cd98f00b204e9800998ecf8427e"/><file name="logo.phtml" hash="9ab2ebe0829c5559e6d854d024e69c26"/></dir><dir name="fullscreen"><dir name="widget"><file name="content.phtml" hash="6bfc9ee8833020bf300273efb8768111"/><file name="footer.phtml" hash="158b47f886130826a4edc58df73d7911"/><file name="header.phtml" hash="959f3d652959d9eefde349f5bd42b412"/></dir></dir><dir name="info"><file name="invoice.phtml" hash="ba13d5900d99c8fcf550601e378dcb4c"/></dir><file name="status.phtml" hash="4d7753c3efdcad9a2974b89ec636aa4c"/><file name="widget.phtml" hash="fe6e73c20d78b9a8ca5d6195b7fd07f8"/></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Yellow_Bitcoin.xml" hash="ba0ebabb4fab20d44ef812c976b8b4b9"/></dir></target><target name="mageskin"><dir name="adminhtml"><dir name="base"><dir name="default"><dir name="images"><dir name="bitcoin"><file name="bitcoin_accepted.png" hash="0682420205f3e2001b72901c44073163"/></dir></dir></dir></dir></dir><dir name="frontend"><dir name="base"><dir name="default"><dir name="css"><file name="bitcoin.css" hash="f4e845ab9eb14e25e0a174b73271980a"/></dir><dir name="images"><dir name="bitcoin"><file name="bitcoin_accepted.png" hash="0682420205f3e2001b72901c44073163"/></dir></dir><dir name="js"><file name="iframeResizer.min.js" hash="0f471bcfd5d0edf49ef67542b7a763a0"/></dir></dir></dir></dir></target></contents>
|
38 |
<compatible/>
|
39 |
<dependencies><required><php><min>5.3.0</min><max>6.0.0</max></php></required></dependencies>
|
40 |
</package>
|