function eStore_do_post_payment_tasks($payment_data, $cart_items) { eStore_payment_debug('Performing post payment processing tasks.', true); // Add a check to see if the transaction ID for that email address entry already exists in the customer's database meaning the sale has already been processed? $txn_id = $payment_data['txn_id']; $emailaddress = $payment_data['payer_email']; $sandbox = get_option('eStore_cart_enable_sandbox'); if (!$sandbox) { //Check for already processed transaction if running in live mode if (eStore_is_txn_already_processed($payment_data)) { eStore_payment_debug('The transaction ID and the email address already exists in the database. So the payment have already been processed. No need to do anything for this. This could happen from a server glitch.', false); return false; } } $product_verified = process_payment_data($payment_data, $cart_items); //verify payment data, create download links, send notification if ($product_verified) { //GA tracking if ($payment_data['background_post'] != 'yes') { eStore_payment_debug('GA tracking if being used...', true); eStore_track_ga_ecommerce($payment_data, $cart_items); } else { eStore_payment_debug('This is a background post so GA tracking will not be performed', true); } //Autoresponder signups $firstname = $payment_data['first_name']; $lastname = $payment_data['last_name']; $emailaddress = $payment_data['payer_email']; eStore_item_specific_autoresponder_signup($cart_items, $firstname, $lastname, $emailaddress); eStore_global_autoresponder_signup($firstname, $lastname, $emailaddress); eStore_payment_debug('Recording transaction details...', true); record_sales_data($payment_data, $cart_items); // Record sales data in customers database eStore_aff_award_commission($payment_data, $cart_items); // Award affiliate commission eStore_award_author_commission($payment_data, $cart_items); // Revenue sharing eStore_handle_auto_affiliate_account_creation($payment_data); // Auto affiliate account creation eStore_POST_IPN_data_to_url($payment_data, '', $cart_items); //Post IPN data to external site if needed } eStore_payment_debug('End of post payment processing tasks.', true); }
function eStore_chk_and_record_cust_data_for_free_trial_signup($ipn_data) { $txn_type = $ipn_data['txn_type']; if (array_key_exists("mc_amount1", $ipn_data)) { $amount1 = $ipn_data['mc_amount1']; } else { $amount1 = $ipn_data['amount1']; } debug_log_subsc("Transaction type and amount1 value of this subscription ipn : " . $txn_type . "|" . $amount1, true); if ($txn_type == "subscr_signup" && $amount1 == "0.00") { debug_log_subsc("Recording customer data for free trial subscription signup.", true); $txn_id = $ipn_data['subscr_id']; $ipn_data['txn_id'] = $txn_id; $ipn_data['status'] = "Free Trial"; $id = $ipn_data['item_number']; $item_name = $ipn_data['item_name']; $cart_items = eStore_create_item_data($id, $item_name, "0"); record_sales_data($ipn_data, $cart_items); include_once 'eStore_process_payment_data_helper.php'; process_payment_data($ipn_data, $cart_items); //Process and send notification email //Autoresponder signups $firstname = $ipn_data['first_name']; $lastname = $ipn_data['last_name']; $emailaddress = $ipn_data['payer_email']; eStore_item_specific_autoresponder_signup($cart_items, $firstname, $lastname, $emailaddress); eStore_global_autoresponder_signup($firstname, $lastname, $emailaddress); return true; } return false; //Not a free trial }