Skip to content

Commit

Permalink
Fix bug "You can not pass submit_type in subscription mode" when …
Browse files Browse the repository at this point in the history
…creating stripe sessions
  • Loading branch information
nathansherburn committed Jul 30, 2024
1 parent 6ced2e1 commit 70fd548
Showing 1 changed file with 17 additions and 8 deletions.
25 changes: 17 additions & 8 deletions donation/views/pledge.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,14 +165,23 @@ def post(self, request):


stripe.api_key = settings.STRIPE_API_KEY_DICT.get("eaae" if pledge.is_eaae else "eaa")
session = stripe.checkout.Session.create(
payment_method_types=['card'],
line_items=line_items,
submit_type="donate",
mode='subscription' if pledge.recurring_frequency == RecurringFrequency.MONTHLY else 'payment',
success_url='https://effectivealtruism.org.au/donate/?thankyou',
cancel_url='https://effectivealtruism.org.au/donate/',
)
if (pledge.recurring_frequency == RecurringFrequency.MONTHLY):
session = stripe.checkout.Session.create(
payment_method_types=['card'],
line_items=line_items,
mode='subscription',
success_url='https://effectivealtruism.org.au/donate/?thankyou',
cancel_url='https://effectivealtruism.org.au/donate/',
)
else:
session = stripe.checkout.Session.create(
payment_method_types=['card'],
line_items=line_items,
submit_type="donate",
mode='payment',
success_url='https://effectivealtruism.org.au/donate/?thankyou',
cancel_url='https://effectivealtruism.org.au/donate/',
)
print(session.__dict__)
pledge.stripe_checkout_id = session.id
pledge.save()
Expand Down

0 comments on commit 70fd548

Please sign in to comment.