Skip to content

Commit

Permalink
fix(invoice): Check payment intent instead of Invoice status
Browse files Browse the repository at this point in the history
* Also Typo
  • Loading branch information
shadrak98 authored Feb 2, 2025
1 parent 4d1d4bc commit 1d3b70f
Showing 1 changed file with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,9 @@ def handle_payment_succeeded(self):
# check if invoice is already refunded
stripe = get_stripe()
inv = stripe.Invoice.retrieve(invoice.stripe_invoice_id)

Check failure on line 60 in press/press/doctype/stripe_payment_event/stripe_payment_event.py

View workflow job for this annotation

GitHub Actions / Lint and Format

Ruff (F841)

press/press/doctype/stripe_payment_event/stripe_payment_event.py:60:4: F841 Local variable `inv` is assigned to but never used
if inv.status == "Refunded":
payment_intent = stripe.PaymentIntent.retrieve(invoice.payment_intent)
is_refunded = payment_intent["charges"]["data"][0]["refunded"]
if is_refunded:
return
# if the fc invoice is already paid via credits and the stripe payment succeeded
# issue a refund of the invoice payment
Expand Down Expand Up @@ -113,7 +115,7 @@ def handle_payment_failed(self):
# check if invoice is already voided
stripe = get_stripe()
inv = stripe.Invoice.retrieve(invoice.stripe_invoice_id)
if inv.status == "Void":
if inv.status == "void":
return
# if the fc invoice is already paid via credits and the stripe payment failed
# mark the stripe invoice as void
Expand Down

0 comments on commit 1d3b70f

Please sign in to comment.