Tutorial: Selling a single product

This tutorial will show you have to sell a single product.
Even if you plan to only sell subscriptions, start here for the plugin basics
(and you’ll likely want to add single-purchases to your subscriptions anyway).

Assuming you’ve already done the prerequisites, then this tutorial should take you no more than 10 minutes.

Prerequisites

  • Stripe setup
  • Getting Started

Create a checkout page

The checkout page is where the user is sent to pay for the product(s) they intend to
purchase.

Create a blank page as usual in WordPress and add the shortcode:

[payments-checkout]

You can add any other content to this page you want, but it’s not required.

After your create that page, go to ‘Payment’ -> ‘Pages’ in your
WordPress dashboard and select it for the option ‘Checkout page’. Click ‘Save Changes’.

You don’t need to add this page to the navigation, the plugin
directs users there automatically after a purchase.

Add the ‘Add to Cart’ link.

First choose the product that you want to sell and the desired. If you just followed the stripe.md
tutorial then you should only have one price per product – but this may not be the case later on.

Go to your Stripe dashboard and copy the price id of the desired price
for the product you want to sell. This value should start with price_ followed by a bunch of letters.
If you created the products in stripe.md, use the price of the book ‘A Study in Scarlet’.

Choose a page to list the product. The page can be any page you want, a page, post or custom post type. Let’s just use
the homepage. (Why not get to the point?)

Add the following shortcode to that page:

[payments-product price="price_1234567890ABCDEFGHIJKLMN"]

replacing the price value with your own.

Save the page. You should see a product listing and an ‘Add to Cart’ link on your page.

Add a download (optional)

Depending on your product, you may already be ready to go, but for this tutorial we need to give the
user the ability to download the PDF of the book once they’ve purchased it.

In your Stripe dashboard, go to ‘Payments’ -> ‘Products’ and select the product, in this case ‘A Study in Scarlet’.

Under the downloads section, choose the PDF and click ‘Upload’.

Create an ‘account’ page

The ‘account’ page is where the user goes to see their purchases and any available downloads.

Create a page as normal and add the following shortcode:

[payments-account]

Save the page.

This page should be included in your site navigation. Add it to your top-level menu.

When a user clicks the link they will be forced to log in to your site.

Try it!

Now let’s use one of the Stripe test cards to buy the product.
The best way to do this is to open an incognito/private browser window.

Go to the page where you added the shortcode and click the ‘Add to cart’ button. Once you do, the button
should change to ‘Checkout’. (This functionality is configurable.)

Click ‘Checkout’ to take you to the checkout page.

If you are not logged in, you’ll see an email address field. For logged-in users, this field is hidden.

Fill in the requested data, every field is required.
If you enter an email address – and that email doesn’t yet exist in WordPress – a new user is created for that email.

Use one of the Stripe test cards to complete the transaction.
Any valid date in the future works for the expiration (like 12/34). Any
three-digit code works for the CVC and any five-digit number works for the zip code.

Click ‘Pay Now’ and the page redirects to a ‘Thank you’ confirmation page.

Downloading your Product (optional)

Click the ‘Account’ link (or just go to the Accounts page). You
may be asked to log in. If a new account was created for the email address, then follow the instructions you received via email.

NOTE: email must be setup correctly on your WordPress instance!

On the Accounts page, under payment click the product – in this case ‘A Study in Scarlet’.
Beneath the product details is a link to the PDF.
This link is also protected, so even if a user has the link, it requires them to be logged in.

Next steps

  • Creating a subscription (tutorial-subscription.md)