Example #1
0
    if ($_SESSION['eWAY_key'] && $_SESSION['eWAY_password']) {
        // Call RapidAPI
        $eway_params = array();
        if ($_SESSION['eWAY_sandbox']) $eway_params['sandbox'] = false;
        $service = new eWAY\RapidAPI($_SESSION['eWAY_key'], $_SESSION['eWAY_password'], $eway_params);

        $request = new eWAY\GetAccessCodeResultRequest();
        $request->AccessCode = $AccessCode;
        $result = $service->GetAccessCodeResult($request);

        $in_page = 'view_result';
        if (isset($result->Errors)) {
            $ErrorArray = explode(",", $result->Errors);
            $lblError = "";
            foreach ( $ErrorArray as $error ) {
                $error = $service->getMessage($error);
                $lblError .= $error . "<br />\n";
            }
        }
    }
}

?>


<!doctype html>
<!--[if lt IE 7]> <html class="ie6 oldie"> <![endif]-->
<!--[if IE 7]>    <html class="ie7 oldie"> <![endif]-->
<!--[if IE 8]>    <html class="ie8 oldie"> <![endif]-->
<!--[if gt IE 8]><!-->
<html class="">
Example #2
0
    $request->Method = $_POST['ddlMethod'];
    $request->TransactionType = $_POST['ddlTransactionType'];
    // Call RapidAPI
    $eway_params = array();
    if ($_POST['ddlSandbox']) {
        $eway_params['sandbox'] = true;
    }
    $service = new eWAY\RapidAPI($_POST['txtUsername'], $_POST['txtPassword'], $eway_params);
    $result = $service->DirectPayment($request);
    // Check if any error returns
    if (isset($result->Errors)) {
        // Get Error Messages from Error Code. Error Code Mappings are in the Config.ini file
        $ErrorArray = explode(",", $result->Errors);
        $lblError = "";
        foreach ($ErrorArray as $error) {
            $error = $service->getMessage($error);
            $lblError .= $error . "<br />\n";
        }
    } else {
        $in_page = 'view_result';
    }
}
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
    <title></title>
    <link href="../assets/Styles/Site.css" rel="stylesheet" type="text/css" />
    <link href="../assets/Styles/jquery-ui-1.8.11.custom.css" rel="stylesheet" type="text/css" />
    <script src="../assets/Scripts/jquery-1.4.4.min.js" type="text/javascript"></script>
Example #3
0
 function submit()
 {
     require_once 'eWay/lib.php';
     //Send card data
     $this->credit_card_details = array('card_number' => $_POST['eway_card_number'], 'expiry_month' => $_POST['eway_expiry_month'], 'expiry_year' => $_POST['eway_expiry_year'], 'card_code' => $_POST['eway_card_code']);
     $request = new eWAY\CreateDirectPaymentRequest();
     //Send vars to eWay
     $request->Customer->FirstName = $this->cart_data['billing_address']['first_name'];
     $request->Customer->LastName = $this->cart_data['billing_address']['last_name'];
     $request->Customer->Reference = $this->cart_data['session_id'];
     $request->Customer->City = $this->cart_data['billing_address']['city'];
     $request->Customer->State = $this->cart_data['billing_address']['state'];
     $request->Customer->PostalCode = $this->cart_data['billing_address']['post_code'];
     $request->Customer->Email = $this->cart_data['email_address'];
     //Card info
     $request->Customer->CardDetails->Name = $request->Customer->FirstName . ' ' . $request->Customer->LastName;
     $request->Customer->CardDetails->Number = $this->credit_card_details['card_number'];
     $request->Customer->CardDetails->ExpiryMonth = $this->credit_card_details['expiry_month'];
     $request->Customer->CardDetails->ExpiryYear = $this->credit_card_details['expiry_year'];
     $request->Customer->CardDetails->CVN = $this->credit_card_details['card_code'];
     //Populate values for LineItems
     $i = 0;
     foreach ($this->cart_items as $cart_row) {
         $item[$i] = new eWAY\LineItem();
         $item[$i]->Description = $cart_row['name'];
         $item[$i]->Quantity = $cart_row['quantity'];
         $item[$i]->UnitCost = $cart_row['price'] * 100;
         $item[$i]->Total = $cart_row['price'] * 100 * $cart_row['quantity'];
         $request->Items->LineItem[$i] = $item[$i];
         $i++;
     }
     //Options
     $opt = new eWAY\Option();
     $opt->Value = $this->cart_data['session_id'];
     $request->Options->Option[0] = $opt;
     //Populate values for Payment Object
     $request->Payment->TotalAmount = number_format($this->cart_data['total_price'], 2, '.', '') * 100;
     $request->Payment->CurrencyCode = $this->cart_data['store_currency'];
     $request->Payment->InvoiceReference = $this->cart_data['session_id'];
     //Misc data
     $request->Method = 'ProcessPayment';
     $request->TransactionType = 'Purchase';
     $eway_params = array();
     if (get_option('eway_testmode') == 'test') {
         $eway_params['sandbox'] = true;
     }
     $service = new eWAY\RapidAPI(get_option('eway_apikey'), get_option('eway_apipassword'), $eway_params);
     $result = $service->DirectPayment($request);
     if (isset($result->Errors)) {
         // Get Error Messages from Error Code. Error Code Mappings are in the Config.ini file
         $ErrorArray = explode(",", $result->Errors);
         $lblError = "";
         foreach ($ErrorArray as $error) {
             $error = $service->getMessage($error);
             $lblError .= $error . "<br />\n";
         }
     }
     if (isset($lblError)) {
         $error_messages = wpsc_get_customer_meta('checkout_misc_error_messages');
         if (!is_array($error_messages)) {
             $error_messages = array();
         }
         $error_messages[] = '<strong style="color:red">' . $lblError . ' </strong>';
         wpsc_update_customer_meta('checkout_misc_error_messages', $error_messages);
         $this->return_to_checkout();
         exit;
     }
     if (isset($result->TransactionStatus) && $result->TransactionStatus && (is_bool($result->TransactionStatus) || $result->TransactionStatus != "false")) {
         $sessionid = $result->Payment->InvoiceReference;
         $purchase_log = new WPSC_Purchase_Log($sessionid, 'sessionid');
         $purchase_log->set(array('processed' => WPSC_Purchase_Log::ACCEPTED_PAYMENT, 'transactid' => $result->TransactionID, 'notes' => 'eWay Auth Code : "' . $result->AuthorisationCode . '"'));
         $purchase_log->save();
         $this->go_to_transaction_results($this->cart_data['session_id']);
         exit;
     } else {
         $error_messages = wpsc_get_customer_meta('checkout_misc_error_messages');
         if (!is_array($error_messages)) {
             $error_messages = array();
         }
         $error_messages[] = '<strong style="color:red">' . parse_error_message_eway($result->ResponseMessage) . ' </strong>';
         wpsc_update_customer_meta('checkout_misc_error_messages', $error_messages);
         $checkout_page_url = get_option('shopping_cart_url');
         if ($checkout_page_url) {
             header('Location: ' . $checkout_page_url);
             exit;
         }
     }
 }