Subscribe: Sample HTML button code

These code samples demonstrate various features for a PayPal-hosted Subscribe button:

Important: This page contains unencrypted button code for illustrative purposes only. To prevent malicious tampering of buttons on your live website, always encrypt your manually created buttons.

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.
<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/webstatic/en_US/i/btn/png/btn_subscribe_113x26.png"
    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.
<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/webstatic/en_US/i/btn/png/btn_subscribe_113x26.png"
    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.
<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/webstatic/en_US/i/btn/png/btn_subscribe_113x26.png"
    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.

<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">-- Select a format --</option>
    <option value="plaintext">Plain text</option>
    <option value="HTML">HTML</option>
    </select> <br />

    <!-- Display the payment button. -->
    <input type="image" name="submit"
    src="https://www.paypalobjects.com/webstatic/en_US/i/btn/png/btn_subscribe_113x26.png"
    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.

<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">Enter your size (S, M, L, X, XX) <br />
    <input type="text" name="os0" maxlength="60"> <br />

    <!-- Display the payment button. -->
    <input type="image" name="submit"
    src="https://www.paypalobjects.com/webstatic/en_US/i/btn/png/btn_subscribe_113x26.png"
    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.

Modify subscription button

The Modify Subscription button lets subscribers convert their current subscriptions to a new set of terms. Modify Subscription buttons are useful for letting subscribers upgrade from one subscription level to another. The subscription number remains the same as before. Only the terms of the subscription change.

This sample code illustrates a Modify Subscription button with these features:

  • A subscription price of $69.95 USD.
  • A 6-month billing cycle.
  • No limit on the number of billing cycles.
  • Subscription modification allowed for the previous terms only. New subscriptions are not allowed.

The subscription ends only when the merchant or subscriber cancels it.

<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 revised subscription price and terms. -->
    <input type="hidden" name="currency_code" value="USD">
    <input type="hidden" name="a3" value="69.95">
    <input type="hidden" name="p3" value="6">
    <input type="hidden" name="t3" value="M">

    <!-- Set recurring payments until canceled. -->
    <input type="hidden" name="src" value="1">

    <!-- Let current subscribers modify only. -->
    <input type="hidden" name="modify" value="2">

    <!-- Display the payment button. -->
    <input type="image" name="submit"
    src="https://www.paypalobjects.com/webstatic/en_US/i/btn/png/btn_subscribe_113x26.png"
    alt="Subscribe">
    <img alt="" width="1" height="1"
    src="https://www.paypalobjects.com/en_US/i/scr/pixel.gif" >
</form>

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.

<a href="https://www.paypal.com/cgi-bin/webscr?cmd=_subscr-find&alias=SGGGX43FAKKXN&switch_classic=true">
<img src="https://www.paypalobjects.com/webstatic/en_US/i/btn/png/btn_unsubscribe_113x26.png">
</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.

<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/webstatic/en_US/i/btn/png/btn_unsubscribe_113x26.png"
    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.

<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/webstatic/en_US/i/btn/png/btn_subscribe_113x26.png"
    alt="Subscribe">
    <img alt="" width="1" height="1"
    src="https://www.paypalobjects.com/en_US/i/scr/pixel.gif" >
</form>

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.

Important: The example email payment link is included for illustrative purposes only. In a production environment, you should always use a hosted email payment link to prevent malicious users from tampering with the code. Non-hosted email payment links are not secure.

https://www.paypal.com/cgi-bin/webscr?cmd=_xclick-subscriptions&business=alice@mystore.com&item_name=Alice%27s%20Weekly%20Digest&a3=5.00&p3=1&t3=M&currency_code=USD

For information on pasting button code, see Copy and paste button code.

See also