protected function _canDoCapture($order) { $session = Mage::getSingleton('adminhtml/session'); if ((int) $this->getConfigData('remoteinterface', $order ? $order->getStoreId() : null) != 1) { return false; } try { // Read info directly from the database $read = Mage::getSingleton('core/resource')->getConnection('core_read'); $row = $read->fetchRow("select * from epay_order_status where orderid = '" . $order->getIncrementId() . "'"); if ($row["status"] == '1') { $tid = $row["tid"]; $param = array('merchantnumber' => $this->getConfigData('merchantnumber', $order ? $order->getStoreId() : null), 'transactionid' => $tid, 'epayresponse' => 0, 'pwd' => $this->getConfigData('remoteinterfacepassword', $order ? $order->getStoreId() : null)); $client = new SoapClient('https://ssl.ditonlinebetalingssystem.dk/remote/payment.asmx?WSDL'); $result = $client->gettransaction($param); if ($result->gettransactionResult == 1) { return true; } else { return false; } } else { return false; } } catch (Exception $e) { $session->addException($e, $e->getMessage() . " - Go to the ePay administration to capture the payment manually."); } return true; }
public function getTransactionStatus($tid, $paymentobj) { $res = "<tr><td colspan='2'><br><b>" . Mage::helper('epay')->__('EPAY_LABEL_44') . "</b></td></tr>"; $param = array('merchantnumber' => $paymentobj->getConfigData('merchantnumber', $this->getOrder() ? $this->getOrder()->getStoreId() : null), 'transactionid' => $tid, 'epayresponse' => 0, 'pwd' => $paymentobj->getConfigData('remoteinterfacepassword', $this->getOrder() ? $this->getOrder()->getStoreId() : null)); try { $client = new SoapClient('https://ssl.ditonlinebetalingssystem.dk/remote/payment.asmx?WSDL'); } catch (Exception $e) { echo "<script>alert('ePay: Please deactivate API or contact your system administrator. Error: " . $e->getMessage() . "');</script>"; } $result = $client->gettransaction($param); if ($result->gettransactionResult == 1) { // // Success - Information got! // $res .= "<tr><td>" . Mage::helper('epay')->__('EPAY_LABEL_45') . ":</td>"; $res .= "<td>" . $this->translatePaymentStatus($result->transactionInformation->status) . "</td></tr>"; if (strcmp($result->transactionInformation->status, "PAYMENT_DELETED") == 0) { $res .= "<tr><td>" . Mage::helper('epay')->__('EPAY_LABEL_46') . ":</td>"; $res .= "<td>" . str_replace("T", " ", $result->transactionInformation->deleteddate) . "</td></tr>"; } $res .= "<tr><td>" . Mage::helper('epay')->__('EPAY_LABEL_7') . ":</td>"; $res .= "<td>" . $result->transactionInformation->orderid . "</td></tr>"; $res .= "<tr><td>" . Mage::helper('epay')->__('EPAY_LABEL_47') . ":</td>"; $res .= "<td>" . $result->transactionInformation->acquirer . "</td></tr>"; $res .= "<tr><td>" . Mage::helper('epay')->__('EPAY_LABEL_21') . ":</td>"; $res .= "<td>" . $result->transactionInformation->currency . "</td></tr>"; $res .= "<tr><td>" . Mage::helper('epay')->__('EPAY_LABEL_48') . ":</td>"; $res .= "<td>" . ($result->transactionInformation->splitpayment ? Mage::helper('epay')->__('EPAY_LABEL_50') : Mage::helper('epay')->__('EPAY_LABEL_51')) . "</td></tr>"; $res .= "<tr><td>" . Mage::helper('epay')->__('EPAY_LABEL_49') . ":</td>"; $res .= "<td>" . ($result->transactionInformation->msc ? Mage::helper('epay')->__('EPAY_LABEL_50') : Mage::helper('epay')->__('EPAY_LABEL_51')) . "</td></tr>"; $res .= "<tr><td>" . Mage::helper('epay')->__('EPAY_LABEL_52') . ":</td>"; $res .= "<td>" . $result->transactionInformation->description . "</td></tr>"; $res .= "<tr><td>" . Mage::helper('epay')->__('EPAY_LABEL_53') . ":</td>"; $res .= "<td>" . $result->transactionInformation->cardholder . "</td></tr>"; $res .= "<tr><td>" . Mage::helper('epay')->__('EPAY_LABEL_54') . ":</td>"; $res .= "<td>" . $this->getOrder()->getBaseCurrencyCode() . " " . number_format((int) $result->transactionInformation->authamount / 100, 2, ',', ' ') . " " . ((int) $result->transactionInformation->authamount > 0 ? str_replace("T", " ", $result->transactionInformation->authdate) : "") . "</td></tr>"; $res .= "<tr><td>" . Mage::helper('epay')->__('EPAY_LABEL_55') . ":</td>"; $res .= "<td>" . $this->getOrder()->getBaseCurrencyCode() . " " . number_format((int) $result->transactionInformation->capturedamount / 100, 2, ',', ' ') . " " . ((int) $result->transactionInformation->capturedamount > 0 ? str_replace("T", " ", $result->transactionInformation->captureddate) : "") . "</td></tr>"; $res .= "<tr><td>" . Mage::helper('epay')->__('EPAY_LABEL_56') . ":</td>"; $res .= "<td>" . $this->getOrder()->getBaseCurrencyCode() . " " . number_format((int) $result->transactionInformation->creditedamount / 100, 2, ',', ' ') . " " . ((int) $result->transactionInformation->creditedamount > 0 ? str_replace("T", " ", $result->transactionInformation->crediteddate) : "") . "</td></tr>"; $res .= "<tr><td>" . Mage::helper('epay')->__('EPAY_LABEL_39') . ":</td>"; $res .= "<td>" . $this->getOrder()->getBaseCurrencyCode() . " " . number_format((int) $result->transactionInformation->fee / 100, 2, ',', ' ') . "</td></tr>"; if (isset($result->transactionInformation->history) && isset($result->transactionInformation->history->TransactionHistoryInfo) && count($result->transactionInformation->history->TransactionHistoryInfo) > 0) { // // Important to convert this item to array. If only one item is to be found in the array of history items // the object will be handled as non-array but object only. $historyArray = $result->transactionInformation->history->TransactionHistoryInfo; if (count($result->transactionInformation->history->TransactionHistoryInfo) == 1) { $historyArray = array($result->transactionInformation->history->TransactionHistoryInfo); // convert to array } $res .= "<tr><td colspan='2'><br><br><b>" . Mage::helper('epay')->__('EPAY_LABEL_76') . "</b></td></tr>"; for ($i = 0; $i < count($historyArray); $i++) { $res .= "<tr><td>" . str_replace("T", " ", $historyArray[$i]->created) . "</td>"; $res .= "<td>"; if (strlen($historyArray[$i]->username) > 0) { $res .= $historyArray[$i]->username . ": "; } $res .= $historyArray[$i]->eventMsg . "</td></tr>"; } } } else { if ($result->epayresponse == -1002) { $res .= "<script>alert('" . sprintf(Mage::helper('epay')->__('EPAY_LABEL_57'), $result->epayresponse) . ": " . Mage::helper('epay')->__('EPAY_LABEL_58') . "');</script>"; } elseif ($result->epayresponse == -1003) { $res .= "<script>alert('" . sprintf(Mage::helper('epay')->__('EPAY_LABEL_57'), $result->epayresponse) . ": " . Mage::helper('epay')->__('EPAY_LABEL_59') . "');</script>"; } elseif ($result->epayresponse == -1006) { $res .= "<script>alert('" . sprintf(Mage::helper('epay')->__('EPAY_LABEL_57'), $result->epayresponse) . ": " . Mage::helper('epay')->__('EPAY_LABEL_60') . "');</script>"; } else { $res .= "<script>alert('" . sprintf(Mage::helper('epay')->__('EPAY_LABEL_57'), $result->epayresponse) . ": " . $paymentobj->getEpayErrorText($result->epayresponse) . "');</script>"; } } return $res; }