Пример #1
0
function cancelRefundOrder($orderid)
{
    $result = select_query("tblorders", "invoiceid", array("id" => $orderid));
    $data = mysql_fetch_array($result);
    $invoiceid = $data['invoiceid'];
    $orderid = (int) $orderid;
    if ($invoiceid) {
        $result = select_query("tblinvoices", "status", array("id" => $invoiceid));
        $data = mysql_fetch_array($result);
        $invoicestatus = $data['status'];
        if ($invoicestatus == "Paid") {
            $result = select_query("tblaccounts", "id", array("invoiceid" => $invoiceid));
            $data = mysql_fetch_array($result);
            $transid = $data['id'];
            $gatewayresult = refundInvoicePayment($transid, "", true);
            if ($gatewayresult == "manual") {
                return "manual";
            }
            if ($gatewayresult != "success") {
                return "refundfailed";
            }
        } else {
            if ($invoicestatus == "Refunded") {
                return "alreadyrefunded";
            }
            return "notpaid";
        }
    }
    return "noinvoice";
}
Пример #2
0
             infoBox($aInt->lang("invoices", "initiatepaymenterror"), $aInt->lang("invoices", "initiatepaymenterrormsg"), "error");
         }
     }
 }
 if ($sub == "refund" && $transid) {
     check_token("WHMCS.admin.default");
     checkPermission("Refund Invoice Payments");
     logActivity("Admin Initiated Refund - Invoice ID: " . $id . " - Transaction ID: " . $transid);
     if ($refundtype == "sendtogateway") {
         $sendtogateway = true;
     } else {
         if ($refundtype == "addascredit") {
             $addascredit = true;
         }
     }
     $result = refundInvoicePayment($transid, $amount, $sendtogateway, $addascredit, $sendemail, $refundtransid);
     if ($result == "manual") {
         infoBox($aInt->lang("invoices", "refundsuccess"), $aInt->lang("invoices", "refundmanualsuccessmsg"));
     } else {
         if ($result == "amounterror") {
             infoBox($aInt->lang("invoices", "refundfailed"), $aInt->lang("invoices", "refundamounterrormsg"));
         } else {
             if ($result == "success") {
                 infoBox($aInt->lang("invoices", "refundsuccess"), $aInt->lang("invoices", "refundsuccessmsg"));
             } else {
                 if ($result == "creditsuccess") {
                     infoBox($aInt->lang("invoices", "refundsuccess"), $aInt->lang("invoices", "refundcreditmsg"));
                 } else {
                     infoBox($aInt->lang("invoices", "refundfailed"), $aInt->lang("invoices", "refundfailedmsg"));
                 }
             }
Пример #3
0
function payjunction_refund($params)
{
    $url = "https://payjunction.com/quick_link";
    $fields['dc_logon'] = $params['dc_logon'];
    $fields['dc_password'] = $params['dc_password'];
    $fields['dc_first_name'] = $params['clientdetails']['firstname'];
    $fields['dc_last_name'] = $params['clientdetails']['lastname'];
    $fields['dc_address'] = $params['clientdetails']['address1'];
    $fields['dc_city'] = $params['clientdetails']['city'];
    $fields['dc_state'] = $params['clientdetails']['state'];
    $fields['dc_zipcode'] = $params['clientdetails']['postcode'];
    $fields['dc_country'] = $params['clientdetails']['country'];
    $fields['dc_number'] = $params['cardnum'];
    $fields['dc_expiration_month'] = substr($params['cardexp'], 0, 2);
    $fields['dc_expiration_year'] = substr($params['cardexp'], 2, 2);
    $fields['dc_transaction_amount'] = $params['amount'];
    $fields['dc_notes'] = $params['description'];
    $fields['dc_transaction_type'] = "CREDIT";
    $fields['dc_version'] = "1.2";
    $query_string = "";
    foreach ($fields as $k => $v) {
        $query_string .= "" . $k . "=" . urlencode($v) . "&";
    }
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_POST, 1);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $query_string);
    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    $gatewayresult = curl_exec($ch);
    if (curl_errno($ch)) {
        $gatewayresult = "CurlError=" . curl_error($ch);
    }
    curl_close($ch);
    $content = explode(chr(28), $gatewayresult);
    foreach ($content as $key_value) {
        list($key, $value) = explode("=", $key_value);
        $response[$key] = $value;
    }
    $debugoutput = "";
    foreach ($response as $k => $v) {
        $debugoutput .= "" . $k . " => " . $v . "\n";
    }
    if (strcmp($response['dc_response_code'], "00") == 0 || strcmp($response['dc_response_code'], "85") == 0) {
        refundInvoicePayment($params['invoiceid'], $transid);
        logTransaction("PayJunction", $debugoutput, "Successful");
        $result = "success";
    } else {
        logTransaction("PayJunction", $debugoutput, "Declined");
        $result = "declined";
    }
    return $result;
}