1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* |
5
|
|
|
* |
6
|
|
|
* @category Mygento |
7
|
|
|
* @package Mygento_Payture |
8
|
|
|
* @copyright Copyright © 2016 NKS LLC. (http://www.mygento.ru) |
9
|
|
|
*/ |
10
|
|
|
class Mygento_Payture_Block_Info extends Mage_Payment_Block_Info |
11
|
|
|
{ |
12
|
|
|
|
13
|
|
|
public function getOid() |
14
|
|
|
{ |
15
|
|
|
$info = $this->getInfo(); |
16
|
|
|
if ($info instanceof Mage_Sales_Model_Order_Payment) { |
17
|
|
|
$order = $info->getOrder(); |
18
|
|
|
//$id=$order->getData('increment_id'); |
|
|
|
|
19
|
|
|
//$order=Mage::getSingleton('sales/order')->loadByIncrementId($id); |
|
|
|
|
20
|
|
|
return $order->getId(); |
21
|
|
|
} |
22
|
|
|
return false; |
23
|
|
|
} |
24
|
|
|
|
25
|
|
|
public function getPaylink() |
26
|
|
|
{ |
27
|
|
|
return Mage::helper('payture')->getLink($this->getOid()); |
28
|
|
|
} |
29
|
|
|
|
30
|
|
|
public function isPaid() |
31
|
|
|
{ |
32
|
|
|
$order = Mage::getModel('sales/order')->load($this->getOid()); |
33
|
|
|
if (!$order->hasInvoices()) { |
34
|
|
|
return false; |
35
|
|
|
} |
36
|
|
|
return true; |
37
|
|
|
} |
38
|
|
|
|
39
|
|
|
protected function _construct() |
40
|
|
|
{ |
41
|
|
|
parent::_construct(); |
42
|
|
|
$this->setTemplate('mygento/payture/info.phtml'); |
43
|
|
|
} |
44
|
|
|
|
45
|
|
|
public function getOrder() |
46
|
|
|
{ |
47
|
|
|
$info = $this->getInfo(); |
48
|
|
|
if ($info instanceof Mage_Sales_Model_Order_Payment) { |
49
|
|
|
return $info->getOrder(); |
50
|
|
|
} |
51
|
|
|
} |
52
|
|
|
|
53
|
|
|
public function getTotalSum() |
54
|
|
|
{ |
55
|
|
|
$info = $this->getInfo(); |
56
|
|
|
if ($info instanceof Mage_Sales_Model_Order_Payment) { |
57
|
|
|
$order = $info->getOrder(); |
58
|
|
|
return round($order->getGrandTotal(), 2); |
59
|
|
|
} |
60
|
|
|
} |
61
|
|
|
|
62
|
|
|
public function getRefundlink() |
63
|
|
|
{ |
64
|
|
|
return Mage::helper("adminhtml")->getUrl("adminhtml/payture_index/refund/", array('_secure' => true, 'order' => $this->getOid())); |
65
|
|
|
} |
66
|
|
|
|
67
|
|
|
public function getUnblockTransactionlink() |
68
|
|
|
{ |
69
|
|
|
return Mage::helper("adminhtml")->getUrl("adminhtml/payture_index/cancel/", array('_secure' => true, 'order' => $this->getOid())); |
70
|
|
|
} |
71
|
|
|
|
72
|
|
|
public function getAcceptTransactionlink() |
73
|
|
|
{ |
74
|
|
|
return Mage::helper("adminhtml")->getUrl("adminhtml/payture_index/complete/", array('_secure' => true, 'order' => $this->getOid())); |
75
|
|
|
} |
76
|
|
|
|
77
|
|
View Code Duplication |
public function getState() |
|
|
|
|
78
|
|
|
{ |
79
|
|
|
$collection = Mage::getModel('payture/keys')->getCollection(); |
80
|
|
|
$collection->addFieldToFilter('orderid', $this->getOid()); |
81
|
|
|
if (count($collection) == 0) { |
82
|
|
|
return false; |
83
|
|
|
} |
84
|
|
|
$item = $collection->getFirstItem(); |
85
|
|
|
return $item->getState(); |
86
|
|
|
} |
87
|
|
|
|
88
|
|
|
public function getPaytureName() |
89
|
|
|
{ |
90
|
|
|
return $this->escapeHtml(Mage::getStoreConfig('payment/payture/title')); |
91
|
|
|
} |
92
|
|
|
} |
93
|
|
|
|
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.
The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.
This check looks for comments that seem to be mostly valid code and reports them.