ankurk91/laravel-stripe-exceptions
最新稳定版本:3.18.0
Composer 安装命令:
composer require ankurk91/laravel-stripe-exceptions
包简介
Handle Stripe exceptions gracefully in Laravel php framework.
关键字:
README 文档
README
This package makes it easy to handle Stripe exceptions in Laravel
How do you handle Stripe errors? Are you repeating same code again and again?
Installation
You can install the package via composer:
composer require ankurk91/laravel-stripe-exceptions
Usage
Handle Stripe charge/transfer exceptions by wrapping the API calls in try/catch like:
<?php try { $response = \Stripe\Charge::create([ 'source' => request('source'), 'amount' => 1000, 'currency' => 'usd', ]); } catch (\Throwable $exception) { // send back an errored JSON response to browser throw new \Ankurk91\StripeExceptions\ApiException($exception); }
Handle Stripe connect exceptions:
<?php try { $response = \Stripe\OAuth::token([ 'grant_type' => 'authorization_code', 'code' => request('code') ]); } catch (\Throwable $exception) { // redirect with failed error message // `error` will be flashed in session to destination page throw new \Ankurk91\StripeExceptions\OAuthException($exception, route('stripe.failed')); }
Modifying error messages
You can publish the translation messages via this command
php artisan vendor:publish --provider="Ankurk91\StripeExceptions\StripeServiceProvider" --tag=translations
Features
- Takes advantage of Laravel's inbuilt Reportable & Renderable Exceptions.
- Reports all exceptions when
APP_DEBUGistrue - Prevents logging of exceptions caused by user input, for example
Invalid Card - Captures logged-in user information when an exception gets reported
Security
If you discover any security issues, please email pro.ankurk1[at]gmail[dot]com instead of using the issue tracker.
Changelog
Please see CHANGELOG for more information what has changed recently.
License
The MIT License.
统计信息
- 总下载量: 9.38k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 4
- 点击次数: 1
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2019-01-09