Skip to content

Commit 66e5c43

Browse files
committed
fixes: payment via stripe-api doesn't work
1 parent 76d1f60 commit 66e5c43

File tree

4 files changed

+9
-6
lines changed

4 files changed

+9
-6
lines changed

.env

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,6 @@ DB_USER=your-db-user-name
55
DB_PASSWORD=your-db-password
66
DB_HOST=localhost
77
STRIPE_LIVE_PUBLIC_KEY=your-live-public-key
8-
STRIPE_LIVE_SECRET_KEY=your-live-secret-key
8+
STRIPE_LIVE_SECRET_KEY=your-live-secret-key
9+
STRIPE_TEST_PUBLIC_KEY=your-test-public-key
10+
STRIPE_TEST_SECRET_KEY=your-test-secret-key

core/views.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,8 @@ def get(self, *args, **kwargs):
211211
if order.billing_address:
212212
context = {
213213
'order': order,
214-
'DISPLAY_COUPON_FORM': False
214+
'DISPLAY_COUPON_FORM': False,
215+
'STRIPE_PUBLIC_KEY' : settings.STRIPE_PUBLIC_KEY
215216
}
216217
userprofile = self.request.user.userprofile
217218
if userprofile.one_click_purchasing:

djecommerce/settings/development.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,5 +43,5 @@ def show_toolbar(request):
4343
}
4444
}
4545

46-
STRIPE_PUBLIC_KEY = ''
47-
STRIPE_SECRET_KEY = ''
46+
STRIPE_PUBLIC_KEY = config('STRIPE_TEST_PUBLIC_KEY')
47+
STRIPE_SECRET_KEY = config('STRIPE_TEST_SECRET_KEY')

templates/payment.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,6 @@ <h2 class="my-5 h2 text-center">Payment</h2>
111111
<div class="col-md-12 mb-4">
112112
<div class="card">
113113

114-
<script src="https://js.stripe.com/v3/"></script>
115114
{% if card %}
116115
<div style="padding: 5px 30px;">
117116
<div class="custom-control custom-checkbox">
@@ -170,8 +169,9 @@ <h2 class="my-5 h2 text-center">Payment</h2>
170169

171170
{% block extra_scripts %}
172171

172+
<script src="https://js.stripe.com/v3/"></script>
173173
<script nonce=""> // Create a Stripe client.
174-
var stripe = Stripe('');
174+
var stripe = Stripe('{{STRIPE_PUBLIC_KEY}}');
175175

176176
// Create an instance of Elements.
177177
var elements = stripe.elements();

0 commit comments

Comments
 (0)