Version Notes
Basic functionality to pay overdue payments/unpaid invoices that are created by the administrator and is visible on the customer dashboard for further payment.
Download this release
Release Info
Developer | Folio3 |
Extension | folio3_overdue |
Version | 1.0.0 |
Comparing to | |
See all releases |
Version 1.0.0
- app/code/community/Folio3/Overdue/Block/Customer/Account/Navigation.php +20 -0
- app/code/community/Folio3/Overdue/Block/Grid.php +33 -0
- app/code/community/Folio3/Overdue/Block/Invoice.php +43 -0
- app/code/community/Folio3/Overdue/Block/Payment.php +32 -0
- app/code/community/Folio3/Overdue/Block/Payment/Methods.php +180 -0
- app/code/community/Folio3/Overdue/Helper/Data.php +26 -0
- app/code/community/Folio3/Overdue/Model/Paypal/Express.php +80 -0
- app/code/community/Folio3/Overdue/Model/Sales/Order/Payment.php +41 -0
- app/code/community/Folio3/Overdue/Model/System/Config/Source/Payment/Methods.php +40 -0
- app/code/community/Folio3/Overdue/controllers/AccountController.php +190 -0
- app/code/community/Folio3/Overdue/etc/config.xml +79 -0
- app/code/community/Folio3/Overdue/etc/system.xml +42 -0
- app/design/frontend/base/default/layout/folio3_overdue.xml +49 -0
- app/design/frontend/base/default/template/folio3_overdue/grid.phtml +52 -0
- app/design/frontend/base/default/template/folio3_overdue/invoice.phtml +13 -0
- app/design/frontend/base/default/template/folio3_overdue/invoice/info.phtml +38 -0
- app/design/frontend/base/default/template/folio3_overdue/invoice/payment.phtml +74 -0
- app/design/frontend/base/default/template/folio3_overdue/invoice/payment/methods.phtml +46 -0
- app/etc/modules/Folio3_Overdue.xml +8 -0
- package.xml +18 -0
app/code/community/Folio3/Overdue/Block/Customer/Account/Navigation.php
ADDED
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class Folio3_Overdue_Block_Customer_Account_Navigation extends Mage_Customer_Block_Account_Navigation{
|
3 |
+
/**
|
4 |
+
* Removes link by url
|
5 |
+
*
|
6 |
+
* @param string $url
|
7 |
+
* @return Mage_Page_Block_Template_Links
|
8 |
+
*/
|
9 |
+
public function removeLinkByUrl($url)
|
10 |
+
{
|
11 |
+
foreach ($this->_links as $k => $v) {
|
12 |
+
if ($v->getPath() == trim($url, '/')) {
|
13 |
+
unset($this->_links[$k]);
|
14 |
+
}
|
15 |
+
}
|
16 |
+
|
17 |
+
return $this;
|
18 |
+
}
|
19 |
+
}
|
20 |
+
?>
|
app/code/community/Folio3/Overdue/Block/Grid.php
ADDED
@@ -0,0 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class Folio3_Overdue_Block_Grid extends Mage_Core_Block_Template{
|
3 |
+
public function __construct() {
|
4 |
+
parent::__construct();
|
5 |
+
|
6 |
+
$invoices = Mage::getModel('sales/order_invoice')->getCollection()
|
7 |
+
->join(
|
8 |
+
array('order'=> 'order'),
|
9 |
+
'order.entity_id = order_id',
|
10 |
+
array(
|
11 |
+
'order.customer_id',
|
12 |
+
'order.total_paid',
|
13 |
+
'order.total_due'
|
14 |
+
)
|
15 |
+
)
|
16 |
+
->addFieldToFilter('order.customer_id', Mage::getSingleton('customer/session')->getCustomer()->getId())
|
17 |
+
->addFieldToFilter('main_table.state', 1) //Fetch Invoices which are pending!
|
18 |
+
->setOrder('main_table.created_at', 'desc');
|
19 |
+
|
20 |
+
//Zend_Debug::dump($invoices->getData()); exit;
|
21 |
+
|
22 |
+
$this->setInvoices($invoices);
|
23 |
+
}
|
24 |
+
|
25 |
+
public function getViewUrl(Mage_Sales_Model_Order_Invoice $invoice) {
|
26 |
+
return $this->getUrl('sales/order/view', array('order_id' => $invoice->getOrderId()));
|
27 |
+
}
|
28 |
+
|
29 |
+
public function getPayUrl(Mage_Sales_Model_Order_Invoice $invoice) {
|
30 |
+
return $this->getUrl('*/*/pay', array('invoice_id' => $invoice->getId()));
|
31 |
+
}
|
32 |
+
}
|
33 |
+
?>
|
app/code/community/Folio3/Overdue/Block/Invoice.php
ADDED
@@ -0,0 +1,43 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class Folio3_Overdue_Block_Invoice extends Mage_Core_Block_Template{
|
3 |
+
public function __construct() {
|
4 |
+
parent::__construct();
|
5 |
+
|
6 |
+
$invoices = Mage::getModel('sales/order_invoice')->getCollection()
|
7 |
+
->join(
|
8 |
+
array('order'=> 'order'),
|
9 |
+
'order.entity_id = order_id',
|
10 |
+
array(
|
11 |
+
'order.customer_id',
|
12 |
+
'order.total_paid',
|
13 |
+
'order.total_due'
|
14 |
+
)
|
15 |
+
)
|
16 |
+
->addFieldToFilter('order.customer_id', Mage::getSingleton('customer/session')->getCustomer()->getId())
|
17 |
+
->addFieldToFilter('main_table.state', 1) //Fetch Invoices which are pending!
|
18 |
+
->setOrder('main_table.created_at', 'desc');
|
19 |
+
|
20 |
+
$invoiceId = Mage::app()->getRequest()->getParam('invoice_id');
|
21 |
+
if($invoiceId){
|
22 |
+
$invoices->addFieldToFilter('main_table.entity_id', $invoiceId); //Fetch Invoices which are pending!
|
23 |
+
}
|
24 |
+
|
25 |
+
//Zend_Debug::dump($invoices->getData()); exit;
|
26 |
+
|
27 |
+
$this->setInvoices($invoices);
|
28 |
+
}
|
29 |
+
|
30 |
+
public function getInvoice(){
|
31 |
+
return $this->getInvoices()->getFirstItem();
|
32 |
+
}
|
33 |
+
|
34 |
+
public function getOrder(){
|
35 |
+
$invoice = $this->getInvoice();
|
36 |
+
return $invoice->getOrder();
|
37 |
+
}
|
38 |
+
|
39 |
+
public function getPayPostUrl(){
|
40 |
+
return $this->getUrl('*/*/payPost');
|
41 |
+
}
|
42 |
+
}
|
43 |
+
?>
|
app/code/community/Folio3/Overdue/Block/Payment.php
ADDED
@@ -0,0 +1,32 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class Folio3_Overdue_Block_Payment extends Mage_Checkout_Block_Onepage_Payment{
|
3 |
+
public function __construct(){
|
4 |
+
parent::__construct();
|
5 |
+
}
|
6 |
+
|
7 |
+
public function getPayPostUrl(){
|
8 |
+
return $this->getUrl('*/*/payPost');
|
9 |
+
}
|
10 |
+
|
11 |
+
public function getBackUrl(){
|
12 |
+
return $this->getUrl('*/*/overdue');
|
13 |
+
}
|
14 |
+
|
15 |
+
/**
|
16 |
+
* Retrieve code of current payment method
|
17 |
+
*
|
18 |
+
* @return mixed
|
19 |
+
*/
|
20 |
+
public function getSelectedMethodCode()
|
21 |
+
{
|
22 |
+
$invoiceId = Mage::app()->getRequest()->getParam('invoice_id');
|
23 |
+
if($invoiceId){
|
24 |
+
$invoice = Mage::getModel('sales/order_invoice')->load($invoiceId);
|
25 |
+
if ($method = $invoice->getOrder()->getPayment()->getMethod()) {
|
26 |
+
return $method;
|
27 |
+
}
|
28 |
+
}
|
29 |
+
return false;
|
30 |
+
}
|
31 |
+
}
|
32 |
+
?>
|
app/code/community/Folio3/Overdue/Block/Payment/Methods.php
ADDED
@@ -0,0 +1,180 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class Folio3_Overdue_Block_Payment_Methods extends Folio3_Overdue_Block_Invoice {
|
3 |
+
|
4 |
+
/**
|
5 |
+
* Prepare children blocks
|
6 |
+
*/
|
7 |
+
protected function _prepareLayout()
|
8 |
+
{
|
9 |
+
/**
|
10 |
+
* Create child blocks for payment methods forms
|
11 |
+
*/
|
12 |
+
foreach ($this->getMethods() as $method) {
|
13 |
+
$block = $this->helper('payment')->getMethodFormBlock($method);
|
14 |
+
$block->setMethod($method);
|
15 |
+
|
16 |
+
$this->setChild(
|
17 |
+
'folio3.payment.method.'. $method->getCode(), $block
|
18 |
+
);
|
19 |
+
}
|
20 |
+
|
21 |
+
return parent::_prepareLayout();
|
22 |
+
}
|
23 |
+
|
24 |
+
public function getMethods(){
|
25 |
+
$methods = array();
|
26 |
+
|
27 |
+
$Invoice = $this->getInvoice();
|
28 |
+
foreach ($this->helper('payment')->getStoreMethods($Invoice->getStoreId(), $Invoice->getOrder()) as $method) {
|
29 |
+
if ($this->_canUseMethod($method, $Invoice->getOrder())) {
|
30 |
+
|
31 |
+
$this->_assignMethod($method, $Invoice->getOrder());
|
32 |
+
$methods[] = $method;
|
33 |
+
}
|
34 |
+
}
|
35 |
+
|
36 |
+
//$methods = Mage::getSingleton('payment/config')->getActiveMethods();
|
37 |
+
return $methods;
|
38 |
+
}
|
39 |
+
/**
|
40 |
+
* Payment method form html getter
|
41 |
+
* @param Mage_Payment_Model_Method_Abstract $method
|
42 |
+
*/
|
43 |
+
public function getPaymentMethodFormHtml(Mage_Payment_Model_Method_Abstract $method) {
|
44 |
+
return $this->getChildHtml('folio3.payment.method.' . $method->getCode());
|
45 |
+
}
|
46 |
+
|
47 |
+
/**
|
48 |
+
* Return method title for payment selection page
|
49 |
+
*
|
50 |
+
* @param Mage_Payment_Model_Method_Abstract $method
|
51 |
+
*/
|
52 |
+
public function getMethodTitle(Mage_Payment_Model_Method_Abstract $method)
|
53 |
+
{
|
54 |
+
$form = $this->getChild('folio3.payment.method.' . $method->getCode());
|
55 |
+
if ($form && $form->hasMethodTitle()) {
|
56 |
+
return $form->getMethodTitle();
|
57 |
+
}
|
58 |
+
return $method->getTitle();
|
59 |
+
}
|
60 |
+
|
61 |
+
/**
|
62 |
+
* Payment method additional label part getter
|
63 |
+
* @param Mage_Payment_Model_Method_Abstract $method
|
64 |
+
*/
|
65 |
+
public function getMethodLabelAfterHtml(Mage_Payment_Model_Method_Abstract $method)
|
66 |
+
{
|
67 |
+
if ($form = $this->getChild('folio3.payment.method.' . $method->getCode())) {
|
68 |
+
return $form->getMethodLabelAfterHtml();
|
69 |
+
}
|
70 |
+
}
|
71 |
+
|
72 |
+
/**
|
73 |
+
* Declare template for payment method form block
|
74 |
+
*
|
75 |
+
* @param string $method
|
76 |
+
* @param string $template
|
77 |
+
* @return Mage_Payment_Block_Form_Container
|
78 |
+
*/
|
79 |
+
public function setMethodFormTemplate($method='', $template='')
|
80 |
+
{
|
81 |
+
if (!empty($method) && !empty($template)) {
|
82 |
+
if ($block = $this->getChild('folio3.payment.method.'.$method)) {
|
83 |
+
$block->setTemplate($template);
|
84 |
+
}
|
85 |
+
}
|
86 |
+
return $this;
|
87 |
+
}
|
88 |
+
|
89 |
+
protected function _canUseMethod($method){
|
90 |
+
if (($method instanceof Mage_Payment_Model_Method_Abstract) && $method->canUseCheckout() && $method->isAvailable($this->getOrder())) {
|
91 |
+
if (!$method->canUseForCountry($this->getOrder()->getBillingAddress()->getCountry())) {
|
92 |
+
return false;
|
93 |
+
}
|
94 |
+
|
95 |
+
if (!$method->canUseForCurrency($this->getOrder()->getStore()->getBaseCurrencyCode())) {
|
96 |
+
return false;
|
97 |
+
}
|
98 |
+
|
99 |
+
/**
|
100 |
+
* Checking for min/max order total for assigned payment method
|
101 |
+
*/
|
102 |
+
$total = $this->getOrder()->getBaseGrandTotal();
|
103 |
+
$minTotal = $method->getConfigData('min_order_total');
|
104 |
+
$maxTotal = $method->getConfigData('max_order_total');
|
105 |
+
|
106 |
+
if((!empty($minTotal) && ($total < $minTotal)) || (!empty($maxTotal) && ($total > $maxTotal))) {
|
107 |
+
return false;
|
108 |
+
}
|
109 |
+
|
110 |
+
$AllowedMethods = Mage::helper('folio3_overdue')->getAllowedMethods();
|
111 |
+
$canUse = false;
|
112 |
+
|
113 |
+
foreach($AllowedMethods as $AllowedMethod){
|
114 |
+
if($method->getCode() == $AllowedMethod){
|
115 |
+
$canUse = true;
|
116 |
+
}
|
117 |
+
}
|
118 |
+
|
119 |
+
return $canUse;
|
120 |
+
}
|
121 |
+
|
122 |
+
return false;
|
123 |
+
}
|
124 |
+
|
125 |
+
/**
|
126 |
+
* Check payment method model
|
127 |
+
*
|
128 |
+
* @param Mage_Payment_Model_Method_Abstract|null
|
129 |
+
* @return bool
|
130 |
+
*/
|
131 |
+
protected function __canUseMethod($method, $Order)
|
132 |
+
{
|
133 |
+
$AllowedMethods = (array) Mage::getConfig()->getNode('default/folio3_overdue/allowed_methods');
|
134 |
+
$canUse = false;
|
135 |
+
|
136 |
+
if($method && $method->canUseCheckout() && $method->isApplicableToQuote(
|
137 |
+
$Order, Mage_Payment_Model_Method_Abstract::CHECK_USE_FOR_COUNTRY
|
138 |
+
| Mage_Payment_Model_Method_Abstract::CHECK_USE_FOR_CURRENCY
|
139 |
+
| Mage_Payment_Model_Method_Abstract::CHECK_ORDER_TOTAL_MIN_MAX
|
140 |
+
)){
|
141 |
+
|
142 |
+
foreach($AllowedMethods as $AllowedMethod=>$isEnabled){
|
143 |
+
if($method->getCode() == $AllowedMethod && $isEnabled){
|
144 |
+
$canUse = true;
|
145 |
+
}
|
146 |
+
}
|
147 |
+
}
|
148 |
+
|
149 |
+
return $canUse;
|
150 |
+
}
|
151 |
+
|
152 |
+
/**
|
153 |
+
* Check and prepare payment method model
|
154 |
+
*
|
155 |
+
* Redeclare this method in child classes for declaring method info instance
|
156 |
+
*
|
157 |
+
* @param Mage_Payment_Model_Method_Abstract $method
|
158 |
+
* @return bool
|
159 |
+
*/
|
160 |
+
protected function _assignMethod($method, $Order)
|
161 |
+
{
|
162 |
+
$method->setInfoInstance($Order->getPayment());
|
163 |
+
return $this;
|
164 |
+
}
|
165 |
+
|
166 |
+
/**
|
167 |
+
* Retrieve code of current payment method
|
168 |
+
*
|
169 |
+
* @return mixed
|
170 |
+
*/
|
171 |
+
public function getSelectedMethodCode()
|
172 |
+
{
|
173 |
+
if ($method = $this->getInvoice()->getOrder()->getPayment()->getMethod()) {
|
174 |
+
return $method;
|
175 |
+
}
|
176 |
+
return false;
|
177 |
+
}
|
178 |
+
}
|
179 |
+
|
180 |
+
?>
|
app/code/community/Folio3/Overdue/Helper/Data.php
ADDED
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Folio3_Overdue_Helper_Data extends Mage_Core_Helper_Abstract{
|
4 |
+
public function canPayDues(){
|
5 |
+
return true;
|
6 |
+
}
|
7 |
+
|
8 |
+
public function getInvoice(){
|
9 |
+
$invoice_id = Mage::app()->getRequest()->getParam('invoice_id');
|
10 |
+
$invoice = Mage::getModel('sales/order_invoice')->load($invoice_id);
|
11 |
+
|
12 |
+
return $invoice;
|
13 |
+
}
|
14 |
+
|
15 |
+
public function getOrder(){
|
16 |
+
$invoice_id = Mage::app()->getRequest()->getParam('invoice_id');
|
17 |
+
$invoice = Mage::getModel('sales/order_invoice')->load($invoice_id);
|
18 |
+
|
19 |
+
return $invoice->getOrder();
|
20 |
+
}
|
21 |
+
|
22 |
+
public function getAllowedMethods(){
|
23 |
+
$methods = Mage::getStoreConfig('Overdue/config/allowedMethods');
|
24 |
+
return explode(',', $methods);
|
25 |
+
}
|
26 |
+
}
|
app/code/community/Folio3/Overdue/Model/Paypal/Express.php
ADDED
@@ -0,0 +1,80 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Folio3_Overdue_Model_Paypal_Express extends Mage_Paypal_Model_Express {
|
4 |
+
/**
|
5 |
+
* Collect Dues of an Order Payment
|
6 |
+
*
|
7 |
+
* @param Mage_Sales_Model_Order_Payment $payment
|
8 |
+
* @param float $amount
|
9 |
+
* @return Apex_Deposit_Paypal_Model_Express
|
10 |
+
*/
|
11 |
+
public function newAuthorization(Varien_Object $payment, $amount) {
|
12 |
+
$order = $payment->getOrder();
|
13 |
+
|
14 |
+
$returnURL = Mage::getUrl('*/*/auth', array('order_id' => $order->getId()));
|
15 |
+
$calcelURL = Mage::getUrl('*/*/cancel', array('order_id' => $order->getId()));
|
16 |
+
|
17 |
+
$api = $this->_pro->getApi()->setAmount($amount)
|
18 |
+
->setCurrencyCode($order->getBaseCurrencyCode())
|
19 |
+
->setInvNum($order->getIncrementId())
|
20 |
+
->setReturnUrl($returnURL)
|
21 |
+
->setCancelUrl($calcelURL)
|
22 |
+
->setSolutionType("sole")
|
23 |
+
->setPaymentAction($this->_pro->getConfig()->paymentAction);
|
24 |
+
|
25 |
+
if ($this->_pro->getConfig()->requireBillingAddress == Mage_Paypal_Model_Config::REQUIRE_BILLING_ADDRESS_ALL) {
|
26 |
+
$api->setRequireBillingAddress(1);
|
27 |
+
}
|
28 |
+
|
29 |
+
// supress or export shipping address
|
30 |
+
if ($order->getIsVirtual()) {
|
31 |
+
if ($this->_pro->getConfig()->requireBillingAddress == Mage_Paypal_Model_Config::REQUIRE_BILLING_ADDRESS_VIRTUAL) {
|
32 |
+
$api->setRequireBillingAddress(1);
|
33 |
+
}
|
34 |
+
$api->setSuppressShipping(true);
|
35 |
+
}
|
36 |
+
else {
|
37 |
+
$address = $order->getShippingAddress();
|
38 |
+
$isOverriden = 0;
|
39 |
+
|
40 |
+
if (true === $address->validate()) {
|
41 |
+
$isOverriden = 1;
|
42 |
+
$api->setAddress($address);
|
43 |
+
}
|
44 |
+
|
45 |
+
$order->getPayment()->setAdditionalInformation(
|
46 |
+
Mage_Paypal_Model_Express_Checkout::PAYMENT_INFO_TRANSPORT_SHIPPING_OVERRIDEN, $isOverriden
|
47 |
+
);
|
48 |
+
|
49 |
+
$order->getPayment()->save();
|
50 |
+
}
|
51 |
+
|
52 |
+
// Add line items
|
53 |
+
$paypalCart = Mage::getModel('paypal/cart', array($order));
|
54 |
+
$api->setPaypalCart($paypalCart)
|
55 |
+
->setIsLineItemsEnabled($this->_pro->getConfig()->lineItemsEnabled);
|
56 |
+
|
57 |
+
// Call API and redirect with token
|
58 |
+
$api->callSetExpressCheckout();
|
59 |
+
$token = $api->getToken();
|
60 |
+
|
61 |
+
$redirectUrl = $this->_pro->getConfig()->getExpressCheckoutStartUrl($token);
|
62 |
+
$order->getPayment()->setAdditionalInformation(Mage_Paypal_Model_Express_Checkout::PAYMENT_INFO_TRANSPORT_TOKEN, $token);
|
63 |
+
$order->getPayment()->save();
|
64 |
+
|
65 |
+
$this->_redirectUrl = $redirectUrl;
|
66 |
+
return $this;
|
67 |
+
}
|
68 |
+
|
69 |
+
public function setNewTransactionInfo($payment, $token){
|
70 |
+
$this->_pro->getApi()->setToken($token)->callGetExpressCheckoutDetails();
|
71 |
+
|
72 |
+
Mage::getSingleton('paypal/info')->importToPayment($this->_pro->getApi(), $payment);
|
73 |
+
$payment->setAdditionalInformation(Mage_Paypal_Model_Express_Checkout::PAYMENT_INFO_TRANSPORT_PAYER_ID, $this->_pro->getApi()->getPayerId())
|
74 |
+
->setAdditionalInformation(Mage_Paypal_Model_Express_Checkout::PAYMENT_INFO_TRANSPORT_TOKEN, $token)
|
75 |
+
;
|
76 |
+
|
77 |
+
$payment->save();
|
78 |
+
}
|
79 |
+
|
80 |
+
}
|
app/code/community/Folio3/Overdue/Model/Sales/Order/Payment.php
ADDED
@@ -0,0 +1,41 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class Folio3_Overdue_Model_Sales_Order_Payment extends Mage_Sales_Model_Order_Payment{
|
3 |
+
function resetExistingPaymentInfo(){
|
4 |
+
/*
|
5 |
+
cc_exp_month = NULL,
|
6 |
+
cc_exp_month = NULL,
|
7 |
+
cc_last4 = NULL,
|
8 |
+
last_trans_id = NULL,
|
9 |
+
cc_owner = NULL,
|
10 |
+
cc_type = NULL,
|
11 |
+
po_number = NULL,
|
12 |
+
cc_exp_year = NULL,
|
13 |
+
cc_number_enc = NULL,
|
14 |
+
additional_information = NULL
|
15 |
+
*/
|
16 |
+
|
17 |
+
$this->setCcExpMonth(null);
|
18 |
+
$this->setCcExpYear(null);
|
19 |
+
$this->setCcLast4(null);
|
20 |
+
$this->setLastTransId(null);
|
21 |
+
$this->setCcOwner(null);
|
22 |
+
$this->setCcType(null);
|
23 |
+
$this->setPoNumber(null);
|
24 |
+
$this->setCcNumberEnc(null);
|
25 |
+
$this->setData('additional_information', NULL);
|
26 |
+
|
27 |
+
return $this;
|
28 |
+
}
|
29 |
+
|
30 |
+
public function setCcInfo($ccInfo){
|
31 |
+
$this->setCcType($ccInfo['cc_type']);
|
32 |
+
$this->setCcExpMonth($ccInfo['cc_exp_month']);
|
33 |
+
$this->setCcExpYear($ccInfo['cc_exp_year']);
|
34 |
+
$this->setCcNumber($ccInfo['cc_number']);
|
35 |
+
$this->setCcCid($ccInfo['cc_cid']);
|
36 |
+
|
37 |
+
return $this;
|
38 |
+
}
|
39 |
+
}
|
40 |
+
|
41 |
+
?>
|
app/code/community/Folio3/Overdue/Model/System/Config/Source/Payment/Methods.php
ADDED
@@ -0,0 +1,40 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class Folio3_Overdue_Model_System_Config_Source_Payment_Methods
|
3 |
+
{
|
4 |
+
|
5 |
+
public function getAllOptions()
|
6 |
+
{
|
7 |
+
if (!$this->_options) {
|
8 |
+
$methods = $this->_getActivPaymentMethods();
|
9 |
+
$this->_options = $methods;
|
10 |
+
}
|
11 |
+
return $this->_options;
|
12 |
+
}
|
13 |
+
|
14 |
+
private function _getActivPaymentMethods()
|
15 |
+
{
|
16 |
+
$payments = Mage::getSingleton('payment/config')->getActiveMethods();
|
17 |
+
foreach ($payments as $paymentCode=>$paymentModel) {
|
18 |
+
if($paymentModel->canAuthorize()) {
|
19 |
+
$paymentTitle = Mage::getStoreConfig('payment/' . $paymentCode . '/title');
|
20 |
+
$methods[$paymentCode] = array(
|
21 |
+
'label' => $paymentTitle,
|
22 |
+
'value' => $paymentCode,
|
23 |
+
);
|
24 |
+
}
|
25 |
+
}
|
26 |
+
|
27 |
+
if(isset($methods['free'])){
|
28 |
+
unset($methods['free']);
|
29 |
+
}
|
30 |
+
|
31 |
+
return $methods;
|
32 |
+
|
33 |
+
}
|
34 |
+
|
35 |
+
public function toOptionArray(){
|
36 |
+
return $this->getAllOptions();
|
37 |
+
}
|
38 |
+
}
|
39 |
+
|
40 |
+
?>
|
app/code/community/Folio3/Overdue/controllers/AccountController.php
ADDED
@@ -0,0 +1,190 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
require_once Mage::getModuleDir('controllers', 'Mage_Customer').DS.'AccountController.php';
|
3 |
+
class Folio3_Overdue_AccountController extends Mage_Customer_AccountController{
|
4 |
+
/**
|
5 |
+
* Default customer account page
|
6 |
+
*/
|
7 |
+
public function indexAction()
|
8 |
+
{
|
9 |
+
$this->loadLayout();
|
10 |
+
$this->_initLayoutMessages('customer/session');
|
11 |
+
$this->_initLayoutMessages('catalog/session');
|
12 |
+
|
13 |
+
$this->getLayout()->getBlock('content')->append(
|
14 |
+
$this->getLayout()->createBlock('customer/account_dashboard')
|
15 |
+
);
|
16 |
+
|
17 |
+
$this->getLayout()->getBlock('head')->setTitle($this->__('My Account'));
|
18 |
+
$this->renderLayout();
|
19 |
+
}
|
20 |
+
|
21 |
+
public function overdueAction(){
|
22 |
+
$this->loadLayout();
|
23 |
+
$this->_initLayoutMessages('customer/session');
|
24 |
+
$this->_initLayoutMessages('catalog/session');
|
25 |
+
|
26 |
+
$this->renderLayout();
|
27 |
+
}
|
28 |
+
|
29 |
+
public function payAction(){
|
30 |
+
$invoice_id = Mage::app()->getRequest()->getParam('invoice_id');
|
31 |
+
|
32 |
+
if(!$invoice_id){
|
33 |
+
$this->_redirect('*/*/overdue');
|
34 |
+
return;
|
35 |
+
}
|
36 |
+
|
37 |
+
$this->loadLayout();
|
38 |
+
$this->_initLayoutMessages('customer/session');
|
39 |
+
$this->_initLayoutMessages('catalog/session');
|
40 |
+
|
41 |
+
$this->renderLayout();
|
42 |
+
}
|
43 |
+
|
44 |
+
public function payPostAction(){
|
45 |
+
if (!$this->_validateFormKey()) {
|
46 |
+
$this->_redirect('*/*/overdue');
|
47 |
+
return;
|
48 |
+
}
|
49 |
+
|
50 |
+
$params = Mage::app()->getRequest()->getPost();
|
51 |
+
if($this->_validatePayPost($params)){
|
52 |
+
$invoice_id = Mage::app()->getRequest()->getParam('invoice_id');
|
53 |
+
$invoice = Mage::getModel('sales/order_invoice')->load($invoice_id);
|
54 |
+
$order = $invoice->getOrder();
|
55 |
+
|
56 |
+
$amount = (float) ($order->getTotalDue());
|
57 |
+
$payment = $order->getPayment()->resetExistingPaymentInfo();
|
58 |
+
$PaymentInfo = $params['payment'];
|
59 |
+
|
60 |
+
//--- Change Payment Method
|
61 |
+
$payment->setMethod($PaymentInfo['method']);
|
62 |
+
//$payment->getMethodInstance()->assignData($PaymentInfo);
|
63 |
+
|
64 |
+
try {
|
65 |
+
$AuthInfo = null;
|
66 |
+
if($payment->getMethodInstance()->isGateway()){
|
67 |
+
$payment->setCcInfo($PaymentInfo);
|
68 |
+
$AuthInfo = $payment->getMethodInstance()->authorize($payment, $amount);
|
69 |
+
|
70 |
+
if($AuthInfo instanceof Mes_Gateway_Model_Paymentmodel){
|
71 |
+
$payment->setParentTransactionId($payment->getTransactionId());
|
72 |
+
}
|
73 |
+
}
|
74 |
+
else{
|
75 |
+
$AuthInfo = $payment->getMethodInstance()->newAuthorization($payment, $amount, $PaymentInfo);
|
76 |
+
}
|
77 |
+
|
78 |
+
if (is_object($AuthInfo) && $AuthInfo instanceof Mage_Payment_Model_Method_Abstract) {
|
79 |
+
if ($AuthInfo->isGateway()) {
|
80 |
+
//-- For Gateway Payment Methods (Credit Card)
|
81 |
+
$this->_savePaymentInfo($payment, $amount);
|
82 |
+
return;
|
83 |
+
} else {
|
84 |
+
//-- For NonGateway Payment Methods (Paypal Express)
|
85 |
+
$this->_redirectUrl($AuthInfo->getData('_redirect_url'));
|
86 |
+
return;
|
87 |
+
}
|
88 |
+
}
|
89 |
+
|
90 |
+
throw new Exception(__('Authorization returned Invalid Object!'));
|
91 |
+
}
|
92 |
+
catch (Exception $e) {
|
93 |
+
Mage::getSingleton('customer/session')->addError($e->getMessage());
|
94 |
+
$this->_redirectUrl(Mage::getUrl('*/*/overdue'));
|
95 |
+
return;
|
96 |
+
}
|
97 |
+
}
|
98 |
+
else{
|
99 |
+
Mage::getSingleton('customer/session')->addError('Invalid Post Data!');
|
100 |
+
|
101 |
+
if(isset($params['order_id']))
|
102 |
+
$this->_redirect('*/*/pay', array('order_id' => $params['order_id']));
|
103 |
+
else
|
104 |
+
$this->_redirect('*/*/overdue');
|
105 |
+
|
106 |
+
return;
|
107 |
+
}
|
108 |
+
|
109 |
+
//--- Your Payment Code Business Logic Here!
|
110 |
+
|
111 |
+
}
|
112 |
+
|
113 |
+
public function authAction() {
|
114 |
+
$order_id = (int) $this->getRequest()->getParam('order_id');
|
115 |
+
$order = Mage::getModel('sales/order')->load($order_id);
|
116 |
+
$payment = $order->getPayment();
|
117 |
+
|
118 |
+
try {
|
119 |
+
$amount = (float) ($order->getTotalDue());
|
120 |
+
$token = Mage::app()->getRequest()->getParam('token');
|
121 |
+
$payment->getMethodInstance()->setNewTransactionInfo($payment, $token);
|
122 |
+
$payment->getMethodInstance()->authorize($payment, $amount);
|
123 |
+
|
124 |
+
$this->_savePaymentInfo($payment, $amount);
|
125 |
+
}
|
126 |
+
catch (Exception $e) {
|
127 |
+
Mage::getSingleton('customer/session')->addError($e->getMessage());
|
128 |
+
$this->_redirectUrl(Mage::getUrl('*/*/overdue'));
|
129 |
+
return;
|
130 |
+
}
|
131 |
+
}
|
132 |
+
|
133 |
+
private function _savePaymentInfo(Mage_Sales_Model_Order_Payment $payment, $amount) {
|
134 |
+
$order = $payment->getOrder();
|
135 |
+
|
136 |
+
$message = '';
|
137 |
+
$state = $order->getState();
|
138 |
+
$status = $order->getStatus();
|
139 |
+
|
140 |
+
$formatedPrice = $order->getBaseCurrency()->formatTxt($amount);
|
141 |
+
|
142 |
+
if ($payment->getIsTransactionPending()) {
|
143 |
+
$message = Mage::helper('paypal')->__('Authorizing amount of %s is pending approval on gateway.', $formatedPrice);
|
144 |
+
|
145 |
+
$state = Mage_Sales_Model_Order::STATE_PAYMENT_REVIEW;
|
146 |
+
if ($payment->getIsFraudDetected()) {
|
147 |
+
$status = Mage_Sales_Model_Order::STATUS_FRAUD;
|
148 |
+
}
|
149 |
+
}
|
150 |
+
else {
|
151 |
+
$message = Mage::helper('paypal')->__('Authorized amount of %s.', $formatedPrice);
|
152 |
+
}
|
153 |
+
|
154 |
+
$transaction = $payment->addTransaction(
|
155 |
+
Mage_Sales_Model_Order_Payment_Transaction::TYPE_AUTH, null, false, $message
|
156 |
+
)->setIsClosed(0)->save();
|
157 |
+
|
158 |
+
$payment->importTransactionInfo($transaction);
|
159 |
+
|
160 |
+
$unpaidInvoice = $order->getInvoiceCollection()->getFirstItem();
|
161 |
+
$unpaidInvoice->setIsPaid(false);
|
162 |
+
$unpaidInvoice->capture();
|
163 |
+
|
164 |
+
Mage::getModel('core/resource_transaction')
|
165 |
+
->addObject($payment)
|
166 |
+
->addObject($unpaidInvoice)
|
167 |
+
->addObject($order)
|
168 |
+
->save();
|
169 |
+
|
170 |
+
Mage::getSingleton('customer/session')->addSuccess("Thank you! Your payment has been paid successfully.");
|
171 |
+
$this->_redirectUrl(Mage::getUrl('*/*/overdue'));
|
172 |
+
}
|
173 |
+
|
174 |
+
|
175 |
+
private function _validatePayPost($params){
|
176 |
+
if(isset($params['order_id']) && $params['order_id'] != '') {
|
177 |
+
if (isset($params['invoice_id']) && $params['invoice_id'] != '') {
|
178 |
+
$order = Mage::getModel('sales/order')->load($params['order_id']);
|
179 |
+
$customer_id = Mage::getSingleton('customer/session')->getId();
|
180 |
+
|
181 |
+
if ($order->getCustomerId() == $customer_id) {
|
182 |
+
return true;
|
183 |
+
}
|
184 |
+
}
|
185 |
+
}
|
186 |
+
|
187 |
+
return false;
|
188 |
+
}
|
189 |
+
}
|
190 |
+
?>
|
app/code/community/Folio3/Overdue/etc/config.xml
ADDED
@@ -0,0 +1,79 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<modules>
|
4 |
+
<Folio3_Overdue>
|
5 |
+
<version>1.0.0</version>
|
6 |
+
</Folio3_Overdue>
|
7 |
+
</modules>
|
8 |
+
<global>
|
9 |
+
<models>
|
10 |
+
<folio3_overdue>
|
11 |
+
<class>Folio3_Overdue_Model</class>
|
12 |
+
</folio3_overdue>
|
13 |
+
<paypal>
|
14 |
+
<rewrite>
|
15 |
+
<express>Folio3_Overdue_Model_Paypal_Express</express>
|
16 |
+
</rewrite>
|
17 |
+
</paypal>
|
18 |
+
<sales>
|
19 |
+
<rewrite>
|
20 |
+
<order_payment>Folio3_Overdue_Model_Sales_Order_Payment</order_payment>
|
21 |
+
</rewrite>
|
22 |
+
</sales>
|
23 |
+
</models>
|
24 |
+
<blocks>
|
25 |
+
<folio3_overdue>
|
26 |
+
<class>Folio3_Overdue_Block</class>
|
27 |
+
</folio3_overdue>
|
28 |
+
<customer>
|
29 |
+
<rewrite>
|
30 |
+
<account_navigation>Folio3_Overdue_Block_Customer_Account_Navigation</account_navigation>
|
31 |
+
</rewrite>
|
32 |
+
</customer>
|
33 |
+
</blocks>
|
34 |
+
<helpers>
|
35 |
+
<folio3_overdue>
|
36 |
+
<class>Folio3_Overdue_Helper</class>
|
37 |
+
</folio3_overdue>
|
38 |
+
</helpers>
|
39 |
+
</global>
|
40 |
+
<frontend>
|
41 |
+
<routers>
|
42 |
+
<customer>
|
43 |
+
<args>
|
44 |
+
<modules>
|
45 |
+
<Folio3_Overdue before="Mage_Customer">Folio3_Overdue</Folio3_Overdue>
|
46 |
+
</modules>
|
47 |
+
</args>
|
48 |
+
</customer>
|
49 |
+
</routers>
|
50 |
+
<layout>
|
51 |
+
<updates>
|
52 |
+
<folio3_overdue>
|
53 |
+
<file>folio3_overdue.xml</file>
|
54 |
+
</folio3_overdue>
|
55 |
+
</updates>
|
56 |
+
</layout>
|
57 |
+
</frontend>
|
58 |
+
<adminhtml>
|
59 |
+
<acl>
|
60 |
+
<resources>
|
61 |
+
<admin>
|
62 |
+
<children>
|
63 |
+
<system>
|
64 |
+
<children>
|
65 |
+
<config>
|
66 |
+
<children>
|
67 |
+
<Overdue>
|
68 |
+
<title>Overdue Payments</title>
|
69 |
+
</Overdue>
|
70 |
+
</children>
|
71 |
+
</config>
|
72 |
+
</children>
|
73 |
+
</system>
|
74 |
+
</children>
|
75 |
+
</admin>
|
76 |
+
</resources>
|
77 |
+
</acl>
|
78 |
+
</adminhtml>
|
79 |
+
</config>
|
app/code/community/Folio3/Overdue/etc/system.xml
ADDED
@@ -0,0 +1,42 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<tabs>
|
4 |
+
<folio3 translate="label" module="folio3_overdue">
|
5 |
+
<label>Folio3 Extensions</label>
|
6 |
+
<sort_order>100</sort_order>
|
7 |
+
</folio3>
|
8 |
+
</tabs>
|
9 |
+
<sections>
|
10 |
+
<Overdue translate="label" module="folio3_overdue">
|
11 |
+
<label>Payments Overdue</label>
|
12 |
+
<tab>folio3</tab>
|
13 |
+
<frontend_type>text</frontend_type>
|
14 |
+
<sort_order>998</sort_order>
|
15 |
+
<show_in_default>1</show_in_default>
|
16 |
+
<show_in_website>1</show_in_website>
|
17 |
+
<show_in_store>1</show_in_store>
|
18 |
+
<groups>
|
19 |
+
<config translate="label">
|
20 |
+
<label>Configuration</label>
|
21 |
+
<frontend_type>text</frontend_type>
|
22 |
+
<sort_order>1</sort_order>
|
23 |
+
<show_in_default>1</show_in_default>
|
24 |
+
<show_in_website>0</show_in_website>
|
25 |
+
<show_in_store>1</show_in_store>
|
26 |
+
<fields>
|
27 |
+
<allowedMethods translate="label">
|
28 |
+
<label>Allowed Payment Methods</label>
|
29 |
+
<comment>Allowed Payment Methods</comment>
|
30 |
+
<frontend_type>multiselect</frontend_type>
|
31 |
+
<source_model>folio3_overdue/system_config_source_payment_methods</source_model>
|
32 |
+
<sort_order>1</sort_order>
|
33 |
+
<show_in_default>1</show_in_default>
|
34 |
+
<show_in_website>0</show_in_website>
|
35 |
+
<show_in_store>1</show_in_store>
|
36 |
+
</allowedMethods>
|
37 |
+
</fields>
|
38 |
+
</config>
|
39 |
+
</groups>
|
40 |
+
</Overdue>
|
41 |
+
</sections>
|
42 |
+
</config>
|
app/design/frontend/base/default/layout/folio3_overdue.xml
ADDED
@@ -0,0 +1,49 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<layout version="0.1.0">
|
3 |
+
<customer_account>
|
4 |
+
<reference name="customer_account_navigation">
|
5 |
+
<action method="addLink" translate="label">
|
6 |
+
<name>overdue</name>
|
7 |
+
<path>customer/account/overdue</path>
|
8 |
+
<label>Overdue Payments</label>
|
9 |
+
</action>
|
10 |
+
</reference>
|
11 |
+
</customer_account>
|
12 |
+
|
13 |
+
<customer_account_overdue>
|
14 |
+
<label>Customer Overdue Payments</label>
|
15 |
+
<update handle="customer_account"/>
|
16 |
+
|
17 |
+
<reference name="my.account.wrapper">
|
18 |
+
<block type="folio3_overdue/grid" name="folio3.overdue.grid" template="folio3_overdue/grid.phtml" />
|
19 |
+
</reference>
|
20 |
+
</customer_account_overdue>
|
21 |
+
|
22 |
+
<customer_account_pay>
|
23 |
+
<label>Customer Overdue Payments</label>
|
24 |
+
<update handle="customer_account"/>
|
25 |
+
|
26 |
+
<reference name="head">
|
27 |
+
<action method="addItem"><type>skin_js</type><name>js/opcheckout.js</name></action>
|
28 |
+
</reference>
|
29 |
+
|
30 |
+
<reference name="my.account.wrapper">
|
31 |
+
<block type="folio3_overdue/invoice" name="folio3.overdue.invoice" template="folio3_overdue/invoice.phtml">
|
32 |
+
<block type="folio3_overdue/invoice" name="folio3.overdue.invoice.info" template="folio3_overdue/invoice/info.phtml" />
|
33 |
+
|
34 |
+
<!-- PAYMENTS METHOD FORM -->
|
35 |
+
<block type="folio3_overdue/payment" name="folio3.overdue.invoice.payment" template="folio3_overdue/invoice/payment.phtml">
|
36 |
+
<block type="folio3_overdue/payment_methods" name="folio3.overdue.invoice.payment.methods" template="folio3_overdue/invoice/payment/methods.phtml">
|
37 |
+
<action method="setMethodFormTemplate"><method>purchaseorder</method><template>payment/form/purchaseorder.phtml</template></action>
|
38 |
+
</block>
|
39 |
+
</block>
|
40 |
+
</block>
|
41 |
+
</reference>
|
42 |
+
</customer_account_pay>
|
43 |
+
|
44 |
+
<customer_group_general>
|
45 |
+
<reference name="customer_account_navigation">
|
46 |
+
<action method="removeLinkByUrl"><url>customer/account/overdue/</url></action>
|
47 |
+
</reference>
|
48 |
+
</customer_group_general>
|
49 |
+
</layout>
|
app/design/frontend/base/default/template/folio3_overdue/grid.phtml
ADDED
@@ -0,0 +1,52 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<div class="page-title">
|
2 |
+
<h1><?php echo $this->__('Overdue Payments'); ?></h1>
|
3 |
+
</div>
|
4 |
+
<?php echo $this->getMessagesBlock()->getGroupedHtml() ?>
|
5 |
+
<?php //echo $this->getPagerHtml(); ?>
|
6 |
+
<?php $_invoices = $this->getInvoices(); ?>
|
7 |
+
<?php if($_invoices->getSize()): ?>
|
8 |
+
<table class="data-table" id="overdue-payments">
|
9 |
+
<col width="1" />
|
10 |
+
<col width="1" />
|
11 |
+
<col />
|
12 |
+
<col width="1" />
|
13 |
+
<col width="1" />
|
14 |
+
<col width="1" />
|
15 |
+
<thead>
|
16 |
+
<tr>
|
17 |
+
<th><?php echo $this->__('Invoice #') ?></th>
|
18 |
+
<th><?php echo $this->__('Date') ?></th>
|
19 |
+
<th><?php echo $this->__('Ship To') ?></th>
|
20 |
+
<th><span class="nobr"><?php echo $this->__('Paid') ?></span></th>
|
21 |
+
<th><span class="nobr"><?php echo $this->__('Due') ?></span></th>
|
22 |
+
<th><span class="nobr"><?php echo $this->__('Total') ?></span></th>
|
23 |
+
<!--<th><span class="nobr"><?php /*echo $this->__('Order Status') */?></span></th>-->
|
24 |
+
<th> </th>
|
25 |
+
</tr>
|
26 |
+
</thead>
|
27 |
+
<tbody>
|
28 |
+
<?php $_odd = ''; ?>
|
29 |
+
<?php foreach ($_invoices as $_invoice): ?>
|
30 |
+
<tr>
|
31 |
+
<td><?php echo $_invoice->getIncrementId() ?></td>
|
32 |
+
<td><span class="nobr"><?php echo $this->formatDate($_invoice->getCreatedAtStoreDate()) ?></span></td>
|
33 |
+
<td><?php echo $_invoice->getShippingAddress() ? $this->escapeHtml($_invoice->getShippingAddress()->getName()) : ' ' ?></td>
|
34 |
+
<td><?php echo Mage::helper('core')->currency($_invoice->getTotalPaid()) ?></td>
|
35 |
+
<td><?php echo Mage::helper('core')->currency($_invoice->getTotalDue()) ?></td>
|
36 |
+
<td><?php echo Mage::helper('core')->currency($_invoice->getGrandTotal()) ?></td>
|
37 |
+
<td class="a-center">
|
38 |
+
<span class="nobr"><a href="<?php echo $this->getViewUrl($_invoice) ?>"><?php echo $this->__('View Order') ?></a>
|
39 |
+
<?php /*<span class="separator">|</span><a href="<?php echo $this->getTrackUrl($_invoice) ?>"><?php echo $this->__('Track Order') ?></a> */ ?>
|
40 |
+
<?php if ($this->helper('folio3_overdue')->canPayDues($_invoice)) : ?>
|
41 |
+
<span class="separator">|</span> <a href="<?php echo $this->getPayUrl($_invoice) ?>" class="link-reorder"><?php echo $this->__('Pay') ?></a>
|
42 |
+
<?php endif ?>
|
43 |
+
</span>
|
44 |
+
</td>
|
45 |
+
</tr>
|
46 |
+
<?php endforeach; ?>
|
47 |
+
</tbody>
|
48 |
+
</table>
|
49 |
+
<script type="text/javascript">decorateTable('overdue-payments');</script>
|
50 |
+
<?php else: ?>
|
51 |
+
<p><?php echo $this->__('You have no overdue payments.'); ?></p>
|
52 |
+
<?php endif ?>
|
app/design/frontend/base/default/template/folio3_overdue/invoice.phtml
ADDED
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php $invoice = $this->getInvoice(); ?>
|
2 |
+
<div class="page-title">
|
3 |
+
<h1><?php echo $this->__('Overdue Payments') ?></h1>
|
4 |
+
<h3><?php echo $this->__('Invoice# ' . $invoice->getIncrementId()) ?></h3>
|
5 |
+
</div>
|
6 |
+
|
7 |
+
<?php echo $this->getMessagesBlock()->toHtml() ?>
|
8 |
+
<?php echo $this->getChildHtml('folio3.overdue.invoice.info'); ?>
|
9 |
+
<br />
|
10 |
+
|
11 |
+
<?php if($invoice): ?>
|
12 |
+
<?php echo $this->getChildHtml('folio3.overdue.invoice.payment'); ?>
|
13 |
+
<?php endif; ?>
|
app/design/frontend/base/default/template/folio3_overdue/invoice/info.phtml
ADDED
@@ -0,0 +1,38 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php //echo $this->getPagerHtml(); ?>
|
2 |
+
<?php $invoices = $this->getInvoices(); ?>
|
3 |
+
<?php if($invoices->getSize()): ?>
|
4 |
+
<table class="data-table" id="overdue-payments">
|
5 |
+
<col width="1" />
|
6 |
+
<col width="1" />
|
7 |
+
<col />
|
8 |
+
<col width="1" />
|
9 |
+
<col width="1" />
|
10 |
+
<col width="1" />
|
11 |
+
<thead>
|
12 |
+
<tr>
|
13 |
+
<th><?php echo $this->__('Invoice #') ?></th>
|
14 |
+
<th><?php echo $this->__('Date') ?></th>
|
15 |
+
<th><?php echo $this->__('Ship To') ?></th>
|
16 |
+
<th><span class="nobr"><?php echo $this->__('Paid') ?></span></th>
|
17 |
+
<th><span class="nobr"><?php echo $this->__('Due') ?></span></th>
|
18 |
+
<th><span class="nobr"><?php echo $this->__('Total') ?></span></th>
|
19 |
+
</tr>
|
20 |
+
</thead>
|
21 |
+
<tbody>
|
22 |
+
<?php $_odd = ''; ?>
|
23 |
+
<?php foreach ($invoices as $invoice): ?>
|
24 |
+
<tr>
|
25 |
+
<td><?php echo $invoice->getIncrementId() ?></td>
|
26 |
+
<td><span class="nobr"><?php echo $this->formatDate($invoice->getCreatedAtStoreDate()) ?></span></td>
|
27 |
+
<td><?php echo $invoice->getShippingAddress() ? $this->escapeHtml($invoice->getShippingAddress()->getName()) : ' ' ?></td>
|
28 |
+
<td><?php echo Mage::helper('core')->currency($invoice->getTotalPaid()) ?></td>
|
29 |
+
<td><?php echo Mage::helper('core')->currency($invoice->getTotalDue()) ?></td>
|
30 |
+
<td><?php echo Mage::helper('core')->currency($invoice->getGrandTotal()) ?></td>
|
31 |
+
</tr>
|
32 |
+
<?php endforeach; ?>
|
33 |
+
</tbody>
|
34 |
+
</table>
|
35 |
+
<script type="text/javascript">decorateTable('overdue-payments');</script>
|
36 |
+
<?php else: ?>
|
37 |
+
<p><?php echo $this->__('You have no overdue payments.'); ?></p>
|
38 |
+
<?php endif ?>
|
app/design/frontend/base/default/template/folio3_overdue/invoice/payment.phtml
ADDED
@@ -0,0 +1,74 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<script type="text/javascript">
|
2 |
+
//<![CDATA[
|
3 |
+
var quoteBaseGrandTotal = <?php echo (float)$this->getQuoteBaseGrandTotal(); ?>;
|
4 |
+
var checkQuoteBaseGrandTotal = quoteBaseGrandTotal;
|
5 |
+
var payment = new Payment('co-payment-form', '<?php echo $this->getPayPostUrl('*/*/payPost', array('_secure' => $this->getRequest()->isSecure())) ?>');
|
6 |
+
var lastPrice;
|
7 |
+
//]]>
|
8 |
+
</script>
|
9 |
+
|
10 |
+
<!--<div id="checkout-step-payment" class="f3_overdue">-->
|
11 |
+
<form action="<?php echo $this->getPayPostUrl(); ?>" method="POST" id="co-payment-form">
|
12 |
+
<fieldset>
|
13 |
+
<dl class="sp-methods f3_overdue">
|
14 |
+
<?php echo $this->getChildHtml('folio3.overdue.invoice.payment.methods') ?>
|
15 |
+
</dl>
|
16 |
+
</fieldset>
|
17 |
+
<fieldset class="no-display">
|
18 |
+
<input name="form_key" type="hidden" value="<?php echo Mage::getSingleton('core/session')->getFormKey() ?>" />
|
19 |
+
<input name="order_id" type="hidden" value="<?php echo Mage::helper('folio3_overdue')->getInvoice()->getOrder()->getId(); ?>" />
|
20 |
+
<input name="invoice_id" type="hidden" value="<?php echo Mage::helper('folio3_overdue')->getInvoice()->getId(); ?>" />
|
21 |
+
</fieldset>
|
22 |
+
<div class="buttons-set">
|
23 |
+
<p class="required"><?php echo $this->__('* Required Fields') ?></p>
|
24 |
+
<p class="back-link"><a href="<?php echo $this->escapeUrl($this->getBackUrl()) ?>"><small>« </small><?php echo $this->__('Back') ?></a></p>
|
25 |
+
<button data-action="save-overdue-payment" type="submit" title="<?php echo Mage::helper('core')->quoteEscape($this->__('Submit')) ?>" class="button"><span><span><?php echo $this->__('Submit') ?></span></span></button>
|
26 |
+
</div>
|
27 |
+
</form>
|
28 |
+
|
29 |
+
<div class="tool-tip" id="payment-tool-tip" style="display:none;">
|
30 |
+
<div class="btn-close"><a href="#" id="payment-tool-tip-close" title="<?php echo $this->__('Close') ?>"><?php echo $this->__('Close') ?></a></div>
|
31 |
+
<div class="tool-tip-content"><img src="<?php echo $this->getSkinUrl('images/cvv.gif') ?>" alt="<?php echo $this->__('Card Verification Number Visual Reference') ?>" title="<?php echo $this->__('Card Verification Number Visual Reference') ?>" /></div>
|
32 |
+
</div>
|
33 |
+
<!--</div>-->
|
34 |
+
|
35 |
+
<script type="text/javascript">
|
36 |
+
//< ![CDATA[
|
37 |
+
var customForm = new VarienForm('co-payment-form', true);
|
38 |
+
|
39 |
+
jQuery('#co-payment-form').ready(function(){
|
40 |
+
jQuery('#co-payment-form').submit(function(){
|
41 |
+
if(!payment.validate()) return false;
|
42 |
+
});
|
43 |
+
|
44 |
+
jQuery('.cvv-what-is-this').each(function(index, element){
|
45 |
+
Event.observe(element, 'click', toggleToolTip);
|
46 |
+
});
|
47 |
+
});
|
48 |
+
//]]>
|
49 |
+
</script>
|
50 |
+
|
51 |
+
<script type="text/javascript">
|
52 |
+
//<![CDATA[
|
53 |
+
function toggleToolTip(event){
|
54 |
+
if($('payment-tool-tip')){
|
55 |
+
$('payment-tool-tip').setStyle({
|
56 |
+
top: (Event.pointerY(event)-560)+'px'//,
|
57 |
+
//left: (Event.pointerX(event)+100)+'px'
|
58 |
+
})
|
59 |
+
$('payment-tool-tip').toggle();
|
60 |
+
}
|
61 |
+
Event.stop(event);
|
62 |
+
}
|
63 |
+
if($('payment-tool-tip-close')){
|
64 |
+
Event.observe($('payment-tool-tip-close'), 'click', toggleToolTip);
|
65 |
+
}
|
66 |
+
//]]>
|
67 |
+
</script>
|
68 |
+
|
69 |
+
<script type="text/javascript">
|
70 |
+
//<![CDATA[
|
71 |
+
payment.currentMethod = "<?php echo $this->getSelectedMethodCode() ?>";
|
72 |
+
//]]>
|
73 |
+
});
|
74 |
+
</script>
|
app/design/frontend/base/default/template/folio3_overdue/invoice/payment/methods.phtml
ADDED
@@ -0,0 +1,46 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Folio3 Overdue payment methods
|
4 |
+
*
|
5 |
+
* @var $this Folio3_Overdue_Block_Payment_Methods
|
6 |
+
*/
|
7 |
+
?>
|
8 |
+
<?php
|
9 |
+
$methods = $this->getMethods();
|
10 |
+
$oneMethod = count($methods) <= 1;
|
11 |
+
?>
|
12 |
+
<?php if (empty($methods)): ?>
|
13 |
+
<dt>
|
14 |
+
<?php echo $this->__('No Payment Methods') ?>
|
15 |
+
</dt>
|
16 |
+
<?php else:
|
17 |
+
foreach ($methods as $_method):
|
18 |
+
$_code = $_method->getCode();
|
19 |
+
?>
|
20 |
+
<dt id="dt_method_<?php echo $_code ?>">
|
21 |
+
<?php if(!$oneMethod): ?>
|
22 |
+
<input id="p_method_<?php echo $_code ?>" value="<?php echo $_code ?>" type="radio" name="payment[method]" title="<?php echo $this->escapeHtml($_method->getTitle()) ?>" onclick="payment.switchMethod('<?php echo $_code ?>')"<?php if($this->getSelectedMethodCode()==$_code): ?> checked="checked"<?php endif; ?> class="radio left" />
|
23 |
+
<?php else: ?>
|
24 |
+
<span class="no-display"><input id="p_method_<?php echo $_code ?>" value="<?php echo $_code ?>" type="radio" name="payment[method]" checked="checked" class="radio" /></span>
|
25 |
+
<?php $oneMethod = $_code; ?>
|
26 |
+
<?php endif; ?>
|
27 |
+
<label for="p_method_<?php echo $_code ?>"><?php echo $this->escapeHtml($this->getMethodTitle($_method)) ?> <?php echo $this->getMethodLabelAfterHtml($_method) ?></label>
|
28 |
+
</dt>
|
29 |
+
<?php if ($html = $this->getPaymentMethodFormHtml($_method)): ?>
|
30 |
+
<dd id="dd_method_<?php echo $_code ?>">
|
31 |
+
<?php echo $html; ?>
|
32 |
+
</dd>
|
33 |
+
<?php endif; ?>
|
34 |
+
<?php endforeach;
|
35 |
+
endif;
|
36 |
+
?>
|
37 |
+
<?php echo $this->getChildChildHtml('additional'); ?>
|
38 |
+
<script type="text/javascript">
|
39 |
+
//<![CDATA[
|
40 |
+
<?php echo $this->getChildChildHtml('scripts'); ?>
|
41 |
+
payment.init();
|
42 |
+
<?php if (is_string($oneMethod)): ?>
|
43 |
+
payment.switchMethod('<?php echo $oneMethod ?>');
|
44 |
+
<?php endif; ?>
|
45 |
+
//]]>
|
46 |
+
</script>
|
app/etc/modules/Folio3_Overdue.xml
ADDED
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<config>
|
2 |
+
<modules>
|
3 |
+
<Folio3_Overdue>
|
4 |
+
<active>true</active>
|
5 |
+
<codePool>community</codePool>
|
6 |
+
</Folio3_Overdue>
|
7 |
+
</modules>
|
8 |
+
</config>
|
package.xml
ADDED
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<package>
|
3 |
+
<name>folio3_overdue</name>
|
4 |
+
<version>1.0.0</version>
|
5 |
+
<stability>stable</stability>
|
6 |
+
<license uri="https://opensource.org/licenses/OSL-3.0">Open Software License (OSL)</license>
|
7 |
+
<channel>community</channel>
|
8 |
+
<extends/>
|
9 |
+
<summary>Basic functionality to pay overdue payments/unpaid invoices that are created by the administrator and is visible on the customer dashboard for further payment.</summary>
|
10 |
+
<description>Basic functionality to pay overdue payments/unpaid invoices that are created by the administrator and is visible on the customer dashboard for further payment.</description>
|
11 |
+
<notes>Basic functionality to pay overdue payments/unpaid invoices that are created by the administrator and is visible on the customer dashboard for further payment.</notes>
|
12 |
+
<authors><author><name>Folio3</name><user>MAG003179920</user><email>ecommerce@folio3.com</email></author></authors>
|
13 |
+
<date>2016-10-04</date>
|
14 |
+
<time>08:57:25</time>
|
15 |
+
<contents><target name="magecommunity"><dir name="Folio3"><dir name="Overdue"><dir name="Block"><dir name="Customer"><dir name="Account"><file name="Navigation.php" hash="ae427a314d9cf84191aa7ae08f22af56"/></dir></dir><file name="Grid.php" hash="a9d8265e4736d4763058b842d6864455"/><file name="Invoice.php" hash="49b689067ff47b548a41322a82406e20"/><dir name="Payment"><file name="Methods.php" hash="4d945d521738e0695083e21769a8eb36"/></dir><file name="Payment.php" hash="65b6a5da6e93c53583c7c2970ad4ae20"/></dir><dir name="Helper"><file name="Data.php" hash="8f38250e918fa0b39cc0076870bf570a"/></dir><dir name="Model"><dir name="Paypal"><file name="Express.php" hash="8c4a83f87100a7af8546612d446309fc"/></dir><dir name="Sales"><dir name="Order"><file name="Payment.php" hash="5d0d0805b76b419e96d4046c1e69be69"/></dir></dir><dir name="System"><dir name="Config"><dir name="Source"><dir name="Payment"><file name="Methods.php" hash="8f70703d545cb783f09ff5b999874abd"/></dir></dir></dir></dir></dir><dir name="controllers"><file name="AccountController.php" hash="dfba0491317836f8250cbeb6bb9c6c70"/></dir><dir name="etc"><file name="config.xml" hash="a826b7d6d41b51fb814a781cb8820509"/><file name="system.xml" hash="f46c052e2cbe0ed2421b19b62d58d4b8"/></dir></dir></dir></target><target name="magedesign"><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="folio3_overdue.xml" hash="2943d4c7b0815da2032a27e4eaf7278f"/></dir><dir name="template"><dir name="folio3_overdue"><file name="grid.phtml" hash="ca72a5a29ae70340781abc0162d56dfe"/><dir name="invoice"><file name="info.phtml" hash="da14d85a35f30ccedb40c5c5a87f4df0"/><dir name="payment"><file name="methods.phtml" hash="8419dc2f62522eb4d12e109dad3276ed"/></dir><file name="payment.phtml" hash="832b4ba8e6f24f890622b8d385e10a61"/></dir><file name="invoice.phtml" hash="537ea53d5d0ae09f8a2bbcd856f1997c"/></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Folio3_Overdue.xml" hash="8aefc56264b5ebc7fd181c6f6be9fad8"/></dir></target></contents>
|
16 |
+
<compatible/>
|
17 |
+
<dependencies><required><php><min>5.1.0</min><max>6.0.0</max></php></required></dependencies>
|
18 |
+
</package>
|