function unocoin_estore_filter_store_action_page($content) { global $post; if ($post->post_name == 'wpbc-order-info') { if (isset($_REQUEST['wpbc_co']) && $_REQUEST['gateway'] == 'unocoin') { if (isset($_REQUEST['result']) && $_REQUEST['result'] == 'error' && isset($_REQUEST['error_type'])) { $content = '<p>There was an error with the transaction processing. Please see below for details</p>'; $errortype = strip_tags($_REQUEST['error_type']); $content .= 'ErrorType: ' . $errortype; return $content; } if (isset($_REQUEST['wpbc_unocoin_gateway']) && isset($_REQUEST['order_id'])) { $order_id = base64_decode(strip_tags($_REQUEST['order_id'])); $content = '<p>Thank you for your payment. You should receive an email with your order summary</p>'; return $content; } if (isset($_REQUEST['wpbc_user_info_submit']) && $_REQUEST['wpbc_user_info_submit'] == "yes") { $config = WP_UnocoinBitcoin_Config::getInstance(); $api_key = $config->getValue('wpbc_unocoin_api_key'); if (empty($api_key)) { echo "You need to enter your unocoin credentials in the plugin settings"; return; } $transaction_speed = $config->getValue('wpbc_unocoin_transaction_speed'); if (!$transaction_speed) { $transaction_speed = "low"; } $item_name = strip_tags($_REQUEST["item_name"]); $currency = strip_tags($_REQUEST["currency"]); $cart_id = "wpbc" . uniqid(); $amount = strip_tags($_REQUEST["price"]); $price = number_format($amount, 2, '.', ''); // Create AccessCode Request Object $first_name = !empty($_REQUEST["fname"]) ? strip_tags(str_replace("'", "`", $_REQUEST["fname"])) : ''; $last_name = !empty($_REQUEST["lname"]) ? strip_tags(str_replace("'", "`", $_REQUEST["lname"])) : ''; $address = !empty($_REQUEST["address"]) ? strip_tags(str_replace("'", "`", $_REQUEST["address"])) : ''; $city = !empty($_REQUEST["city"]) ? strip_tags(str_replace("'", "`", $_REQUEST["city"])) : ''; $state = !empty($_REQUEST["state"]) ? strip_tags(str_replace("'", "`", $_REQUEST["state"])) : ''; $zip = !empty($_REQUEST["zip"]) ? strip_tags(str_replace("'", "`", $_REQUEST["zip"])) : ''; $country = !empty($_REQUEST["country"]) ? strip_tags(str_replace("'", "`", $_REQUEST["country"])) : ''; $email = !empty($_REQUEST["email"]) ? strip_tags(str_replace("'", "`", $_REQUEST["email"])) : ''; $phone = !empty($_REQUEST["phone"]) ? strip_tags(str_replace("'", "`", $_REQUEST["phone"])) : ''; //------------------------ $options = array(); $options['buyerName'] = $first_name . " " . $last_name; $options['buyerAddress1'] = $address; $options['buyerCity'] = $city; $options['buyerState'] = $state; $options['buyerZip'] = $zip; $options['buyerCountry'] = $country; $options['buyerEmail'] = $email; if ($phone != "") { $options['buyerPhone'] = $phone; } include_once "lib/unocoin_lib.php"; $options['itemDesc'] = $item_name; $options['currency'] = $currency; $return_url = $config->getValue('wpbc_unocoin_form_page_url'); $order_id = base64_encode($cart_id); $notification_url = add_query_arg(array('wpbc_unocoin_callback' => '1'), $return_url); $redirect_url = add_query_arg(array('wpbc_unocoin_gateway' => '1', 'order_id' => $order_id), $return_url); $options['notificationURL'] = $notification_url; //pass sessionid along so that it can be used to populate the transaction results page $options['redirectURL'] = $redirect_url; $options['transactionSpeed'] = $transaction_speed; $options['apiKey'] = $api_key; //create a new order $wpbc_bitcoin_orders = array('post_title' => 'WPBC Bitcoin Order', 'post_type' => 'wpbc_bitcoin_orders', 'post_content' => '', 'post_status' => 'trash'); // Insert the post into the database $post_id = wp_insert_post($wpbc_bitcoin_orders); if ($post_id) { $updated_wpbc_order = array('ID' => $post_id, 'post_title' => $cart_id, 'post_type' => 'wpbc_bitcoin_orders'); wp_update_post($updated_wpbc_order); update_post_meta($post_id, 'wpbc_order_id', $cart_id); update_post_meta($post_id, 'wpbc_first_name', $first_name); update_post_meta($post_id, 'wpbc_last_name', $last_name); update_post_meta($post_id, 'wpbc_email_address', $email); update_post_meta($post_id, 'wpbc_total_amount', $price); update_post_meta($post_id, 'wpbc_address', $address); update_post_meta($post_id, 'wpbc_city', $city); update_post_meta($post_id, 'wpbc_state', $state); update_post_meta($post_id, 'wpbc_zip', $zip); update_post_meta($post_id, 'wpbc_country', $country); if ($phone != "") { update_post_meta($post_id, 'wpbc_phone', $phone); } $status = "In Progress"; update_post_meta($post_id, 'wpbc_order_status', $status); $item_details = "Item Name: " . $item_name . ", Price: " . $price . " " . $currency; update_post_meta($post_id, 'wpbc_items_ordered', $item_details); } // $options['posData'] = $post_id; $options['fullNotifications'] = true; $invoice = unocoinCreateInvoice($cart_id, $price, $cart_id, $options); if (isset($invoice['error'])) { $error_url = add_query_arg(array('wpbc_co' => '1', 'gateway' => 'unocoin', 'result' => 'error', 'error_type' => $invoice["error"]), $error_url); wpbc_redirect_to_url($error_url); } else { //invoice created successfully wpbc_redirect_to_url($invoice['url']); } } else { //This is a checkout request via Google Wallet for digital goods. Lets process it. $atts = array(); $content = wpbc_order_form::display_form_handler($atts); } } } return $content; }
static function order_form_body_content($atts) { echo '<script type="text/javascript" src="' . WP_UNOCOINBITCOIN_PLUGIN_URL . '/jquery.validate.js"></script>'; $validate_output = <<<EOT <script type="text/javascript"> /* <![CDATA[ */ jQuery.noConflict(); jQuery(document).ready(function(\$){ \$("#wp_unocoinbitcoin_order_form").validate(); \$("input#copyaddress").click(function() { if (\$("input#copyaddress").is(':checked')) { // Checked, copy values \$("input#shipping_fname").val(\$("input#fname").val()); \$("input#shipping_lname").val(\$("input#lname").val()); \$("input#shipping_address").val(\$("input#address").val()); \$("input#shipping_city").val(\$("input#city").val()); \$("input#shipping_state").val(\$("input#state").val()); \$("input#shipping_zip").val(\$("input#zip").val()); var bcountry = \$("select#country").val(); \$('select#shipping_country option[value=' + bcountry + ']').attr('selected', 'selected'); \$("input#shipping_email").val(\$("input#email").val()); \$("input#shipping_phone").val(\$("input#phone").val()); } else { // Clear on uncheck \$("input#shipping_fname").val(""); \$("input#shipping_lname").val(""); \$("input#shipping_address").val(""); \$("input#shipping_city").val(""); \$("input#shipping_state").val(""); \$("input#shipping_zip").val(""); \$('select#shipping_country option[value=""]').attr('selected', 'selected'); \$("input#shipping_email").val(""); \$("input#shipping_phone").val(""); } }); }); /* ]]> */ </script> EOT; echo $validate_output; $show_cart = true; $show_billing_details = 1; $show_shipping_details = 0; $show_credit_card_details = 0; //Common stripping $_REQUEST["fname"] = strip_tags($_REQUEST["fname"]); $_REQUEST["lname"] = strip_tags($_REQUEST["lname"]); $_REQUEST["address"] = strip_tags($_REQUEST["address"]); $_REQUEST["city"] = strip_tags($_REQUEST["city"]); $_REQUEST["state"] = strip_tags($_REQUEST["state"]); $_REQUEST["zip"] = strip_tags($_REQUEST["zip"]); $_REQUEST["country"] = strip_tags($_REQUEST["country"]); $_REQUEST["email"] = strip_tags($_REQUEST["email"]); $_REQUEST["phone"] = strip_tags($_REQUEST["phone"]); ?> <div align="center" class="wrapper"> <div class="wp_unocoinbitcoin_order_form_container"> <form id="wp_unocoinbitcoin_order_form" name="wp_unocoinbitcoin_order_form" method="post" action="" enctype="multipart/form-data" onsubmit="" class="wp_unocoinbitcoin_order_form"> <div id="wp_unocoinbitcoin_order_form_content"> <?php if (!empty($_SESSION['estore_unocoin_form_submission_error'])) { echo '<div class="estore_unocoin_form_submission_error">' . $_SESSION['estore_unocoin_form_submission_error'] . '</div>'; } $item_name = strip_tags($_REQUEST["item_name"]); $item_price = strip_tags($_REQUEST["price"]); $currency = strip_tags($_REQUEST["currency"]); if ($show_cart) { echo "Item Name: " . $item_name . "<br />"; echo "Price: " . $item_price . " " . $currency . "<br />"; } ?> <input type="hidden" name="item_name" value="<?php echo $item_name; ?> " /> <input type="hidden" name="price" value="<?php echo $item_price; ?> " /> <input type="hidden" name="currency" value="<?php echo $currency; ?> " /> <?php $text = WP_unocoinBitcoin::get_text_message(); $countries = wpbc_order_form::get_country_list(); if ($show_billing_details) { wpbc_order_form::billing_block($countries, $text); } if ($show_shipping_details) { wpbc_order_form::shipping_block($countries, $text); } if ($show_credit_card_details) { wpbc_order_form::credit_card_block($text); } ?> <div class="estore_unocoin_clr"></div> <div class="submit-btn"><input src="<?php echo WP_UNOCOINBITCOIN_PLUGIN_URL; ?> /images/submit_button.png" type="image" name="submit" /></div> <input type="hidden" name="wpbc_user_info_submit" value="yes" /> </div> </form> </div> </div> <?php }