website management, web design, web management

(800) 314-8932

(800) 31-IT-WEB

  • Home
  • Web Design
  • Web Management
  • Promote
  • Optimize
  • Testimonials
  • Web Packages
  • Blog
  • Contact
  • Recent Comments

    • Aaron on Wordpress vs. Movable Type vs. Drupal vs. Joomla
    • Aditya on Wordpress vs. Movable Type vs. Drupal vs. Joomla
    • Richard Kersey on Wordpress vs. Movable Type vs. Drupal vs. Joomla
    • Lawrence on Wordpress vs. Movable Type vs. Drupal vs. Joomla
    • Uberhacker on Wordpress vs. Movable Type vs. Drupal vs. Joomla
  • Tags

    affordable business cms content content management system design domain names drupal engine free goal goals Google hosting joomla maintenance management manager optimization phone project management requirements search search optimization site site design site maintenance web site maintenance solutions management starting a business start up system tasks tips toll free tools tricks web web design Web Hosting web site website website design website goals website management wordpress
  • Categories

    • Advertising
    • Aweber
    • Blogging
    • CSS / XHTML
    • Domain Registration
    • Ecommerce
    • Fireworks
    • Flash
    • General
    • Google
    • HTML
    • PayPal
    • Photoshop
    • Private
    • S.E.O.
    • Web Hosting
  • Archives

    • July 2009
    • March 2009
    • February 2009
    • January 2009
    • December 2008
    • September 2008
    • August 2008
    • June 2008
    • April 2008
    • March 2008
    • February 2008
    • January 2008
    • December 2007
    • October 2007
    • July 2007
    • April 2007
    • March 2007
    • June 2006
    • March 2006
    • February 2006
    • January 2006
    • December 2005
    • November 2005
  • Pages

    • Advertising Design
      • Animated Gif Images
      • Flash and Standard Animated Advertisements
      • Rich Media Flash Advertisements
    • Affiliate - Link Exchange
    • Client Testimonial Archive
    • Discount Logo Design

PayPal Subscription and Payment Plan Buttons Integrated with Aweber

If you have a subscription service, or payment plan button on your website and you’ve tried to integrate it with Aweber so that the payee is automatically subscribed to your Aweber Newsletter, then you may have come across the problem that Aweber only supports a Buy It Now button or link.

Using PHP (and lots of other languages), you can perform a PayPal -> YourSite -> Aweber transaction that does the same thing for a Subscription or Payment Plan button. You can’t do an automatic PayPal -> Aweber transaction, but this the best work around we’ve come up with.

Quick Summary for the impatient: Copy the code in the text box below, and customize the two options at the top of the script which are notated in the code.

The first thing necessary is to create a page on your website with the following code. This code will have two options we need to customize before it will work, but we need the url of your thank you page before we get into the paypal setup, so create that page first.

<?php

// These two items are the only two you need to edit.

// 1. add your key here

$auth_token = “RtWe0qNpNLiZlsdkdiseESasdr3vqpqlimqNzvfSPqHFhgKUc0bVhwKdgwNy”;

// 2. add your aweber list name to the beginning of this email address

$aweber_email_list = “list-name@aweber.com”;

// read the post from PayPal system and add ‘cmd’

$req = ‘cmd=_notify-synch’;

$tx_token = $_GET['tx'];

$req .= “&tx=$tx_token&at=$auth_token”;
// 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);

// If possible, securely post back to paypal using HTTPS

// Your PHP server will need to be SSL enabled

// $fp = fsockopen (’ssl://www.paypal.com’, 443, $errno, $errstr, 30);
if (!$fp) {

// HTTP ERROR

} else {

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

// read the body data

$res = ”;

$headerdone = false;

while (!feof($fp)) {

$line = fgets ($fp, 1024);

if (strcmp($line, “\r\n”) == 0) {

// read the header

$headerdone = true;

}

else if ($headerdone)

{

// header has been read. now read the contents

$res .= $line;

}

}
// parse the data

$lines = explode(”\n”, $res);

$keyarray = array();

if (strcmp ($lines[0], “SUCCESS”) == 0) {

for ($i=1; $i<count($lines);$i++){

list($key,$val) = explode(”=”, $lines[$i]);

$keyarray[urldecode($key)] = urldecode($val);

}

// check the payment_status is Completed

// check that txn_id has not been previously processed

// check that receiver_email is your Primary PayPal email

// check that payment_amount/payment_currency are correct

// process payment

$firstname = $keyarray['first_name'];

$lastname = $keyarray['last_name'];

$email = $keyarray['payer_email'];

$itemname = $keyarray['item_name'];

$amount = $keyarray['payment_gross'];
$headers = ‘From: “‘.$firstname.’ ‘.$lastname.’” <’.$email.’>’ . “\r\n” .

‘Reply-To: “‘.$firstname.’ ‘.$lastname.’” <’.$email.’>’ . “\r\n” .

‘X-Mailer: PHP/’ . phpversion();
mail($aweber_email_list, ”, ”, $headers);
echo (”<p><h3>Thank you for your purchase!</h3>Please check your email in 5-10 minutes to confirm your subscription.</p>”);
echo (”<b>Payment Details</b><br>\n”);

echo (”<li>Name: “.$firstname.” “.$lastname.”</li>\n”);

echo (”<li>Email: “.$email.”</li>\n”);

echo (”<li>Item: “.$itemname.”</li>\n”);

echo (”<li>Amount: $”.$amount.”</li>\n”);

echo (”");

}

else if (strcmp ($lines[0], “FAIL”) == 0) {

// log for manual investigation

}
}
fclose ($fp);
?>
Your transaction has been completed, and a receipt for your purchase has been emailed to you.<br />

You may log into your account at <a xhref=’https://www.paypal.com’>www.paypal.com</a> to view details of this transaction.<br />

####END CODE#####
Now that you have a new page, and you’ve got the url to that page, now go to PayPal and setup your Subscription Button. After filling in the necessary items, click the “Add More Options” button instead of the “Create Button Now”. On the more options page choose paste the url to the page you just created into Successful Payment URL input box. Then next to the text “Payment Data Transfer” click the Edit button. On this page turn “Auto Return” to “On”. Paste your url again in the input box below that. Now scroll down turn “Payment Data Transfer” to “On” and now copy the “Identity Token” and put it into the page you created on your website. Set the rest of your options as needed, click “Save”, then on the next page “Create Button Now”.

Now you should of course copy and paste your button code into your site. Then there is just one more option to setup. Go to your Aweber account get your list name, and put that into the script on your site as the email address “list-name@aweber.com”. You should be all set now, with your website now sending an email to Aweber about the new subscription.

Note: If you’re on a shared hosting plan you may experience difficulties with the very simple mail script because your host may require that you send emails from or to a domain within your account. If thats the case, adding a BCC or CC to the email script so that a copy goes to your domain should work.

Download aweber - paypal pap here.

Other readers also liked...

Free Sample Thank You Note Book from Ultimate Resumes

Why a Web Page Needs to Load Quickly for Search Optimization

This entry was posted on Sunday, January 13th, 2008 at 4:46 pm and is filed under Advertising, Aweber, Ecommerce, General, PayPal. You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.

6 Responses to “PayPal Subscription and Payment Plan Buttons Integrated with Aweber”

  1. Meng Says:
    March 3rd, 2008 at 11:10 am

    Hi

    Like to know how do I obtain the Key under

    // These two items are the only two you need to edit.

    // 1. add your key here

  2. Richard Kersey Says:
    March 3rd, 2008 at 11:21 am

    Yes that may be confusing if you haven’t done it before. There are a few ways to get to it, but no direct way unless you know the url: https://www.paypal.com/us/cgi-bin/webscr?cmd=_profile-website-payments

    Once you turn “Payment Data Transfer” to “ON”, you will have your “Identity Token”.

    During the button making process, you get to the bottom choose: “Add More Options”. This will give you an option about half way down for Payment Data Transfer. If you click “Edit” that will bring you to the url above and allow you get your token as well.

  3. Meng Says:
    March 4th, 2008 at 10:08 am

    Thanks got it !

    Will try it out

  4. Mark Says:
    March 10th, 2008 at 10:17 pm

    The ####END CODE##### is not actually part of the code, right?

    The last line of code is -

    to view details of this transaction.

    Is that right?

    I’m not getting anything but a blank screen when I execute this code.

    I don’t have an AWeber account yet, but I should still see the confirmation text, right?

    Thx!

  5. Richard Kersey Says:
    March 11th, 2008 at 1:55 pm

    Mark, you should turn on your error reporting and see if you have any syntax errors or if there is a problem you can’t see.

    Check here for instructions on turning your error reporting on.
    http://us3.php.net/error_reporting

  6. Drew Says:
    March 17th, 2008 at 10:33 am

    Works perfectly! Thanks!

Leave a Reply

The Basics - for when you're just starting out.

FREE DOMAIN

Check for domain availability, and get it for FREE!

HOSTING

Full featured Linux web hosting, with 24/7 support & 30 day money back guarantee.

WEB DESIGN

Goal focused design and Website management. From small to enterprise level, you've found your solution.

Yahoo Instant Message

Start a Skype Chat

GTalk Instant Message

AOL Instant Message

© 2003 - 2009 RazorIT ™ LLC - Terms & Conditions • Contact Us • (800) 314-8932