YetAnotherForum
Welcome Guest Search | Active Topics | Log In | Register

Processing PayPal data Options
DieterW
#1 Posted : Friday, October 28, 2005 12:00:52 PM
Rank: Starting Member

Groups: Registered

Joined: 10/28/2005
Posts: 4
Location: ,
Hello, that's what I get from PayPal by processing my script:
Code:

tx=7EX527128V244491N
&st=Completed
&amt=1.00
&cc=USD
&cm=
&sig=oYn4sCoEpDNKo%2fNEl1%2fHvmJBjEPATRJAErfNDvcmzyUgWjhmH3fraUXPD4oK5QIlqjp1DvMytPV63rIlybAME4wA2%2bgsoP4lSBP1F8y33Fh0n0iOfkT0cQZgvbPdJo8RJoOiydy%2fPn07WEdjoVb2vRmaVOdzhj0Gg6pJ9APlvyI%3d
I add the
Code:
&cmd=_notify-validate
send it back to PayPal via LWP and get back 'INVALID' And ... I think 'tx' should be 'txn_id' 'st' should be 'payment_status' and so on I'm helpless ... what's going wrong ?
Sponsor  
 
DieterW
#2 Posted : Friday, October 28, 2005 1:48:20 PM
Rank: Starting Member

Groups: Registered

Joined: 10/28/2005
Posts: 4
Location: ,
Okey ...
I think the problem is
sig=oYn4sCoEpDNKo%2fNEl1%2fHvmJBjEPATRJAErfNDvcmzyUgWjhmH3fraUXPD4oK5QIlqjp1DvMytPV63rIlybAME4wA2%2bgsoP4lSBP1F8y33Fh0n0iOfkT0cQZgvbPdJo8RJoOiydy%2fPn07WEdjoVb2vRmaVOdzhj0Gg6pJ9APlvyI%3d

that I have to decode.

If I should be right ...
- which method of encoding has been used by PayPal?
- have I to decode it before sending it back to PayPal?
- can someone point me to the related module I have to use?
Andrew Chang
#3 Posted : Friday, October 28, 2005 9:05:53 PM
Rank: Starting Member

Groups: Registered

Joined: 1/10/2003
Posts: 738
Location: ,
sub ack_ipn {
# ack the ipn
my $ua = new LWP::UserAgent;

# build the request
my $req = new HTTP::Request("POST", $PAYPAL_URL);
$req->content_type("application/x-www-form-urlencoded");
$req->content(query_string() . "&cmd=_notify-validate");
# get the response
my $resp = $ua->request($req);
if (($resp->is_success) && ($resp->content eq "VERIFIED")) {
return 1;
} else {
# attempt to identify error
if (($resp->is_success) && ($resp->content eq "INVALID")) {
error_notify("Notification received was NOT from PayPal - Message was ignored.",
"acknowledge IPN", 0, 0);
}
else {
error_notify("Notification could not be acknowledged due to a network or PayPal issue. "
."PayPal will retry until it succeeds.", "acknowledge IPN", 1, 0);
}
return undef;
}
}

Andrew W. Chang
President
Scorpion Systems
Winner PayPal® Star Developer Award 2005
AndrewC@scorpionsystems.net
http://www.scorpionsystems.net

Phone: 631.789.5785
Fax : 631.842.4321
DieterW
#4 Posted : Saturday, October 29, 2005 8:48:04 AM
Rank: Starting Member

Groups: Registered

Joined: 10/28/2005
Posts: 4
Location: ,
Thanks for your fast reply
but unfortunately it doesn't solve the problem.

That's what I get from PayPal:

tx=7EX527128V244491N
st=Completed
amt=1.00
cc=USD
cm=
sig=oYn4sCoEpDNKo%2fNEl1%2fHvmJBjEPATRJAErfNDvcmzyUgWjhmH3fraUXPD4oK5QIlqjp1DvMytPV63rIlybAME4wA2%2bgsoP4lSBP1F8y33Fh0n0iOfkT0cQZgvbPdJo8RJoOiydy%2fPn07WEdjoVb2vRmaVOdzhj0Gg6pJ9APlvyI%3d

and that's what I send to PayPal via LWP:

tx=7EX527128V244491N
st=Completed
amt=1.00
cc=USD
cm=
sig=oYn4sCoEpDNKo%2fNEl1%2fHvmJBjEPATRJAErfNDvcmzyUgWjhmH3fraUXPD4oK5QIlqjp1DvMytPV63rIlybAME4wA2%2bgsoP4lSBP1F8y33Fh0n0iOfkT0cQZgvbPdJo8RJoOiydy%2fPn07WEdjoVb2vRmaVOdzhj0Gg6pJ9APlvyI%3d
cmd=_notify-validate

PayPal-Response: INVALID

So I wonder what I have to do in order to get the content of:
'item_name'
'item_number'
'payment_status'
'mc_gross'
'mc_currency'
'txn_id'
'receiver_email'
'payer_email'
Andrew Chang
#5 Posted : Monday, October 31, 2005 5:06:10 AM
Rank: Starting Member

Groups: Registered

Joined: 1/10/2003
Posts: 738
Location: ,
print "Content-Type: text/html\n\n";
# read post from PayPal system and add 'cmd'
read (STDIN, $query, $ENV{'CONTENT_LENGTH'});
$query .= '&cmd=_notify-validate';

# post back to PayPal system to validate
use LWP::UserAgent;
$ua = new LWP::UserAgent;
$req = new HTTP::Request 'POST','http://www.paypal.com/cgi-bin/webscr';
$req->content_type('application/x-www-form-urlencoded');
$req->content($query);
$res = $ua->request($req);

# split posted variables into pairs
@pairs = split(/&/, $query);
$count = 0;
foreach $pair (@pairs) {
($name, $value) = split(/=/, $pair);
$value =~ tr/+/ /;
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
$variable{$name} = $value;
$count++;
}

# assign posted variables to local variables
$receiver_email = $variable{'receiver_email'};

$txn_id = $variable{'txn_id'};
$txn_type = $variable{'txn_type'};
$item_name = $variable{'item_name'};
$item_number = $variable{'item_number'};
$invoice = $variable{'invoice'};

$payment_status = $variable{'payment_status'};
$pending_reason = $variable{'pending_reason'};
$payment_gross = $variable{'mc_gross'};
$payment_currency = $variable{'mc_currency'};
$payment_date = $variable{'payment_date'};
$payment_type = $variable{'payment_type'};

$payer_id = $variable{'payer_id'};
$payer_email = $variable{'payer_email'};
$payer_status = $variable{'payer_status'};
$first_name = $variable{'first_name'};
$last_name = $variable{'last_name'};
$address_street = $variable{'address_street'};
$address_city = $variable{'address_city'};
$address_state = $variable{'address_state'};
$address_zip = $variable{'address_zip'};
$address_country = $variable{'address_country'};
$address_status = $variable{'address_status'};

Andrew W. Chang
President
Scorpion Systems
Winner PayPal® Star Developer Award 2005
AndrewC@scorpionsystems.net
http://www.scorpionsystems.net

Phone: 631.789.5785
Fax : 631.842.4321
DieterW
#6 Posted : Thursday, November 03, 2005 9:51:21 AM
Rank: Starting Member

Groups: Registered

Joined: 10/28/2005
Posts: 4
Location: ,
Yes, I know how to use LWP and I know how to get the name/value pairs.
My problem is:
I still get just this data

tx=7EX527128V244491N
st=Completed
amt=1.00
cc=USD
cm=
sig=oYn4sCoEpDNKo%2fNEl1%...

from PayPal.
phpmattk
#7 Posted : Friday, January 13, 2006 3:30:49 PM
Rank: Starting Member

Groups: Registered

Joined: 1/13/2006
Posts: 2
Location: ,
The return/PDT url will receive these variables:

tx : transaction id
st : status of the payment
amt : amount
cc : currency code
cm : custom value
sig : encrypted signature

Your script must POST back the txn token, along with the identity token, with cmd=_notify-synch.

PayPal will POST back SUCCESS/FAIL and the data.

https://www.paypal.com/pdt

Turn on IPN if you want all that post info 'no hablo englis' jerkwad was refering to.
Users browsing this topic
Guest
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

YAFVision Theme by Jaben Cargman (Tiny Gecko)
Powered by YAF | YAF © 2003-2009, Yet Another Forum.NET
This page was generated in 0.506 seconds.