1 | <?php |
||
10 | class Mygento_Payture_Model_Payture |
||
11 | { |
||
12 | public function processOrder($order, $enc_key) |
||
27 | |||
28 | protected function requestApiPost($url, $arpost) |
||
60 | |||
61 | private function initSession($order, $enc_key, $itemid) |
||
62 | { |
||
63 | $paytype = Mage::getStoreConfig('payment/payture/paytype'); |
||
64 | $request = array( |
||
65 | 'SessionType' => $paytype, |
||
66 | 'OrderId' => $order->getId(), |
||
67 | 'Amount' => $order->getGrandTotal() * 100, |
||
68 | 'Total' => $order->getGrandTotal(), |
||
69 | 'IP' => $order->getRemoteIp(), |
||
70 | 'Url' => Mage::getUrl( |
||
71 | 'payture/payment/result/', |
||
72 | array('_secure' => true, 'order' => $enc_key) |
||
73 | ) |
||
74 | ); |
||
75 | // @codingStandardsIgnoreStart |
||
76 | if (Mage::getStoreConfig('payment/payture/taxenable')) { |
||
77 | $request['Cheque'] = base64_encode(Mage::helper('payture')->getOrderItemsJson($order)); |
||
78 | Mage::helper('payture')->addLog('Cheque base64_json_decode: ' . print_r(Mage::helper('core')->jsonDecode(base64_decode($request['Cheque'])),1)); |
||
79 | } |
||
80 | // @codingStandardsIgnoreEnd |
||
81 | |||
82 | //add product names |
||
83 | $products = ''; |
||
84 | $items = $order->getItemsCollection(); |
||
85 | foreach ($items as $item) { |
||
86 | if ($item->getOriginalPrice() > 0) { |
||
87 | $products .= $item->getName() . ', '; |
||
88 | } |
||
89 | } |
||
90 | |||
91 | if (substr($products, strlen($products) - 2, 2) == ', ') { |
||
92 | $products = substr($products, 0, strlen($products) - 2); |
||
93 | } |
||
94 | |||
95 | $request['Product'] = $products; |
||
96 | |||
97 | $result = $this->requestApiPost(Mage::helper('payture')->getHost() . 'Init', $request); |
||
98 | Mage::helper('payture')->addLog($result); |
||
99 | $xml = simplexml_load_string($result); |
||
100 | |||
101 | if ((bool) $xml["Success"][0] == true) { |
||
|
|||
102 | if ($xml["SessionId"][0]) { |
||
103 | $item = Mage::getModel('payture/keys')->load($itemid); |
||
104 | $item->setSessionid($xml["SessionId"][0]); |
||
105 | $item->setPaytype($paytype); |
||
106 | $item->setState('New'); |
||
107 | $item->setDate(Mage::getModel('core/date')->date('Y-m-d H:i:s')); |
||
108 | $item->save(); |
||
109 | return $xml["SessionId"][0]; |
||
110 | } |
||
111 | } else { |
||
112 | $session = Mage::getSingleton('checkout/session'); |
||
113 | $session->addError($xml["ErrCode"][0]); |
||
114 | return false; |
||
115 | } |
||
116 | } |
||
117 | |||
118 | public function processStatus($status, $order_id, $key_id) |
||
132 | |||
133 | public function checkSign($order_id, $check_result) |
||
141 | |||
142 | /** |
||
143 | * |
||
144 | * @param type $type |
||
145 | * @param type $receipt |
||
146 | * @param type $order |
||
147 | * @return type |
||
148 | */ |
||
149 | public function modifyOrder($type, $receipt, $order) |
||
165 | } |
||
166 |
When comparing two booleans, it is generally considered safer to use the strict comparison operator.