#Ishan-transfers

1 messages · Page 1 of 1 (latest)

elder ruin
robust hearth
#

As you can see in the screenshot, I can see failed charges.

#

But here, I am unable to see failed transfers.

elder ruin
#

Does this mean that a failed transfer object is never created ?
yep

#

if the API call fails, no Transfer object is created

robust hearth
#

try {
Transfer.create();
} catch( StripeException se) {

} catch( Exception e) {

}

#

Will this exception handling be enough ?

#

I mean will this two catch blocks be enough ?

elder ruin
#

seems good to me as a starting point yep! It wouldn't miss anything at least

robust hearth
#

Ok. Thanks for your help. I am done.

#

Wait.

#

I have one more question.

#

I want to show the reason why the transfer failed.

#

Now, when I did a curl request, I got the message : 'Insufficient funds in Stripe account. In test mode, you can add funds to your available balance (bypassing your pending balance) by creating a charge with 4000 0000 0000 0077 as the card number. You can use the /v1/balance endpoint to view your Stripe balance (for more details, see stripe.com/docs/api#balance).'

#

So will 'se.getStripeError().getMessage()' will give me the same text message in catch block ?

#

I cannot show this entire message to a user. Just 'Insufficient funds in Stripe account' will be enough for us.

elder ruin
#

that error is intended for you as the developer , and you can check the balance before making the API call to avoid it

#

but in general you could check getCode() https://stripe.com/docs/error-codes and look for https://stripe.com/docs/error-codes#balance-insufficient and then show a more appropriate user-facing string if you wish

robust hearth
#

Will I get the same message text in live mode too ?

bright otter
#

@robust hearth Taking over – just catching up!

#

The message will be similar yes, but obviously minus the test mode specific message

robust hearth
#

Ok. I will handle this then. Thanks. I am done now.