#Bart
1 messages ยท Page 1 of 1 (latest)
Hello ๐
AFAIK If there aren't enough funds then a payout object won't be generated. So it doesn't having an ID is expected (I can double check)
but shouldnt status atleast be returned?
or just an error i can print out
because this is the whole erorr
how can i just output "balance insufficent
The returned data should be in JSON format
ah wait
are you using Stripe's server-side java library?
no the code above i sent in the first message is in Golang
gotcha. I'm not super familiar with golang as much so I'm not sure what kind of object we return as err.
Is the screenshot you've attached is what you see when you print err?
We have some examples here in how you can handle the error callback
https://stripe.com/docs/api/errors/handling?lang=go
if err != nil {
// Try to safely cast a generic error to a stripe.Error so that we can get at
// some additional Stripe-specific information about what went wrong.
if stripeErr, ok := err.(*stripe.Error); ok {
// The Code field will contain a basic identifier for the failure.
switch stripeErr.Code {
case stripe.ErrorCodeCardDeclined:
case stripe.ErrorCodeExpiredCard:
case stripe.ErrorCodeIncorrectCVC:
case stripe.ErrorCodeIncorrectZip:
// etc.
}
// The Err field can be coerced to a more specific error type with a type
// assertion. This technique can be used to get more specialized
// information for certain errors.
if cardErr, ok := stripeErr.Err.(*stripe.CardError); ok {
fmt.Printf("Card was declined with code: %v\n", cardErr.DeclineCode)
} else {
fmt.Printf("Other Stripe error occurred: %v\n", stripeErr.Error())
}
} else {
fmt.Printf("Other error occurred: %v\n", err.Error())
}
}```
I assume for the error you're getting it should be something like
stripe.ErrorCodeBalanceInsufficient or something
omg thank you ive been wondering how to check errors directly like that
im going to test it
works!
Ah nice, glad that worked ๐
how can i find a list of errors for specific api calls?
found this but how do i know which is for which
It would mostly be a really long switch case depending on what API endpoint you're going to be using ๐
We also have this
https://stripe.com/docs/error-codes