PayPal Hacks. 100 Industrial-Strength Tips and Tools Free Open Book

PayPal Hacks. 100 Industrial-Strength Tips and Tools

Previous Section  < Day Day Up >  Next Section

Hack 63 Time Your Subscriptions to End on Specific Dates

figs/moderate.gif figs/hack63.gif

Use some simple JavaScript and PayPal's trial period to calculate the lengths of new subscriptions, assuring they all expire at the same time.

Imagine you own a diaper service for Rhesus monkeys. Your customers subscribe by the month, and every month some customers allow their subscriptions to lapse. You need to get these customers back on board so you get some help from your brother-in-law Leon, a guy with a knack for bringing monkey owners around. Market research suggests lapsed subscribers are best contacted seven to nine days after dropping the service, just when the smell has started to get the attention of local law enforcement. But Leon doesn't want to call two or three people a day. He'd rather make 60 or 90 calls all at once.

PayPal doesn't offer a feature to set the date a subscription will expire; the subscription expires at a time that corresponds to the date the customer signed up. For example, a monthly subscription started on the 12th will run until the 12th of the next month. But you can use this hack to ensure that every new subscription will be billed on the first of the month, keeping Leon as happy as a Rhesus monkey in a fresh nappy.[1]

[1] No simians were harmed in the writing of this hack, with the possible exception of the author.

6.4.1 Hacking the Trial Period

One handy feature of PayPal's subscriptions is the trial period. It allows you to set an introductory price for new subscribers that changes to the standard rate when the trial period expires. For example, you might offer access to your online information service for $1 during a three-day trial period, after which the price jumps to $100 a month.

To time your subscriptions to expire on the same day, bend the terms of the trial period so that each customer is charged a prorated amount for the balance of the month, after which the standard monthly rate kicks in. The JavaScript code makes this easy by completing these tasks:

  1. Calculate how many days are left in the current month.

  2. Find the prorated price by dividing the monthly subscription fee by the number of days in a month (31 days in this example) and multiplying by the number of days left.

  3. Stuff the calculated values into the subscription button when the buyer clicks Subscribe.

Just use this for your subscription sign-up page:

<html>

<head>

<title>Prorated Subscription</title>

</head>

<body>

<script language="JavaScript">

function CalcDate( ) {



var subend



//Set the start day to today

today=new Date( )



//Set the end date

//If it is December now, then the ending date needs to be January 1 of 

                next year

if (today.getMonth == 12) {

        subend=new Date(today.getFullYear( )+1, 1, 1)

} else {

        subend=new Date(today.getFullYear( ), today.getMonth( )+1, 1)

}



//Set 1 day in milliseconds

var one_day=1000*60*60*24



//Calculate the difference between the two dates, convert to days, and put

                it in the day_count variable

var day_count = (Math.ceil((subend.getTime( )-today.getTime( ))/(one_day)))



//Set the subscription fee, then calculate the prorated value

var sub_fee = 10

var prorated_fee = Math.floor(((sub_fee/31)*day_count)*100)/100



//Write the values to the form on click

document.fmSubscribe.p1.value = day_count

document.fmSubscribe.a1.value = prorated_fee

}

</script>



<form action="https://www.paypal.com/cgi-bin/webscr" 

                method="post" name="fmSubscribe">

<input type="image" src="https://www.paypal.com/en_US/i/btn/x-click-but20.gif"

                onClick="CalcDate( )" border="0" name="submit">

<input type="hidden" name="cmd" value="_xclick-subscriptions">

<input type="hidden" name="business" value="burchell@inebraska.com">

<input type="hidden" name="item_name" value="Monkey Nappy Service">

<input type="hidden" name="item_number" value="Sub-001">

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

<input type="hidden" name="currency_code" value="USD">

<input type="hidden" name="a3" value="10.00">

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

<input type="hidden" name="t3" value="M">

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

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



<!-- Values for the "trial period" -->

<input type="hidden" name="a1" value="">

<input type="hidden" name="p1" value="">

<input type="hidden" name="t1" value="D">

</form>



</body>

</html>

6.4.2 Hacking the Hack

PayPal allows you to have two subscription trial periods. If you'd like to offer new subscribers a special rate and also have them all expire on the same schedule, use the first trial period for the discount (or even free) trial and the second trial period to prorate the balance of the month. Set the second trial period to the number of days left in the month after accounting for the days in the first trial.

For a three-day free trial, for instance, the trial period section of the button might look like this:

<!-- Values for the "trial period" -->

<input type="hidden" name="a1" value="0">

<input type="hidden" name="p1" value="3">

<input type="hidden" name="t1" value="D">

<input type="hidden" name="a2" value="">

<input type="hidden" name="p2" value="">

<input type="hidden" name="t2" value="D">

Don't forget to modify the JavaScript code to figure the end date of the second (prorated) trial period, which may fall at the end of next month.


    Previous Section  < Day Day Up >  Next Section
    Index: [SYMBOL][A][B][C][D][E][F][G][H][I][J][L][M][N][O][P][Q][R][S][T][U][V][W][X][Y]


         Main Menu
    PayPal Hacks
    Table of Contents
    Copyright
    Credits
    Preface
    Chapter 1. Account Management
    Chapter 2. Making Payments
    Chapter 3. Selling with PayPal
    Chapter 4. Payment Buttons
    Chapter 5. Storefronts and Shopping Carts
    Chapter 6. Managing Subscriptions
    Introduction: Hacks #61-64
    Hack 61 Sell Subscriptions to Your Online Content
    Hack 62 Offer Tiered Subscriptions
    Hack 63 Time Your Subscriptions to End on Specific Dates
    Hack 64 Manage Subscription Passwords the Easy Way
    Chapter 7. IPN and PDT
    Chapter 8. The PayPal Web Services API
    Colophon
    Index


    More Books
    PHP Hacks
    Processing Xml With Java - A Guide To Sax, Dom, Jdom, Jaxp, And Trax
    The Koran (Holy Qur'an)
    Macromedia Flash 8 Bible
    Search Engine Optimization for Dummies
    YouTube Traffic
    PHP 5 for Dummies
    Harry Potter and The Chamber of Secrets
    Harry Potter and the Sorcerer's Stone
    The Pilgrim's Progress
    Wireless Hacks
    Flash Hacks. 100 Industrial-Strength Tips & Tools
    PayPal Hacks. 100 Industrial-Strength Tips and Tools
    Amazon Hacks
    Pdf Hacks
    The Da Vinci Code
    Google Hacks
    The Holy Bible
    Windows XP For Dummies
    Harry Potter and the Half-Blood Prince
    Seo Book
    Upgrading and Repairing Networks
    Macromedia Dreamweaver 8 UNLEASHED
    Windows XP Annoyances
    Windows XP Hacks
    Microsoft Windows XP Power Toolkit
    Teach Yourself MS Office In 24Hours
    iPod & iTunes Missing Manual
    PC Hacks 100 Industrial-Strength Tips and Tools
    PC Overclocking, Optimization, and Tuning - 2th Edition
    PC Hardware In A Nutshell 3rd Edition
    PC Hardware in a Nutshell, 2nd Edition
    Upgrading and Repairing PCs
    Google for Dummies
    MySQL Cookbook
    Teach Yourself Macromedia Flash 8 In 24 Hours
    PHP CookBook
    Sams Teach Yourself JavaScript in 24 Hours
    PHP5 Manual
    Free Games Paper Airplanes
    500 Juegos Gratis 500 Giochi Gratis 500 Jeux Gratuits 500 Jogos Gratis 500 Kostenlose Spiele