News:

Support the VirtueMart project and become a member

Main Menu

values on ipn postback

Started by anilson1, May 08, 2009, 02:54:36 AM

Previous topic - Next topic

anilson1

I have 2 questions.

1 - what is the difference between the inputbox named="notify_url" on paypal bottun code (view code 1 below) and the Notification URL entered on paypal site under "Instant Payment Notification (IPN) settings"? Don't they mean the same? don't they mean the same? What is the difference between them?

2 - When the buy bottun is pressed, the post information is transmitted to paypal page, then it redirects to the page sent from the inputbox named="notify_url" on the buy bottun, then back to paypal page, and then what ??? Once I verify all the information posted back from paypal and enter it into my database. How can I move to another page? will paypal redirect me again to another page (thankyou.php) or do I have to use - header("location:/thankyou.php);?? where do i put (on the paypal code) the page customer go after payment?

Please see codes.

-----------code 1 (paypal bottun on sendpage.php)----------------------

<input type="hidden" name=-"cmd" value="_xclick">
<input type="hidden" name="notify_url" value="http://www.mysite.com/notify.php">
<input type="hidden" name="return" value="http://www.mysite.com/thankyou.php">

<input type="hidden" name="mc_gross" value="<?php echo $price; ?>">
<input type="hidden" name="item_number" value="<?php echo $week; ?>">
<input type="hidden" name="payer_id" value="<?php echo $u_ID; ?>">

<input type="hidden" name="mc_currency" value="CAD">
<input type="hidden" name="item_name" value="super">

<input type="image" onclick="sendpayment()" src="https://www.paypal.com/en_US/i/btn/btn_paynow_SM.gif" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!">

<img alt="" border="0" src="https://www.paypal.com/en_US/i/src/pixel.gif" width="1" height="1">

--------------end code1-------------

-----------------code 2(notify.php)---------------
<?php

// 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 ('ssl://www.paypal.com&#039;, 80, $errno, $errstr, 30);

// assign posted variables to local variables
$game = $_POST['item_name'];
$weekslf = $_POST['item_number'];
$payment_status = $_POST['payment_status'];
$payment_amount = $_POST['mc_gross'];
$payment_currency = $_POST['mc_currency'];
$txn_id = $_POST['txn_id'];
$userID = $_POST['payer_id'];

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
// check that payment_amount/payment_currency are correct
// process payment

else if (strcmp ($res, "INVALID") == 0) {
// log for manual investigation
}
}
fclose ($fp);
}
?>
------------------end code2--------------