Skip to content

Commit

Permalink
Add config options to stripe checkout process
Browse files Browse the repository at this point in the history
  • Loading branch information
smathot committed Feb 11, 2024
1 parent 54134d5 commit 3919d23
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
4 changes: 4 additions & 0 deletions heymans/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,3 +191,7 @@ def validate_user(username, password):
# The webhook secret is used to ensure that webhook calls actually come from
# stripe
stripe_webhook_secret = os.environ.get('STRIPE_WEBHOOK_SECRET', None)
# Additional keywords passed to stripe.checkout.Session.create to customize
# the checkout process
stripe_checkout_keywords = dict(allow_promotion_codes=True,
payment_method_types=['card', 'paypal'])
3 changes: 1 addition & 2 deletions heymans/routes/subscribe.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,9 @@ def create_checkout_session():
success_url=f'{config.server_url}/subscribe/success/{{CHECKOUT_SESSION_ID}}',
cancel_url=f'{config.server_url}/',
client_reference_id=heymans.user_id,
allow_promotion_codes=True,
mode='subscription',
line_items=[{'price': config.stripe_price_id, 'quantity': 1}],
)
**config.stripe_checkout_keywords)
return redirect(checkout_session.url, code=303)
except Exception as e:
return jsonify({'error': {'message': str(e)}}), 400
Expand Down

0 comments on commit 3919d23

Please sign in to comment.