Jump to content


Photo

editing paypal.pl files


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

#1 guestcam

guestcam

    Newbie

  • Members
  • Pip
  • 8 posts

Posted 16 November 2002 - 03:45 PM

I'd like to offer my users serveral subscription options while using IPN and password management. So if someone out there can confirm or correct my thoughts below - that would be great.

1.inside the PAYPAL.pl script:
when not offering trial periods, what is the proper values for $PERIOD1 and $PERIOD2 ? should I put an empty string? or comment out the entire line? or is '0 D' good?

2. in my join pages html:
I currently assume for a join page to have three different subscriptions, I'll need to reference 3 different values for the notify_url field in each of the 3 forms/buttons. Is that right or is there actually a way to make the same paypal.pl script handle three subscription options? (ie one month reoccuring, quarterly reoccuring, annual)

thanks
Harry


Harry

#2 guestcam

guestcam

    Newbie

  • Members
  • Pip
  • 8 posts

Posted 18 November 2002 - 10:05 AM

so in general - how long does it take to get a reply from the admins/ops on questions posted? I'd like to move forward on my paysite developement.......


Harry

#3 paypal_pb

paypal_pb

    Advanced Member

  • Members
  • 2,960 posts

Posted 18 November 2002 - 10:54 AM

Less than 2 hours during business hours.

1. Leave them blank.

2. You could modify the script with the below:


# User Constants - customize these to YOUR installation (see manual)
# -------------------------------------------------------------------

# Set this to the path of your .htpassword file
my $PASSWORD_FILE = '';

# Set this to the path of your processed_txns file
my $TRANSACTION_FILE = '';

# You only need to change this if you are running with https
# see the manual for details
my $PAYPAL_URL = 'http://www.paypal.com/cgi-bin/webscr';

# The script matches the subscription terms specified by your 'join'
# button to the terms specified below. This script supports up to
# 3 different join buttons. If you have a trial period, fill in
# the '1' fields. If not, leave empty. For 'PERIOD' specify like
# '1 M' for one month. For 'AMOUNT' specify like '12.95'.

# Join button a
my $PERIOD1a = '';
my $AMOUNT1a = '';
my $PERIOD3a = '';
my $AMOUNT3a = '';

# Join button b
my $PERIOD1b = '';
my $AMOUNT1b = '';
my $PERIOD3b = '';
my $AMOUNT3b = '';

# Join button c
my $PERIOD1c = '';
my $AMOUNT1c = '';
my $PERIOD3c = '';
my $AMOUNT3c = '';

my $AMOUNT2 = '';
my $PERIOD2 = '';

# Set this to the path of sendmail. On Linux and FreeBSD systems this
# is typically '/usr/sbin/sendmail', on Solaris systems it is usually
# found at '/usr/lib/sendmail'
my $SENDMAIL_PATH = '';

# Set this to the email address you'd like to have error notification
# messages sent to
my $ADMIN_EMAIL = '';

# Set this to your primary PayPal email address
my @PAYMENT_EMAILS = ('');

# -------------------------------------------------------------------


main();

sub main {

# acknowlege the ipn from PayPal
if (ack_ipn()) {
# decide what to do with msg received
handle_ipn();
}
# IPN was successfully processed
respond(1);
}

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;
}
}

sub handle_ipn {

# handle the msg received
if ((param("txn_type") eq "subscr_signup") && (validate_signup())) {
# make sure a username was sent
if (!param("username")) {
error_notify("No username found. Check your subscription button or link.", "add user", 0, 1);
return;
}
# add subscriber to password file
add_user(param("username"), param("password"), param("subscr_id"));
} elsif (param("txn_type") eq "subscr_eot") {
# make sure a username was sent
if (!param("username")) {
error_notify("No username found. Check your subscription button or link.", "remove user", 0, 1);
return;
}
# remove subscriber from password file
remove_user(param("username"));
} else {
# ignore message
}
}

sub match_terms {
# validate the terms and amounts
my $p1 = shift;
my $a1 = shift;
my $p3 = shift;
my $a3 = shift;

if (($PERIOD2 eq param("period2") && $AMOUNT2 eq param("amount2"))&&
($p1 eq param("period1") && $a1 eq param("amount1")) &&
($p3 eq param("period3") && $a3 eq param("amount3"))) {
return 1;
} else {
return undef;
}
}

sub validate_signup {
# validate the terms and amounts
if (match_terms($PERIOD1a, $AMOUNT1a, $PERIOD3a, $AMOUNT3a) ||
match_terms($PERIOD1b, $AMOUNT1b, $PERIOD3b, $AMOUNT3b) ||
match_terms($PERIOD1c, $AMOUNT1c, $PERIOD3c, $AMOUNT3c)) {
} else {
error_notify("Although payment was accepted the account was not activated.",
"validate subscription terms", 0, 1);
return undef;
}

# validate the receiver email
my $valid = undef;
foreach (@PAYMENT_EMAILS) {
if (param("receiver_email") eq $_) {
$valid = 1;
}
}
if (!$valid)
{
error_notify("An IPN was received that did not match your primary email " .
"address - Message was ignored.",
"validate receiver email ", 0, 0);
return undef;
}


file_open($TRANSACTION_FILE, "+<");
# validate transaction id
if (find_txn(param("subscr_id"))) {
# transaction was previously processed
file_close($TRANSACTION_FILE);
error_notify("An IPN was received that was already processed " .
"- Message was ignored.", "validate subscription id", 0, 0);
return undef;
} else {
file_close($TRANSACTION_FILE);
}

return 1;
}


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

#4 guestcam

guestcam

    Newbie

  • Members
  • Pip
  • 8 posts

Posted 18 November 2002 - 12:10 PM

thanks Patrick, I already made my three scripts - but I will certainly make another join page sometime soon and will try this script you posted.


Can I ask some other questions on subscritions, html on the join page and the code inside paypal.pl ?

In testing out my code - I have notice (what I find to be) an annoying feature of the paypal confirmation/conclusion page is IT DOES NOT MENTION the username/password!

Do I have control over that at all? Is there a way, from HTML in my form/button code, or from paypal.pl that I can make the username and password appear?

I would prefer that they appear on the paypal conclussion page (the one that has the button to goto the success page).
My next preference would be the confirming email contains their user/pass info.

Got a solution for me Patrick?
Harry
PS: I tried to be clever and made my 'success' page inside a protected directory that only allowed http_referer to be https://www.paypal.com . Unfortunately, the button method paypal uses to send people to my page leaves http_referer blank.


Harry

#5 paypal_pb

paypal_pb

    Advanced Member

  • Members
  • 2,960 posts

Posted 18 November 2002 - 12:48 PM

Note: the PERL code snippet above is partial. It replaces a block of code in the regular paypal.pl

If the username and password is not being displayed on the last PayPal page, it indicates that Password Management is not "turned on". Make sure you have:

<input type="hidden" name="usr_manage" value="1">

in your join buttons.

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

#6 guestcam

guestcam

    Newbie

  • Members
  • Pip
  • 8 posts

Posted 18 November 2002 - 03:12 PM

RE: "If the username and password is not being displayed on the last PayPal page, it indicates that Password Management is not 'turned on'. "

Well I have to disagree with that.

I DO have password management turned on.
And I DO have that code snippet in each form's code.
And I DO have usernames and passwords generated for me by paypal.
Paypal even inserts them into the htpasswd file.
So Paypal knows I want password management and its doing it.

However, that leave us at:
the original thought of "How do I get the paypal confirmation page to display the username and password it just generated?"

or instead, the answer to "How can I get paypal to include in the confirming email the username and password?"

Orrrrr even???? Are the username and password available to me as form fields to post back to my SUCCESS page?? If I cannot get the first two options from paypal - perhaps I can get my success page to show the users their info and give them the link to the members area?

Harry



Harry




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users