$value) { if ($key == "cverify") { $_EXPECTED = $value; continue; } $ipnFields[] = $key; } sort($ipnFields); foreach ($ipnFields as $field) { $pop = $pop . $_POST[$field] . "|"; } $pop = $pop . $secretKey; $calcedVerify = sha1(mb_convert_encoding($pop, "UTF-8")); $calcedVerify = strtoupper(substr($calcedVerify,0,8)); $_RESULTS = $calcedVerify; if ($_POST['ctransreceipt'] == '********' && $_POST['ctransaction'] == 'TEST' && $FORCE_TESTS_TO_WORK){ return true; } return $calcedVerify == $_POST["cverify"]; } // PROCESS ONLY WHEN VERIFIED TRANSACTION if(ipnVerify()) { $SUBJECT = "New Transaction: ".ucfirst(strtolower($_POST['ctransaction'])).": $" . $_POST['caccountamount']/100 ; $BODY = 'Product: ' . $_POST['cprodtitle'] ."\n"; $BODY .= 'Vendor: ' . $_POST['ctranspublisher'] ."\n"; if ($_POST['ctransaffiliate']) $BODY .= "Affiliate: " . $_POST['ctransaffiliate'] . "\n"; $BODY .= "Amount: $" . $_POST['caccountamount']/100 . "\n"; if ($_POST['ctid']) $BODY .= "TID: " . $_POST['ctid'] . "\n"; if ($_POST['ccustfullname']) $BODY .= "Customer Name: " . $_POST['ccustfullname']. "\nCustomer Email: " . $_POST['ccustemail']. "\n"; $BODY .= "\n\nhttp://www.OkaMahendra.com - Belajar Bisnis Online"; } else { $SUBJECT = 'FAILED TRANSACTION'; $BODY = 'SECURITY CHECK FAILED TO VERIFY'; $BODY .= print_r($_POST, true); $BODY .= "Expected $_EXPECTED but found $_RESULTS instead"; } mail($EMAIL_TO, $SUBJECT, $BODY , $HEADER); ?>