Jump to content


Photo

Not entering:while loop eliteweaver scri


  • This topic is locked This topic is locked
2 replies to this topic

#1 Guest(old)

Guest(old)

    Junior Member

  • Members
  • 312 posts

Posted 14 November 2002 - 06:49 AM

My scrpt:
<?php
error_reporting(0);

//$fp = fsockopen ("www.paypal.com", 80, $errno, $errstr, 30); if($fp)
//{
//echo "<br>PayPal connection confirmed!<br>";
//}
//elseif(!$fp) {
//echo "<br>PayPal cannot be contacted!<br><br>Error Number: $errno<br>Error String: $errstr<br>";
//}

// IPN Posting Modes, Choose: 1 or 2
echo $HTTP_POST_VARS ['receiver_email']."jhjh";

$postmode = "1";

//* 1 = Live Via PayPal Network
//* 2 = Test Via EliteWeaver UK
$req1 = 'cmd=_notify-validate';

foreach ($HTTP_POST_VARS as $key1 => $value) {
$value = urlencode(stripslashes($value));
$req1 .= "&$key1=$value";
echo "1";
echo $req1;
echo $value;
}

// Read the Posted IPN and Add "cmd" for Post back Validation
echo "<br>hello<br>";
$postvars = array();
while (list ($key, $value) = each ($HTTP_POST_VARS ))
{
$postvars[] = $key;
echo $key;
echo $value."fddf<br>";
}
$req = 'cmd=_notify-validate';
for ($var = 0; $var < count ($postvars); $var++)
{
$postkey = $postvars[$var];
$postvalue = $$postvars[$var];
$req .= "&" . $postkey . "=" . urlencode ($postvalue);
echo $postkey;
echo $postvalue;
echo $req;
echo "hello";
}

// PostMode 1: Live Via PayPal Network

if ($postmode == 1)
{
$fp = fsockopen ("www.paypal.com", 80, $errno, $errstr, 30);
$header .= "POST /cgi-bin/webscr HTTP/1.0\r\n";
#$header .= "Host: www.paypal.com\r\n"; // Host on Dedicated IP
$header .= "Content-Type: application/x-www-form-urlencoded\r\n";
$header .= "Content-Length: " . strlen ($req) . "\r\n\r\n";
//* Note: "Connection: Close" is Not required Using HTTP/1.0
}

// PostMode 2: Test Via EliteWeaver UK

elseif ($postmode == 2)
{
$fp = fsockopen ("www.eliteweaver.co.uk", 80, $errno, $errstr, 30);
$header .= "POST /testing/ipntest.php HTTP/1.0\r\n";
$header .= "Host: www.eliteweaver.co.uk\r\n"; // Host on Shared IP
$header .= "Content-Type: application/x-www-form-urlencoded\r\n";
$header .= "Content-Length: " . strlen ($req) . "\r\n\r\n";
//* Note: "Connection: Close" is Not required Using HTTP/1.0
}

// Selected PostMode was Probably Not Set to 1 or 2

else
{
$pme=1;
echo "PostMode: $postmode is invalid!";
exit;
}

// Problem: Now is this your Firewall or your Ports?
// Maybe Setup a little email Notification here. . .

if (!$fp && !$pme)
{
echo "Problem: Error Number: $errno Error String: $errstr";
exit;
}

// If No Problems have Occured then we proceed with the Processing

else
{

// If globals is "off" but you are Not Security Conscious then Remove: #

extract($HTTP_POST_VARS );

// Else, if globals is "off" and you are Security Conscious then you
// will have to assign all posted variables to local variables

// Note: If globals is "on" or you extracted then you don't need to localize

// Standard - Instant Payment Notifiction Variables (Localization)

$receiver_email = $HTTP_POST_VARS ['receiver_email'];
$item_name = $HTTP_POST_VARS ['item_name'];
$item_number = $HTTP_POST_VARS ['item_number'];
$quantity = $HTTP_POST_VARS ['quantity'];
$invoice = $HTTP_POST_VARS ['invoice'];
$custom = $HTTP_POST_VARS ['custom'];
$option_name1 = $HTTP_POST_VARS ['option_name1'];
$option_selection1 = $HTTP_POST_VARS ['option_selection1'];
$option_name2 = $HTTP_POST_VARS ['option_name2'];
$option_selection2 = $HTTP_POST_VARS ['option_selection2'];
$num_cart_items = $HTTP_POST_VARS ['num_cart_items'];
$payment_status = $HTTP_POST_VARS ['payment_status'];
$pending_reason = $HTTP_POST_VARS ['pending_reason'];
$payment_date = $HTTP_POST_VARS ['payment_date'];
$payment_gross = $HTTP_POST_VARS ['payment_gross'];
$payment_fee = $HTTP_POST_VARS ['payment_fee'];
$mc_gross = $HTTP_POST_VARS ['mc_gross']; // Live: 07/09/2002
$mc_fee = $HTTP_POST_VARS ['mc_fee']; // Live: 07/09/2002
$mc_currency = $HTTP_POST_VARS ['mc_currency']; // Live: 07/09/2002
$txn_id = $HTTP_POST_VARS ['txn_id'];
$txn_type = $$HTTP_POST_VARS ['txn_type'];
$first_name = $$HTTP_POST_VARS ['first_name'];
$last_name = $$HTTP_POST_VARS ['last_name'];
$address_street = $$HTTP_POST_VARS ['address_street'];
$address_city = $$HTTP_POST_VARS ['address_city'];
$address_state = $$HTTP_POST_VARS ['address_state'];
$address_zip = $$HTTP_POST_VARS ['address_zip'];
$address_country = $$HTTP_POST_VARS ['address_country'];
$address_status = $$HTTP_POST_VARS ['address_status'];
$payer_email = $$HTTP_POST_VARS ['payer_email'];
$payer_id = $$HTTP_POST_VARS ['payer_id']; // Live: 09/09/2002
$payer_status = $$HTTP_POST_VARS ['payer_status'];
$payment_type = $$HTTP_POST_VARS ['payment_type'];
$notify_version = $$HTTP_POST_VARS ['notify_version'];
$verify_sign = $$HTTP_POST_VARS ['verify_sign'];

// Subscription - Instant Payment Notifiction Variables (Localization)
// You must Remove: # if you are Using the Subscription Variables

#$subscr_date = $$HTTP_POST_VARS ['subscr_date'];
#$period1 = $$HTTP_POST_VARS ['period1'];
#$period2 = $$HTTP_POST_VARS ['period2'];
#$period3 = $$HTTP_POST_VARS ['period3'];
#$amount1 = $$HTTP_POST_VARS ['amount1'];
#$amount2 = $$HTTP_POST_VARS ['amount2'];
#$amount3 = $$HTTP_POST_VARS ['amount3'];
#$recurring = $$HTTP_POST_VARS ['recurring'];
#$reattempt = $$HTTP_POST_VARS ['reattempt'];
#$retry_at = $$HTTP_POST_VARS ['retry_at'];
#$recur_times = $$HTTP_POST_VARS ['recur_times'];
#$username = $$HTTP_POST_VARS ['username'];
#$password = $$HTTP_POST_VARS ['password'];
#$subscr_id = $$HTTP_POST_VARS ['subscr_id'];

fputs ($fp, $header . $req);

while (!feof($fp))
{
$res = fgets ($fp, 1024);
$res = trim ($res); // Required on some Environments

// IPN was Confirmed as both Genuine and VERIFIED

if (strcmp ($res, "VERIFIED") == 0)
{
echo "verified";
// Check that the "payment_status" variable is: Completed
// If it is Pending you may Want to Inform your Customer?
// Check your DB to Ensure this "txn_id" is Not a Duplicate
// You may want to Check the "payment_gross" matches listed Prices?
// You definately want to Check the "receiver_email" is yours
// Update your DB and Process this Payment accordingly
echo "Result: $res"; // Remove: # for Testing
}

// IPN was Not Validated as Genuine and is INVALID

elseif (strcmp ($res, "INVALID") == 0)
{
echo "invalid";
// Check your code for any Post back Validation problems
// Investigate the Fact that this Could be a spoofed IPN
// If updating your DB, Ensure this "txn_id" is Not a Duplicate
echo "Result: $res"; // Remove: # for Testing
}}

// Terminate the Socket connection and Exit

fclose ($fp);
exit;
}

#########################################################
# THIS SCRIPT IS FREEWARE AND IS NOT FOR RE-SALE #
#########################################################

?>

Getting test error
"Summary: Your script is not posting back to us! "

Not entering in the first while loop also. Please help.
Thanks,
Amit




#2 paypal_pb

paypal_pb

    Advanced Member

  • Members
  • 2,960 posts

Posted 14 November 2002 - 10:41 AM

You may need to contact Eliteweaver directly about that.

Also, you might consider starting with our sample code from https://www.paypal.com/ipn and POSTing the FORM below as a test (change "action" to point to your script):

<form method="post" action="http://www.mysite.com/ipn.cfm">
<input type="submit" name="" value="Test IPN">
<input type="hidden" name="payment_date" value="17:53:45 Nov 5, 2002 PST">
<input type="hidden" name="txn_type" value="web_accept">
<input type="hidden" name="last_name" value="Breitenbach">
<input type="hidden" name="item_name" value="">
<input type="hidden" name="payment_gross" value="0.01">
<input type="hidden" name="mc_currency" value="USD">
<input type="hidden" name="payment_type" value="instant">
<input type="hidden" name="verify_sign" value="AlWncXKLadIepzMosHhM.VWxC0Z6AZYI0ynXRnEUma0d3RMC.TXWaJro">
<input type="hidden" name="payer_status" value="unverified">
<input type="hidden" name="payer_email" value="pb-test@paypal.com">
<input type="hidden" name="txn_id" value="01G32341KC3727119">
<input type="hidden" name="first_name" value="Patrick">
<input type="hidden" name="quantity" value="1">
<input type="hidden" name="receiver_email" value="pb-sell@paypal.com">
<input type="hidden" name="payer_id" value="QGVDAFGZ9XHLJ">
<input type="hidden" name="payment_method" value="non_cc">
<input type="hidden" name="item_number" value="">
<input type="hidden" name="payment_status" value="Completed">
<input type="hidden" name="mc_gross" value="0.01">
<input type="hidden" name="custom" value="">
<input type="hidden" name="notify_version" value="1.4">
</form>


Patrick Breitenbach
PayPal, Inc.
Dev Net: https://www.paypal.com/pdn

#3 EliteWeaver

EliteWeaver

    Junior Member

  • Members
  • 239 posts

Posted 14 November 2002 - 12:03 PM

Amit -

I think I answered your problem on another board but you are using an old version of our bare bones script!

It still works but the latest version is much better ;-)


What is this:

foreach ($HTTP_POST_VARS as $key1 => $value) {
$value = urlencode(stripslashes($value));
$req1 .= "&$key1=$value";
echo "1";
echo $req1;
echo $value;
}

What do you think you are doing to the poor old post values?

Remove this and it will work!


Best regards,

Marcus Cicero
EliteWeaver UK





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users