Creating Checkout Sessions
Last updated
Last updated
Creating a Checkout Session involves letting Stripe know what purchases the user is going to make (which we'll do via the plugin) and then navigating to a Stripe hosted checkout page.
You'll need to build a workflow with 4 actions to do this. I recommend attaching this workflow to a "Purchase" or "Checkout" button.
1. Create a new "Transaction" (or whatever data type you're using to record transactions in your database
You don't need to worry about making any changes to the transaction at this stage (we'll do that later)
2. Add the "Stripe - Create Checkout Session (Cart)" action to the workflow
This action can be bound under the "plugins" tab of the drop-down menu
You'll need to complete 8 fields:
Success URL: The URL the user is redirected to after successfully completing their purchase
Cancel URL: The URL the user is redirected to if they decide to cancel a payment
Price (Cents): A list of the price of EACH item in the shopping cart (see below for example)
Quantity: A list of the quantity of each item in the cart that the user wishes to purchase (see below for example)
Currency: The currency to be used in the Checkout Session. Must be a 3-digit ISO code (EG: "usd" or "eur") and must be a currency supported by Stripe - you can see a full list of supported currencies here: https://stripe.com/docs/currencies
Product Name: A list of the name of each item in the cart (see below for an example)
The next two fields are only necessary to fill out if the user of your app has the option to purchase SUBSCRIPTION items. If you are not selling any subscription items, these 2 fields can be left blank.
Subscription: A list of "Yes/No"'s, where "Yes" indicates that the product is a subsciption item and "No" indicates it's a one-off payment (see below for an example)
Frequency: A list of texts that indicates whether the subscription products are charged on a daily, weekly, monthly or yearly basis. Values have to be one of:
day
week
month
year
Example:
There is also an optional field called 'Customer ID'. If you've saved down an previous customer's Stripe Customer ID to your database, you can reference it in this field. This will mean the Customer won't have to put in their personal details again (address, card number etc.).
If you do not save down Stripe Customer ID's or prefer to have the customer re-enter their details on the Stripe Checkout Session page, you can leave this field blank.
3. Make changes to the transaction created in Step #1
Record the:
checkout sesssion id
total amount
customer
4. Navigate to the URL created in Step #2
This is what will actually take us to the Stripe hosted checkout page. Use the "Open an external website" action to go the URL we created in step #2.