Example #1
0
function epay_refund($params)
{
    $amount = $params['amount'];
    $epay_params = array();
    $epay_params['merchantnumber'] = $params['merchantnumber'];
    $epay_params['transactionid'] = $params['transid'];
    $epay_params['amount'] = $amount * 100;
    $epay_params['pbsresponse'] = -1;
    $epay_params['epayresponse'] = -1;
    $soap = new SoapClient('https://ssl.ditonlinebetalingssystem.dk/remote/payment.asmx?WSDL');
    $soap_credit_result = $soap->credit($epay_params);
    if ($soap_credit_result->creditResult == true) {
        return array("status" => "success", "transid" => $params["transid"], "rawdata" => $return);
    } elseif ($soap_credit_result->creditResult == false) {
        return array("status" => "declined", "rawdata" => $return);
    } else {
        return array("status" => "error", "rawdata" => $return);
    }
}
Example #2
0
 public function refund(Varien_Object $payment, $amount)
 {
     $session = Mage::getSingleton('adminhtml/session');
     //
     // Verify if remote interface is enabled
     //
     try {
         if ((int) $this->getConfigData('remoteinterface', $payment->getOrder() ? $payment->getOrder()->getStoreId() : null) != 1) {
             $this->addOrderComment($payment->getOrder(), Mage::helper('epay')->__('EPAY_LABEL_74'));
             throw new Exception(Mage::helper('epay')->__('EPAY_LABEL_74'));
         }
         //
         // Read info directly from the database
         $read = Mage::getSingleton('core/resource')->getConnection('core_read');
         $row = $read->fetchRow("select * from epay_order_status where orderid = '" . $payment->getOrder()->getIncrementId() . "'");
         if ($row["status"] == '1') {
             $epayamount = (string) ($amount * 100);
             $tid = $row["tid"];
             $param = array('merchantnumber' => $this->getConfigData('merchantnumber', $payment->getOrder() ? $payment->getOrder()->getStoreId() : null), 'transactionid' => $tid, 'amount' => $epayamount, 'group' => '', 'pbsresponse' => 0, 'epayresponse' => 0, 'pwd' => $this->getConfigData('remoteinterfacepassword', $payment->getOrder() ? $payment->getOrder()->getStoreId() : null));
             $client = new SoapClient('https://ssl.ditonlinebetalingssystem.dk/remote/payment.asmx?WSDL');
             $result = $client->credit($param);
             if ($result->creditResult == 1) {
                 //
                 // Success - transaction credited!
                 //
                 $this->addOrderComment($payment->getOrder(), "Transaction with id: " . $tid . " has been credited by amount: " . number_format($amount, 2, ",", "."));
             } else {
                 if ($result->epayresponse == -1002) {
                     $this->addOrderComment($payment->getOrder(), "An error (" . $result->epayresponse . ") occured in the communication to ePay: The merchantnumber you are using does not exists or is disabled. Please log into your ePay account to verify your merchantnumber. This can be done from the menu: SETTINGS -> PAYMENT SYSTEM.");
                     throw new Exception("An error (" . $result->epayresponse . ") occured in the communication to ePay: The merchantnumber you are using does not exists or is disabled. Please log into your ePay account to verify your merchantnumber. This can be done from the menu: SETTINGS -> PAYMENT SYSTEM.");
                 } elseif ($result->epayresponse == -1003) {
                     $this->addOrderComment($payment->getOrder(), "An error (" . $result->epayresponse . ") occured in the communication to ePay: The IP address your system calls ePay from is UNKNOWN. Please log into your ePay account to verify enter the IP address your system calls ePay from. This can be done from the menu: API / WEBSERVICES -> ACCESS.");
                     throw new Exception("An error (" . $result->epayresponse . ") occured in the communication to ePay: The IP address your system calls ePay from is UNKNOWN. Please log into your ePay account to verify enter the IP address your system calls ePay from. This can be done from the menu: API / WEBSERVICES -> ACCESS.");
                 } elseif ($result->epayresponse == -1006) {
                     $this->addOrderComment($payment->getOrder(), "An error (" . $result->epayresponse . ") occured in the communication to ePay: Your ePay account has not access to API / Remote Interface. This is only for ePay BUSINESS accounts. Please contact ePay to upgrade your ePay account.");
                     throw new Exception("An error (" . $result->epayresponse . ") occured in the communication to ePay: Your ePay account has not access to API / Remote Interface. This is only for ePay BUSINESS accounts. Please contact ePay to upgrade your ePay account.");
                 } elseif ($result->epayresponse == -1021) {
                     $this->addOrderComment($payment->getOrder(), "An error (" . $result->epayresponse . ") occured in the communication to ePay: An operation every 15 minutes can be performed on a transaction. Please wait 15 minutes and try again.");
                     throw new Exception("An error (" . $result->epayresponse . ") An operation every 15 minutes can be performed on a transaction. Please wait 15 minutes and try again.");
                 } else {
                     $this->addOrderComment($payment->getOrder(), "An error (" . $result->epayresponse . ") occured in the communication to ePay: " . $this->getEpayErrorText($result->epayresponse));
                     throw new Exception("An error (" . $result->epayresponse . ") occured in the communication to ePay: " . $this->getEpayErrorText($result->epayresponse));
                 }
             }
         } else {
             //
             // Somehow the order was not found - this must be an error!
             //
             throw new Exception("Order not found - please check the epay_order_status table!");
         }
     } catch (Exception $e) {
         $session->addException($e, $e->getMessage() . " - Go to the ePay administration to credit the payment manually.");
     }
     return $this;
 }
Example #3
0
 /**
  * @param mixed $data
  * @return CaptureResponse
  */
 public function sendData($data)
 {
     $client = new \SoapClient($this->endpoint . '?WSDL');
     $result = $client->credit($data);
     return $this->response = new RefundResponse($this, array('creditResult' => $result->creditResult, 'pbsResponse' => $result->pbsresponse, 'epayresponse' => $result->epayresponse));
 }