function hDeck()
 {
     //$the_project = parent::the_project();
     $prod_settings = parent::get_project_settings();
     if (empty($prod_settings)) {
         $prod_settings = getProductDefaultSettings();
     }
     $post_id = parent::get_project_postid();
     $end_type = get_post_meta($post_id, 'ign_end_type', true);
     $item_fund_goal = apply_filters('id_project_goal', parent::the_goal(), $post_id);
     $p_current_sale = apply_filters('id_funds_raised', parent::get_project_raised(), $post_id);
     //
     $item_fund_end = parent::end_date();
     $end_day = parent::end_day();
     $end_month = parent::end_month();
     $end_year = parent::end_year();
     $days_left = parent::days_left();
     //
     $rating_per = apply_filters('id_percentage_raised', parent::percent(), apply_filters('id_funds_raised', parent::get_project_raised(), $post_id, true), $post_id, apply_filters('id_project_goal', parent::the_goal(), $post_id, true));
     //$p_count = new stdClass;
     //$p_count->p_number = parent::get_project_orders();
     $p_number = apply_filters('id_number_pledges', parent::get_project_orders(), $post_id);
     $currencyCodeValue = $prod_settings->currency_code;
     $cCode = setCurrencyCode($currencyCodeValue);
     $hDeck = new stdClass();
     $hDeck->end_type = $end_type;
     $hDeck->goal = $item_fund_goal;
     $hDeck->total = $p_current_sale;
     // what is this for?
     //$hDeck->show_dates = $show_dates;
     $hDeck->end = $item_fund_end;
     $hDeck->day = $end_day;
     $hDeck->month = apply_filters('id_end_month', $end_month);
     $hDeck->year = $end_year;
     $hDeck->days_left = apply_filters('id_project_days_left', $days_left, $post_id);
     //
     $hDeck->percentage = $rating_per;
     $hDeck->pledges = $p_number;
     $hDeck->currency_code = $cCode;
     return $hDeck;
 }
Exemplo n.º 2
0
function custom_settings()
{
    require 'languages/text_variables.php';
    global $wpdb;
    if (isset($_GET['pid']) && $_GET['pid'] !== "") {
        $pid = $_GET['pid'];
        $pay_selection = getDefaultPaymentMethod();
        $project = new ID_Project($pid);
        $product_settings = $project->get_project_settings();
        $products = $project->the_project();
        if (!empty($product_settings)) {
            $form = unserialize($product_settings->form_settings);
            $serializedForm = $product_settings->form_settings;
            $mc_api = $product_settings->mailchimp_api_key;
            $mc_list = $product_settings->mailchimp_list_id;
            $aweber_email = $product_settings->aweber_email;
            $mailtype = $product_settings->active_mailtype;
            $paypal_email = $product_settings->paypal_email;
            $currency_code = $product_settings->currency_code;
        } else {
            $mc_api = '';
            $mc_list = '';
            $aweber_email = '';
            $mailtype = '';
            $paypal_email = '';
            $currency_code = 'USD';
            $form = '';
            $serializedForm = serialize($form);
        }
    } else {
        $products = ID_Project::get_all_projects();
    }
    if (isset($_POST['btnSubmitProdSettings'])) {
        if (isset($_POST['mailchimp_api_key'])) {
            $mc_api = $_POST['mailchimp_api_key'];
        }
        if (isset($_POST['mailchimp_list_id'])) {
            $mc_list = $_POST['mailchimp_list_id'];
        }
        if (isset($_POST['aweber_email'])) {
            $aweber_email = $_POST['aweber_email'];
        }
        if (isset($_POST['active_mailtype'])) {
            $mailtype = $_POST['active_mailtype'];
        }
        if (isset($_POST['paypal_email'])) {
            $paypal_email = $_POST['paypal_email'];
        }
        if (isset($_POST['currency_code'])) {
            $currency_code = $_POST['currency_code'];
        }
        if (isset($_POST['ignitiondeck_form'])) {
            $form = $_POST['ignitiondeck_form'];
            $serializedForm = serialize($_POST['ignitiondeck_form']);
        }
        if (empty($product_settings)) {
            $sql_insert_product = "INSERT INTO " . $wpdb->prefix . "ign_product_settings (\n\t\t\t\t\t\t\t\t\t\tproduct_id,\n\t\t\t\t\t\t\t\t\t\tmailchimp_api_key,\n\t\t\t\t\t\t\t\t\t\tmailchimp_list_id,\n\t\t\t\t\t\t\t\t\t\taweber_email,\n\t\t\t\t\t\t\t\t\t\tactive_mailtype,\n\t\t\t\t\t\t\t\t\t\tform_settings,\n\t\t\t\t\t\t\t\t\t\tpaypal_email,\n\t\t\t\t\t\t\t\t\t\tcurrency_code\n\t\t\t\t\t\t\t\t\t) VALUES (\n\t\t\t\t\t\t\t\t\t\t'" . $_GET['pid'] . "',\n\t\t\t\t\t\t\t\t\t\t'" . $mc_api . "',\n\t\t\t\t\t\t\t\t\t\t'" . $mc_list . "',\n\t\t\t\t\t\t\t\t\t\t'" . $aweber_email . "',\n\t\t\t\t\t\t\t\t\t\t'" . $mailtype . "',\n\t\t\t\t\t\t\t\t\t\t'" . $serializedForm . "',\n\t\t\t\t\t\t\t\t\t\t'" . $paypal_email . "',\n\t\t\t\t\t\t\t\t\t\t'" . $currency_code . "'\n\t\t\t\t\t\t\t\t\t)";
            $wpdb->query($sql_insert_product);
            $message = '<div class="updated fade below-h2" id="message" class="updated"><p>' . $tr_Save_Settings . '</p></div>';
        } else {
            $sql_update_product = "UPDATE " . $wpdb->prefix . "ign_product_settings SET\n\t\t\t\t\t\t\t\t\tmailchimp_api_key = '" . $mc_api . "',\n\t\t\t\t\t\t\t\t\tmailchimp_list_id = '" . $mc_list . "',\n\t\t\t\t\t\t\t\t\taweber_email = '" . $aweber_email . "',\n\t\t\t\t\t\t\t\t\tactive_mailtype = '" . $mailtype . "',\n\t\t\t\t\t\t\t\t\tform_settings = '" . $serializedForm . "',\n\t\t\t\t\t\t\t\t\tpaypal_email = '" . $paypal_email . "',\n\t\t\t\t\t\t\t\t\tcurrency_code = '" . $currency_code . "'\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\tWHERE product_id = '" . $_GET['pid'] . "'\n\t\t\t\t\t\t\t\t\t";
            $wpdb->query($sql_update_product);
            $message = '<div class="updated fade below-h2" id="message" class="updated"><p>' . $tr_Settings_updated . '</p></div>';
        }
    } else {
        if (isset($_POST['btnClearProdSettings']) && $_POST['btnClearProdSettings'] != "") {
            $pid = $_GET['pid'];
            $project = new ID_Project($pid);
            $clear = $project->clear_project_settings();
            echo '<script>window.location="";</script>';
        } else {
            if (isset($_POST['btnClearAllSettings']) && $_POST['btnClearAllSettings'] != "") {
                $sql = "DELETE FROM " . $wpdb->prefix . "ign_product_settings";
                $clear_all_product_settings = $wpdb->query($sql);
            }
        }
    }
    echo '<div class="wrap">
			' . admin_menu_html();
    include_once 'templates/admin/_customSettings.php';
    echo '</div>';
}
function projectPurchaseAdaptive()
{
    if (isset($_POST)) {
        //exit;
    }
    if (isset($_POST['submitPaymentAdaptive'])) {
        // Store all the required variables in SESSION to get them later
        session_start();
        $project_id = $_POST['project_id'];
        $project = new ID_Project($project_id);
        $payment_variables = array("fname" => isset($_POST['first_name']) ? $_POST['first_name'] : '', "lname" => isset($_POST['last_name']) ? $_POST['last_name'] : '', "email" => isset($_POST['email']) ? $_POST['email'] : '', "address" => isset($_POST['address']) ? $_POST['address'] : '', "country" => isset($_POST['country']) ? $_POST['country'] : '', "state" => isset($_POST['state']) ? $_POST['state'] : '', "city" => isset($_POST['city']) ? $_POST['city'] : '', "zip" => isset($_POST['zip']) ? $_POST['zip'] : '', "product_id" => isset($_POST['project_id']) ? absint($_POST['project_id']) : '', "level" => isset($_POST['level']) ? absint($_POST['level']) : '', "prod_price" => isset($_POST['price']) ? str_replace(',', '', $_POST['price']) : '');
        $_SESSION['ig_payment_variables'] = http_build_query($payment_variables);
        //print_r($payment_variables);
        //echo $_SESSION['ig_payment_variables'];
        // Getting the Adaptive payment settings
        $adaptive_pay_settings = getAdaptivePayPalSettings();
        require_once 'paypal/lib/AdaptivePayments.php';
        // GETTING product default settings
        $default_prod_settings = getProductDefaultSettings();
        // Getting product settings and if they are not present, set the default settings as product settings
        $prod_settings = $project->get_project_settings();
        if (empty($prod_settings)) {
            $prod_settings = $default_prod_settings;
        }
        # Endpoint: this is the server URL which you have to connect for submitting your API request.
        //Chanege to https://svcs.paypal.com/  to go live */
        if ($adaptive_pay_settings->paypal_mode == "sandbox") {
            define('API_BASE_ENDPOINT', 'https://svcs.sandbox.paypal.com/');
            define('PAYPAL_REDIRECT_URL', 'https://www.sandbox.paypal.com/webscr&cmd=');
            $app_id = "APP-80W284485P519543T";
        } else {
            define('API_BASE_ENDPOINT', 'https://svcs.paypal.com/');
            define('PAYPAL_REDIRECT_URL', 'https://www.paypal.com/webscr&cmd=');
            $app_id = $adaptive_pay_settings->app_id;
        }
        /***** 3token API credentials *****************/
        define('API_AUTHENTICATION_MODE', '3token');
        define('API_USERNAME', $adaptive_pay_settings->api_username);
        define('API_PASSWORD', $adaptive_pay_settings->api_password);
        define('API_SIGNATURE', $adaptive_pay_settings->api_signature);
        define('X_PAYPAL_APPLICATION_ID', $app_id);
        require_once 'paypal/lib/Config/paypal_sdk_clientproperties.php';
        //print_r($adaptive_pay_settings);
        // Setting the necessary variables for the payment
        $returnURL = site_url() . "/?payment_success=1&product_id=" . $_POST['project_id'];
        $cancelURL = site_url() . "/?payment_cancel=1";
        $notifyURL = esc_url(site_url()) . "/?ipn_handler=1&" . $_SESSION['ig_payment_variables'];
        $currencyCode = $prod_settings->currency_code;
        $email = esc_attr($_POST['email']);
        $preapprovalKey = "";
        $requested = '';
        $payRequest = new PayRequest();
        $payRequest->actionType = "PAY";
        $payRequest->cancelUrl = $cancelURL;
        $payRequest->returnUrl = $returnURL;
        $payRequest->ipnNotificationUrl = $notifyURL;
        $payRequest->clientDetails = new ClientDetailsType();
        $payRequest->clientDetails->applicationId = $app_id;
        //"APP-1JE4291016473214C";
        //$payRequest->clientDetails->deviceId = DEVICE_ID;
        $payRequest->clientDetails->ipAddress = $_SERVER['REMOTE_ADDR'];
        $payRequest->currencyCode = $currencyCode;
        $payRequest->senderEmail = $email;
        $payRequest->requestEnvelope = new RequestEnvelope();
        $payRequest->requestEnvelope->errorLanguage = "en_US";
        //$payRequest->preapprovalKey = "PA-16707604HP296522Y";
        //print_r($payRequest);
        if ($preapprovalKey !== "") {
            $payRequest->preapprovalKey = $preapprovalKey;
            //echo $preapprovalKey."keyhere";
        }
        $receiver1 = new receiver();
        $receiver1->email = $adaptive_pay_settings->paypal_email;
        $receiver1->amount = esc_attr(str_replace(',', '', $_POST['price']));
        $payRequest->receiverList = new ReceiverList();
        $payRequest->receiverList = array($receiver1);
        /* 	Make the call to PayPal to get the Pay token
         *	If the API call succeded, then redirect the buyer to PayPal
         *	to begin to authorize payment.  If an error occured, show the
         *	resulting errors
         */
        $ap = new AdaptivePayments();
        //print_r($ap);
        $response = $ap->Pay($payRequest);
        //echo "end of line<br/>";
        if (strtoupper($ap->isSuccess) == 'FAILURE') {
            //echo "inside failure<br/>";
            $fault = $ap->getLastError();
            if (isset($fault)) {
                $errors = $fault->error;
            }
            if (count($errors) > 1) {
                $errors_content = array();
                foreach ($errors as $error) {
                    $errors_content[] = $error->message;
                }
            } else {
                $errors_content = $errors->message;
            }
            // For error handling
            /*if (is_object($fault->error))
            			{ 
            
            				//$errors_content = '<table width =\"450px\" align=\"center\">';
            				$errors_content;
            				$errors_content = '';
            				foreach($fault->error as $err) {
            
            					//$errors_content .= '<tr>';
            					//$errors_content .= '<td>';
            					//$errors_content .= 'Error ID: ' . $err->errorId . '<br />';
            					//$errors_content .= 'Domain: ' . $err->domain . '<br />';
            					//$errors_content .= 'Severity: ' . $err->severity . '<br />';
            					//$errors_content .= 'Category: ' . $err->category . '<br />';
            					$errors_content .= $err . "<br />";
            
            					if(empty($err->parameter)) {
            						//$errors_content .= '<br />';
            					}
            					else {
            						//$errors_content .= 'Parameter: ' . $err->parameter . '<br /><br />';
            					}
            						
            					//$errors_content .= '</td>';
            					//$errors_content .= '</tr>';
            				}
            				//$errors_content .= '</table>';
            			}
            			else
            			{
            
            				$errors_content = "";
            				//$errors_content .= 'Error ID: ' . $fault->error->errorId . '<br />';
            				//$errors_content .= 'Domain: ' . $fault->error->domain . '<br />';
            				//$errors_content .= 'Severity: ' . $fault->error->severity . '<br />';
            				//$errors_content .= 'Category: ' . $fault->error->category . '<br />';
            				$errors_content .= $fault->error->message . '<br />';
            				if(empty($fault->error->parameter)) {
            					//$errors_content .= '</br>';
            				}
            				else {
            					//$errors_content .= 'Parameter: ' . $fault->error->parameter . '<br /><br />';
            				}
            			}*/
            if ($_POST['price'] > 0) {
                $_SESSION['paypal_errors_content'] = $errors_content;
            } else {
                $_SESSION['paypal_errors_content'] = "Please enter an amount greater than 0.00";
            }
        } else {
            //echo "inside non-fail<br/>";
            $_SESSION['payKey'] = $response->payKey;
            if ($response->paymentExecStatus == "COMPLETED") {
                //$location = "PaymentDetails.php";
                $success_url = site_url() . "/?payment_success=1&product_id=" . $_POST['project_id'];
                echo '<script type="text/javascript">window.location="' . $success_url . '";</script>';
            } else {
                $token = $response->payKey;
                $payPalURL = PAYPAL_REDIRECT_URL . '_ap-payment&paykey=' . $token;
                echo '<script type="text/javascript">window.location="' . $payPalURL . '";</script>';
                //header("Location: ".$payPalURL);
            }
        }
    }
}
 function id_purchase_form()
 {
     $project = new ID_Project($this->project_id);
     $the_project = $project->the_project();
     $project_id = $this->project_id;
     $post_id = $project->get_project_postid();
     $project_settings = $project->get_project_settings();
     if (empty($prod_settings)) {
         $defaults = $project->get_project_defaults();
         $project_settings = $defaults;
     }
     $no_levels = get_post_meta($post_id, "ign_product_level_count", true);
     $project_type = get_post_meta($post_id, 'ign_project_type', true);
     $project_desc = get_post_meta($post_id, "ign_product_level_1_desc", true);
     $level_data = $project->get_level_data($post_id, $no_levels);
     // level one stuff
     $level_one_data = new stdClass();
     $is_level_invalid = getLevelLimitReached($this->project_id, $post_id, 1);
     $meta_title = $the_project->ign_product_title;
     $meta_price = get_post_meta($post_id, "ign_product_price", true);
     $meta_desc = $the_project->product_details;
     $meta_order = get_post_meta($post_id, 'ign_projectmeta_level_order', true);
     $level_one_data->is_level_invalid = $is_level_invalid;
     $level_one_data->meta_title = $meta_title;
     $level_one_data->meta_price = $meta_price;
     $level_one_data->meta_desc = $meta_desc;
     $level_one_data->meta_order = $meta_order;
     $level_one_data->id = 1;
     // add level one to object
     array_unshift($level_data, $level_one_data);
     $custom_level_order = get_post_meta($post_id, 'custom_level_order', true);
     if ($custom_level_order) {
         usort($level_data, 'ID_Project::level_sort');
     }
     //GETTING the currency symbols
     $currencyCodeValue = $project_settings->currency_code;
     $cCode = setCurrencyCode($currencyCodeValue);
     //GETTING the form settings
     $form_settings = getProductFormSettings($project_id);
     if (!isset($form_settings)) {
         $form_settings = $project_settings->form_settings;
         $form_settings = unserialize($form_settings);
     } else {
         $form_settings = unserialize($form_settings);
     }
     $form_id = rand(21927391, 92817275);
     // Getting the Payment method first, to load the appropriate URLs if needed and
     // submit button name
     // this is paypal code that could be removed if disabled
     $payment_method = getDefaultPaymentMethod();
     if (isset($payment_method) && $payment_method->payment_gateway == "adaptive_paypal") {
         $adaptive_pay_settings = getAdaptivePayPalSettings();
         if (isset($adaptive_pay_settings)) {
             if ($adaptive_pay_settings->paypal_mode == "sandbox") {
                 $paypal_address = "https://www.sandbox.paypal.com/webapps/adaptivepayment/flow/pay";
             } else {
                 $paypal_address = "https://www.paypal.com/webapps/adaptivepayment/flow/pay";
             }
             if ($adaptive_pay_settings->fund_type == 'fixed') {
                 $submit_btn_name = 'btnSubmitPreapproval';
             } else {
                 $submit_btn_name = "submitPaymentAdaptive";
             }
         }
     } else {
         $submit_btn_name = "submitPaymentPopup";
         //will be caught by standard payments function for Paypal
     }
     $purchase_form = new stdClass();
     $purchase_form->project_id = $project_id;
     $purchase_form->post_id = $post_id;
     $purchase_form->the_project = $the_project;
     $purchase_form->project_settings = $project_settings;
     $purchase_form->no_levels = $no_levels;
     $purchase_form->level_data = $level_data;
     $purchase_form->project_type = $project_type;
     $purchase_form->project_desc = $project_desc;
     $purchase_form->currencyCodeValue = $currencyCodeValue;
     $purchase_form->cCode = $cCode;
     $purchase_form->form_settings = $form_settings;
     $purchase_form->form_id = $form_id;
     if (isset($paypal_address)) {
         $purchase_form->paypal_address = $paypal_address;
     }
     $purchase_form->submit_btn_name = $submit_btn_name;
     if (isset($adaptive_pay_settings)) {
         $purchase_form->adaptive_pay_settings = $adaptive_pay_settings;
     }
     return $purchase_form;
 }
function get_product_levels_callback()
{
    global $wpdb;
    require 'languages/text_variables.php';
    if (isset($_POST['Project'])) {
        $project_id = absint($_POST['Project']);
        $project = new ID_Project($project_id);
        $product_settings = $project->get_project_settings();
        if (empty($product_settings)) {
            $product_settings = $project->get_project_defaults();
        }
        //GETTING the currency symbol
        if (isset($product_settings)) {
            $currencyCodeValue = $product_settings->currency_code;
            $cCode = setCurrencyCode($currencyCodeValue);
        } else {
            $currencyCodeValue = 'USD';
            $cCode = '$';
        }
        $post_id = $project->get_project_postid();
        $level_count = get_post_meta($post_id, 'ign_product_level_count', true);
        $meta_price_1 = get_post_meta($post_id, "ign_product_price", true);
        $options = "<option data-price='" . number_format($meta_price_1, 2, '.', '') . "' value=\"1\">" . $tr_Level . " 1: " . $tr_Price . " " . apply_filters('id_display_currency', apply_filters('id_price_format', absint($meta_price_1), $post_id), absint($meta_price_1), $post_id) . "</option>";
        if (isset($level_count) && $level_count > 0) {
            for ($i = 1; $i <= $level_count; $i++) {
                $meta_price = get_post_meta($post_id, $name = "ign_product_level_" . $i . "_price", true);
                if ($meta_price !== "") {
                    $options .= "<option data-price='" . number_format($meta_price, 2, '.', '') . "' value=\"" . $i . "\">" . $tr_Level . " " . $i . ": " . $tr_Price . " " . apply_filters('id_display_currency', apply_filters('id_price_format', $meta_price, $post_id), $meta_price, $post_id) . "</option>";
                }
            }
        }
        echo $options;
    }
    exit;
}