fix(billing): Prevent stripe issue when settling bill using credits#5769
fix(billing): Prevent stripe issue when settling bill using credits#5769Bowrna wants to merge 3 commits intofrappe:developfrom
Conversation
Codecov Report❌ Patch coverage is
❌ 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
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
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 |
|
hi @dharunashokkumar the check is made on payment intent status and not on stripe invoice status. |
|
@Bowrna closing this as it is resolved |
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.