🛒
Stripe Checkout (Shopping Cart) Plugin
  • 👋Introduction
  • Installing the Plugin
  • Configuring Stripe API Keys
  • Setting up your Database
  • Adding items to the shopping cart
  • Creating Checkout Sessions
  • Embedding payment forms in your app
  • Adding Shipping Rates
  • Automatically Create Stripe Customer ID's
  • Saving down details of a transaction
  • Stripe Tax
  • Discounts
  • Support Queries
Powered by GitBook
On this page

Setting up your Database

PreviousConfiguring Stripe API KeysNextAdding items to the shopping cart

Last updated 1 year ago

You can see my full recommended database setup in the demo app.

Please note that database set up I describe on this page is merely my own recommendation. It is absolutely possible to use the plugin with various different database configurations.

I recommend creating the below 3 data types in order to utilise the Stripe Checkout (Shopping Cart) plugin.

  1. Cart Item

  2. Product

  3. Transaction

There are also some additional fields I recommend adding to the User data type.

Cart Item

The Cart Item data type will be used to represent the items that are in a User's shopping cart. It will also be used with the plugin to send data to Stripe and ultimately create the Stripe Checkout Session where the products/services are purchased.

The Cart Item data type has the following fields:

  • frequency: Used for subscription products to determine how often a subscription is charged. Value should be "day", "week", "month" or "year" for subscription products. Can be left blank for one-time purchases.

  • product: Linked to the "Product" data type (see below)

  • quantity: The number of each product that is to be purchased

  • subscription: A "Yes/No" field that indicates whether the product is a subscription product ("Yes") or a one-off purchase ("No")

  • total cost: The total value (in cents) of each line item of product purchased (quantity * price)

Product

The Product data type is used to represent the actual products/services that are for sale on the platform. These will typically be created by the platform who are selling the products/services.

The Product data yype has the following fields:

  • description (optional): A text description of what the product is

  • frequency (necessary): Used for subscription products to determine how often a subscription is charged. Value should be "day", "week", "month" or "year" for subscription products. Can be left blank for one-time purchases.

  • image (optional): An image that represents the product/service. You'll see how this is used on my demo app.

  • name (necessary): The name of the product/service.

  • price (cents) (necessary): The price of the product/service in cents. If it's for a subcription product, it will be the price charged per day, week, month or year.

  • subscription? (necessary): A "Yes/No" field that indicates whether the product is a subscription product ("Yes") or a one-off purchase ("No")

Transaction

The transaction data type is used to record details of transactions that occur on your platform.

The Transaction data type has the following fields:

  • checkout session id: The ID of the Stripe Checkout Session that was used for the transaction

  • currency: The currency that was used for the transaction

  • payment status: Indicates whether the payment was successful or not

  • total amount: The total value of the transaction (in cents)

User

The User data type has the following custom fields:

  • customer id: The Stripe Customer ID associated with the customer

  • shopping cart: A list of Cart Items. This is used to indicate which items are currently in the User's shopping cart.