//check txn_id is unique $checktrans = $wpdb->get_results("select transid from {$detailstable}"); $astatus = $wpdb->get_var("select status from {$detailstable} where checkid='{$checkid}' limit 1"); foreach ($checktrans as $trans) { if (strpos($trans->transid, $ecash->ipn_data['RefNr']) === true) { $astatus = 'Failed'; $txn_id = __("Duplicated-", 'eshop') . $wpdb->escape($ecash->ipn_data['RefNr']); } } //the magic bit + creating the subject for our email. $ok = 'no'; if ($astatus == 'Pending') { $subject .= __("Completed Payment", 'eshop'); $ok = 'yes'; eshop_mg_process_product($txn_id, $checkid, 'Waiting'); eshop_send_customer_email($checkid, '5'); } $subject .= __(" Ref:", 'eshop') . $ecash->ipn_data['RefNr']; // email to business a complete copy of the notification from cash to keep!!!!! $array = eshop_rtn_order_details($checkid); $ecash->ipn_data['payer_email'] = $array['ename'] . ' ' . $array['eemail'] . ' '; $body = __("A cash purchase was made", 'eshop') . "\n"; $body .= "\n" . __("from ", 'eshop') . $ecash->ipn_data['payer_email'] . __(" on ", 'eshop') . date('m/d/Y'); $body .= __(" at ", 'eshop') . date('g:i A') . "\n\n"; $body .= __('Details', 'eshop') . ":\n"; if (isset($array['dbid'])) { $body .= get_bloginfo('wpurl') . '/wp-admin/admin.php?page=eshop-orders.php&view=' . $array['dbid'] . "&eshop\n"; } foreach ($ecash->ipn_data as $key => $value) { $body .= "\n{$key}: {$value}"; }
foreach ($p->ipn_data as $key => $value) { $body .= "\n{$key}: {$value}"; } $body .= "\n\n" . __('Regards, Your friendly automated response.', 'eshop') . "\n\n"; $headers = eshop_from_address(); $eshopemailbus = $eshopoptions['business']; if (isset($eshopoptions['business_sec']) && $eshopoptions['business_sec'] != '') { $eshopemailbus = $eshopoptions['business_sec']; } $to = apply_filters('eshop_gateway_details_email', array($eshopemailbus)); wp_mail($to, $subject, $body, $headers); if ($ok == 'yes') { //only need to send out for the successes! //lets make sure this is here and available include_once WP_PLUGIN_DIR . '/eshop/cart-functions.php'; eshop_send_customer_email($checked, '3'); } } else { //not validated $chkamt = number_format($p->ipn_data['mc_gross'] - $p->ipn_data['tax'], 2); $checked = md5($p->ipn_data['business'] . $p->ipn_data['custom'] . $chkamt); if ($eshopoptions['status'] == 'live') { $txn_id = $wpdb->escape($p->ipn_data['txn_id']); $subject = __('Paypal IPN -', 'eshop'); } else { $txn_id = __("TEST-", 'eshop') . $wpdb->escape($p->ipn_data['txn_id']); $subject = __('Testing: Paypal IPN - ', 'eshop'); } $astatus = $wpdb->get_var("select status from {$detailstable} where checkid='{$checked}' limit 1"); //add any memo from user at paypal here $memo = $wpdb->escape($p->ipn_data['memo']);
$shipid = $_POST['shipping'][$ch]; $query3 = $wpdb->get_results("UPDATE {$dtable} set shipid='{$shipid}' where checkid='{$ch}'"); $arraydetail = eshop_rtn_order_details($ch); } echo '<div class="updated fade"><p>' . __('Shipping id changed successfully.', 'eshop') . '</p></div>'; } else { echo '<div class="error fade"><p>' . __('No Order were selected.', 'eshop') . '</p></div>'; } } //end update ship id //sent email if (isset($_POST['sentemail']) && isset($_POST['emailsub'])) { if (isset($_POST['move']) && $_POST['move'][0] != '') { foreach ($_POST['move'] as $v => $ch) { $mg_id = 3; eshop_send_customer_email($ch, $mg_id); } echo '<div class="updated fade"><p>' . __('Sentemail successfully.', 'eshop') . '</p></div>'; } else { echo '<div class="error fade"><p>' . __('No Order were selected.', 'eshop') . '</p></div>'; } } //end sent email //Export cvs if (isset($_POST['csvexport']) && isset($_POST['csvsub'])) { if (isset($_POST['move']) && $_POST['move'][0] != '') { $_SESSION['invoice'] = ''; echo '<div id = "csvexport" ><table>'; foreach ($_POST['move'] as $v => $ch) { $resulti = $wpdb->get_results("Select * From {$itable} where checkid='{$ch}' ORDER BY id ASC", 'ARRAY_A'); $resultd = $wpdb->get_results("Select * From {$dtable} where checkid='{$ch}' ORDER BY id ASC", 'ARRAY_A');