Skip to content

Commit

Permalink
Merge pull request #123 from effective-altruism-australia/master
Browse files Browse the repository at this point in the history
Fix bug "You can not pass `submit_type` in `subscription` mode" when …
  • Loading branch information
nathansherburn authored Jul 30, 2024
2 parents 3847ef5 + 70fd548 commit 1e049bf
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 1e049bf

Please sign in to comment.