Skip to content

Commit 94e2e70

Browse files
committed
chore: add Stripe docs
1 parent 459c783 commit 94e2e70

File tree

3 files changed

+56
-6
lines changed

3 files changed

+56
-6
lines changed

README.md

+12
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,10 @@ cp .env.example .env
8282
> JWT_SECRET=
8383
> GEMINI_API_KEY=
8484
> UNSPLASH_API_KEY=
85+
> STRIPE_SECRET_KEY=
86+
> WEBSITE_URL=https://opensass.org
87+
> STRIPE_PRICE_ONE=price_1...
88+
> STRIPE_PRICE_TWO=price_1...
8589
> ```
8690
>
8791
> If you're missing any of these keys, check the service's developer portal to generate them.
@@ -108,6 +112,10 @@ To obtain your API key, navigate to [Google AI Studio](https://aistudio.google.c
108112

109113
AIBook uses Unsplash which provides a powerful API to search for and retrieve high-quality images. To communicate with this api you will need a [Secret key](https://unsplash.com/oauth/applications). If you don't already have one, sign up for a free account at Unsplash, create a new app, and copy the Secret key at the bottom of the page after creating the app.
110114

115+
### 💳 Stripe API
116+
117+
Follow [our quick guide](./Stripe.md) to set up your stripe account and connect it to your project!
118+
111119
### 🚀 Building and Running
112120

113121
- Run the client:
@@ -129,6 +137,10 @@ Happy compiling! 😄
129137

130138
![Gemini Models](https://github.com/user-attachments/assets/58f531d0-c352-40eb-8bb2-aed7359fccbc)
131139

140+
- Stripe support.
141+
142+
![Stripe Demo](https://github.com/user-attachments/assets/2bbeacb0-ad01-4477-96b6-3e3d7f8c4bed)
143+
132144
- Built-in Dark and Light themes.
133145

134146
![Light Dark Themes](https://github.com/user-attachments/assets/71820497-efcc-4227-a906-e97cdf9aa45b)

Stripe.md

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# Set Up Stripe Env Vars
2+
3+
1. **Create Products and Pricing in Stripe**
4+
- Go to the [Stripe Dashboard](https://dashboard.stripe.com/).
5+
- **Create a Product**:
6+
- Navigate to **Products > Add Product**.
7+
8+
![add product](https://github.com/user-attachments/assets/46a2ca96-4769-48a4-b7a4-5188e030e9e5)
9+
10+
- Enter product details (e.g., "Monthly Plan", "Yearly Plan").
11+
12+
![Monthly Plan](https://github.com/user-attachments/assets/3fba067e-143c-455c-9d44-96b042a3560f)
13+
![Yearly Plan](https://github.com/user-attachments/assets/eac0da1e-a14b-4f36-98f2-c4107f4cfc53)
14+
15+
1. **Retrieve Your Product Price IDs**
16+
- After creating products, note the **Price IDs** (e.g., `price_1...`) from the pricing section.
17+
- **STRIPE_PRICE_ONE** = `price_1AbCDeFgHiJkLmNOpQrStUv` (Monthly Plan).
18+
- **STRIPE_PRICE_TWO** = `price_1XyZaBcDeFgHiJkLmNoQrStUv` (Yearly Plan).
19+
20+
![price id](https://github.com/user-attachments/assets/4ac40893-40d3-4cb4-83a6-45dd6e130a4a)
21+
![price id](https://github.com/user-attachments/assets/709ea1f6-5543-428d-ad9a-d4164d4f0762)
22+
![price id](https://github.com/user-attachments/assets/fe5d558d-79cc-48cd-9d52-7de8e48bfe35)
23+
![price id](https://github.com/user-attachments/assets/9a6f7cfa-e609-460e-9501-043d1c8b2880)
24+
25+
1. **Set the Environment Variables**
26+
Add the following to your `.env` file:
27+
```env
28+
STRIPE_SECRET_KEY=sk_test_4eC39HqLyjWDarjtT1zdp7dc
29+
WEBSITE_URL=http://0.0.0.0:3000
30+
STRIPE_PRICE_ONE=price_1AbCDeFgHiJkLmNOpQrStUv
31+
STRIPE_PRICE_TWO=price_1XyZaBcDeFgHiJkLmNoQrStUv
32+
```
33+
34+
1. **Set the hard coded price values**
35+
Set the following price values:
36+
37+
Your environment variables are set and ready for Stripe integration.

src/components/pricing.rs

+7-6
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ use dioxus::prelude::*;
99
use dioxus_logger::tracing;
1010
use gloo_storage::SessionStorage;
1111
use gloo_storage::Storage;
12-
use std::env;
1312

1413
#[derive(Props, Clone, PartialEq)]
1514
struct PricingOption {
@@ -18,7 +17,7 @@ struct PricingOption {
1817
description: &'static str,
1918
features: Vec<&'static str>,
2019
highlight: bool,
21-
plan_id: Option<String>,
20+
plan_id: Option<&'static str>,
2221
}
2322

2423
#[component]
@@ -51,7 +50,8 @@ pub fn Pricing() -> Element {
5150
"Priority customer support",
5251
],
5352
highlight: true,
54-
plan_id: Some(env::var("STRIPE_PRICE_ONE").expect("STRIPE_PRICE_ONE must be set.")),
53+
// TODO: Change to env var
54+
plan_id: Some("price_1QO1"),
5555
},
5656
PricingOption {
5757
title: "Yearly",
@@ -66,10 +66,11 @@ pub fn Pricing() -> Element {
6666
"Priority support",
6767
],
6868
highlight: false,
69-
plan_id: Some(env::var("STRIPE_PRICE_TWO").expect("STRIPE_PRICE_TWO must be set.")),
69+
// TODO: Change to env var
70+
plan_id: Some("price_1QO1"),
7071
},
7172
];
72-
let handle_plan_selection = move |plan: (Option<String>, &'static str)| {
73+
let handle_plan_selection = move |plan: (Option<&'static str>, &'static str)| {
7374
if let Some(plan_id) = plan.0 {
7475
spawn({
7576
let plan_title = plan.1.to_string();
@@ -156,7 +157,7 @@ pub fn Pricing() -> Element {
156157
if option.highlight { "bg-blue-500 text-white hover:bg-blue-600" } else { "bg-gray-300 text-gray-700 hover:bg-gray-400" }),
157158
onclick: move |e: Event<MouseData>| {
158159
e.stop_propagation();
159-
handle_plan_selection((option.plan_id.clone(), option.title));
160+
handle_plan_selection((option.plan_id, option.title));
160161
},
161162
"Select Plan"
162163
}

0 commit comments

Comments
 (0)