Skip to content

Commit

Permalink
Use new failed_payment table structure
Browse files Browse the repository at this point in the history
  • Loading branch information
SamWinterhalder committed Mar 28, 2021
1 parent 2c45a15 commit d1b720d
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion memberships/payments.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def handle_stripe_payment(event):
return session_completed(event)
if event["type"] == "invoice.payment_failed":
FailedPayment.objects.create(
stripe_customer_id=event["data"]["object"]["customer"],
member=Member.objects.get(stripe_customer_id=event["data"]["object"]["customer"]),
stripe_subscription_id=event["data"]["object"]["subscription"],
stripe_event_type=event["type"],
)
Expand Down
3 changes: 2 additions & 1 deletion memberships/tests/test_stripe_webhooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@ def test_a_membership_is_created_for_the_member_in_the_database(self):
self.assertEqual(1, memberships.count())

def test_a_failed_payment_for_membership_gets_logged_to_db(self):
self.member.stripe_customer_id = "cus_12345"
self.member.save()
response = self.client.post(
reverse("stripe_webhook"),
{
Expand Down Expand Up @@ -147,7 +149,6 @@ def test_existing_membership_renewal_date_updated_upon_payment(self):
)
self.member.renewal_date = make_aware(datetime(2020, 1, 1, 12, 55, 59, 123456))
self.member.save()
Member.objects.get
response = self.client.post(
reverse("stripe_webhook"),
{
Expand Down

0 comments on commit d1b720d

Please sign in to comment.