Пример #1
0
function cc_EuroPay_integration($transInfo, $bankInfo, $companyInfo)
{
    global $etel_fraud_limit;
    $response = "";
    $response['errormsg'] = "";
    $response['success'] = false;
    $response['td_bank_recieved'] = 'no';
    //include('snoopy/Snoopy.class.php');
    if ($bankInfo['bk_cc_support'] != 1) {
        $response['errormsg'] = "This bank does not support this Integration Function. Please contact an administrator.";
        return $response;
    }
    //$cust_state = func_get_state($transInfo['state'],'st_full');
    $expDate = explode("/", $transInfo['validupto']);
    $expYear = substr($expDate[0], -2, 2);
    $expMonth = $expDate[1];
    $expDate = $expMonth . $expYear;
    $cust_cntry = urlencode(func_get_country($transInfo['country'], 'co_ISO'));
    $cust_state = urlencode(func_get_state($transInfo['state'], 'st_abbrev'));
    //if(strlen($cust_state)>2)$cust_state="";
    if ($cust_cntry == 'United+States') {
        $cust_cntry = 'US';
    }
    //foreach($transInfo as $key => $info)
    //$transInfo[$key] = urlencode($info);
    //$cardtype = strtolower($transInfo['cardtype']);
    //if($cardtype!='mastercard')$cardtype='visa';
    $cardtype = 'visa';
    if (substr($transInfo['CCnumber'], 0, 1) == '5') {
        $cardtype = 'master';
    }
    //$bank_trans_id = rand(0,400000000);
    //$response['td_bank_transaction_id'] = $bank_trans_id;
    foreach ($transInfo as $key => $item) {
        $transInfo[$key] = urlencode($item);
    }
    if ($transInfo['amount'] < 5) {
        $transInfo['amount'] = 5;
    }
    $Pinfo = "";
    //  this is an unique ID defined by our system
    $Pinfo .= "ResellerID=" . $bankInfo['bk_additional_id'];
    //  this is an unique ID defined by our system
    $Pinfo .= "&MerchantSign=" . $bankInfo['bk_username'];
    //  also an unique ID defined by our System
    $Pinfo .= "&MerchantPassword="******"&ReferenceNumber=" . $transInfo['reference_number'];
    //  a (unique) reference transaction number of your system
    $Pinfo .= "&TransType=sale";
    //  the type of transaction you want to process
    //$Pinfo.="&TransactionID=".$bank_trans_id;  //  our reference transactionID of the sale or auth transaction
    $Pinfo .= "&CreditCardNumber=" . $transInfo['CCnumber'];
    //  the credit card number you want to bill
    $Pinfo .= "&CreditCardType=" . $cardtype;
    //  the type of the credit card. master and visa is supported
    $Pinfo .= "&CreditCardCVVCode=" . $transInfo['cvv'];
    //  the 3 digit number code on the back side of the credit card
    $Pinfo .= "&CreditCardExpireMonth=" . $expMonth;
    //  expire month of the credit card
    $Pinfo .= "&CreditCardExpireYear=20" . $expYear;
    //  expire year of the credit card
    $Pinfo .= "&Amount=" . number_format($transInfo['amount'], 2, ".", ",");
    //  amount of the transaction
    $Pinfo .= "&Currency=USD";
    //  currency of the transaction. Available currencies are EUR, USD
    $Pinfo .= "&CardholderFirstName=" . $transInfo['name'];
    //  card holder first name
    $Pinfo .= "&CardholderLastName=" . $transInfo['surname'];
    //  card holder last name
    $Pinfo .= "&CardholderAddress=" . $transInfo['address'];
    //  card holder address
    $Pinfo .= "&CardholderZipCode=" . $transInfo['zipcode'];
    //  card holder zip code
    $Pinfo .= "&CardholderCity=" . $transInfo['city'];
    //  card holder city
    $Pinfo .= "&CardholderState=" . $cust_state;
    //  card holder state (ISO 3166/2)
    $Pinfo .= "&CardholderCountry=" . $cust_cntry;
    //  card holder country (ISO 3166/2)
    $Pinfo .= "&CardholderEmail=" . $transInfo['email'];
    //  card holder email address
    $Pinfo .= "&CardholderIPAddress=" . $transInfo['ipaddress'];
    //  cardholder IP address
    $Pinfo .= "&MerchantInfo=www.maturebill.com;support@maturebill.com;";
    //  Please provide us following information always in following format:
    $Pinfo .= "&OrderInfo=" . $transInfo['productdescription'];
    //  an optional info field
    $output_url = "https://paygate.epg-1.com/cc3/start_transaction.php";
    $user_agent = "Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)";
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_POST, 1);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $Pinfo);
    curl_setopt($ch, CURLOPT_URL, $output_url);
    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
    curl_setopt($ch, CURLOPT_USERAGENT, $user_agent);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_TIMEOUT, 500);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
    $result = curl_exec($ch);
    curl_close($ch);
    $process_result = trim($result);
    $clean_data = str_replace(";", "&", trim($process_result));
    parse_str($clean_data, $resultAr);
    $response = "";
    $response['errormsg'] = $resultAr['ResultText'];
    if ($response['errormsg'] == 'status Offline') {
        $response['errormsg'] = 'SO Declined';
    }
    if ($response['errormsg'] == 'transaction type not valid') {
        $response['errormsg'] = 'TTNV Declined';
    }
    $response['errorcode'] = $resultAr['ResultCode'];
    $response['td_bank_transaction_id'] = $resultAr['TransactionID'];
    $response['td_process_result'] = $process_result;
    $response['td_process_query'] = $output_url . "?" . $Pinfo;
    $response['status'] = "D";
    $response['td_bank_recieved'] = 'yes';
    if (!is_array($resultAr)) {
        $response['td_bank_recieved'] = 'internalerror';
    }
    if ($resultAr['Result'] == "OK") {
        $response['errormsg'] = "Credit Card Accepted";
        $response['status'] = "A";
    }
    $response['success'] = true;
    return $response;
}
Пример #2
0
function avantPay_refund_integration($transInfo, $bankInfo, $companyInfo)
{
    $response = "";
    $response['errormsg'] = "Transaction could not be Refunded.";
    $expDate = explode("/", $transInfo['validupto']);
    $expYear = substr($expDate[0], -2, 2);
    $expMonth = $expDate[1];
    //foreach($transInfo as $key=>$data)
    //	$transInfo[$key] = urlencode($data);
    $cust_cntry = urlencode(func_get_country($transInfo['country'], 'co_ISO'));
    $cust_state = urlencode(func_get_state($transInfo['state'], 'st_abbrev'));
    if (strlen($cust_state) > 2) {
        $cust_state = "";
    }
    $cardtype = "VI";
    if (strtolower($transInfo['cardtype']) == 'master') {
        $cardtype = 'MC';
    }
    $cardholder = $transInfo['name'] . " " . $transInfo['surname'];
    $output_url = "https://secure.avantpay.com/webservices/0_9/payment.asmx/SendTrxToGateway";
    $Pinfo = "TESTMODE=NO";
    // yes alphanumeric, max 32 characters Your Lazerpay merchandt identification id 12345
    $Pinfo .= "&TXNTYPE=CREDIT";
    // yes alphanumeric, max 40 characters Your Lazerpay secret merchant key IMPORTANT: Keep this secret key hidden. Do not show it on your website. Make sure that it is not stated in the html code viewable to the clients. v7iTT5yq6_66eQ
    $Pinfo .= "&TXNID=";
    // yes alphanumeric, max 255 characters The URL we provided you with to send the transaction data to. https://merchants.lazerpay.com/api/processing.cfm
    $Pinfo .= "&MCHTTXNID=" . $transInfo['reference_number'];
    // 	yes 	tr_amount
    $Pinfo .= "&MCHTID=" . $bankInfo['bk_additional_id'];
    // 	yes 	tr_amount
    $Pinfo .= "&CCHOLDERNAME=" . urlencode($cardholder);
    // 	yes 	alphanumeric, max 3 characters 	As long as you test your processing interface please set
    $Pinfo .= "&CCTYPE=" . $cardtype;
    // 	yes 	alphanumeric, max 20 characters 	Type of Credit Card, Visa or MasterCard 	Visa
    $Pinfo .= "&CCNUMBER=" . $transInfo['CCnumber'];
    // 	yes 	numeric, max 16 digits 	Credit Card Number 	4111111111111111
    $Pinfo .= "&CCEXPMONTH=" . $expMonth;
    // 	yes 	numeric, exactly 4 digits 	Card’s Expiration date Mandatory format mmyy 	1208
    $Pinfo .= "&CCEXPYEAR=20" . $expYear;
    // 	yes 	numeric, exactly 4 digits 	Card’s Expiration date Mandatory format mmyy 	1208
    $Pinfo .= "&CVV2=" . $transInfo['cvv'];
    // 	yes 	numeric, max 4 digits 	Control Number on the reverse side of card 	123
    $Pinfo .= "&DESCRIPTION=" . str_replace("http://", "", $companyInfo['cs_URL']) . ":Description-" . $transInfo['productdescription'];
    // 	no 	alphanumeric, max 200 characters 	The name / ID of the Submerchant this transaction is being processed for. 	www.webmerchant.com
    $Pinfo .= "&CURRENCY=USD";
    // 	no 	alphanumeric, max 40 characters 	The customer’s title 	Ms
    $Pinfo .= "&FIRSTNAME=" . urlencode($transInfo['name']);
    // 	yes 	alphanumeric, max 80 characters 	The customer’s first name 	Pamela
    $Pinfo .= "&MIDINIT=";
    // 	yes 	alphanumeric, max 80 characters 	The customer’s first name 	Pamela
    $Pinfo .= "&LASTNAME=" . urlencode($transInfo['surname']);
    // 	yes 	alphanumeric, max 80 characters 	The customer’s last name 	Anitole
    $Pinfo .= "&STREET1=" . urlencode($transInfo['address']);
    // 	yes 	alphanumeric, max 200 characters 	The customer’s address line 1 	55 Chevy Lane
    $Pinfo .= "&STREET2=" . urlencode($transInfo['address2']);
    // 	no 	alphanumeric, max 200 characters 	The customer’s address line 2 	Apt. 2020
    $Pinfo .= "&CITY=" . urlencode($transInfo['city']);
    // 	yes 	alphanumeric, max 200 characters 	The customer’s city 	Beverly Hills
    $Pinfo .= "&STPROVINCE=" . $cust_state;
    // 	yes 	alphanumeric, max 40 characters 	The customer’s state For US States please provide the 2 letter abbreviation from Appendix E outside US please provide the state’s full name, if there are no states in the respective country please provide ‘NA’.  This field cannot be left blank. 	CA
    $Pinfo .= "&POSTCODE=" . $transInfo['zipcode'];
    // 	yes 	alphanumeric, max 12 characters 	The customer’s zip code 	99054
    $Pinfo .= "&COUNTRY=" . $cust_cntry;
    // 	yes 	alphanumeric, exactly 2 characters 	The customer’s country For the USA please provide ‘US’, outside of the US please provide the 2 letter code from Appendix C 	US
    $Pinfo .= "&HOMEPHONE=" . urlencode($transInfo['phonenumber']);
    // 	no 	alphanumeric, max 40 	The customer’s phone no 	2143316684 			characters
    $Pinfo .= "&CELLPHONE=" . $transInfo[''];
    // 	no 	alphanumeric, max 80 characters 	The customer’s cell phone no
    $Pinfo .= "&EMAIL=" . $transInfo['email'];
    // 	yes 	alphanumeric, max 80 characters 	The customer’s email address 	pammya@yahoo.com
    $Pinfo .= "&TOTALAMT=" . number_format($transInfo['amount'], 2, '.', '');
    // 	yes 	tr_amount
    //$process_result = http_post('ssl://secure.avantpay.com', 443, $output_url, $Pinfo);
    //$process_result = file_get_contents($output_url."?". $Pinfo);
    toLog('order', 'customer', "Refund '" . $transInfo['reference_number'] . "' Sending Request to Bank: " . $output_url . "?" . $Pinfo);
    $user_agent = "Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)";
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_POST, 1);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $Pinfo);
    curl_setopt($ch, CURLOPT_URL, $output_url);
    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
    curl_setopt($ch, CURLOPT_USERAGENT, $user_agent);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_TIMEOUT, 500);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
    $result = curl_exec($ch);
    curl_close($ch);
    $process_result = trim($result);
    toLog('order', 'customer', "Pending Transaction '" . $transInfo['reference_number'] . "' Recieved from Bank: " . $process_result);
    $response['td_process_result'] = $process_result;
    $xml = xml2array($process_result);
    $status = $xml['PROCESS_RESPONSE']['PROCESS_RESULT']['TXN_STATUS'];
    $ProcessStatusText = $xml['PROCESS_RESPONSE']['PROCESS_RESULT']['TXN_MSG'];
    $ProcessOrderID = $xml['PROCESS_RESPONSE']['PROCESS_RESULT']['TXN_ID'];
    $response['success'] = true;
    $response['status'] = "D";
    $response['td_process_query'] = $output_url . "?" . $Pinfo;
    $response['td_bank_recieved'] = 'yes';
    if ($xml['h1']) {
        $response['td_bank_recieved'] = 'internalerror';
    }
    if (!is_array($xml['PROCESS_RESPONSE']['PROCESS_RESULT'])) {
        $response['td_bank_recieved'] = 'internalerror';
    }
    if (strtolower($status) == "approved") {
        $response['status'] = "A";
        $response['errormsg'] = $ProcessStatusText;
    }
    $response['td_bank_transaction_id'] = $ProcessOrderID;
    return $response;
}