cartalyst / stripe-laravel

Cartalyst Stripe package integration for Laravel.
BSD 3-Clause "New" or "Revised" License
335 stars 57 forks source link

Get Stripe decline codes #34

Closed ibarral closed 6 years ago

ibarral commented 6 years ago

Hello,

If a card issuer declines a payment, Stripe provides some decline codes:

https://stripe.com/docs/declines/codes

Is there any way to get that codes?

Thanks!

brunogaspar commented 6 years ago

Hello,

If you've meant to say if that's possible to retrieve the code like card_declined, then yes, that's possible.

Example:

try {
    $charge = Stripe::charges()->create([
        'currency' => 'USD',
        'amount'   => 123,45,
        'card'     => 'some-token',
    ]);
} catch (\Exception $e) {
   $errorCode = $e->getErrorCode();
}

If that's not what you're looking for, please elaborate a bit better.

Hope it helps!