$extradetails .= __("Currency codes do not match, someone was trying to make a fraudulent purchase!", 'eshop'); } //check reciever email is correct - we will use business for now if ($p->ipn_data['receiver_email'] != $eshopoptions['business']) { $astatus = 'Failed'; $txn_id .= __(" - Fraud", 'eshop'); $extradetails .= __("The business email address in eShop does not match your main email address at Paypal.", 'eshop'); } //add any memo from user at paypal here $memo = $wpdb->escape($p->ipn_data['memo']); $mquery = $wpdb->query("UPDATE {$detailstable} set thememo='{$memo}' where checkid='{$checked}'"); //the magic bit + creating the subject for our email. if ($astatus == 'Pending' && $p->ipn_data['payment_status'] == 'Completed') { $subject .= __("Completed Payment", 'eshop'); $ok = 'yes'; eshop_mg_process_product($txn_id, $checked); } elseif ($p->ipn_data['payment_status'] == ' Refunded') { do_action('eshop_order_status_updated', $checked, 'Failed'); $subject .= __("Refunded Payment", 'eshop'); $ok = 'no'; $extradetails .= __("You have received a refund notification, eShop doesn't know how to handle these, but details of the notification are included below.", 'eshop'); } else { $query2 = $wpdb->query("UPDATE {$detailstable} set status='Failed',transid='{$txn_id}' where checkid='{$checked}'"); $subject .= __("A Failed Payment", 'eshop'); $ok = 'no'; $extradetails .= __("The transaction was not completed successfully. eShop could not validate the order.", 'eshop'); if ($p->ipn_data['payment_status'] != 'Completed' && isset($p->ipn_data['pending_reason'])) { $extradetails .= __("The transaction was not completed successfully at Paypal. The pending reason for this is", 'eshop') . ' ' . $_POST['pending_reason']; } } $subject .= " Ref:" . $txn_id;
} //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}";