Beispiel #1
0
    // $opt1->Value = $_POST['txtOption1'];
    // $opt2 = new eWAY\Option();
    // $opt2->Value = $_POST['txtOption2'];
    // $opt3 = new eWAY\Option();
    // $opt3->Value = $_POST['txtOption3'];
    // $request->Options->Option[0]= $opt1;
    // $request->Options->Option[1]= $opt2;
    // $request->Options->Option[2]= $opt3;
    $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';
    }
}
?>
Beispiel #2
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;
         }
     }
 }
Beispiel #3
0
        $_SESSION['eWAY_password'] = $_POST['APIPassword'];
        $_SESSION['eWAY_sandbox'] = $_POST['ddlSandbox'];

        $in_page = 'payment_page';
    }
}

if ( isset($_GET['AccessCode']) ) {
    $AccessCode = $_GET['AccessCode'];

    // should be somewhere from config instead of SESSION
    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";
            }
        }
    }
        $_SESSION['eWAY_password'] = $_POST['APIPassword'];
        $_SESSION['eWAY_sandbox'] = $_POST['ddlSandbox'];

        $in_page = 'payment_page';
    }
}

if ( isset($_GET['AccessCode']) ) {
    $AccessCode = $_GET['AccessCode'];

    // should be somewhere from config instead of SESSION
    if ($_SESSION['eWAY_key'] && $_SESSION['eWAY_password']) {
        // Call RapidAPI
        $eway_params = array();
        if ($_SESSION['eWAY_sandbox']) $eway_params['sandbox'] = true;
        $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";
            }
        }
    }
Beispiel #5
0
        // Populate values for Payment Object
        $request->Payment->TotalAmount = $charge1.'00';
        $request->Payment->InvoiceNumber = $invoice_no;
        $request->Payment->CurrencyCode = $_POST['txtCurrencyCode'];
    }
	 	
	  $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['APIKey'], $_POST['APIPassword'], $eway_params);
    $result = $service->DirectPayment($request);


		
	
		// create new PDF document
		$pdf = new MYPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
		
		// set document information
		$pdf->SetCreator(PDF_CREATOR);
		$pdf->SetAuthor('EziFuneral');
		$pdf->SetTitle('TCPDF Example 003');
		$pdf->SetSubject('At Need Plan');
		$pdf->SetKeywords('TCPDF, PDF, example, test, guide');
		
Beispiel #6
0
<?php

//define( 'SHORTINIT', true );
require_once dirname(dirname(dirname(dirname(__FILE__)))) . '/wp-load.php';
// check if payment was successfull
if (is_file(dirname(dirname(__FILE__)) . '/carrental-payments-eway/RapidAPI.php')) {
    require_once dirname(dirname(__FILE__)) . '/carrental-payments-eway/RapidAPI.php';
    $payments_others = unserialize(get_option('carrental_available_payments_others'));
    if ($payments_others && !empty($payments_others) && isset($payments_others['eway']) && $payments_others['eway']['enabled'] == 'yes') {
        $request = new eWAY\GetAccessCodeResultRequest();
        $request->AccessCode = $_GET['AccessCode'];
        $service = new eWAY\RapidAPI($payments_others['eway']['api-key'], $payments_others['eway']['api-password']);
        $result = $service->GetAccessCodeResult($request);
        if ($result) {
            if ($result->ResponseMessage) {
                if (substr($result->ResponseMessage, 0, 2) == 'A2' && $result->TotalAmount > 0) {
                    // payment approved
                    $wpdb->query($wpdb->prepare('UPDATE ' . CarRental::$db['booking'] . ' SET `paid_online` = ' . (double) ($result->TotalAmount / 100) . ', `status` = 1 WHERE MD5(CONCAT(`id_order`, %s, `email`)) = %s', CarRental::$hash_salt, $result->InvoiceReference));
                    $lang = 'en_GB';
                    if (isset($result->Options) && isset($result->Options[0]) && isset($result->Options[0]->Value) && !empty($result->Options[0]->Value)) {
                        $lang = $result->Options[0]->Value;
                    }
                    // Send e-mail
                    $emailBody = get_option('carrental_reservation_email_' . $lang);
                    if ($emailBody == '') {
                        $emailBody = get_option('carrental_reservation_email_en_GB');
                    }
                    $emailSubject = get_option('carrental_reservation_email_subject_' . $lang);
                    if ($emailSubject == '') {
                        $emailSubject = get_option('carrental_reservation_email_subject_en_GB');
                    }
Beispiel #7
0
    // Populate values for Options
    $opt1 = new eWAY\Option();
    $opt1->Value = $_POST['txtOption1'];
    $opt2 = new eWAY\Option();
    $opt2->Value = $_POST['txtOption2'];
    $opt3 = new eWAY\Option();
    $opt3->Value = $_POST['txtOption3'];
    $request->Options->Option[0] = $opt1;
    $request->Options->Option[1] = $opt2;
    $request->Options->Option[2] = $opt3;
    // Call RapidAPI
    $eway_params = array();
    if ($_POST['ddlSandbox']) {
        $eway_params['sandbox'] = true;
    }
    $service = new eWAY\RapidAPI($_POST['txtUsername'], $_POST['txtPassword'], $eway_params);
    $result = $service->Refund($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';
    }
}
?>
Beispiel #8
0
 /**
  *	Booking 4/4
  */
 public static function carrental_confirm_reservation()
 {
     $order_hash = self::save_booking($_POST);
     if ((int) $_POST['paypal'] == 1 && (double) $_POST['total_rental'] > 0) {
         $paypal = get_option('carrental_paypal');
         $available_payments = unserialize(get_option('carrental_available_payments'));
         if (isset($available_payments) && isset($available_payments['carrental-paypal-security-deposit']) && (double) $available_payments['carrental-paypal-security-deposit'] > 0) {
             // if paypal security deposit is set
             $_POST['total_rental'] = $_POST['total_rental'] * ((double) $available_payments['carrental-paypal-security-deposit'] / 100);
             if (isset($available_payments['carrental-paypal-security-deposit-round'])) {
                 if ($available_payments['carrental-paypal-security-deposit-round'] == 'up') {
                     $_POST['total_rental'] = ceil($_POST['total_rental']);
                 } elseif ($available_payments['carrental-paypal-security-deposit-round'] == 'down') {
                     $_POST['total_rental'] = floor($_POST['total_rental']);
                 } else {
                     $_POST['total_rental'] = round($_POST['total_rental'], 2);
                 }
             } else {
                 $_POST['total_rental'] = round($_POST['total_rental'], 2);
             }
         }
         // Redirect to PayPal
         $query = array();
         $query['cmd'] = '_xclick';
         $query['business'] = $paypal;
         $query['email'] = $_POST['email'];
         $query['item_name'] = 'Car Rental Reservation #' . $order_hash;
         $query['quantity'] = 1;
         $query['return'] = home_url() . '?page=carrental&payment=paypal&summary=' . $order_hash;
         $query['item_number'] = $order_hash;
         $query['custom'] = isset($_SESSION['carrental_language']) && !empty($_SESSION['carrental_language']) ? $_SESSION['carrental_language'] : 'en_GB';
         $query['notify_url'] = CARRENTAL__PLUGIN_URL . 'paypal_ipn.php';
         $query['cancel_return'] = $_SERVER['HTTP_REFERER'] . '&paymentError=1';
         $query['amount'] = number_format((double) $_POST['total_rental'], 2, '.', '');
         $query['currency_code'] = $_POST['currency_code'];
         // Prepare query string
         $query_string = http_build_query($query);
         Header('Location: https://www.paypal.com/cgi-bin/webscr?' . $query_string);
         return;
     }
     // is it eway payment?
     if ($_POST['payment_option'] == 'eway' && (double) $_POST['total_rental'] > 0) {
         $payments_others = unserialize(get_option('carrental_available_payments_others'));
         if ($payments_others && !empty($payments_others) && isset($payments_others['eway']) && $payments_others['eway']['enabled'] == 'yes' && (double) $payments_others['eway']['security-deposit'] > 0) {
             $_POST['total_rental'] = $_POST['total_rental'] * ((double) $payments_others['eway']['security-deposit'] / 100);
             if (isset($payments_others['eway']['security-deposit-round'])) {
                 if ($payments_others['eway']['security-deposit-round'] == 'up') {
                     $_POST['total_rental'] = ceil($_POST['total_rental']);
                 } elseif ($payments_others['eway']['security-deposit-round'] == 'down') {
                     $_POST['total_rental'] = floor($_POST['total_rental']);
                 } else {
                     $_POST['total_rental'] = round($_POST['total_rental'], 2);
                 }
             } else {
                 $_POST['total_rental'] = round($_POST['total_rental'], 2);
             }
             require_once dirname(dirname(__FILE__)) . '/carrental-payments-eway/RapidAPI.php';
             $request = new eWAY\CreateAccessCodesSharedRequest();
             $request->Payment->TotalAmount = number_format((double) $_POST['total_rental'], 2, '.', '') * 100;
             // Amount is in cents, 100 = $1.00
             //$request->Payment->CurrencyCode = 'AUD';//$_POST['currency_code'];
             $request->Payment->InvoiceReference = $order_hash;
             $request->Options->Option[] = isset($_SESSION['carrental_language']) && !empty($_SESSION['carrental_language']) ? $_SESSION['carrental_language'] : 'en_GB';
             $request->RedirectUrl = CARRENTAL__PLUGIN_URL . 'eway_ipn.php';
             $request->CancelUrl = $_SERVER['HTTP_REFERER'] . '&ewayError=1';
             $service = new eWAY\RapidAPI($payments_others['eway']['api-key'], $payments_others['eway']['api-password']);
             //print_r($request);die();
             // Get the AccessCode
             $result = $service->CreateAccessCodesShared($request);
             if (!empty($result->Errors)) {
                 die(eWAY\ResponseCode::getMessage($result->Errors));
             }
             // Send the customer to eWAY to pay
             header("Location: " . $result->SharedPaymentUrl);
             exit;
         }
     }
     // is it mercadopago payment?
     if ($_POST['payment_option'] == 'mercadopago' && (double) $_POST['total_rental'] > 0) {
         $payments_others = unserialize(get_option('carrental_available_payments_others'));
         if ($payments_others && !empty($payments_others) && isset($payments_others['mercadopago']) && $payments_others['mercadopago']['enabled'] == 'yes' && (double) $payments_others['mercadopago']['security-deposit'] > 0) {
             $_POST['total_rental'] = $_POST['total_rental'] * ((double) $payments_others['mercadopago']['security-deposit'] / 100);
             if (isset($payments_others['mercadopago']['security-deposit-round'])) {
                 if ($payments_others['mercadopago']['security-deposit-round'] == 'up') {
                     $_POST['total_rental'] = ceil($_POST['total_rental']);
                 } elseif ($payments_others['mercadopago']['security-deposit-round'] == 'down') {
                     $_POST['total_rental'] = floor($_POST['total_rental']);
                 } else {
                     $_POST['total_rental'] = round($_POST['total_rental'], 2);
                 }
             } else {
                 $_POST['total_rental'] = round($_POST['total_rental'], 2);
             }
             require_once dirname(dirname(__FILE__)) . '/carrental-payments-mercadopago/mercadopago.php';
             $mp = new MP($payments_others['mercadopago']['client-id'], $payments_others['mercadopago']['client-secret']);
             $sandbox = false;
             $mp->sandbox_mode($sandbox);
             $preference_data = array("items" => array(array("id" => $order_hash, "title" => 'Car Rental Reservation #' . $order_hash, "currency_id" => 'ARS', "category_id" => "Category", "quantity" => 1, "unit_price" => (double) number_format((double) $_POST['total_rental'], 2, '.', ''))), "back_urls" => array("success" => home_url() . '?page=carrental&payment=paypal&summary=' . $order_hash, "failure" => $_SERVER['HTTP_REFERER'] . '&paymentError=1', "pending" => home_url() . '?page=carrental&payment=paypal&summary=' . $order_hash), "auto_return" => "approved", "notification_url" => CARRENTAL__PLUGIN_URL . 'mercadopago_ipn.php', "external_reference" => $order_hash . '#' . (isset($_SESSION['carrental_language']) && !empty($_SESSION['carrental_language']) ? $_SESSION['carrental_language'] : 'en_GB'), "expires" => false, "expiration_date_from" => null, "expiration_date_to" => null);
             try {
                 $preference = $mp->create_preference($preference_data);
             } catch (Exception $e) {
                 echo 'Error during MercadoPago payment: ' . $e->getMessage() . '. Please contact the administrator.';
                 exit;
             }
             Header('Location: ' . $preference['response'][($sandbox ? 'sandbox_' : '') . 'init_point']);
             exit;
         }
     }
     do_action('carrental_after_save_booking', $order_hash);
     Header('Location: ' . home_url() . '?page=carrental&summary=' . $order_hash);
     exit;
 }