Skip to content

fix(billing): Prevent stripe issue when settling bill using credits#5769

Closed
Bowrna wants to merge 3 commits intofrappe:developfrom
Bowrna:billing_fix_void_stripe_id
Closed

fix(billing): Prevent stripe issue when settling bill using credits#5769
Bowrna wants to merge 3 commits intofrappe:developfrom
Bowrna:billing_fix_void_stripe_id

Conversation

@Bowrna
Copy link
Copy Markdown
Contributor

@Bowrna Bowrna commented Mar 18, 2026

When finalizing invoice using prepaid credits, we are running stripe related checks as the first try of settlement of invoice is made via Card. User face following issue as the invoice is not in correct state to move to void state. Added a check that will fix this issue.

File "apps/frappe/frappe/utils/typing_validations.py", line 32, in wrapper
return func(*args, **kwargs)
File "apps/press/press/press/doctype/invoice/invoice.py", line 1065, in change_stripe_invoice_status
stripe.Invoice.void_invoice(self.stripe_invoice_id)
File "env/lib/python3.10/site-packages/stripe/util.py", line 237, in _wrapper
return class_method(*args, **kwargs)
File "env/lib/python3.10/site-packages/stripe/api_resources/abstract/custom_method.py", line 23, in custom_method_request
return cls.static_request(http_verb, url, **params)
File "env/lib/python3.10/site-packages/stripe/api_resources/abstract/api_resource.py", line 64, in static_request
response, api_key = requestor.request(method
, url
, params, headers)
File "env/lib/python3.10/site-packages/stripe/api_requestor.py", line 122, in request
resp = self.interpret_response(rbody, rcode, rheaders)
File "env/lib/python3.10/site-packages/stripe/api_requestor.py", line 373, in interpret_response
self.handle_error_response(rbody, rcode, resp.data, rheaders)
File "env/lib/python3.10/site-packages/stripe/api_requestor.py", line 152, in handle_error_response
raise err
stripe.error.InvalidRequestError: Request: You can only pass in open invoices. This invoice isn't open.

@Bowrna Bowrna requested a review from shadrak98 as a code owner March 18, 2026 06:18
@codecov
Copy link
Copy Markdown

codecov Bot commented Mar 18, 2026

Codecov Report

❌ Patch coverage is 4.00000% with 24 lines in your changes missing coverage. Please review.
✅ Project coverage is 51.05%. Comparing base (869d3b5) to head (17b200b).
⚠️ Report is 5057 commits behind head on develop.

Files with missing lines Patch % Lines
press/press/doctype/invoice/invoice.py 4.00% 24 Missing ⚠️

❌ Your patch status has failed because the patch coverage (4.00%) is below the target coverage (75.00%). You can increase the patch coverage or adjust the target coverage.

Additional details and impacted files
@@             Coverage Diff              @@
##           develop    #5769       +/-   ##
============================================
- Coverage    73.03%   51.05%   -21.98%     
============================================
  Files          106      869      +763     
  Lines        17031    71837    +54806     
  Branches       272      272               
============================================
+ Hits         12438    36679    +24241     
- Misses        4571    35136    +30565     
  Partials        22       22               
Flag Coverage Δ
dashboard 73.03% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@dharunashokkumar
Copy link
Copy Markdown

one question..... what happens if the Stripe invoice status is something other than "open" and also not "processing"? e.g "paid", "uncollectible", "draft " should there be a log or comment added in that case so it doesn't silently skip the void? Right now it looks like the code would just fall through without any trace

@Bowrna
Copy link
Copy Markdown
Contributor Author

Bowrna commented Mar 30, 2026

hi @dharunashokkumar the check is made on payment intent status and not on stripe invoice status.

@shadrak98 shadrak98 closed this Apr 20, 2026
@shadrak98
Copy link
Copy Markdown
Contributor

@Bowrna closing this as it is resolved

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants