function isValid($cc_no)
 {
     $sum = 0;
     $digits = 0;
     // Reverse and clean the number
     $cc_no = strrev(creditCard::cleanNum($cc_no));
     // VALIDATION ALGORITHM
     // Loop through the number one digit at a time
     // Double the value of every second digit (starting from the right)
     // Concatenate the new values with the unaffected digits
     for ($ndx = 0; $ndx < strlen($cc_no); ++$ndx) {
         $digits .= $ndx % 2 ? $cc_no[$ndx] * 2 : $cc_no[$ndx];
     }
     // Add all of the single digits together
     for ($ndx = 0; $ndx < strlen($digits); ++$ndx) {
         $sum += $digits[$ndx];
     }
     // Valid card numbers will be transformed into a multiple of 10
     return $sum % 10 ? FALSE : TRUE;
 }
 public function updateReoccCustomer()
 {
     //Check credit card number first
     $creditCard1 = new creditCard();
     try {
         // Get the creditCardNumber.
         if ($creditCard1->isValid($this->cardNumber) == false) {
             $this->status = 1;
             $this->authorizationResult = "REJECT: 40";
             $this->error = "INVALID CC NUMBER!";
             return;
         }
     } catch (Exception $e) {
         $this->status = 1;
         $this->authorizationResult = "REJECT: 40";
         $this->error = "INVALID CC NUMBER!";
         return;
     }
     if ($this->cardType != "") {
     } else {
         $this->cardType = $creditCard1->ccType($this->cardNumber);
         if ($this->cardType == "UNKNOWN") {
             $this->status = 1;
             $this->authorizationResult = "REJECT: 40";
             $this->error = "UNKNOWN CC TYPE!";
             return;
         }
     }
     if ($this->serverType == 1) {
         $this->doLogin();
         if ($this->loginOK == false) {
             $this->status = 0;
             $this->error = "ERROR 1";
             $this->authorizationResult = "FAILED: INVALID AGENT CODE/PASSWORD";
             return;
         }
     }
     // Read input variables, send for processing, parse response and store in output variables.
     try {
         $params = "AgentCode=" . $this->agentCode;
         $params = $params . "&Password="******"&CustCode=" . $this->customerCode;
         $params = $params . "&FirstName=" . $this->firstName;
         $params = $params . "&LastName=" . $this->lastName;
         $params = $params . "&Address=" . $this->streetAddress;
         $params = $params . "&City=" . $this->city;
         $params = $params . "&State=" . $this->state;
         $params = $params . "&ZipCode=" . $this->zipCode;
         $params = $params . "&CCNum1=" . $creditCard1->cleanNum($this->cardNumber);
         $params = $params . "&CCEXPIRY1=" . $this->cardExpiry;
         $params = $params . "&MOP1=" . $this->cardType;
         $params = $params . "&Amount1=" . $this->dollarAmount;
         $params = $params . "&BeginDate1=" . $this->beginDate;
         $params = $params . "&EndDate1=" . $this->endDate;
         $params = $params . "&ScheduleType1=" . $this->scheduleType;
         $params = $params . "&ScheduleDate1=" . $this->scheduleDate;
         $params = $params . "&Reoccurring1=" . $this->reoccuringStatus;
         if ($this->invoiceNumber != "") {
             $params = $params . "&InvoiceNum=" . $this->invoiceNumber;
         }
         $params = $params . "&Version=" . $this->version;
         $url = "";
         $postAction = "/itravel/Customer_Update.pro";
         $user_agent = "Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)";
         try {
             if ($this->testMode == true) {
                 $url = "http://" . $this->webServer . $postAction;
             } else {
                 $url = "https://" . $this->webServer . $postAction;
             }
             $ch = curl_init();
             curl_setopt($ch, CURLOPT_POST, 1);
             curl_setopt($ch, CURLOPT_POSTFIELDS, $params);
             curl_setopt($ch, CURLOPT_URL, $url);
             curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
             curl_setopt($ch, CURLOPT_USERAGENT, $user_agent);
             curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
             if ($this->serverType == 1) {
                 curl_setopt($ch, CURLOPT_COOKIEFILE, $this->cookieFile);
             } else {
                 curl_setopt($ch, CURLOPT_USERPWD, $this->agentCode . ":" . $this->password);
                 //
             }
             curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
             // this line makes it work under https
             if ($this->proxyHost != "" and $this->proxyPort > 0) {
                 //set up proxy
                 curl_setopt($ch, CURLOPT_PROXY, $this->proxyHost);
                 curl_setopt($ch, CURLOPT_PROXYPORT, $this->proxyPort);
                 curl_setopt($ch, CURLOPT_PROXYUSERPWD, $this->proxyUsername . "," . $this->proxyPassword);
                 curl_setopt($ch, CURLOPT_HTTPPROXYTUNNEL, true);
             }
             $iatsReturn = curl_exec($ch);
             $this->error = curl_error($ch);
             $errorNumber = curl_errno($ch);
             //echo  $iatsReturn;
             curl_close($ch);
             @unlink($this->cookieFile);
             if ($errorNumber != 0) {
                 $this->status = 0;
                 $this->error = "Error:" + $this->error;
                 $this->authorizationResult = "FAILURE: SENDERROR";
                 return;
             } else {
                 $this->status = 0;
                 $this->authorizationResult = "FAILURE: UNKNOWN";
                 $this->error = "ERROR!";
                 if (strpos($iatsReturn, "HTTP 401.") > 0) {
                     $this->status = 0;
                     $this->error = "Error 1";
                     $this->authorizationResult = "INVALID AGENT CODE / PASSWORD";
                     //echo $iatsReturn //full error msg
                     return;
                 }
                 if (strpos($iatsReturn, "Reoccurring1") <= 0) {
                     $this->status = 0;
                     $this->error = "FAILURE";
                     $this->authorizationResult = $iatsReturn;
                     return;
                 }
                 $this->status = 1;
                 $this->error = "";
                 $this->authorizationResult = "OK: THE CUSTOMER HAS BEEN UPDATED";
             }
             //end else
         } catch (Exception $e) {
             $this->status = 0;
             $this->error = "FAILURE: ERRORCONN";
             $this->authorizationResult = "FAILURE: ERRORCONN";
             return;
         }
     } catch (Exception $e) {
         $this->status = 0;
         $this->error = "12002";
         $this->authorizationResult = "FAILURE: SYSERROR";
         return;
     }
 }
예제 #3
0
 /**
  * Methods for processing a credit card.
  */
 public function processCreditCard()
 {
     //Check credit card number first
     $creditCard1 = new creditCard();
     try {
         // Get the creditCardNumber.
         if ($creditCard1->isValid($this->cardNumber) == false) {
             $this->status = 1;
             $this->authorizationResult = "REJECT: 40";
             $this->error = "INVALID CC NUMBER!";
             return;
         }
     } catch (Exception $e) {
         $this->status = 1;
         $this->authorizationResult = "REJECT: 40";
         $this->error = "INVALID CC NUMBER!";
         return;
     }
     if ($this->cardType != "") {
     } else {
         $this->cardType = $creditCard1->ccType($this->cardNumber);
         if ($this->cardType == "UNKNOWN") {
             $this->status = 1;
             $this->authorizationResult = "REJECT: 40";
             $this->error = "UNKNOWN CC TYPE!";
             return;
         }
     }
     // Read input variables, send for processing, parse response and store in output variables.
     try {
         $params = "AgentCode=" . $this->agentCode;
         $params = $params . "&Password="******"&CCNum=" . $creditCard1->cleanNum($this->cardNumber);
         $params = $params . "&CCExp=" . $this->cardExpiry;
         $params = $params . "&MOP=" . $this->cardType;
         $params = $params . "&Total=" . $this->dollarAmount;
         if ($this->invoiceNumber != "") {
             $params = $params . "&InvoiceNum=" . $this->invoiceNumber;
         }
         if ($this->preapprovalCode != "") {
             $params = $params . "&PreapprovalCode=" . $this->preapprovalCode;
         }
         if ($this->comment != "") {
             $params = $params . "&Comment=" . $this->comment;
         }
         if ($this->CVV2 != "") {
             $params = $params . "&CVV2=" . $this->CVV2;
         }
         if ($this->issueNumber != "") {
             $params = $params . "&IssueNum=" . $this->issueNumber;
         }
         $params = $params . "&FirstName=" . $this->firstName;
         $params = $params . "&LastName=" . $this->lastName;
         $params = $params . "&Address=" . $this->streetAddress;
         $params = $params . "&City=" . $this->city;
         $params = $params . "&State=" . $this->state;
         $params = $params . "&ZipCode=" . $this->zipCode;
         $params = $params . "&Version=" . $this->version;
         $url = "";
         $postAction = "/trams/authresult.pro";
         $user_agent = "Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)";
         try {
             if ($this->testMode == true) {
                 $url = "http://" . $this->webServer . $postAction;
             } else {
                 $url = "https://" . $this->webServer . $postAction;
             }
             $ch = curl_init();
             curl_setopt($ch, CURLOPT_POST, 1);
             curl_setopt($ch, CURLOPT_POSTFIELDS, $params);
             curl_setopt($ch, CURLOPT_URL, $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_SSL_VERIFYPEER, false);
             // this line makes it work under https
             if ($this->proxyHost != "" and $this->proxyPort > 0) {
                 //set up proxy
                 curl_setopt($ch, CURLOPT_PROXY, $this->proxyHost);
                 curl_setopt($ch, CURLOPT_PROXYPORT, $this->proxyPort);
                 curl_setopt($ch, CURLOPT_PROXYUSERPWD, $this->proxyUsername . "," . $this->proxyPassword);
                 curl_setopt($ch, CURLOPT_HTTPPROXYTUNNEL, true);
             }
             $iatsReturn = curl_exec($ch);
             $this->error = curl_error($ch);
             $errorNumber = curl_errno($ch);
             //echo  $iatsReturn;
             curl_close($ch);
             if ($errorNumber != 0) {
                 $this->status = 0;
                 $this->error = "Error:" + $this->error;
                 $this->authorizationResult = "REJECT: ERRORPOST";
                 return;
             } else {
                 $this->status = 0;
                 $this->authorizationResult = "REJECT: 1";
                 $this->error = "AUTH ERROR!";
                 $iatsReturn = stristr($iatsReturn, "AUTHORIZATION RESULT:");
                 $iatsReturn = substr($iatsReturn, strpos($iatsReturn, ":") + 1, strpos($iatsReturn, "<") - strpos($iatsReturn, ":") - 1);
                 if ($iatsReturn == "") {
                     $this->status = 0;
                     $this->error = "PAGE ERROR";
                     $this->authorizationResult = "REJECT: ERRPAGE";
                 } else {
                     $this->status = 1;
                     $this->error = "";
                     $this->authorizationResult = $iatsReturn;
                 }
             }
             //end else
         } catch (Exception $e) {
             $this->status = 0;
             $this->error = "Error: ERRORCONN";
             $this->authorizationResult = "REJECT: ERRORCONN";
             return;
         }
     } catch (Exception $e) {
         $this->status = 0;
         $this->error = "12002";
         $this->authorizationResult = "REJECT: SYSERROR";
         return;
     }
 }
<?php

require_once 'model/session.php';
$session = new Session();
$data = NULL;
if (isset($_GET['order-id'])) {
    require_once 'model/order.php';
    require_once 'model/credit_card.php';
    require_once 'model/delivery_address.php';
    $order = new Order();
    $credit_card = new creditCard();
    $delivery_address = new deliveryAddress();
    $data = $order->find('id', $_GET['order-id']);
    $card = $credit_card->multipleFind('user_id', $data['user_id']);
    $address = $delivery_address->multipleFind('user_id', $data['user_id']);
}
?>

<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="utf-8">
	<?php 
include "./include/header.php";
?>
	<title>Restaurant Finder</title>
</head>
<body>
	<?php 
include "./include/navbar.php";
?>
<?php

require_once $_SERVER['DOCUMENT_ROOT'] . "/model/credit_card.php";
$credit_card = new creditCard();
print_r($credit_card->newCard($_POST));
?>