Subscribe: Sample HTML button code
Last updated: Sept 19th, 2:31am
These code samples demonstrate various features for a PayPal-hosted Subscribe button:
- Basic Subscribe button
- Trial periods
- Limited billing cycles
- Product options
- Unsubscribe button
- Password management
- Reattempted payments
- Email payment links
Basic Subscribe button
This sample HTML code illustrates a basic Subscribe button with these features:
- No trial periods.
- A subscription price of $5.00 USD.
- A monthly billing cycle.
- The subscription ends only when the merchant or subscriber cancels it.
1<form action="https://www.paypal.com/cgi-bin/webscr" method="post"> <!-- Identify your business so that you can collect the payments. --> <input type="hidden" name="business" value="alice@mystore.com"> <!-- Specify a Subscribe button. --> <input type="hidden" name="cmd" value="_xclick-subscriptions"> <!-- Identify the subscription. --> <input type="hidden" name="item_name" value="Alice's Weekly Digest"> <input type="hidden" name="item_number" value="DIG Weekly"> <!-- Set the terms of the regular subscription. --> <input type="hidden" name="currency_code" value="USD"> <input type="hidden" name="a3" value="5.00"> <input type="hidden" name="p3" value="1"> <input type="hidden" name="t3" value="M"> <!-- Set recurring payments until canceled. --> <input type="hidden" name="src" value="1"> <!-- Display the payment button. --> <input type="image" name="submit" src="https://www.paypalobjects.com/en_US/i/btn/btn_subscribe_LG.gif" alt="Subscribe"> <img alt="" width="1" height="1" src="https://www.paypalobjects.com/en_US/i/scr/pixel.gif" > </form>
Trial periods
This sample HTML code illustrates a Subscribe button with these features:
- An initial trial period that is free and lasts for seven days.
- A second trial period that costs $5.00 USD and lasts for an additional three weeks.
- The regular subscription begins four weeks after the subscriber signs up.
1<form action="https://www.paypal.com/cgi-bin/webscr" method="post"> <!-- Identify your business so that you can collect the payments. --> <input type="hidden" name="business" value="alice@mystore.com"> <!-- Specify a Subscribe button. --> <input type="hidden" name="cmd" value="_xclick-subscriptions"> <!-- Identify the subscription. --> <input type="hidden" name="item_name" value="Alice's Weekly Digest"> <input type="hidden" name="item_number" value="DIG Weekly"> <!-- Set the terms of the 1st trial period. --> <input type="hidden" name="currency_code" value="USD"> <input type="hidden" name="a1" value="0"> <input type="hidden" name="p1" value="7"> <input type="hidden" name="t1" value="D"> <!-- Set the terms of the 2nd trial period. --> <input type="hidden" name="a2" value="5.00"> <input type="hidden" name="p2" value="3"> <input type="hidden" name="t2" value="W"> <!-- Set the terms of the regular subscription. --> <input type="hidden" name="a3" value="49.99"> <input type="hidden" name="p3" value="1"> <input type="hidden" name="t3" value="Y"> <!-- Set recurring payments until canceled. --> <input type="hidden" name="src" value="1"> <!-- Display the payment button. --> <input type="image" name="submit" src="https://www.paypalobjects.com/en_US/i/btn/btn_subscribe_LG.gif" alt="Subscribe"> <img alt="" width="1" height="1" src="https://www.paypalobjects.com/en_US/i/scr/pixel.gif" > </form>
Limited billing cycles
This sample HTML code illustrates a Subscribe button that requires renewal, with these features:
- A subscription price of $69.95 USD.
- A monthly billing cycle.
- Expiration after six months, requiring renewal.
1<form action="https://www.paypal.com/cgi-bin/webscr" method="post"> <!-- Identify your business so that you can collect the payments. --> <input type="hidden" name="business" value="alice@mystore.com"> <!-- Specify a Subscribe button. --> <input type="hidden" name="cmd" value="_xclick-subscriptions"> <!-- Identify the subscription. --> <input type="hidden" name="item_name" value="Alice's Monthly Digest"> <input type="hidden" name="item_number" value="DIG Weekly"> <!-- Set the terms of the recurring payments. --> <input type="hidden" name="a3" value="69.95"> <input type="hidden" name="p3" value="1"> <input type="hidden" name="t3" value="M"> <!-- Set recurring payments to stop after 6 billing cycles. --> <input type="hidden" name="src" value="1"> <input type="hidden" name="srt" value="6"> <!-- Display the payment button. --> <input type="image" name="submit" src="https://www.paypalobjects.com/en_US/i/btn/btn_subscribe_LG.gif" alt="Subscribe"> <img alt="" width="1" height="1" src="https://www.paypalobjects.com/en_US/i/scr/pixel.gif" > </form>
Product options
When you add product options to your Subscribe buttons with HTML code that you write yourself. You can have a maximum of 10 product options, each with their own sets of choices. The options can be either drop-down menus or text boxes.
The following topics provide information for the sample code that illustrates various ways to add product options to Subscribe buttons.
Product options
This sample HTML code illustrates a basic Subscribe button with a drop-down menu of product options.
1<form action="https://www.paypal.com/cgi-bin/webscr" method="post"> <!-- Identify your business so that you can collect the payments. --> <input type="hidden" name="business" value="alice@mystore.com"> <!-- Specify a Subscribe button. --> <input type="hidden" name="cmd" value="_xclick-subscriptions"> <!-- Identify the subscription. --> <input type="hidden" name="item_name" value="Alice's Weekly Digest"> <input type="hidden" name="item_number" value="DIG Weekly"> <!-- Set the terms of the regular subscription. --> <input type="hidden" name="a3" value="5.00"> <input type="hidden" name="p3" value="1"> <input type="hidden" name="t3" value="M"> <!-- Set recurring payments until canceled. --> <input type="hidden" name="src" value="1"> <!-- Provide a drop-down menu option field. --> <input type="hidden" name="on0" value="Format">Format <br /> <select name="os0"> <option value="Select a format"></option> <option value="plaintext"></option> <option value="HTML"></option> </select> <br /> <!-- Display the payment button. --> <input type="image" name="submit" src="https://www.paypalobjects.com/en_US/i/btn/btn_subscribe_LG.gif" alt="Subscribe"> <img alt="" width="1" height="1" src="https://www.paypalobjects.com/en_US/i/scr/pixel.gif" > </form>
The Subscribe button with an options drop-down menu:
Paste the code below an image or a text description of the item on your web page.
Product options as text boxes
This sample code illustrates a basic Subscribe button with a text box for entering product options.
1<form action="https://www.paypal.com/cgi-bin/webscr" method="post"> <!-- Identify your business so that you can collect the payments. --> <input type="hidden" name="business" value="alice@mystore.com"> <!-- Specify a Subscribe button. --> <input type="hidden" name="cmd" value="_xclick-subscriptions"> <!-- Identify the subscription. --> <input type="hidden" name="item_name" value="Alice's Weekly Digest"> <input type="hidden" name="item_number" value="DIG Weekly"> <!-- Set the terms of the regular subscription. --> <input type="hidden" name="a3" value="5.00"> <input type="hidden" name="p3" value="1"> <input type="hidden" name="t3" value="M"> <!-- Set recurring payments until canceled. --> <input type="hidden" name="src" value="1"> <!-- Provide the buyer with a text box option field. --> <input type="hidden" name="on0" value="Size"> <br /> <input type="text" name="os0" maxlength="60"> <br /> <!-- Display the payment button. --> <input type="image" name="submit" src="https://www.paypalobjects.com/en_US/i/btn/btn_subscribe_LG.gif" alt="Subscribe"> <img alt="" width="1" height="1" src="https://www.paypalobjects.com/en_US/i/scr/pixel.gif" > </form>
The Subscribe button with an options text box:
Paste the code below an image or a text description of the item on your web page.
Unsubscribe button
While other payment buttons are implemented by HTML form markup, Unsubscribe
buttons are image links to the subscription cancellation function on the
PayPal website. The URL for the image link is specified with the
HREF
attribute, and it includes these URL-encoded parameters:
-
cmd
– value is_subscr-find
, which tells PayPal to cancel the current, active subscription of the PayPal account holder who clicked the Unsubscribe button. -
alias
– value is the secure merchant account ID of the subscription provider's PayPal account. This value is in the My business info section of your PayPal account profile.
This code implements an Unsubscribe button that lets subscribers cancel their current, active subscriptions.
1<a href="https://www.paypal.com/cgi-bin/webscr?cmd=_subscr-find&alias=SGGGX43FAKKXN&switch_classic=true">2<img src="https://www.paypalobjects.com/en_US/i/btn/btn_unsubscribe_LG.gif">3</a>
This code displays this button image:
Paste the code near a text explanation of how subscription cancellations work on your web page.
Password management
This sample HTML code illustrates a Subscribe button that has PayPal generate usernames and passwords automatically.
1<form action="https://www.paypal.com/cgi-bin/webscr" method="post"> <!-- Identify your business so that you can collect the payments. --> <input type="hidden" name="business" value="alice@mystore.com"> <!-- Specify a Subscribe button. --> <input type="hidden" name="cmd" value="_xclick-subscriptions"> <!-- Identify the subscription. --> <input type="hidden" name="item_name" value="Alice's Weekly Digest"> <input type="hidden" name="item_number" value="DIG Weekly"> <!-- Set the terms of the regular subscription. --> <input type="hidden" name="currency_code" value="USD"> <input type="hidden" name="a3" value="19.95"> <input type="hidden" name="p3" value="1"> <input type="hidden" name="t3" value="M"> <!-- Set recurring payments until canceled. --> <input type="hidden" name="src" value="1"> <!-- Have PayPal generate usernames and passwords. --> <input type="hidden" name="usr_manage" value="1"> <!-- Display the payment button. --> <input type="image" name="submit" src="https://www.paypalobjects.com/en_US/i/btn/btn_unsubscribe_LG.gif" alt="Subscribe"> <img alt="" width="1" height="1" src="https://www.paypalobjects.com/en_US/i/scr/pixel.gif" > </form>
Reattempted payments
This sample HTML code illustrates a Subscribe button that has PayPal reattempt failed recurring payments before canceling subscriptions.
1<form action="https://www.paypal.com/cgi-bin/webscr" method="post"> <input type="hidden" name="business" value="alice@mystore.com"> <!-- Specify a Subscribe button. --> <input type="hidden" name="cmd" value="_xclick-subscriptions"> <!-- Identify the subscription. --> <input type="hidden" name="item_name" value="Alice's Weekly Digest"> <input type="hidden" name="item_number" value="DIG Weekly"> <!-- Set the terms of the regular subscription. --> <input type="hidden" name="currency_code" value="USD"> <input type="hidden" name="a3" value="19.95"> <input type="hidden" name="p3" value="1"> <input type="hidden" name="t3" value="M"> <!-- Set recurring payments until canceled. --> <input type="hidden" name="src" value="1"> <!-- PayPal reattempts failed recurring payments. --> <input type="hidden" name="sra" value="1"> <!-- Display the payment button. --> <input type="image" name="submit" src="https://www.paypalobjects.com/en_US/i/btn/btn_subscribe_LG.gif" alt="Subscribe"> <img alt="" width="1" height="1" src="https://www.paypalobjects.com/en_US/i/scr/pixel.gif" > </form>
Email payment links
The sample URL code in this section illustrates a basic Subscribe email payment link with these features:
- No trial period.
- A subscription price of $5.00 USD.
- A one-month billing cycle.
- No limit on the number of billing cycles.
The subscription ends only when the merchant or subscriber cancels it.
1https://www.paypal.com/cgi-bin/webscr?&business=alice@mystore.com&item_name=Alice%27s%20Weekly%20Digest&=&=&=M¤cy_code=USD
For information on pasting button code, see Copy and paste button code.