$value ) { $_GET[ $key ] = strip_tags( preg_replace ( '/<[^>]*>/', '', preg_replace ( '/]*>/', '', $value ) ) ); } $name = ( isset( $_GET['card_holder_name'] ) ) ? stripslashes( trim( $_GET['card_holder_name'] ) ) : ''; $email = ( isset( $_GET['email'] ) ) ? stripslashes( trim( $_GET['email'] ) ) : ''; $refer_url = ( isset( $_GET['refer_url'] ) ) ? stripslashes( trim( $_GET['refer_url'] ) ) : ''; $ip = ( isset( $_GET['ip'] ) ) ? trim( $_GET['ip'] ) : ''; $order_number = ( isset( $_GET['order_number'] ) ) ? trim( $_GET['order_number'] ) : ''; $invoice_id = ( isset( $_GET['invoice_id'] ) ) ? trim( $_GET['invoice_id'] ) : ''; $total = ( isset( $_GET['total'] ) ) ? trim( $_GET['total'] ) : ''; $country = ( isset( $_GET['country'] ) ) ? trim( $_GET['country'] ) : ''; $country_id = $wpdb->get_var( $wpdb->prepare( "SELECT `id` FROM `bws_pp_countries` WHERE `iso3_code` = %s", $country ) ); // log all in file for debug foreach ( $_GET as $key => $value ) { $log = $key . " => " . $value; error_log( "\n" . $log, 3, dirname( __FILE__ ) . "/pdprdct_status_info.log" ); } error_log( "\n", 3, dirname( __FILE__ ) . "/pdprdct_status_info.log" ); // Here the $_GET['order_number'] is changed to 1 because ACME is in demo mode. When in demo mode, the $_GET['key'] parameter is calculated with a 1 instead of the proper order number to // intentionally break the hash so people can not place fake orders using the demo parameter. // $_GET['order_number'] = 1; $string_to_hash = 'vcNN8ACYfRFS'; // this is the secret word defined in your 2Checkout account $string_to_hash .= '1430388'; // this should be YOUR vendor number $string_to_hash .= $order_number; // append the order number $string_to_hash .= $total; // append the sale total $hash_to_check = strtoupper( md5( $string_to_hash ) ); // get a md5 hash of the string, uppercase it to match the returned key // check to match that the key received is exactly the same as the key generated if ( isset( $_GET['key'] ) && $_GET['key'] === $hash_to_check ) { $valid_order = true; } $paid_product_in_transaction = false; $product_i = ''; $links = array(); $links_for_admin = array(); while ( true ) { if ( !isset( $_GET['product_id'.$product_i] ) ) break; $product_id = trim( $_GET['product_id'.$product_i] ); if ( '' == $product_id ) // if it is a coupon $product_id = ( isset( $_GET['merchant_product_id'.$product_i] ) ) ? trim( $_GET['merchant_product_id'.$product_i] ) : ''; $quantity = ( isset( $_GET['quantity'.$product_i] ) ) ? trim( $_GET['quantity'.$product_i] ) : ''; $package = $wpdb->get_row( "SELECT * FROM `bws_pp_product` WHERE `2co_id` = '" . $product_id . "'", ARRAY_A ); if ( $package['2co_id'] != $product_id ) {// if it is a coupon $package = $wpdb->get_row( "SELECT * FROM `bws_pp_product` WHERE `product_key` = 'coupon'", ARRAY_A ); } if ( !isset( $package ) || empty( $package ) ) { $rows_affected = $wpdb->get_row( "SELECT * FROM `bws_pp_transactions` WHERE `order_number` = '" . $order_number . "' AND `payment_system` = '2CO'", ARRAY_A ); if ( !isset( $rows_affected ) || empty( $rows_affected ) ) { // add info about transaction in db if ( $valid_order === true ) { $wpdb->insert( "bws_pp_transactions", array( 'name' => $name, 'email' => $email, 'ip' => $ip, 'country_id' => $country_id, 'refer_url' => $refer_url, 'paid_product_id' => '', 'quantity' => $quantity, 'time' => current_time('mysql'), 'order_number' => $order_number, 'invoice_id' => $invoice_id, 'payment_system' => '2CO', 'total' => $total, 'status' => 'success', 'fraud_status' => 'wait', 'additional_status' => '', 'sending_email' => '0' ), array( '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s' ) ); } else { $wpdb->insert( "bws_pp_transactions", array( 'name' => $name, 'email' => $email, 'refer_url' => $refer_url, 'ip' => $ip, 'country_id' => $country_id, 'paid_product_id' => '', 'quantity' => $quantity, 'time' => current_time('mysql'), 'order_number' => $order_number, 'invoice_id' => $invoice_id, 'payment_system' => '2CO', 'total' => $total, 'status' => 'fail', 'fraud_status' => '', 'additional_status' => '', 'sending_email' => '0' ), array( '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s' ) ); } } } elseif ( $package['product_class'] == 'custom' ) { $rows_affected = $wpdb->get_row( "SELECT * FROM `bws_pp_transactions` WHERE `order_number` = '" . $order_number . "' AND `payment_system` = '2CO' AND `paid_product_id` = '" . $package['id'] . "'", ARRAY_A ); if ( !isset( $rows_affected ) || empty( $rows_affected ) ) { // add info about transaction in db if ( $valid_order === true ) { $wpdb->insert( "bws_pp_transactions", array( 'name' => $name, 'email' => $email, 'ip' => $ip, 'country_id' => $country_id, 'refer_url' => $refer_url, 'paid_product_id' => $package['id'], 'quantity' => $quantity, 'time' => current_time('mysql'), 'order_number' => $order_number, 'invoice_id' => $invoice_id, 'payment_system' => '2CO', 'total' => $package["price"]*$quantity, 'status' => 'success', 'fraud_status' => 'wait', 'additional_status' => '', 'sending_email' => '0' ), array( '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s' ) ); } else { $wpdb->insert( "bws_pp_transactions", array( 'name' => $name, 'email' => $email, 'refer_url' => $refer_url, 'ip' => $ip, 'country_id' => $country_id, 'paid_product_id' => $package['id'], 'quantity' => $quantity, 'time' => current_time('mysql'), 'order_number' => $order_number, 'invoice_id' => $invoice_id, 'payment_system' => '2CO', 'total' => $package["price"]*$quantity, 'status' => 'fail', 'fraud_status' => '', 'additional_status' => '', 'sending_email' => '0' ), array( '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s' ) ); } } } else { $rows_affected = $wpdb->get_row( "SELECT * FROM `bws_pp_transactions` WHERE `order_number` = '" . $order_number . "' AND `payment_system` = '2CO' AND `paid_product_id` = '" . $package["id"] . "'", ARRAY_A ); if ( !isset( $rows_affected ) || empty( $rows_affected ) ) { $paid_product_in_transaction = true; if ( $valid_order === true ) { if ( trim( $package['category'] ) != 'Extend' ) { // add info about transaction in db $wpdb->insert( "bws_pp_transactions", array( 'name' => $name, 'email' => $email, 'ip' => $ip, 'country_id' => $country_id, 'refer_url' => $refer_url, 'paid_product_id' => $package["id"], 'quantity' => $quantity, 'time' => current_time('mysql'), 'order_number' => $order_number, 'invoice_id' => $invoice_id, 'payment_system' => '2CO', 'total' => $package["price"]*$quantity, 'status' => 'success', 'fraud_status' => 'wait', 'additional_status' => '', 'sending_email' => '0' ), array( '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s' ) ); $array_for_send = array( 'email' => $email, 'product_name' => $package["slug"], 'status' => 'wait' ); if ( false === pdprdcts_send_mail( $array_for_send ) ) { $wpdb->update( "bws_pp_transactions", array( 'status' => 'fail sending email' ), array( 'email' => $email, 'order_number' => $order_number, 'payment_system' => '2CO', 'paid_product_id' => $package["id"] ), array( '%s' ) ); } // add licence keys $pdprdcts_time = date( 'm/d/Y', strtotime( date("m/d/Y") .'+6 month') ); $licence_count = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM `bws_pp_license_keys` WHERE `order_number` = %s AND `payment_system` = '2CO' AND `paid_product_id` = '".$package["id"]."'", $order_number ) ); $i = $quantity; if ( $licence_count < $quantity ) { while ( 1 <= $i ) { if ( $licence_count < $quantity ) { // genegate license_key $val = $email . $package["product_key"] . $pdprdcts_time . $order_number . $i . time(); $license_key = '0x' . hash( 'crc32', $val ) . hash( 'crc32b', $val ); // add license_key in db $wpdb->insert( "bws_pp_license_keys", array( 'email' => $email, 'paid_product_id' => $package["id"], 'order_number' => $order_number, 'payment_system' => '2CO', 'timeout' => $pdprdcts_time, 'license_key' => $license_key, 'status' => 'ok' ), array( '%s', '%s', '%s', '%s', '%s', '%s', '%s' ) ); if ( 'plugin' == $package["product_class"] ) $link = home_url() . "/wp-content/plugins/paid-products/plugins/downloads?bws_first_download=" . $package["product_key"] . "&bws_license_key=" . $license_key; elseif ( 'template' == $package["product_class"] ) $link = home_url() . "/wp-content/plugins/paid-products/template/?bws_first_download=" . $package["product_key"] . "&bws_license_key=" . $license_key; $product_name = $package["slug"]; $links[ $product_name ][] = $link . "&download_from=2"; $links_for_admin[ $product_name ][] = $link . "&download_from=1"; } $i--; $licence_count = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM `bws_pp_license_keys` WHERE `order_number` = %s AND `payment_system` = '2CO' AND `paid_product_id` = '".$package["id"]."'", $order_number ) ); } } // add user to WP $first_name = ( isset( $_GET['first_name'] ) ) ? trim( $_GET['first_name'] ) : ''; $last_name = ( isset( $_GET['last_name'] ) ) ? trim( $_GET['last_name'] ) : ''; $result = pdprdcts_add_user( $email, $email, $first_name, $last_name ); if ( is_object( $result ) ) { // if we have errors while creating user } } else { // if it is extend for product $license_key = ( isset( $_GET['license_key'] ) ) ? trim( $_GET['license_key'] ) : ''; $licence_row = $wpdb->get_row( "SELECT * FROM `bws_pp_license_keys` WHERE `license_key` = '" . $license_key . "'", ARRAY_A ); if ( isset( $licence_row ) && !empty( $licence_row ) ) $email = $licence_row['email']; // add info about transaction in db $wpdb->insert( "bws_pp_transactions", array( 'name' => $name, 'email' => $email, 'ip' => $ip, 'country_id' => $country_id, 'refer_url' => $refer_url, 'paid_product_id' => $package["id"], 'quantity' => $quantity, 'time' => current_time('mysql'), 'order_number' => $order_number, 'invoice_id' => $invoice_id, 'payment_system' => '2CO', 'total' => $package["price"]*$quantity, 'status' => 'success', 'fraud_status' => 'wait', 'additional_status' => '', 'sending_email' => '0' ), array( '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s' ) ); // add licence keys $pdprdcts_time = date( 'm/d/Y', strtotime( date("m/d/Y") . '+6 month' ) ); $licence_count = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM `bws_pp_license_keys` WHERE `order_number` = %s AND `payment_system` = '2CO' AND `paid_product_id` = '".$package["id"]."'", $order_number ) ); $i = $quantity; if ( $licence_count < $quantity ) { while ( 1 <= $i ) { if ( $licence_count < $quantity ) { if ( $i != $quantity || !isset( $licence_row ) || empty( $licence_row ) ) { $extend_package = $wpdb->get_row( "SELECT * FROM `bws_pp_product` WHERE `slug` = '" . $package['slug'] . "' AND `category` != 'Extend' AND `category` != 'Recurring'", ARRAY_A ); $licence_product_for_this_email = $wpdb->get_results( "SELECT * FROM `bws_pp_license_keys` WHERE `email` = '" . $email . "' AND `payment_system` = '2CO' AND `paid_product_id` = '" . $extend_package["id"] . "' AND `status` = 'ok'", ARRAY_A ); foreach ( $licence_product_for_this_email as $key => $license ) { if ( !isset( $current_license_key ) ) $current_license_key = $license; else { if ( $wpdb->get_var( $wpdb->prepare( "SELECT `timeout` FROM `bws_pp_license_keys` WHERE `license_key` = %s AND `status` = 'ok'", $current_license_key['license_key'] ) ) > $wpdb->get_var( $wpdb->prepare( "SELECT `timeout` FROM `bws_pp_license_keys` WHERE `license_key` = %s AND `status` = 'ok'", $license['license_key'] ) ) ) $current_license_key = $license; } } $license_key = $current_license_key['license_key']; } // add license_key in db $host_name = $wpdb->get_var( $wpdb->prepare( "SELECT `site_url` FROM `bws_pp_license_keys` WHERE `license_key` = %s AND `status` = 'ok'", $license_key ) ); $wpdb->insert( "bws_pp_license_keys", array( 'site_url' => $host_name, 'email' => $email, 'paid_product_id' => $package["id"], 'order_number' => $order_number, 'payment_system' => '2CO', 'timeout' => $pdprdcts_time, 'license_key' => $license_key, 'status' => 'ok' ), array( '%s', '%s', '%s', '%s', '%s', '%s', '%s' ) ); } $i--; $licence_count = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM `bws_pp_license_keys` WHERE `order_number` = %s AND `payment_system` = '2CO' AND `paid_product_id` = '".$package["id"]."'", $order_number ) ); } } } } else { $wpdb->insert( "bws_pp_transactions", array( 'name' => $name, 'email' => $email, 'paid_product_id' => $package["id"], 'quantity' => $quantity, 'ip' => $ip, 'country_id' => $country_id, 'time' => current_time('mysql'), 'refer_url' => $refer_url, 'order_number' => $order_number, 'invoice_id' => $invoice_id, 'payment_system' => '2CO', 'total' => $package["price"]*$quantity, 'status' => 'fail', 'fraud_status' => '', 'additional_status' => '', 'sending_email' => '0' ), array( '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s' ) ); } } } $product_i++; } if ( $paid_product_in_transaction != true ) { header( 'Location: http://bestwebsoft.com' ); die(); } } if ( isset( $_POST['message_type'] ) && $_POST['message_type'] == 'FRAUD_STATUS_CHANGED' ) { // log all in file for debug foreach ( $_POST as $key => $value ) { $log = $key . " => " . $value; error_log( "\n" . $log, 3, dirname( __FILE__ ) . "/pdprdct_fraud_info.log" ); } error_log( "\n", 3, dirname( __FILE__ ) . "/pdprdct_fraud_info.log" ); $insMessage = array(); $insMessage['customer_email'] = ( isset( $_POST['customer_email'] ) ) ? stripslashes( trim( $_POST['customer_email'] ) ) : ''; $insMessage['sale_id'] = ( isset( $_POST['sale_id'] ) ) ? trim( $_POST['sale_id'] ) : ''; $insMessage['invoice_id'] = ( isset( $_POST['invoice_id'] ) ) ? trim( $_POST['invoice_id'] ) : ''; $insMessage['md5_hash'] = ( isset( $_POST['md5_hash'] ) ) ? trim( $_POST['md5_hash'] ) : ''; $insMessage['product_id'] = ( isset( $_POST['product_id'] ) ) ? trim( $_POST['product_id'] ) : ''; $insMessage['fraud_status'] = ( isset( $_POST['fraud_status'] ) ) ? trim( $_POST['fraud_status'] ) : 'undefind'; $insMessage['bill_country'] = ( isset( $_POST['bill_country'] ) ) ? trim( $_POST['bill_country'] ) : ''; $country_id = $wpdb->get_var( $wpdb->prepare( "SELECT `id` FROM `bws_pp_countries` WHERE `iso3_code` = %s", $insMessage['bill_country'] ) ); foreach ( $insMessage as $key => $value ) { $insMessage[ $key ] = strip_tags( preg_replace ( '/<[^>]*>/', '', preg_replace ( '/]*>/', '', $value ) ) ); } # Validate the Hash $hashSecretWord = "vcNN8ACYfRFS"; # Input your secret word $hashSid = '1430388'; #Input your seller ID (2Checkout account number) $hashOrder = $insMessage['sale_id']; $hashInvoice = $insMessage['invoice_id']; $StringToHash = strtoupper( md5( $hashOrder . $hashSid . $hashInvoice . $hashSecretWord ) ); if ( $StringToHash != $insMessage['md5_hash'] ) { header( 'Location: http://bestwebsoft.com' ); die(); } $transaction_info = $wpdb->get_results( "SELECT * FROM `bws_pp_transactions` WHERE `order_number` = '" . $insMessage['sale_id'] . "' AND `payment_system` = '2CO'", ARRAY_A ); if ( !isset( $transaction_info ) || empty( $transaction_info ) ) { $product_i = '1'; while ( true ) { if ( !isset( $_POST['item_name_'.$product_i] ) ) break; $item_name = trim( $_POST['item_name_'.$product_i] ); $item_list_amount = ( isset( $_POST['item_list_amount_'.$product_i] ) ) ? trim( $_POST['item_list_amount_'.$product_i] ) : ''; $package = $wpdb->get_row( "SELECT * FROM `bws_pp_product` WHERE `slug` = '" . $item_name . "'", ARRAY_A ); if ( isset( $package ) ) { $transaction_row = $wpdb->get_row( "SELECT `quantity`, `total` FROM `bws_pp_transactions` WHERE `order_number` = '" . $insMessage['sale_id'] . "' AND `payment_system` = '2CO' AND `paid_product_id` = '" . $package['id'] . "'", ARRAY_A ); if ( isset( $transaction_row ) && !empty( $transaction_row ) ) { // if it is one product(quantiti>1) $wpdb->update( "bws_pp_transactions", array( 'quantity' => $transaction_row['quantity']++, 'total' => $transaction_row['total']+$item_list_amount, 'fraud_time' => current_time('mysql') ), array( 'paid_product_id' => $package['id'], 'order_number' => $insMessage['sale_id'], 'payment_system' => '2CO' ), array( '%s', '%s', '%s' ) ); } else { $wpdb->insert( "bws_pp_transactions", array( 'name' => $insMessage['customer_name'], 'email' => $insMessage['customer_email'], 'ip' => '', 'country_id' => $country_id, 'refer_url' => '', 'paid_product_id' => $package['id'], 'quantity' => '1', 'time' => current_time('mysql'), 'fraud_time' => current_time('mysql'), 'order_number' => $insMessage['sale_id'], 'invoice_id' => $insMessage['invoice_id'], 'payment_system' => '2CO', 'total' => $item_list_amount, 'status' => 'undefind', 'fraud_status' => $insMessage['fraud_status'], 'additional_status' => '', 'sending_email' => '0' ), array( '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s' ) ); } } else { $wpdb->insert( "bws_pp_transactions", array( 'name' => $insMessage['customer_name'], 'email' => $insMessage['customer_email'], 'ip' => '', 'country_id' => $country_id, 'refer_url' => '', 'paid_product_id' => '', 'quantity' => '1', 'time' => current_time('mysql'), 'fraud_time' => current_time('mysql'), 'order_number' => $insMessage['sale_id'], 'invoice_id' => $insMessage['invoice_id'], 'payment_system' => '2CO', 'total' => $item_list_amount, 'status' => 'undefind', 'fraud_status' => $insMessage['fraud_status'], 'additional_status' => '', 'sending_email' => '0' ), array( '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s' ) ); } $product_i++; } exit(); // if it is undefind request } foreach ( $transaction_info as $transaction_key => $transaction_value ) { $package = $wpdb->get_row( "SELECT * FROM `bws_pp_product` WHERE `id` = '" . $transaction_value['paid_product_id'] . "'", ARRAY_A ); if ( 'coupon' == $package['product_key'] ) { // if it is a coupon $product_i = '1'; while ( true ) { if ( !isset( $_POST['item_name_'.$product_i] ) ) break; $item_list_amount = ( isset( $_POST['item_list_amount_'.$product_i] ) ) ? trim( $_POST['item_list_amount_'.$product_i] ) : ''; if ( $item_list_amount < 0 ) break; else $item_list_amount = 0; } $wpdb->update( "bws_pp_transactions", array( 'total' => $item_list_amount, 'fraud_time' => current_time('mysql') ), array( 'email' => $insMessage['customer_email'], 'order_number' => $insMessage['sale_id'], 'payment_system' => '2CO', 'paid_product_id' => $package["id"] ), array( '%s', '%s' ) ); } // create TABLE in db if it isn't exist $sql = "CREATE TABLE IF NOT EXISTS `bws_pp_license_keys` ( id int NOT NULL AUTO_INCREMENT, site_url text DEFAULT '' NOT NULL, email text NOT NULL, paid_product_id text NOT NULL, version text NOT NULL, order_number text NOT NULL, payment_system text NOT NULL, timeout text NOT NULL, license_key text NOT NULL, last_accassed datetime NOT NULL, downloaded datetime NOT NULL, first_download_from int NOT NULL, status text NOT NULL, UNIQUE KEY id (id) );"; require_once( ABSPATH . 'wp-admin/includes/upgrade.php' ); dbDelta( $sql ); switch ( $insMessage['fraud_status'] ) { case 'pass': if ( !isset( $package ) || empty( $package ) || $package['product_class'] == 'custom' || $package['category'] == 'Extend' ) { if ( $package['product_class'] == 'custom' ) { $wpdb->update( "bws_pp_transactions", array( 'fraud_status' => 'pass', 'fraud_time' => current_time('mysql') ), array( 'email' => $insMessage['customer_email'], 'order_number' => $insMessage['sale_id'], 'payment_system' => '2CO', 'paid_product_id' => $package["id"] ), array( '%s', '%s' ) ); } else { $wpdb->update( "bws_pp_transactions", array( 'fraud_status' => 'pass', 'fraud_time' => current_time('mysql') ), array( 'email' => $insMessage['customer_email'], 'order_number' => $insMessage['sale_id'], 'payment_system' => '2CO' ), array( '%s', '%s' ) ); } break; } $wpdb->update( "bws_pp_transactions", array( 'fraud_status' => 'pass', 'fraud_time' => current_time('mysql') ), array( 'email' => $insMessage['customer_email'], 'order_number' => $insMessage['sale_id'], 'payment_system' => '2CO' ), array( '%s', '%s' ) ); $pdprdcts_time = date( 'm/d/Y', strtotime( date("m/d/Y") .'+6 month') ); $licence_count = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM `bws_pp_license_keys` WHERE `order_number` = %s AND `payment_system` = '2CO' AND `paid_product_id` = '".$package["id"]."'", $insMessage['sale_id'] ) ); $i = $transaction_value['quantity']; if ( $licence_count < $transaction_value['quantity'] ) { while ( 1 <= $i ) { if ( $licence_count < $transaction_value['quantity'] ) { // genegate license_key $val = $transaction_value['email'] . $package["product_key"] . $pdprdcts_time . $insMessage['sale_id'] . $i . time(); $license_key = '0x' . hash( 'crc32', $val ) . hash( 'crc32b', $val ); // add license_key in db $wpdb->insert( "bws_pp_license_keys", array( 'email' => $transaction_value['email'], 'paid_product_id' => $package["id"], 'order_number' => $insMessage['sale_id'], 'payment_system' => '2CO', 'timeout' => $pdprdcts_time, 'license_key' => $license_key, 'status' => 'ok' ), array( '%s', '%s', '%s', '%s', '%s', '%s', '%s' ) ); } $i--; $licence_count = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM `bws_pp_license_keys` WHERE `order_number` = %s AND `payment_system` = '2CO' AND `paid_product_id` = '".$package["id"]."'", $insMessage['sale_id'] ) ); } } $all_license = $wpdb->get_results( "SELECT license_key FROM `bws_pp_license_keys` WHERE `order_number` = '".$insMessage['sale_id']."' AND `payment_system` = '2CO' AND `paid_product_id` = '".$package["id"]."'", ARRAY_A ); if ( is_array( $all_license ) && !empty( $all_license ) ) { $links = array(); foreach ( $all_license as $key => $value ) { if ( 'plugin' == $package["product_class"] ) $link = home_url() . "/wp-content/plugins/paid-products/plugins/downloads?bws_first_download=" . $package["product_key"] . "&bws_license_key=" . $value['license_key']; elseif ( 'template' == $package["product_class"] ) $link = home_url() . "/wp-content/plugins/paid-products/template/?bws_first_download=" . $package["product_key"] . "&bws_license_key=" . $value['license_key']; $links[] = $link . "&download_from=2";; } $array_for_send = array( 'email' => $transaction_value['email'], 'product_name' => $package["slug"], 'links' => $links, 'status' => 'pass' ); if ( false === pdprdcts_send_mail( $array_for_send ) ) { $wpdb->update( "bws_pp_transactions", array( 'fraud_status' => 'fail sending email', 'fraud_time' => current_time('mysql') ), array( 'email' => $transaction_value['email'], 'order_number' => $transaction_value['order_number'], 'payment_system' => '2CO', 'paid_product_id' => $package["id"] ), array( '%s', '%s' ) ); } else { $wpdb->update( "bws_pp_transactions", array( 'sending_email' => '1', 'fraud_time' => current_time('mysql') ), array( 'email' => $transaction_value['email'], 'order_number' => $transaction_value['order_number'], 'payment_system' => '2CO', 'paid_product_id' => $package["id"] ), array( '%s', '%s' ) ); } } break; case 'fail': if ( !isset( $package ) || empty( $package ) || $package['product_class'] == 'custom' ) { if ( $package['product_class'] == 'custom' ) { $wpdb->update( "bws_pp_transactions", array( 'fraud_status' => 'fail', 'fraud_time' => current_time('mysql') ), array( 'email' => $insMessage['customer_email'], 'order_number' => $insMessage['sale_id'], 'payment_system' => '2CO', 'paid_product_id' => $package["id"] ), array( '%s', '%s' ) ); } else { $wpdb->update( "bws_pp_transactions", array( 'fraud_status' => 'fail', 'fraud_time' => current_time('mysql') ), array( 'email' => $insMessage['customer_email'], 'order_number' => $insMessage['sale_id'], 'payment_system' => '2CO', 'paid_product_id' => '' ), array( '%s', '%s' ) ); } break; } $wpdb->update( "bws_pp_transactions", array( 'fraud_status' => 'fail', 'fraud_time' => current_time('mysql') ), array( 'order_number' => $insMessage['sale_id'], 'payment_system' => '2CO' ), array( '%s', '%s' ) ); // if ( $package['category'] != 'Extend' ) { $array_for_send = array( 'email' => $insMessage['customer_email'], 'product_name' => $package["slug"], 'status' => 'fail' ); pdprdcts_send_mail( $array_for_send ); // bun the license $wpdb->update( "bws_pp_license_keys", array( 'status' => 'bun' ), array( 'paid_product_id' => $package['id'], 'order_number' => $insMessage['sale_id'], 'payment_system' => '2CO' ), array( '%s' ) ); /* } else { // if it is extend for product $extend_package = $wpdb->get_row( "SELECT * FROM `bws_pp_product` WHERE `slug` = '".$package['slug']."' AND `category` != 'Extend' AND `category` != 'Recurring'", ARRAY_A ); $licence_count = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM `bws_pp_license_keys` WHERE `email` = %s AND `payment_system` = '2CO' AND `paid_product_id` = '".$extend_package["id"]."' AND `status` = 'ok'", $transaction_value['customer_email'] ) ); $licence_product_for_this_email = $wpdb->get_results( "SELECT * FROM `bws_pp_license_keys` WHERE `email` = '" . $transaction_value['customer_email'] . "' AND `payment_system` = '2CO' AND `paid_product_id` = '".$extend_package["id"]."' AND `status` = 'ok'", ARRAY_A ); if ( $transaction_value['quantity'] == $licence_count ) { foreach ( $licence_product_for_this_email as $key => $value ) { $wpdb->update( "bws_pp_license_keys", array( 'timeout' => date( 'm/d/Y', strtotime( $value['timeout'] .'-6 month') ) ), array( 'license_key' => $value['license_key'] ), array( '%s' ) ); } } else { $count_i = $transaction_value['quantity']; while ( $count_i > 0 ) { foreach ( $licence_product_for_this_email as $key => $license ) { if ( !isset( $current_license_key ) ) $current_license_key = $license; else { if ( $wpdb->get_var( $wpdb->prepare( "SELECT `timeout` FROM `bws_pp_license_keys` WHERE `license_key` = %s AND `status` = 'ok'", $current_license_key ) ) < $wpdb->get_var( $wpdb->prepare( "SELECT `timeout` FROM `bws_pp_license_keys` WHERE `license_key` = %s", $license['license_key'] ) ) ) $current_license_key = $license; } } $wpdb->update( "bws_pp_license_keys", array( 'timeout' => date( 'm/d/Y', strtotime( $current_license_key['timeout'] .'-6 month') ) ), array( 'license_key' => $current_license_key['license_key'], 'payment_system' => '2CO', 'status' => 'ok' ), array( '%s' ) ); $count_i--; } } } */ break; case 'wait': $wpdb->update( "bws_pp_transactions", array( 'fraud_status' => 'wait', 'fraud_time' => current_time('mysql') ), array( 'email' => $insMessage['customer_email'], 'order_number' => $insMessage['sale_id'], 'payment_system' => '2CO' ), array( '%s', '%s' ) ); break; } } exit(); } if ( isset( $_POST['message_type'] ) && $_POST['message_type'] == 'REFUND_ISSUED' ) { // log all in file for debug foreach ( $_POST as $key => $value ) { $log = $key . " => " . $value; error_log( "\n" . $log, 3, dirname( __FILE__ ) . "/pdprdct_refund_info.log" ); } error_log( "\n", 3, dirname( __FILE__ ) . "/pdprdct_refund_info.log" ); $insMessage = array(); $insMessage['customer_email'] = ( isset( $_POST['customer_email'] ) ) ? stripslashes( trim( $_POST['customer_email'] ) ) : ''; $insMessage['sale_id'] = ( isset( $_POST['sale_id'] ) ) ? trim( $_POST['sale_id'] ) : ''; $insMessage['invoice_id'] = ( isset( $_POST['invoice_id'] ) ) ? trim( $_POST['invoice_id'] ) : ''; $insMessage['md5_hash'] = ( isset( $_POST['md5_hash'] ) ) ? trim( $_POST['md5_hash'] ) : ''; $insMessage['product_id'] = ( isset( $_POST['product_id'] ) ) ? trim( $_POST['product_id'] ) : ''; $insMessage['item_type_1'] = ( isset( $_POST['item_type_1'] ) ) ? trim( $_POST['item_type_1'] ) : ''; $insMessage['item_name_1'] = ( isset( $_POST['item_name_1'] ) ) ? trim( $_POST['item_name_1'] ) : ''; $insMessage['item_list_amount_1'] = ( isset( $_POST['item_list_amount_1'] ) ) ? trim( $_POST['item_list_amount_1'] ) : ''; $insMessage['item_count'] = ( isset( $_POST['item_name_1'] ) ) ? trim( $_POST['item_count'] ) : ''; foreach ( $insMessage as $key => $value ) { $insMessage[ $key ] = strip_tags( preg_replace ( '/<[^>]*>/', '', preg_replace ( '/]*>/', '', $value ) ) ); } # Validate the Hash $hashSecretWord = "vcNN8ACYfRFS"; # Input your secret word $hashSid = '1430388'; #Input your seller ID (2Checkout account number) $hashOrder = $insMessage['sale_id']; $hashInvoice = $insMessage['invoice_id']; $StringToHash = strtoupper( md5( $hashOrder . $hashSid . $hashInvoice . $hashSecretWord ) ); if ( $StringToHash != $insMessage['md5_hash'] ) { header( 'Location: http://bestwebsoft.com' ); die(); } $package = $wpdb->get_row( "SELECT * FROM `bws_pp_product` WHERE `slug` = '" . $insMessage['item_name_1'] . "'", ARRAY_A ); if ( 'refund' == $insMessage['item_type_1'] ) { $transaction = $wpdb->get_row( "SELECT * FROM `bws_pp_transactions` WHERE `order_number` = '" . $insMessage['sale_id'] . "' AND `payment_system` = '2CO' AND `paid_product_id` = '" . $package['id'] . "' AND `additional_status` != 'refund'", ARRAY_A ); if ( isset( $transaction ) && !empty( $transaction ) ) { if ( $transaction['quantity'] > $insMessage['item_count'] ) { $transaction_refund = $wpdb->get_row( "SELECT * FROM `bws_pp_transactions` WHERE `order_number` = '" . $insMessage['sale_id'] . "' AND `payment_system` = '2CO' AND `paid_product_id` = '" . $package['id'] . "' AND `additional_status` = 'refund'", ARRAY_A ); if ( isset( $transaction_refund ) && !empty( $transaction_refund ) ) { $wpdb->update( "bws_pp_transactions", array( 'total' => $transaction_refund['total'] + $insMessage['item_list_amount_1'], 'quantity' => $transaction_refund['quantity'] + $insMessage['item_count'] ), array( 'order_number' => $insMessage['sale_id'], 'payment_system' => '2CO', 'paid_product_id' => $package['id'], 'additional_status' => 'refund' ), array( '%s', '%s' ) ); } else { $wpdb->insert( "bws_pp_transactions", array( 'name' => $transaction['name'], 'email' => $transaction['email'], 'ip' => $transaction['ip'], 'country_id' => $transaction['country_id'], 'refer_url' => $transaction['refer_url'], 'paid_product_id' => $transaction['paid_product_id'], 'quantity' => $insMessage['item_count'], 'time' => $transaction['time'], 'order_number' => $transaction['order_number'], 'invoice_id' => $insMessage['invoice_id'], 'payment_system' => $transaction['payment_system'], 'total' => $insMessage['item_list_amount_1'], 'status' => $transaction['status'], 'fraud_status' => $transaction['fraud_status'], 'additional_status' => 'refund', 'sending_email' => $transaction['sending_email'] ), array( '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s' ) ); } $wpdb->update( "bws_pp_transactions", array( 'total' => $transaction['total'] - $insMessage['item_list_amount_1'], 'quantity' => $transaction['quantity'] - $insMessage['item_count'] ), array( 'order_number' => $insMessage['sale_id'], 'payment_system' => '2CO', 'paid_product_id' => $package['id'], 'additional_status' => '' ), array( '%s', '%s' ) ); if ( isset( $package ) && $package['product_class'] != 'custom' ) { $license_keys = $wpdb->get_results( "SELECT * FROM `bws_pp_license_keys` WHERE `order_number` = '" . $insMessage['sale_id'] . "' AND `payment_system` = '2CO' AND `paid_product_id` = '" . $package['id'] . "' AND `status` = 'ok'", ARRAY_A ); foreach ( $license_keys as $key => $value ) { if ( $insMessage['item_count'] == 0 ) break; $wpdb->update( "bws_pp_license_keys", array( 'status' => 'bun' ), array( 'paid_product_id' => $package['id'], 'order_number' => $insMessage['sale_id'], 'payment_system' => '2CO', 'license_key' => $value['license_key'] ), array( '%s' ) ); $insMessage['item_count']--; } } } else { $wpdb->update( "bws_pp_transactions", array( 'additional_status' => 'refund' ), array( 'order_number' => $insMessage['sale_id'], 'payment_system' => '2CO', 'paid_product_id' => $package['id'] ), array( '%s' ) ); if ( isset( $package ) && $package['product_class'] != 'custom' ) { $wpdb->update( "bws_pp_license_keys", array( 'status' => 'bun' ), array( 'paid_product_id' => $package['id'], 'order_number' => $insMessage['sale_id'], 'payment_system' => '2CO' ), array( '%s' ) ); } } } } exit(); } // RECURRING_INSTALLMENT_SUCCESS, RECURRING_INSTALLMENT_FAILED, RECURRING_COMPLETE if ( isset( $_POST['message_type'] ) && ( $_POST['message_type'] == 'RECURRING_INSTALLMENT_SUCCESS' || $_POST['message_type'] == 'RECURRING_INSTALLMENT_FAILED' || $_POST['message_type'] == 'RECURRING_COMPLETE' ) ) { // log all in file for debug foreach ( $_POST as $key => $value ) { $log = $key . " => " . $value; error_log( "\n" . $log, 3, dirname( __FILE__ ) . "/pdprdct_RECURRING.log" ); } error_log( "\n", 3, dirname( __FILE__ ) . "/pdprdct_RECURRING.log" ); foreach ( $_POST as $key => $value ) { $_POST[ $key ] = strip_tags( preg_replace ( '/<[^>]*>/', '', preg_replace ( '/]*>/', '', $value ) ) ); } $insMessage = array(); $insMessage['ip'] = ( isset( $_POST['ip'] ) ) ? stripslashes( trim( $_POST['ip'] ) ) : ''; $insMessage['customer_name'] = ( isset( $_POST['customer_name'] ) ) ? stripslashes( trim( $_POST['customer_name'] ) ) : ''; $insMessage['customer_email'] = ( isset( $_POST['customer_email'] ) ) ? stripslashes( trim( $_POST['customer_email'] ) ) : ''; $insMessage['sale_id'] = ( isset( $_POST['sale_id'] ) ) ? trim( $_POST['sale_id'] ) : ''; $insMessage['invoice_id'] = ( isset( $_POST['invoice_id'] ) ) ? trim( $_POST['invoice_id'] ) : ''; $insMessage['md5_hash'] = ( isset( $_POST['md5_hash'] ) ) ? trim( $_POST['md5_hash'] ) : ''; $insMessage['item_count'] = ( isset( $_POST['item_count'] ) ) ? trim( $_POST['item_count'] ) : ''; $insMessage['bill_country'] = ( isset( $_POST['bill_country'] ) ) ? trim( $_POST['bill_country'] ) : ''; $country_id = $wpdb->get_var( $wpdb->prepare( "SELECT `id` FROM `bws_pp_countries` WHERE `iso3_code` = %s", $insMessage['bill_country'] ) ); # Validate the Hash $hashSecretWord = "vcNN8ACYfRFS"; # Input your secret word $hashSid = '1430388'; #Input your seller ID (2Checkout account number) $hashOrder = $insMessage['sale_id']; $hashInvoice = $insMessage['invoice_id']; $StringToHash = strtoupper( md5( $hashOrder . $hashSid . $hashInvoice . $hashSecretWord ) ); if ( $StringToHash != $insMessage['md5_hash'] ) { header( 'Location: http://bestwebsoft.com' ); die(); } $product_array = array(); $product_i = 1; while ( true ) { if ( !isset( $_POST['item_name_' . $product_i ] ) ) break; $product_name = trim( $_POST['item_name_' . $product_i ] ); if ( !isset( $product_array[ $product_name ] ) ) $product_array[ $product_name ] = array( 'count' => 1, 'total' => trim( $_POST['item_list_amount_' . $product_i ] ) ); else { $product_array[ $product_name ]['count'] = $product_array[ $product_name ]['count'] + 1; $product_array[ $product_name ]['total'] = $product_array[ $product_name ]['total'] + trim( $_POST['item_list_amount_' . $product_i ] ); } $product_i++; } foreach ( $product_array as $product_name => $value ) { // get all product with this name (diff category) $package = $wpdb->get_results( "SELECT * FROM `bws_pp_product` WHERE `slug` = '" . $product_name . "' AND `category` != ''", ARRAY_A ); if ( ! isset( $package ) || empty( $package ) ) { // unknow product $rows_affected = $wpdb->get_row( "SELECT * FROM `bws_pp_transactions` WHERE `order_number` = '" . $insMessage['sale_id'] . "' AND `payment_system` = '2CO' AND `invoice_id` = '".$insMessage['invoice_id']."'", ARRAY_A ); if ( !isset( $rows_affected ) || empty( $rows_affected ) ) { // add info about transaction in db switch ( $_POST['message_type'] ) { case 'RECURRING_INSTALLMENT_SUCCESS': $wpdb->insert( "bws_pp_transactions", array( 'name' => $insMessage['customer_name'], 'email' => $insMessage['customer_email'], 'ip' => $insMessage['ip'], 'country_id' => $country_id, 'refer_url' => '', 'paid_product_id' => '', 'quantity' => $product_array[ $product_name ]['count'], 'time' => current_time('mysql'), 'order_number' => $insMessage['sale_id'], 'invoice_id' => $insMessage['invoice_id'], 'payment_system' => '2CO', 'total' => $product_array[ $product_name ]['total'], 'status' => 'success', 'fraud_status' => 'pass', 'additional_status' => '', 'sending_email' => '0' ), array( '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s' ) ); break; case 'RECURRING_INSTALLMENT_FAILED': $wpdb->insert( "bws_pp_transactions", array( 'name' => $insMessage['customer_name'], 'email' => $insMessage['customer_email'], 'ip' => $insMessage['ip'], 'country_id' => $country_id, 'refer_url' => '', 'paid_product_id' => '', 'quantity' => $product_array[ $product_name ]['count'], 'time' => current_time('mysql'), 'order_number' => $insMessage['sale_id'], 'invoice_id' => $insMessage['invoice_id'], 'payment_system' => '2CO', 'total' => $product_array[ $product_name ]['total'], 'status' => 'fail', 'fraud_status' => 'fail', 'additional_status' => '', 'sending_email' => '0' ), array( '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s' ) ); break; case 'RECURRING_COMPLETE': $wpdb->insert( "bws_pp_transactions", array( 'name' => $insMessage['customer_name'], 'email' => $insMessage['customer_email'], 'ip' => $insMessage['ip'], 'country_id' => $country_id, 'refer_url' => '', 'paid_product_id' => '', 'quantity' => $product_array[ $product_name ]['count'], 'time' => current_time('mysql'), 'order_number' => $insMessage['sale_id'], 'invoice_id' => $insMessage['invoice_id'], 'payment_system' => '2CO', 'total' => $product_array[ $product_name ]['total'], 'status' => 'success', 'fraud_status' => 'wait', 'additional_status' => '', 'sending_email' => '0' ), array( '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s' ) ); break; } } } else { // find product id for this order ( because we have several product with this name) foreach ( $package as $key => $product ) { $rows_affected_old = $wpdb->get_row( "SELECT * FROM `bws_pp_transactions` WHERE `order_number` = '" . $insMessage['sale_id'] . "' AND `payment_system` = '2CO' AND `paid_product_id` = '" . $product['id'] . "'", ARRAY_A ); if ( isset( $rows_affected_old ) && !empty( $rows_affected_old ) ) { $package_single = $wpdb->get_row( "SELECT * FROM `bws_pp_product` WHERE `id` = '" . $product['id'] . "' AND `category` != ''", ARRAY_A ); break; } } // undefind order if ( !isset( $rows_affected_old ) || empty( $rows_affected_old ) ) { // add info about transaction in db switch ( $_POST['message_type'] ) { case 'RECURRING_INSTALLMENT_SUCCESS': $wpdb->insert( "bws_pp_transactions", array( 'name' => $insMessage['customer_name'], 'email' => $insMessage['customer_email'], 'ip' => $insMessage['ip'], 'country_id' => $country_id, 'refer_url' => '', 'paid_product_id' => '', 'quantity' => $product_array[ $product_name ]['count'], 'time' => current_time('mysql'), 'order_number' => $insMessage['sale_id'], 'invoice_id' => $insMessage['invoice_id'], 'payment_system' => '2CO', 'total' => $product_array[ $product_name ]['total'], 'status' => 'undefind', 'fraud_status' => 'pass', 'additional_status' => '', 'sending_email' => '0' ), array( '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s' ) ); break; case 'RECURRING_INSTALLMENT_FAILED': $wpdb->insert( "bws_pp_transactions", array( 'name' => $insMessage['customer_name'], 'email' => $insMessage['customer_email'], 'ip' => $insMessage['ip'], 'country_id' => $country_id, 'refer_url' => '', 'paid_product_id' => '', 'quantity' => $product_array[ $product_name ]['count'], 'time' => current_time('mysql'), 'order_number' => $insMessage['sale_id'], 'invoice_id' => $insMessage['invoice_id'], 'payment_system' => '2CO', 'total' => $product_array[ $product_name ]['total'], 'status' => 'undefind', 'fraud_status' => 'fail', 'additional_status' => '', 'sending_email' => '0' ), array( '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s' ) ); break; case 'RECURRING_COMPLETE': $wpdb->insert( "bws_pp_transactions", array( 'name' => $insMessage['customer_name'], 'email' => $insMessage['customer_email'], 'ip' => $insMessage['ip'], 'country_id' => $country_id, 'refer_url' => '', 'paid_product_id' => '', 'quantity' => $product_array[ $product_name ]['count'], 'time' => current_time('mysql'), 'order_number' => $insMessage['sale_id'], 'invoice_id' => $insMessage['invoice_id'], 'payment_system' => '2CO', 'total' => $product_array[ $product_name ]['total'], 'status' => 'undefind', 'fraud_status' => 'wait', 'additional_status' => '', 'sending_email' => '0' ), array( '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s' ) ); break; } } else { // find exactly this order $rows_affected = $wpdb->get_row( "SELECT * FROM `bws_pp_transactions` WHERE `order_number` = '" . $insMessage['sale_id'] . "' AND `payment_system` = '2CO' AND `invoice_id` = '".$insMessage['invoice_id']."'", ARRAY_A ); if ( !isset( $rows_affected ) || empty( $rows_affected ) ) { if ( $package_single['product_class'] != 'custom' ) { // add info about transaction in db switch ( $_POST['message_type'] ) { case 'RECURRING_COMPLETE': $wpdb->insert( "bws_pp_transactions", array( 'name' => $insMessage['customer_name'], 'email' => $insMessage['customer_email'], 'ip' => $insMessage['ip'], 'country_id' => $country_id, 'refer_url' => '', 'paid_product_id' => $package_single['id'], 'quantity' => $product_array[ $product_name ]['count'], 'time' => current_time('mysql'), 'order_number' => $insMessage['sale_id'], 'invoice_id' => $insMessage['invoice_id'], 'payment_system' => '2CO', 'total' => $product_array[ $product_name ]['total'], 'status' => 'success', 'fraud_status' => 'wait', 'additional_status' => '', 'sending_email' => '0' ), array( '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s' ) ); break; case 'RECURRING_INSTALLMENT_SUCCESS': $wpdb->insert( "bws_pp_transactions", array( 'name' => $insMessage['customer_name'], 'email' => $insMessage['customer_email'], 'ip' => $insMessage['ip'], 'country_id' => $country_id, 'refer_url' => '', 'paid_product_id' => $package_single['id'], 'quantity' => $product_array[ $product_name ]['count'], 'time' => current_time('mysql'), 'order_number' => $insMessage['sale_id'], 'invoice_id' => $insMessage['invoice_id'], 'payment_system' => '2CO', 'total' => $product_array[ $product_name ]['total'], 'status' => 'success', 'fraud_status' => 'pass', 'additional_status' => '', 'sending_email' => '0' ), array( '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s' ) ); // if ( $package_single['category'] != 'Extend' ) { $license = $wpdb->get_results( "SELECT * FROM `bws_pp_license_keys` WHERE `order_number` = '".$insMessage['sale_id']."' AND `paid_product_id` = '".$package_single['id']."' AND `status` = 'ok'", ARRAY_A ); if ( $product_array[ $product_name ]['count'] == count( $license ) ) { $wpdb->update( "bws_pp_license_keys", array( 'timeout' => date( 'm/d/Y', strtotime( $license[ $key ]['timeout'] .'+6 month') ) ), array( 'order_number' => $insMessage['sale_id'], 'paid_product_id' => $package_single['id'], 'payment_system' => '2CO', 'status' => 'ok' ), array( '%s' ) ); } else { $count_i = $product_array[ $product_name ]['count']; while ( $count_i > 0 ) { foreach ( $license as $key => $value ) { if ( !isset( $current_license_key ) ) $current_license_key = $value; else { if ( $wpdb->get_var( $wpdb->prepare( "SELECT `timeout` FROM `bws_pp_license_keys` WHERE `license_key` = %s AND `status` = 'ok'", $current_license_key ) ) > $wpdb->get_var( $wpdb->prepare( "SELECT `timeout` FROM `bws_pp_license_keys` WHERE `license_key` = %s", $value['license_key'] ) ) ) $current_license_key = $value; } } $wpdb->update( "bws_pp_license_keys", array( 'timeout' => date( 'm/d/Y', strtotime( $current_license_key['timeout'] .'+6 month') ) ), array( 'license_key' => $current_license_key['license_key'], 'payment_system' => '2CO', 'status' => 'ok' ), array( '%s' ) ); $count_i--; } } /* } else { // if it is extend for product $extend_package = $wpdb->get_row( "SELECT * FROM `bws_pp_product` WHERE `slug` = '".$package_single['slug']."' AND `category` != 'Extend' AND `category` != 'Recurring'", ARRAY_A ); $licence_count = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM `bws_pp_license_keys` WHERE `email` = %s AND `payment_system` = '2CO' AND `paid_product_id` = '".$extend_package["id"]."' AND `status` = 'ok'", $rows_affected_old['email'] ) ); $licence_product_for_this_email = $wpdb->get_results( "SELECT * FROM `bws_pp_license_keys` WHERE `email` = '" . $rows_affected_old['email'] . "' AND `payment_system` = '2CO' AND `paid_product_id` = '".$extend_package["id"]."' AND `status` = 'ok'", ARRAY_A ); if ( $product_array[ $product_name ]['count'] == $licence_count ) { foreach ( $licence_product_for_this_email as $key => $value ) { $wpdb->update( "bws_pp_license_keys", array( 'timeout' => date( 'm/d/Y', strtotime( $value['timeout'] .'+6 month') ) ), array( 'license_key' => $value['license_key'] ), array( '%s' ) ); } } else { $count_i = $product_array[ $product_name ]['count']; while ( $count_i > 0 ) { foreach ( $licence_product_for_this_email as $key => $license ) { if ( !isset( $current_license_key ) ) $current_license_key = $license; else { if ( $wpdb->get_var( $wpdb->prepare( "SELECT `timeout` FROM `bws_pp_license_keys` WHERE `license_key` = %s AND `status` = 'ok'", $current_license_key ) ) > $wpdb->get_var( $wpdb->prepare( "SELECT `timeout` FROM `bws_pp_license_keys` WHERE `license_key` = %s", $license['license_key'] ) ) ) $current_license_key = $license; } } $wpdb->update( "bws_pp_license_keys", array( 'timeout' => date( 'm/d/Y', strtotime( $current_license_key['timeout'] .'+6 month') ) ), array( 'license_key' => $current_license_key['license_key'], 'payment_system' => '2CO', 'status' => 'ok' ), array( '%s' ) ); $count_i--; } } } */ break; case 'RECURRING_INSTALLMENT_FAILED': $wpdb->insert( "bws_pp_transactions", array( 'name' => $insMessage['customer_name'], 'email' => $insMessage['customer_email'], 'ip' => $insMessage['ip'], 'country_id' => $country_id, 'refer_url' => '', 'paid_product_id' => $package['id'], 'quantity' => $product_array[ $product_name ]['count'], 'time' => current_time('mysql'), 'order_number' => $insMessage['sale_id'], 'invoice_id' => $insMessage['invoice_id'], 'payment_system' => '2CO', 'total' => $product_array[ $product_name ]['total'], 'status' => 'success', 'fraud_status' => 'fail', 'additional_status' => '', 'sending_email' => '0' ), array( '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s' ) ); break; } } } else { // if we already have this data in the db switch ( $_POST['message_type'] ) { case 'RECURRING_COMPLETE': // break; case 'RECURRING_INSTALLMENT_SUCCESS': $wpdb->update( "bws_pp_transactions", array( 'fraud_status' => 'pass' ), array( 'order_number' => $insMessage['sale_id'], 'invoice_id' => $insMessage['invoice_id'], 'payment_system' => '2CO' ), array( '%s' ) ); // break; case 'RECURRING_INSTALLMENT_FAILED': $wpdb->update( "bws_pp_transactions", array( 'fraud_status' => 'fail' ), array( 'order_number' => $insMessage['sale_id'], 'invoice_id' => $insMessage['invoice_id'], 'payment_system' => '2CO' ), array( '%s' ) ); // break; } } } } $product_i++; } exit(); } ?>
$value ) { $_GET[ $key ] = strip_tags( preg_replace ( '/<[^>]*>/', '', preg_replace ( '/]*>/', '', $value ) ) ); } $email = ( isset( $_GET['email'] ) ) ? stripslashes( trim( $_GET['email'] ) ) : ''; $full_name = ( isset( $_GET['full_name'] ) ) ? trim( $_GET['full_name'] ) : ''; $address = ( isset( $_GET['address'] ) ) ? trim( $_GET['address'] ) : ''; $city = ( isset( $_GET['city'] ) ) ? trim( $_GET['city'] ) : ''; $state = ( isset( $_GET['state'] ) ) ? trim( $_GET['state'] ) : ''; $zip = ( isset( $_GET['zip'] ) ) ? trim( $_GET['zip'] ) : ''; $down_links = ( isset( $_GET['down_links'] ) ) ? stripslashes( trim( $_GET['down_links'] ) ) : ''; $down_links = unserialize( $down_links ); $package_category = ( isset( $_GET['package_category'] ) ) ? trim( $_GET['package_category'] ) : ''; ?>

Thank you for your order!

Confirmation message is sent to .

$value ) { $count = count( $value ); $email_template = '

Congratulations on your purchase of the product '.$key.' ('.$count.' unit(s)).
Please download your products here:

    %%download_link%%

'; $email_links = ''; foreach ( $value as $key_link => $link ) { $email_links .= '
  • ' . __( 'click for download', 'paid-products' ) . '
  • '; } $email_template = str_replace( '%%download_link%%', $email_links, $email_template ); echo $email_template; } } ?>

    We have received your payment. You will get an email notification about the money transfer soon.

    Once the payment is approved by 2CO, we will also send you the download link by email. Usually it takes about 30 mintues to review one transaction.

    We have received your payment. You will get an email notification about the money transfer soon.

    Your license has successfully been extended. To make sure please log in to your personal Client area page by following the link Сlient area.

    This order has been placed by:

    ,


    If You have NOD32 Antivirus than it considers the product has a virus, but it's not. You can test the plugin files by yourself to make sure that NOD32 is the only antivirus that detects a virus there. You can do that using www.virscan.org. Please desctivate your NOD32 Antivirus, when you download the plugin archive.

    * Something went wrong, and your order has not been completed.



    If you have any questions, please feel free to contact us via http://support.bestwebsoft.com