Hi,
Does anyone know / can offer any help with authorize.net’s SIM integration. I need to do the following:
After a user submits an order have the email of that user posted to my receipt page (and I would run other database queries send emails etc.).
1.) So I need it to post the data to the return link I have specified after they have ordered (I can do that).
2.) Then I need PHP code that will read what info it has posted and run mysql queries, email the user etc.
Anyone do this before or know what kind of code I should use for the return page? I read the authorize.net SIM documentation about 1,000 times and I still can’t figure it out (they don’t really explain much about the receipt page in their docs). I’m thinking it would be something like PayPal IPN here is the code for that if that helps, if anyone knew how to do this I would be REALLY REALLY IMPRESSED! Thanks for any help you can offer:
// read the post from PayPal system and add 'cmd'
$req = 'cmd=_notify-validate';
foreach ($_POST as $key => $value) {
$value = urlencode(stripslashes($value));
$req .= "&$key=$value";
}
// post back to PayPal system to validate
$header .= "POST /cgi-bin/webscr HTTP/1.0\r\n";
$header .= "Content-Type: application/x-www-form-urlencoded\r\n";
$header .= "Content-Length: " . strlen($req) . "\r\n\r\n";
$fp = fsockopen ('www.paypal.com', 80, $errno, $errstr, 30);
// assign posted variables to local variables
$item_name = $POST['item_name'];
$item_number = $POST['item_number'];
$payment_status = $POST['payment_status'];
$payment_gross = $POST['payment_gross'];
$txn_id = $POST['txn_id'];
$receiver_email = $POST['receiver_email'];
$payer_email = $_POST['payer_email'];
if (!$fp) {
// HTTP ERROR
} else {
fputs ($fp, $header . $req);
while (!feof($fp)) {
$res = fgets ($fp, 1024);
if (strcmp ($res, "VERIFIED") == 0) {
// check the payment_status is Completed
// check that txn_id has not been previously processed
// check that receiver_email is your Primary PayPal email
// process payment
}
else if (strcmp ($res, "INVALID") == 0) {
// log for manual investigation
}
}
fclose ($fp);
}
?>