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; }
function id_setup_nags() { $settings = getSettings(); // Let's check if the notices have been cleared before $settings_notice = get_option('id_settings_notice'); $defaults_notice = get_option('id_defaults_notice'); $products_notice = get_option('id_products_notice'); $idf_notice = get_option('id_idf_notice'); if (empty($settings) && empty($settings_notice)) { // add settings nag add_action('admin_notices', 'id_settings_notice'); } $defaults = getProductDefaultSettings(); if ((empty($defaults) || !is_object($defaults)) && empty($defaults_notice)) { // add defaults nag add_action('admin_notices', 'id_defaults_notice'); } $products = ID_Project::get_all_projects(); if (empty($products) && empty($products_notice)) { // add products nag add_action('admin_notices', 'id_products_notice'); } if (!idf_exists() && empty($idf_notice)) { add_action('admin_notices', 'id_idf_notice'); } }
function adaptivePreapproval() { if (isset($_POST['btnSubmitPreapproval'])) { global $wpdb; $tz = get_option('timezone_string'); if (empty($tz)) { $tz = 'UTC'; } date_default_timezone_set($tz); //print_r($_POST); session_start(); $payment_variables = array("fname" => $_POST['first_name'], "lname" => $_POST['last_name'], "email" => $_POST['email'], "address" => $_POST['address'], "country" => $_POST['country'], "state" => $_POST['state'], "city" => $_POST['city'], "zip" => $_POST['zip'], "product_id" => absint($_POST['project_id']), "level" => absint($_POST['level']), "prod_price" => str_replace(',', '', $_POST['price'])); $preapproval_key = ""; $project = new ID_Project($variables['product_id']); $post_id = $project->get_project_postid(); $product_name = get_the_title($post_id); $_SESSION['ig_payment_variables'] = http_build_query($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 = getProductSettings(absint(esc_attr($_POST['project_id']))); 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/AdaptivePayments/Preapproval/'); define('PAYPAL_REDIRECT_URL', 'https://www.sandbox.paypal.com/webscr&cmd=_ap-preapproval&preapprovalkey=' . $preapproval_key); $app_id = "APP-80W284485P519543T"; } else { define('API_BASE_ENDPOINT', 'https://svcs.paypal.com/AdaptivePayments/Preapproval/'); define('PAYPAL_REDIRECT_URL', 'https://www.paypal.com/webscr&cmd=_ap-preapproval&preapprovalkey=' . $preapproval_key); $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'; $returnURL = site_url() . "/?payment_success=1&product_id=" . absint(esc_attr($_POST['project_id'])); $cancelURL = site_url() . "/?payment_cancel=1"; $notifyURL = esc_url(site_url()) . "/?ipn_handler=1&type=paypal_preauth&" . $_SESSION['ig_payment_variables']; $currencyCode = $prod_settings->currency_code; $senderEmail = esc_attr($_POST['email']); $preauth = new PreapprovalRequest(); $preauth->cancelUrl = $cancelURL; $preauth->ipnNotificationUrl = $notifyURL; $preauth->returnUrl = $returnURL; $preauth->currencyCode = $currencyCode; $preauth->maxNumberOfPayments = "1"; $preauth->maxNumberofPaymentsPerPeriod = 1; $preauth->endingDate = date("Y-m-d\\Z", strtotime("+ 364 day")); $preauth->startingDate = date('Y-m-d\\Z'); $preauth->maxTotalAmountOfAllPayments = esc_attr(str_replace(',', '', $_POST['price'])); $preauth->memo = $product_name . ' pledge of ' . number_format($_POST['price'], 2, '.', ',') . ' ' . $currencyCode; $preauth->clientDetails = new ClientDetailsType(); $preauth->clientDetails->applicationId = $app_id; //$preauth->clientDetails->deviceId = DEVICE_ID; //$preauth->clientDetails->ipAddress = "127.0.0.1"; //$preapprovalRequest->maxNumberOfPayments = $maxNumberOfPayments; //$preapprovalRequest->maxTotalAmountOfAllPayments = $maxTotalAmountOfAllPayments; $preauth->requestEnvelope = new RequestEnvelope(); $preauth->requestEnvelope->errorLanguage = "en_US"; $preauth->senderEmail = $senderEmail; $ap = new AdaptivePayments(); $response = $ap->Preapproval($preauth); //print_r($preauth); //print_r($response); //print_r($ap); if (strtoupper($ap->isSuccess) == 'FAILURE') { $fault = $ap->getLastError(); // For error handling if (is_array($fault->error)) { $errors_content = '<table width =\\"450px\\" align=\\"center\\">'; 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 .= 'Message: ' . $err->message . '<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 = '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 .= 'Message: ' . $fault->error->message . '<br />'; if (empty($fault->error->parameter)) { $errors_content .= '</br>'; } else { $errors_content .= 'Parameter: ' . $fault->error->parameter . '<br /><br />'; } } $_SESSION['paypal_errors_content'] = $errors_content; } else { // Redirect to paypal.com here $_SESSION['preapprovalKey'] = $response->preapprovalKey; $token = $response->preapprovalKey; $payPalURL = PAYPAL_REDIRECT_URL . '_ap-preapproval&preapprovalkey=' . $token; echo '<script type="text/javascript">window.location="' . $payPalURL . '";</script>'; } } }
/** This function is now deprecated -> now pulled from the IgnitionDeck Deck class the_deck method */ function the_levels($id) { global $wpdb; $project_id = get_post_meta($id, 'ign_project_id', true); $level_count = get_post_meta($id, 'ign_product_level_count', true); // 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 = getProductSettings($project_id); if (empty($prod_settings)) { $prod_settings = $default_prod_settings; } $currency_code = $prod_settings->currency_code; //GETTING the currency symbols $cCode = setCurrencyCode($currency_code); $level_data = array(); for ($i = 1; $i <= $level_count; $i++) { $level_sales = $wpdb->prepare('SELECT COUNT(*) as count FROM ' . $wpdb->prefix . 'ign_pay_info WHERE product_id=%d AND product_level = %d', $project_id, $i); $return_sales = $wpdb->get_row($level_sales); $level_sales = $return_sales->count; if ($i == 1) { $level_title = html_entity_decode(get_post_meta($id, 'ign_product_title', true)); $level_desc = html_entity_decode(get_post_meta($id, 'ign_product_details', true)); $level_price = get_post_meta($id, 'ign_product_price', true); if ($level_price > 0) { $level_price = number_format($level_price, 0, '.', ','); } $level_limit = get_post_meta($id, 'ign_product_limit', true); $level_order = get_post_meta($id, 'ign_projectmeta_level_order', true); $level_data[] = array('id' => $i, 'title' => $level_title, 'description' => $level_desc, 'price' => $level_price, 'sold' => $level_sales, 'limit' => $level_limit, 'currency_code' => $cCode, 'order' => $level_order); } else { $level_title = html_entity_decode(get_post_meta($id, 'ign_product_level_' . $i . '_title', true)); $level_desc = html_entity_decode(get_post_meta($id, 'ign_product_level_' . $i . '_desc', true)); $level_price = get_post_meta($id, 'ign_product_level_' . $i . '_price', true); if ($level_price > 0) { $level_price = number_format($level_price, 0, '.', ','); } $level_limit = get_post_meta($id, 'ign_product_level_' . $i . '_limit', true); $level_order = get_post_meta($id, 'ign_product_level_' . $i . '_order', true); $level_data[] = array('id' => $i, 'title' => $level_title, 'description' => $level_desc, 'price' => $level_price, 'limit' => $level_limit, 'sold' => $level_sales, 'currency_code' => $cCode, 'order' => $level_order); } } return $level_data; }
function idpp_process_handler() { global $wpdb; $product_id = $_POST['Project']; $sql = $wpdb->prepare('SELECT * FROM ' . $wpdb->prefix . 'ign_pay_info WHERE product_id = %s AND status=%s', $product_id, 'W'); //echo $sql; $res = $wpdb->get_results($sql); //print_r($res); $adaptive_pay_settings = getAdaptivePayPalSettings(); // 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 = getProductSettings($product_id); if (empty($prod_settings)) { $prod_settings = $default_prod_settings; } require_once 'paypal/lib/AdaptivePayments.php'; # 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_setings->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); require_once 'paypal/lib/Config/paypal_sdk_clientproperties.php'; $no_success = array(); $no_failures = array(); foreach ($res as $payment) { if ($payment->preapproval_key !== '') { // Setting the necessary variables for the payment $returnURL = site_url('/'); $cancelURL = site_url('/'); $notifyURL = site_url('/') . '?ipn_handler=1'; $currencyCode = $prod_settings->currency_code; $email = $payment->email; $preapprovalKey = $payment->preapproval_key; $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 = html_entity_decode($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 = $payment->prod_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(); $response = $ap->Pay($payRequest); //echo "end of line<br/>"; if (strtoupper($ap->isSuccess) == 'SUCCESS') { $no_success[] = 'success'; } else { if (strtoupper($ap->isSuccess) == 'FAILURE') { $no_failures[] = 'failure'; //echo "inside failure<br/>"; $fault = $ap->getLastError(); $errors_content = $fault->error->message; //echo $errors_content; // 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 />'; } }*/ } } } } $response_array['counts'] = array('success' => count($no_success), 'failures' => count($no_failures)); print_r(json_encode($response_array)); exit; }