Exemplo n.º 1
0
function ProcessFormRegister()
{
    global $tpl, $user, $error_list, $order, $mail, $product, $coupon, $pay_class, $currency_code, $currency_unit;
    $product_id = $_REQUEST['product_id'];
    $username = stripslashes($_REQUEST['username']);
    $password = stripslashes($_REQUEST['password']);
    $repassword = stripslashes($_REQUEST['repassword']);
    $firstname = stripslashes($_REQUEST['firstname']);
    $lastname = stripslashes($_REQUEST['lastname']);
    $email = stripslashes($_REQUEST['email']);
    $address1 = stripslashes($_REQUEST['address1']);
    $address2 = stripslashes($_REQUEST['address2']);
    $city = stripslashes($_REQUEST['city']);
    $state = stripslashes($_REQUEST['state']);
    $zip = stripslashes($_REQUEST['zip']);
    $phone = stripslashes($_REQUEST['phone']);
    $payment_gateway = $_REQUEST['payment_gateway'];
    $products = $product->GetProduct($product_id);
    $date_order_mo = $_REQUEST['date_order'];
    //figure out what the timestamp for the month should be
    if ($date_order_mo < date('m')) {
        //year+1
        $date_order = strtotime(date('Y') + 1 . '/' . $date_order_mo . '/1');
    } else {
        $date_order = strtotime(date('Y') . '/' . $date_order_mo . '/1');
    }
    $i = 0;
    if ($product_id == "") {
        $error_list[$i] = "Please select membership type";
        $i++;
    }
    if ($username == "") {
        $error_list[$i] = "Username is required";
        $i++;
    }
    if ($password == "") {
        $error_list[$i] = "Password is required";
        $i++;
    }
    if ($repassword == "") {
        $error_list[$i] = "Retype password is required";
        $i++;
    }
    if ($firstname == "") {
        $error_list[$i] = "Firstname is required";
        $i++;
    }
    if ($lastname == "") {
        $error_list[$i] = "Lastname is required";
        $i++;
    }
    if ($email == "") {
        $error_list[$i] = "Email is required";
        $i++;
    }
    if ($address1 == "") {
        $error_list[$i] = _("Address is required");
        $i++;
    }
    if ($city == "") {
        $error_list[$i] = _("City is required");
        $i++;
    }
    if ($state == "") {
        $error_list[$i] = _("State is required");
        $i++;
    }
    if ($zip == "") {
        $error_list[$i] = _("Zip is required");
        $i++;
    }
    if ($payment_gateway == "" && $products['price'] > 0) {
        $error_list[$i] = "Please select payment gateway";
        $i++;
    }
    if ($user->CheckUser($username, $email)) {
        $error_list[$i] = "Username or email already exist";
        $i++;
    }
    if ($repassword != $password) {
        $error_list[$i] = "password doesnt match";
        $i++;
    }
    if (!IsEmailAddress($email)) {
        $error_list[$i] = "email is not valid";
        $i++;
    }
    if (!is_array($error_list)) {
        $product_id = $_REQUEST['product_id'];
        $price = $products['price'];
        $name = $products['name'];
        $description = $products['description'];
        $item_name = $name . " ( " . $description . " )";
        $invoice_id = getInvoiceId();
        //**** for coupon ****//
        if ($coupon_code != "") {
            $discount_data = $coupon->CheckProductDiscount($coupon_code, $product_id);
            if (!$discount_data) {
            } else {
                $percentage = strrpos($discount_data['coupon_value'], "%");
                if ($percentage) {
                    $percent = str_replace("%", "", $discount_data['coupon_value']);
                    $coupon_value_type = "percentage";
                    $percentage_coupon_value = $percent;
                    $net_price = $discount_data['price'] - $discount_data['price'] * ($percent / 100);
                } else {
                    $coupon_value_type = "price";
                    $price_coupon_value = $discount_data['coupon_value'];
                    $net_price = $discount_data['price'] - $discount_data['coupon_value'];
                }
                $price = $net_price;
                if ($price < 0) {
                    $price = 0;
                }
            }
        }
        if ($price == 0) {
            $user_id = $user->Add($username, $password, $firstname, $lastname, $email, $address1, $address2, $city, $state, $zip, $phone);
            $order_id = $order->AddOrder($user_id, $product_id, $date_order);
            $order_data = $order->GetOrder($order_id);
            $product_name = $order_data['name'];
            $product_desc = $order_data['description'];
            $product_price = $order_data['price'];
            $product_expire = date("Y-m-d", $order_data['date_expire']);
            $from_email = CFG_NOTIFY_EMAIL;
            $from_name = CFG_NOTIFY_FROM;
            $mail->ConfirmOrderEmail(CFG_SITE_NAME, $firstname, $lastname, $from_email, $from_name, $product_name, $product_desc, $product_price, $product_expire, $email);
            $mail->ReceivedOrderEmail(CFG_SITE_NAME, $firstname, $lastname, $from_email, $from_name, $product_name, $product_desc, $product_price, $date_order, $product_expire, CFG_SITE_MAIL);
            $order->UpdateLastEmailSent($order_id, time());
            $login = $user->Login($username, $password, $expire);
            header("Location: index.php");
        } else {
            $firstname = $_REQUEST['firstname'];
            $lastname = $_REQUEST['lastname'];
            $email = $_REQUEST['email'];
            $username = $_REQUEST['username'];
            $password = $_REQUEST['password'];
            $currency_code = $currency_code;
            //$currency_unit ===== GLOBAL VARIABLE
            $return_url = CFG_SITE_URL;
            $cancel_url = CFG_SITE_URL;
            $total = $price;
            $custom = "{$product_id}&{$email}&{$username}&{$password}&{$firstname}&{$lastname}&{$coupon_code}&{$date_order}";
            if ($payment_gateway == "co" || $payment_gateway == "co_subscribe") {
                $gateway_data = $pay_class->GetPaymentGatewayDetail("2" . $payment_gateway);
            } else {
                $gateway_data = $pay_class->GetPaymentGatewayDetail($payment_gateway);
            }
            if ($payment_gateway == "paypal_payments") {
                $notify_url = CFG_SITE_URL . '/payment/paypal.ipn.php';
                $paypal_payments_email = $gateway_data['payment_gateway_account'];
                $paypal_email = $paypal_payments_email;
                include 'payment/paypal.php';
            } elseif ($payment_gateway == "paypal_subscribe") {
                $notify_url = CFG_SITE_URL . '/payment/paypal-subscribe.ipn.php';
                $paypal_subscribe_email = $gateway_data['payment_gateway_account'];
                $listing_period = $products['duration'];
                $listing_period_code = strtoupper($products['duration_unit']);
                $paypal_email = $paypal_subscribe_email;
                include 'payment/paypal-subscribe.php';
            } elseif ($payment_gateway == "co") {
                $notify_url = CFG_SITE_URL . '/payment/2co.ipn.php';
                $co_account = $gateway_data['payment_gateway_account'];
                $list_co_account = explode("&", $co_account);
                $co_sid = $list_co_account[0];
                $co_secret = $list_co_account[1];
                $co_recurring = 0;
                //set subscribe
                include 'payment/2co.php';
            } elseif ($payment_gateway == "co_subscribe") {
                $notify_url = CFG_SITE_URL . '/payment/2co-subscribe.ipn.php';
                $co_account = $gateway_data['payment_gateway_account'];
                $list_co_account = explode("&", $co_account);
                $co_sid = $list_co_account[0];
                $co_secret = $list_co_account[1];
                $co_recurring = 1;
                //set subscribe
                $co_prod_id = $product_id;
                include 'payment/2co-subscribe.php';
            } elseif ($payment_gateway == "alertpay") {
                $notify_url = CFG_SITE_URL . '/payment/alertpay.ipn.php';
                $alertpay_account = $gateway_data['payment_gateway_account'];
                $list_alertpay_account = explode("&", $alertpay_account);
                $payalert_email = $list_alertpay_account[0];
                $payalert_security_code = $list_alertpay_account[1];
                $ap_currency = $currency_code;
                $ap_purchasetype = "service";
                //lainnya subscription & service
                include 'payment/alertpay.php';
            } elseif ($payment_gateway == "alertpay_subscribe") {
                $notify_url = CFG_SITE_URL . '/payment/alertpay.ipn.php';
                $alertpay_subscribe_account = $gateway_data['payment_gateway_account'];
                $list_alertpay_subscribe_account = explode("&", $alertpay_subscribe_account);
                $payalert_email = $list_alertpay_subscribe_account[0];
                $payalert_security_code = $list_alertpay_subscribe_account[1];
                $ap_currency = $currency_code;
                $ap_purchasetype = "Subscription";
                //lainnya subscription & service
                if (strtolower($products['duration_unit']) == "d") {
                    $ap_timeunit = "Day";
                } elseif (strtolower($products['duration_unit']) == "m") {
                    $ap_timeunit = "Month";
                } elseif (strtolower($products['duration_unit']) == "y") {
                    $ap_timeunit = "Year";
                }
                $ap_periodlength = $products['duration'];
                include 'payment/alertpay-subscribe.php';
            } elseif ($payment_gateway == "moneybookers") {
                $notify_url = CFG_SITE_URL . '/payment/moneybookers.ipn.php';
                $moneybookers_email = $gateway_data['payment_gateway_account'];
                include 'payment/moneybookers.php';
            }
        }
    } else {
        ShowFormRegister();
    }
}
Exemplo n.º 2
0
        echo " contain a value and the ap_TrialAmount is not equal to 0.";
    } else {
        if ($ap_Status == "Success") {
            // The is not a free trial and ap_TrialAmount contains some amount and the
            // ap_ReferenceNumber contains a valid transaction reference number.
            $raw = explode('&', urldecode($_POST['apc_1']));
            $val_product_id = $raw[0];
            $val_email = $raw[1];
            $val_username = $raw[2];
            $val_password = $raw[3];
            $val_firstname = $raw[4];
            $val_lastname = $raw[5];
            $val_coupon_code = $raw[6];
            $val_date_order = $raw[7];
            $log = implode("\n", $_POST);
            $invoice_id = getInvoiceId();
            $payment_date = time();
            ProcessIPN($payalert_email, $_POST['ap_merchant'], $_POST['ap_amount'], $val_product_id, $val_username, $val_password, $val_firstname, $val_lastname, $val_email, $log, $payment_date, $payment_gateway, $invoice_id, $val_coupon_code, $val_date_order);
        } else {
            echo "Transaction cancelled means seller explicitely cancelled the subscription or AlertPay ";
            echo "cancelled or it was cancelled since buyer didnt have enough money after resheduling after two times.";
            echo "Take Action appropriately";
            if ($ap_PurchaseType == "Subscription") {
                setSubscriptionVariables();
            } else {
            }
        }
    }
}
function setSubscriptionVariables()
{
Exemplo n.º 3
0
     for ($i = 0; $i < count($data); $i++) {
         deleteRoom($data[$i]);
     }
 }
 if (isset($_POST['add'])) {
     $total = $_POST['total'];
     $amount = $_POST['amount'];
     $section = $_POST['section'];
     $order_date = date("Y-m-d");
     $method = $_POST['method'];
     $client = $_POST['client'];
     //Get Invoice invoice id and insert data
     $query = "select * from invoice where date_issued='" . $order_date . "' and section_id='" . $section . "' and cust_id='" . $client . "'";
     $state = getData($query);
     if (empty($state)) {
         $id = getInvoiceId();
         $qry = "insert into invoice (invoice_number, date_issued, status, amount,section_id,cust_id,user_id) values ('" . $id . "','" . $order_date . "','pending','" . $total . "','" . $section . "','" . $client . "','" . $_SESSION['user_id'] . "')";
         update($qry);
     } else {
         $id = $state[0]['invoice_number'];
         $total_amnt = $total + $state[0]['amount'];
         $qry = "update invoice set amount='" . $total_amnt . "' where invoice_number='" . $id . "' and date_issued='" . $order_date . "'";
         update($qry);
     }
     //Insert Payment in payment Table
     $payid = getPayment();
     $query = "insert into payment (pay_id, amount, cust_id,section_id) values ('" . $payid . "','" . $amount . "','" . $client . "','" . $section . "')";
     update($query);
     header('Location: bill.php');
 }
 ?>
Exemplo n.º 4
0
 $lname = $_POST['lname'];
 $email = $_POST['email'];
 $tel = $_POST['phone'];
 $meal = $_POST['meal'];
 $description = $_POST['description'];
 $cust_id = getCustomerId();
 $date = date_create($from);
 $from = date_format($date, "Y-m-d 11:00:00");
 $date = date_create($to);
 $to = date_format($date, "Y-m-d 14:00:00");
 $date_issue = date('Y-m-d');
 //insert into customer
 $query = "insert into customer values ('" . $cust_id . "','" . $fname . "','" . $mname . "','" . $lname . "','" . $email . "','" . $tel . "')";
 update($query);
 //insert into invoice
 $invoice_no = getInvoiceId();
 $query = "insert into invoice (invoice_number, amount, status,date_issued,section_id,cust_id,user_id) values ('" . $invoice_no . "','" . $totalamnt . "','Pending','" . $date_issue . "','5','" . $cust_id . "','" . $_SESSION["user_id"] . "')";
 update($query);
 //insert amount paid into payment
 $query = "insert into payment (pay_id, amount, code, section_id,cust_id) values ('" . $payid . "','" . $payment . "','" . $code . "','5','" . $cust_id . "')";
 update($query);
 $no = getReserveId();
 $query = "insert into reservation (order_id, arrival_date, departure_date, cust_id, status,invoice_number,description, meal,user_id) values ('" . $no . "' , '" . $from . "' , '" . $to . "','" . $cust_id . "','Active','" . $invoice_no . "','" . $description . "','" . $meal . "','" . $_SESSION["user_id"] . "' )";
 update($query);
 //Standard single rooms
 if (isset($_POST['standard_single'])) {
     $adult_single = $_POST['adult_single'];
     $child_single = $_POST['child_single'];
     $child_singleb = $_POST['child_singleB'];
     $rooms_single = $_POST['stand_single'];
     for ($x = 0; $x < $rooms_single; $x++) {