Clan Adverts

Sponsors

CT on Facebook

Latest Product

User Box

Anonymous
38.107.179.216
Nickname:

Password:

Security Code
Security Code
Type Security Code


PND Downloads Feed

Phpnuke Downloads
How to Delete or Reset yo...
How to Delete or Reset your PHPNuke Admin Account
Lost your admin password ?  Cant login to your admin account ? This s...
Back Online & Stuff
Back Online & Stuff
Look at us with our nifty website back up and running… Seriously...
How to edit the admins in...
How to edit the admins in the forums
Here is a way to make someone admin in your forums on your Evo site. I...
Demo Splash Screen
Demo Splash Screen
Ped @ Clan Themes has released a simple splash screen entrance hack. ...
Free Phpnuke Business The...
Free Phpnuke Business Theme 6
This is the 6th Business theme for Phpnuke that Clan Themes has releas...
Tricked Out Slider
Tricked Out Slider
We have seen some great new things come out of Tricked Out News and th...

Custom Work

PHP Nuke Custom Work

www.clanthemes.com :: View topic - Paypal IPN
Paypal IPN

3 Replies / 1488 Views


Post new topic   Reply to topic  

   www.clanthemes.com Forum Index » Modules

View previous topic :: View next topic


Untergang
Reputation: 642.5 Add RepSubtract Rep
votes: 6
Local time: 11:38 AM
Location: Lommel
belgium.gif

Stand-by Stand-by
Stand-by Stand-by

0.19 posts per day
Medals: 0

Joined: May 08, 2007
Last Visit: 31 Oct 2011
Posts: 346
Points: 22131 

Post Paypal IPN Posted: Thu Jul 03, 2008 9:53 pm

Hi,

I'm working on a digital goods shop, first I used nuketreasury for the ipn.
But it only works with 1 emailadress. So I started making the IPN myself.
The problem is, I can't get it to work, it doesn't add anthing to the database.
Here's my form:
Code:
<form method='post' action='https://www.paypal.com/cgi-bin/webscr' target='paypal'>
<input type='hidden' name='cmd' value='_xclick'>
<input type='hidden' name='business' value='$account'>
<input type='hidden' name='item_name' value='$itemname'>
<input type='hidden' name='item_number' value='$lid'>
<input type='hidden' name='amount' value='$price'>
<input type='hidden' name='notify_url' value='$nukeurl/modules/$module_name/ipn.php'>
<input type='hidden' name='return' value='$nukeurl/modules/$module_name/ipn.php'>
<input type='hidden' name='rm' value='2'>
<input type='hidden' name='cancel_return' value='$nukeurl'>
<input type='hidden' name='on0' value='Username'>
<input type='hidden' name='os0' value='$usernamea'>
<input type='hidden' name='currency_code' value='$currency'>
<input type='hidden' name='quantity' value='1'>
<input type='image' name='add' src='modules/$module_name/images/buy.gif' class='paypal'>
</form>

And the ipn.php:
Code:
<?php
include("../../mainfile.php");
global $db, $prefix;

// 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_amount = $_POST['mc_gross'];
$payment_currency = $_POST['mc_currency'];
$txn_id = $_POST['txn_id'];
$receiver_email = $_POST['receiver_email'];
$payer_email = $_POST['payer_email'];
$buyer = $_POST['option_selection1'];

if (!$fp) {
// HTTP ERROR
echo"ERROR: fp";
} else {
fputs ($fp, $header . $req);
while (!feof($fp)) {
$res = fgets ($fp, 1024);
if (strcmp ($res, "VERIFIED") == 0) {

   // check that txn_id has not been previously processed
   $matchtxn = $db->sql_numrows($db->sql_query("SELECT * FROM ".$prefix."_dlshop_paypal WHERE txn_id='$txn_id'"));
   // check that receiver_email is your Primary PayPal email
   $matchmail = $db->sql_numrows($db->sql_query("SELECT * FROM ".$prefix."_dlshop_items WHERE account='$receiver_email' AND itemname='$item_name'"));
   // check that payment_amount/payment_currency are correct
   $matchprice = $db->sql_numrows($db->sql_query("SELECT * FROM ".$prefix."_dlshop_items WHERE itemname='$item_name' AND currency='$payment_currency' AND price='$payment_amount'"));
//   if($matchtxn == 0 && $matchmail > 0 && $matchprice > 0){
   
   // process payment
   $db->sql_query("INSERT INTO ".$prefix."_dlshop_paypal VALUES (NULL, '$txn_id', '$item_name', '$item_number', '$buyer', '$payment_amount', '$payment_currency', '$receiver_email', '$payer_email')");
//   }

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


Is there someone who can tell me why this doesn't work?

Thanks
 

UDesigns.be  
View user's profileSend private messageSend e-mailVisit poster's website Reply with quote

floppy
Reputation: 2088.8 Add RepSubtract Rep
votes: 22
Local time: 5:38 AM
Location: Jackson Mississippi
usa.gif

Site Admin
Site Admin

1.17 posts per day
Medals: 2 (View more...)
Super Dedicated User (Amount: 1)
Scripts/Coder
Scripts/Coder
Joined: Nov 14, 2006
Last Visit: 03 May 2012
Posts: 2353
Points: 132516 

Post Paypal IPN Posted: Fri Jul 04, 2008 6:49 am

Shop Purchases:
Clan Roster 2.0 · Multi Gaming (Warrior) Evo Theme · COD6 ModernWarfare 2 Teaser Splash Screen · Left for Dead Evo Extreme Version

I don't see the problem right away, but this might help.

Code:
   // process payment
   $db->sql_query("INSERT INTO ".$prefix."_dlshop_paypal VALUES (NULL, '$txn_id', '$item_name', '$item_number', '$buyer', '$payment_amount', '$payment_currency', '$receiver_email', '$payer_email')")
echo mysql_error();
die();


It is hard to tell where it might be fubar'ing but that is my first guess.
 

Phpnuke Downloads | VMaxxRx Male Enhancement  
View user's profileSend private messageVisit poster's website Reply with quote

Untergang
Reputation: 642.5 Add RepSubtract Rep
votes: 6
Local time: 11:38 AM
Location: Lommel
belgium.gif

Stand-by Stand-by
Stand-by Stand-by

0.19 posts per day
Medals: 0

Joined: May 08, 2007
Last Visit: 31 Oct 2011
Posts: 346
Points: 22131 

Post Re: Paypal IPN Posted: Fri Jul 04, 2008 7:25 am

I think I've found something. On paypal, you can edit your Instant Payment Notification Preference.
I still have the link of the nuketreasury module there so, if I edit that, I think it might work.
 

 
View user's profileSend private messageSend e-mailVisit poster's website Reply with quote


Untergang
Reputation: 642.5 Add RepSubtract Rep
votes: 6
Local time: 11:38 AM
Location: Lommel
belgium.gif

Stand-by Stand-by
Stand-by Stand-by

0.19 posts per day
Medals: 0

Joined: May 08, 2007
Last Visit: 31 Oct 2011
Posts: 346
Points: 22131 

Post Re: Paypal IPN Posted: Fri Jul 04, 2008 8:04 am

It might have been that, ot the mainfile.
It gave me an error, so I included the config and make a new connection, and now it works!! :D
 

 
View user's profileSend private messageSend e-mailVisit poster's website Reply with quote
Post new topic   Reply to topic  
   www.clanthemes.com Forum Index » Modules


 
3 Replies / 1488 Views
Page 1 of 1
All times are GMT
Display posts from previous:   
 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum