Jump to content

IPN required


Recommended Posts

Hello, so I just need a simple IPN for me to credit an item. If anyone has an example or would be able to help would be amazing!

So with my donator page people would be able to purchase the item however there is different options for different quantity’s however it’s the same item if that makes sense

Link to comment
Share on other sites

  • 3 weeks later...

IPN is very simple - Paypal can make life rather tricky however as the documentation often varies from the actual code and in fact the sandbox api has been known to differ from the production api making testing potentially expensive.

There's certainly a couple of peeps here how could implement this for you in double-quick time; and/or point you in the right direction.

You state that you are finding to difficult to understand .. exactly what aspect? https://developer.paypal.com/docs/classic/ipn/ht-ipn/ Makes things reasonably clear though it may not be the architecture you require.

Link to comment
Share on other sites

  • 2 weeks later...

Coding for donate page -

	    $enableSandbox = true;
	    $paypalUrl = $enableSandbox ? 'https://www.sandbox.paypal.com/cgi-bin/webscr' : 'https://www.paypal.com/cgi-bin/webscr'; ?>
	<form action="<?php echo $paypalUrl; ?>" method="post">
                        <input type=hidden name=cmd value=_xclick>
                        <input type="hidden" name="business" value="<?php echo $set['paypal'];?>">
                        <input type="hidden" name="item_name" value="<?php echo $set['game_name'];?>|<?php echo $r['userid'];?>DP|1|">
                        <input type="hidden" name="amount" value="5.00">
                        <input type="hidden" name="no_shipping" value="1">
                        <input type="hidden" name="return" value="http://localhost/Game/payments.php?action=done&type=standard">
                        <input type="hidden" name="cancel_return" value="http://localhost/Game/payments.php?action=cancel">
                        <input type="hidden" name="userid" value="<?php echo $set['userid'];?>">
                        <input type="hidden" name="qty" value="1">
                        <input type="hidden" name="currency_code" value="GBP">
                        <input type="hidden" name="tax" value="0">
                        <input type="image" src="images/paypal.png" alt="Donate &pound;5.00" name="submit" >


Coding for payments.php -

header('HTTP/1.1 200 OK');
	$resp = 'cmd=_notify-validate';
foreach ($_POST as $parm => $var) {
    $var = urlencode(stripslashes($var));
    $resp .= "&$parm=$var";
	  $item_name        = $_POST['item_name'];
  $payment_status   = $_POST['payment_status'];
  $payment_amount   = $_POST['mc_gross'];
  $payment_currency = $_POST['mc_currency'];
  $txn_id           = $_POST['txn_id'];
  $receiver_email   = $_POST['receiver_email'];
  $payer_email      = $_POST['payer_email'];
  $qty              = $_POST['qty'];
	$httphead = "POST /cgi-bin/webscr HTTP/1.0\r\n";
$httphead .= "Content-Type: application/x-www-form-urlencoded\r\n";
$httphead .= "Content-Length: " . strlen($resp) . "\r\n\r\n";
$errno ='';
$errstr ='';
$fh = fsockopen ('ssl://www.paypal.com', 443, $errno, $errstr, 30);
	if (!$fh) {
} else {
fputs ($fh, $httphead . $resp);
    while (!feof($fh)) {
            $readresp = fgets ($fh, 1024);
                if (strcmp ($readresp, "VERIFIED") == 0) {
                    item_add($_POST['userid'], 1, $_POST['qty']);
                } else if (strcmp ($readresp, "INVALID") == 0) {
                    echo "Bye";
fclose ($fh);

Still doesn't work? What am I doing wrong. Can someone please help.

Edited by Shades
Link to comment
Share on other sites

  • 4 weeks later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...