Skip to content

Commit

Permalink
demo defaults to demo data
Browse files Browse the repository at this point in the history
  • Loading branch information
Chris Nelson committed Oct 31, 2023
1 parent 3e6358a commit 53b3083
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 10 deletions.
5 changes: 3 additions & 2 deletions .env
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
STRIPE_API_KEY=sk_test_51MVJusCOWcOFl6axNzJX24q3IQFfkjeKvOeiTPWVchDEPa2bkPtkvsCj5s3sDoEoAi7SdgmfkKe5EGEa48ZBiXxo00NbUKRiaZ
STORE_ID=1c036c12-6e39-4352-89e5-dfc34d584538
STORE_ID=ef41a1d1-f527-47f9-815d-ca43b075ef1b
STORE_URL=wss://launch-cart-dev.fly.dev/socket
STRIPE_API_KEY=demo
25 changes: 23 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,24 @@
# launch-cart Demo Store
# Launch Elements Demo Store

This is the demo store for [Launch Elements](https://elements.launchscout.com)

# Running with example data

To run the demo store with example data from a test store and test stripe account:

```
npm install
npm start
```

# Using your own Stripe Account

1. Sign up for an account at `elements.launchscout.com`
2. Connect your stripe account
3. Create a store
4. Copy the values from your store into .env
5. `npm start`

This will create product pages for each product it finds in your Stripe Account. If you don't have any products, you won't see anything :)


This is the demo store for [launch-cart](https://launch-cart.fly.dev)
7 changes: 7 additions & 0 deletions src/_data/demoPrices.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 11 additions & 5 deletions src/_data/prices.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,21 @@
const environment = process.env.CONTEXT
const api_key = process.env.STRIPE_API_KEY;
const stripe = require("stripe")(api_key);
const demoPrices = require('./demoPrices.js').prices;

// One product can have multiple prices but for my use case, it's 1:1 so this works without having to massage the data
// TODO: add Expanding data docs link
async function getPrices() {
console.log('calling prices');
const response = await stripe.prices.list({
expand: ["data.product"],
});
return response.data.filter(price => price.active);
if (api_key === 'demo') {
return demoPrices;
} else {
console.log('calling prices');
const response = await stripe.prices.list({
expand: ["data.product"],
});
const prices = response.data.filter(price => price.active);
return prices;
}
}

module.exports = async function () {
Expand Down
2 changes: 1 addition & 1 deletion src/_includes/layout.njk
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<title>Launch Scout Store</title>
<meta name="description" content="A demo store for launch-cart">
<meta property="og:description" content="A demo store for launch-cart" />

<script type="module" src="https://cdn.jsdelivr.net/npm/launch-elements"></script>
<link rel="preconnect dns-prefetch" href="https://www.google-analytics.com">

<link rel="stylesheet" href="/css/index.css">
Expand Down

0 comments on commit 53b3083

Please sign in to comment.