invalid_request_error mapped to CardException not InvalidRequestException
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 25/100
Research direction
Start in src/main/java/com/stripe/net/LiveStripeResponseGetter.java at handleApiError and inspect the status-402 mapping and nearby exception handling. Confirm that a 402 response whose body type is invalid_request_error is translated to InvalidRequestException rather than CardException, and update or add the relevant error-handling test if one exists.
Written by the indexing model from the issue text.
Description
Describe the bug
handleApiError maps all 402 status code responses to CardException. We have received responses that in the Stripe dashboard are "type": "invalid_request_error", but result in a CardException. (The CardException has a null code which causes us problems.) An example of the Response body is shown further below.
I have been in touch with Stripe support who say "our error documentation doesn't map status codes to specific error types, so the invalid_request_error may not always go hand in hand with the 404 status code.". So I think handleApiError needs to allow for invalid_request_error type in the case 402: branch.
Example of Response body for invalid_request_error type which results in CardException:
Response body
{
"error": {
"message": "The payment is blocked because the used IBAN has been suspended. You can learn more about this at https://support.stripe.com/questions/sepa-debit-chargebacks-faq and if you need assistance processing a payment please contact us via https://support.stripe.com/contact/ for further information.",
"type": "invalid_request_error"
}
}
To Reproduce
Using the Charges API create a Charge with an underlying payment source where the associated IBAN has been disputed 3 times in row. Such that Stripe block the Charge and return an invalid_request_error response. See https://support.stripe.com/questions/sepa-debit-chargebacks-faq
Expected behavior
Expected the Stripe Java SDK to translate the invalid_request_error with HTTP status code 402 into an InvalidRequestException.
Actual behavior: CardException where only the message property is populated, notably not the code.
Code snippets
No response
OS
macOS
Java version
Java 11
stripe-java version
20.121.0
API version
2020-08-27
Additional context
At https://support.stripe.com/questions/sepa-debit-chargebacks-faq Stripe note this is new behavior since 2022-03-07. This is exactly consistent with when we started seeing this issue.
- Dominant language
- Java
- Stars
- 1k
- Forks
- 406
- Avg merge
- 2d 18h
- Merged PRs (30d)
- 20
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from stripe/stripe-java
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
stripe/stripe-java#2280 · 3 comments ·
-
feature-request future
Difficulty 4/5 3-5 days Newbie friendliness 42/100
stripe/stripe-java#2024 · 5 comments · 3 reactions ·
-
feature-request future
Difficulty 3/5 1-2 days Newbie friendliness 45/100
stripe/stripe-java#2012 · 5 comments ·
-
feature-request future
Difficulty 5/5 Over a week Newbie friendliness 25/100
stripe/stripe-java#1964 · 1 comment ·
-
feature-request future
Difficulty 5/5 Over a week Newbie friendliness 35/100
stripe/stripe-java#1905 · 7 comments · 7 reactions ·
All issues in stripe/stripe-java
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
-
bug needs triage
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
-
Difficulty 1/5 Under an hour Newbie friendliness 94/100
objectionary/hone-maven-plugin#1061 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
spring-projects/spring-modulith#1895 ·