10000 Stripe key from env instead hardcoded · cba85/laravel8-saas@e98f5b5 · GitHub
[go: up one dir, main page]

Skip to content
This repository was archived by the owner on Jul 6, 2023. It is now read-only.

Commit e98f5b5

Browse files
committed
Stripe key from env instead hardcoded
1 parent 6fca1ac commit e98f5b5

File tree

3 files changed

+25
-3
lines changed

3 files changed

+25
-3
lines changed

README.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,24 @@
22

33
🚧 Work in progress
44

5+
## Install
6+
7+
```bash
8+
$ composer install
9+
$ cp .env.example .env
10+
$ php artisan key:generate
11+
```
12+
13+
Add your database and Stripe credentials inside the `.env` file.
14+
15+
```bash
16+
$ php artisan migrate
17+
```
18+
19+
Manually add your Stripe products in `plans` table, including Stripe Id.
20+
21+
## Usage
22+
23+
```bash
24+
$ php artisan serve
25+
```

app/Http/Controllers/CheckoutController.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,9 @@ public function index(Request $request)
1111
{
1212
$plans = Plan::get();
1313
$intent = $request->user()->createSetupIntent();
14+
$stripeKey = env('STRIPE_KEY');
1415

15-
return view('checkout', compact('plans', 'intent'));
16+
return view('checkout', compact('plans', 'intent', 'stripeKey'));
1617
}
1718

1819
public function store(Request $request)

resources/views/checkout.blade.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131

3232
<div id="card-element" class="mt-4"></div>
3333

34-
<div style="color: red;" id="card-errors" role="alert" class="mb-4"></div>
34+
<div class="text-danger" id="card-errors" role="alert" class="mb-4"></div>
3535

3636
<button type="submit" class="btn btn-primary" id="card-button" data-secret="{{ $intent->client_secret }}">Payer maintenant</button>
3737
</form>
@@ -40,7 +40,7 @@
4040
</div>
4141

4242
<script>
43-
const stripe = Stripe('pk_test_51INyfxC92VjAODHf5GD7HzZFPVApkkrdtW0XlrIsUjqzt84crKX1LNBlw8STsj1oUEAycjqpdNNIwRPMWbm4qFLZ00v00Lw1qD');
43+
const stripe = Stripe('{{ $stripeKey }}');
4444
const elements = stripe.elements();
4545
4646
const card = elements.create("card");

0 commit comments

Comments
 (0)
0