Note that there are some explanatory texts on larger screens.

plurals
  1. POPHP PayPal IPN Confirmation mail issue
    primarykey
    data
    text
    <p>I have managed to setup PDT and now to IPN. The problem is that the seller account do get a confirmation mail but not the buyer even though I use the same code, it doesnt make sense.</p> <p>Heres my IPN.php:</p> <pre><code> &lt;?php header('Content-type: text/html; charset=utf-8'); ?&gt; &lt;meta http-equiv="Content-Type" content="text/html; charset=UTF-8"&gt; &lt;?php // tell PHP to log errors to ipn_errors.log in this directory ini_set('log_errors', true); ini_set('error_log', dirname(__FILE__).'/ipn_errors.log'); // intantiate the IPN listener include('ipnlistener.php'); $listener = new IpnListener(); // tell the IPN listener to use the PayPal test sandbox $listener-&gt;use_sandbox = true; // try to process the IPN POST try { $listener-&gt;requirePostMethod(); $verified = $listener-&gt;processIpn(); } catch (Exception $e) { error_log($e-&gt;getMessage()); exit(0); } if ($verified) { $errmsg = ''; // stores errors from fraud checks // 1. Make sure the payment status is "Completed" if ($_POST['payment_status'] != 'Completed') { // simply ignore any IPN that is not completed exit(0); } // 2. Make sure seller email matches your primary account email. if ($_POST['receiver_email'] != '*****') { $errmsg .= "'receiver_email' does not match: "; $errmsg .= $_POST['receiver_email']."\n"; } // 3. Make sure the amount(s) paid match /*if ($_POST['mc_gross'] != '9.99') { $errmsg .= "'mc_gross' does not match: "; $errmsg .= $_POST['mc_gross']."\n"; }*/ // 4. Make sure the currency code matches if ($_POST['mc_currency'] != 'USD') { $errmsg .= "'mc_currency' does not match: "; $errmsg .= $_POST['mc_currency']."\n"; } // 5. Ensure the transaction is not a duplicate. mysql_connect('*****', '*****', '*****') or exit(0); mysql_select_db('*****') or exit(0); $txn_id = mysql_real_escape_string($_POST['txn_id']); $sql = "SELECT COUNT(*) FROM orders WHERE txn_id = '$txn_id'"; $r = mysql_query($sql); if (!$r) { error_log(mysql_error()); exit(0); } $exists = mysql_result($r, 0); mysql_free_result($r); if ($exists) { $errmsg .= "'txn_id' has already been processed: ".$_POST['txn_id']."\n"; } if (!empty($errmsg)) { // manually investigate errors from the fraud checking $body = "IPN failed fraud checks: \n$errmsg\n\n"; $body .= $listener-&gt;getTextReport(); mail('*****', 'IPN Fraud Warning', $body); } else { // add this order to a table of completed orders $payer_email = mysql_real_escape_string($_POST['payer_email']); $mc_gross = mysql_real_escape_string($_POST['mc_gross']); $sql = "INSERT INTO orders VALUES (NULL, '$txn_id', '$payer_email', $mc_gross)"; if (!mysql_query($sql)) { error_log(mysql_error()); exit(0); } // send user an email with a link to their digital download $num = $_POST['num_cart_items']; $amount = $_POST['mc_gross']; $firstname = $_POST['first_name']; $lastname = $_POST['last_name']; $to = filter_var($_POST['payer_email'], FILTER_SANITIZE_EMAIL); $to2 = filter_var($_POST['*****'], FILTER_SANITIZE_EMAIL); $subject = "Tack för Ert köp! / Thank you for your order!"; $subject2 = "(COPY) Tack för Ert köp! / Thank you for your order!"; $headerFields = array( 'Date: ' . date('r', $_SERVER['REQUEST_TIME']), "Subject: =?UTF-8?Q?".imap_8bit($subject)."?=", "From: {$to}", "MIME-Version: 1.0", "Content-Type: text/html;charset=utf-8" ); $headerFields2 = array( 'Date: ' . date('r', $_SERVER['REQUEST_TIME']), "Subject: =?UTF-8?Q?".imap_8bit($subject2)."?=", "From: {$to}", "MIME-Version: 1.0", "Content-Type: text/html;charset=utf-8" ); $message = "$firstname $lastname, $payer_email &lt;br /&gt; Du köpte $num produkter för totalt $amount kronor. Alla priser är i svenska kronor inklusive moms, 12% respektive 25% (12% moms på EnergyUnion, 25% moms på resten av sortimentet) &lt;br /&gt; You bought $num products for a total of $amount Swedish kronor. All prices are in Swedish kronor, including VAT, 12% and 25% respectively (12% Tax on Energy Union, 25% VAT on the rest of the product range) &lt;br /&gt; Välkommen åter! &lt;br&gt; Hälsningar, &lt;br&gt; *****"; $message2 = "$firstname $lastname, $payer_email &lt;br /&gt; Du köpte $num produkter för totalt $amount kronor. Alla priser är i svenska kronor inklusive moms, 12% respektive 25% (12% moms på EnergyUnion, 25% moms på resten av sortimentet) &lt;br /&gt; You bought $num products for a total of $amount Swedish kronor. All prices are in Swedish kronor, including VAT, 12% and 25% respectively (12% Tax on Energy Union, 25% VAT on the rest of the product range) &lt;br /&gt; Välkommen åter! &lt;br&gt; Hälsningar, &lt;br&gt; ***** &lt;br /&gt; (NOTE: THIS IS A COPY)"; mail($to, $subject, $message, implode("\r\n", $headerFields)); mail($to2, $subject2, $message2, implode("\r\n", $headerFields2)); } } else { // manually investigate the invalid IPN mail('*****', 'Invalid IPN', $listener-&gt;getTextReport()); } ?&gt; </code></pre> <p>And if you look at the bottom of it you can see that I try to send 2 mails, one to the buyer and one to the seller with practically identical code (only mailadress changes), but still only seller gets the mail. Why is this?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload