function eStore_create_cart_items_data_from_txn_id($txn_id) { $cart_items = array(); $cond = " txn_id = '{$txn_id}'"; $resultset = WP_eStore_Db_Access::findAll(WP_ESTORE_CUSTOMER_TABLE_NAME, $cond); if ($resultset) { foreach ($resultset as $item) { $current_item = array('item_number' => $item->purchased_product_id, 'item_name' => $item->product_name, 'quantity' => $item->purchase_qty, 'mc_gross' => $item->sale_amount, 'mc_currency' => ''); array_push($cart_items, $current_item); } //wp_eStore_write_debug_array($cart_items,true); } return $cart_items; }
function eStore_check_stamping_flag_and_generate_download_key($retrieved_product, $product_id, $url = '', $payment_data = '') { if ($retrieved_product->use_pdf_stamper == 1 && !empty($payment_data)) { if (WP_ESTORE_STAMP_PDF_FILE_AT_DOWNLOAD_TIME === '1') { //Check if file sould be stamped at download time option is enabled $download_key = eStore_generate_download_key($product_id, $url); return $download_key; } if (!empty($url)) { $src_file = $url; } else { $src_file = $retrieved_product->product_download_url; } eStore_payment_debug('Stamping request for product ID: ' . $product_id, true); //Check if it is a multiple file URL product $multi_file_product = false; $product_urls = explode(',', $retrieved_product->product_download_url); if (sizeof($product_urls) > 1) { $multi_file_product = true; } $txn_id = $payment_data['txn_id']; $force_restamp = false; if (isset($payment_data['force_restamp']) && $payment_data['force_restamp'] == '1') { //Don't lookup cached copy eStore_payment_debug('Force restamping is enabled in the request.', true); $force_restamp = true; } if (!empty($txn_id) && !$multi_file_product && !$force_restamp) { eStore_payment_debug('Checking for a reference to the stamped copy of the file for this transaction before invoking another stamp request:' . $txn_id, true); $cond = " txn_id = '{$txn_id}'"; $result = WP_eStore_Db_Access::findAll(WP_ESTORE_DOWNLOAD_LINKS_TABLE_NAME, $cond); if ($result) { eStore_payment_debug('Found a reference to the stamped copy of a file. Performing an indepth check...', true); $random_key = get_option('eStore_random_code'); foreach ($result as $download_item) { $download_key = $download_item->download_key; eStore_payment_debug('Decrypting download key: ' . $download_key, true); $decrypted_data = RC4Crypt::decrypt($random_key, base64_decode(rawurldecode($download_key))); list($product_id_of_stamped_file, $timestamp, $stamped_file_url) = explode('|', $decrypted_data); eStore_payment_debug('Decrypted data... Product ID: ' . $product_id_of_stamped_file . ', Stamped File URL:' . $stamped_file_url, true); if ($product_id == $product_id_of_stamped_file) { eStore_payment_debug('Product IDs match. Using the existing stamped copy of the file.', true); $new_download_key = eStore_generate_download_key($product_id_of_stamped_file, $stamped_file_url); eStore_payment_debug('New Download Key: ' . $new_download_key, true); return $new_download_key; } } eStore_payment_debug('Product IDs do not match. Need to proceed with a fresh stamping.', true); } else { eStore_payment_debug('Could not find a reference to the stamped copy of a file', true); } } $stamped_file_url = eStore_stamp_pdf_file($payment_data, $src_file); if ($stamped_file_url === 'Error!') { eStore_payment_debug('PDF Stamping did not finish correctly!', false); $download_key = "Error with PDF stamping (Error code: PDF01). Perform a manual stamping and make sure the PDF stamper is working on your server."; return $download_key; } $download_key = eStore_generate_download_key($product_id, $stamped_file_url); } else { $download_key = eStore_generate_download_key($product_id, $url); } return $download_key; }