示例#1
0
文件: xmlfunc.php 项目: armic/erpts
 function XPathValue($xpath, $xml)
 {
     $XPathArray = explode("/", $xpath);
     $node = $xml;
     while (list($key, $value) = each($XPathArray)) {
         $node = GetElementByName($node, "<{$value}>", "</{$value}>");
     }
     return $node;
 }
function func_volpay_bankprocess($bank_Username, $bank_Password, $ReferenceNo, $cardType, $CCnumber, $cardExpire, $cvv, $name, $surname, $address, $zipcode, $city, $country, $phonenumber, $state, $email, $currencyCode, $transactAmount, $cnn_connection, $transactionId, $i_company_id)
{
    $data = "";
    $xml_string = "<epxml><header>\n\t\t\t<responsetype>direct</responsetype>\n\t\t\t\t<mid>{$bank_Username}</mid>\n\t\t\t\t<password>{$bank_Password}</password>\n\t\t\t<type>charge</type>\n\t\t\t</header>\n\t\t\t<request><charge>\n\t\t\t\t<etan>{$ReferenceNo}</etan>\n\t\t\t<card>\n\t\t\t\t<cctype>{$cardType}</cctype>\n\t\t\t\t<cc>{$CCnumber}</cc>\n\t\t\t\t<expire>{$cardExpire}</expire>\n\t\t\t\t<cvv>{$cvv}</cvv>\n\t\t\t</card>\n\t\t\t<cardholder>\n\t\t\t\t<name>{$name}</name>\n\t\t\t\t<surname>{$surname}</surname>\n\t\t\t\t<street>{$address}</street>\n\t\t\t\t<housenumber>123</housenumber>\n\t\t\t\t<zip>{$zipcode}</zip>\n\t\t\t\t<city>{$city}</city>\n\t\t\t\t<country>{$country}</country>\n\t\t\t\t<telephone>{$phonenumber}</telephone>\n\t\t\t\t<state>{$state}</state>\n\t\t\t\t<email>{$email}</email>\n\t\t\t</cardholder>\n\t\t\t<amount>\n\t\t\t\t<currency>{$currencyCode}</currency>\n\t\t\t\t<value>{$transactAmount}</value>\n\t\t\t</amount>\n\t\t\t</charge>\n\t\t\t</request></epxml>";
    $data = func_volpaybank_integration_result($xml_string);
    $Nodes = array();
    $count = 0;
    $pos = 0;
    // Goes throw XML file and creates an array of all <XML_TAG> tags.
    while ($node = GetElementByName($data, "<epxml>", "</epxml>")) {
        $Nodes[$count] = $node;
        $count++;
        $data = substr($data, $pos);
        $pos++;
    }
    // Gets infomation from tag siblings.
    for ($i = 0; $i < $count; $i++) {
        $headerCode = GetElementByName($Nodes[$i], "<header>", "</header>");
        $responseDesc = GetElementByName($Nodes[$i], "<response>", "</response>");
        $responseType = GetElementByName($Nodes[$i], "<responsetype>", "</responsetype>");
        $merchantId = GetElementByName($Nodes[$i], "<mid>", "</mid>");
        $merchantType = GetElementByName($Nodes[$i], "<type>", "</type>");
        if (strpos($responseDesc, "error")) {
            $returnCode = GetElementByName($Nodes[$i], "<errorcode>", "</errorcode>");
            $returnMessage = GetElementByName($Nodes[$i], "<errormessage>", "</errormessage>");
            $transNo = GetElementByName($Nodes[$i], "<etan>", "</etan>");
            $strMessage = "<b>Sorry</b>, there was a mistake with your credit card details. Your Order Number {$ReferenceNo} has been declined. ";
            $strMessage .= $returnMessage . "-" . $returnCode;
            $transStatus = $returnMessage . "-" . $returnCode;
        }
        if (strpos($responseDesc, "success")) {
            $returnMessage = GetElementByName($Nodes[$i], "<message>", "</message>");
            $returnCode = GetElementByName($Nodes[$i], "<tan>", "</tan>");
            $transNo = GetElementByName($Nodes[$i], "<etan>", "</etan>");
            $strMessage = "<h3>Thank-you for your order</h3>Your order number is {$ReferenceNo}.Your Order has been Approved and Please refer to this in any correspondence.";
            //$msgtodisplay .= $returnMessage."-".$returnCode ;
            $transStatus = "Success";
        }
    }
    $qrt_insert_bankdetails = "insert into cs_volpay (trans_id,user_id,currency,amount,trans_status,return_code,return_message,reference_number) values({$transactionId},{$i_company_id},'{$currencyCode}',{$transactAmount},'{$transStatus}','{$returnCode}','{$returnMessage}','{$ReferenceNo}') ";
    //	print($qrt_insert_bankdetails);
    if (!($show_sql = mysql_query($qrt_insert_bankdetails, $cnn_connection))) {
        print mysql_errno() . ": " . mysql_error() . "<BR>";
        print "Cannot execute queryin";
        exit;
    }
    $approval_status = $transStatus == "Success" ? "A" : "D";
    $decline_reason = $transStatus == "Success" ? "" : $returnCode . " : " . $returnMessage;
    $pass_status = "PA";
    func_update_approval_status($cnn_connection, $transactionId, $approval_status, $pass_status, $decline_reason);
    if ($transStatus == "Success") {
        //	func_send_transaction_success_mail($transactionId);
    }
    return $transStatus;
}
 $responseDesc = GetElementByName($Nodes[$i], "<response>", "</response>");
 $responseType = GetElementByName($Nodes[$i], "<responsetype>", "</responsetype>");
 $merchantId = GetElementByName($Nodes[$i], "<mid>", "</mid>");
 $merchantType = GetElementByName($Nodes[$i], "<type>", "</type>");
 if (strpos($responseDesc, "error")) {
     $returnCode = GetElementByName($Nodes[$i], "<errorcode>", "</errorcode>");
     $returnMessage = GetElementByName($Nodes[$i], "<errormessage>", "</errormessage>");
     $transNo = GetElementByName($Nodes[$i], "<etan>", "</etan>");
     $strMessage = "<b>Sorry</b>, there was a mistake with your credit card details. Your Order Number {$TransNumber} has been declined. ";
     $strMessage .= $returnMessage . "-" . $returnCode;
     $transStatus = "Failure";
 }
 if (strpos($responseDesc, "success")) {
     $returnMessage = GetElementByName($Nodes[$i], "<message>", "</message>");
     $returnCode = GetElementByName($Nodes[$i], "<tan>", "</tan>");
     $transNo = GetElementByName($Nodes[$i], "<etan>", "</etan>");
     $strMessage = "<h3>Thank-you for your order</h3>Your order number is {$TransNumber}.Your Order has been Approved and Please refer to this in any correspondence.";
     //$msgtodisplay .= $returnMessage."-".$returnCode ;
     $transStatus = "Success";
 }
 $qry_select = "select reference_number from cs_transactiondetails where transactionId={$TransNumber}";
 $select_sql = mysql_query($qry_select, $cnn_cs);
 $value = mysql_fetch_array($select_sql);
 $ref_num = $value[0];
 $qrt_insert_bankdetails = "insert into cs_volpay (trans_id,user_id,currency,amount,trans_status,return_code,return_message,reference_number) values('{$TransNumber}','{$i_company_id}','{$currencyCode}',{$transactAmount},'{$transStatus}','{$returnCode}','{$returnMessage}','{$ref_num}') ";
 if (!($show_sql = mysql_query($qrt_insert_bankdetails, $cnn_cs))) {
     dieLog(mysql_errno() . ": " . mysql_error() . "<BR>");
 }
 $approval_status = $transStatus == "Success" ? "A" : "D";
 $decline_reason = $transStatus == "Success" ? "" : $returnCode . " : " . $returnMessage;
 $pass_status = "";