定制 teamtnt/php-stripe-webhook-tester 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

teamtnt/php-stripe-webhook-tester

最新稳定版本:v1.3.0

Composer 安装命令:

composer require teamtnt/php-stripe-webhook-tester

包简介

A PHP package for testing Stripe Webhooks localy

README 文档

README

Latest Version Software License Build Status Quality Score Total Downloads

The goal of this package is to make testing stripe webhooks easy on a local machine without the use of ngrok or other similar tunneling services. The package will simulate a post request to a specified endpoint with a json containing event data and make sure that your application reacts accordingly.

Install

Via Composer

$ composer require TeamTNT/php-stripe-webhook-tester

Usage

$tester = new TeamTNT\Stripe\WebhookTester();
$tester->setVersion('2018-05-21');
$tester->setEndpoint('http://local.dev/stripe/webhooks');

$response = $tester->triggerEvent('charge.succeeded');

For your convenience you can use chained methods

$tester = new TeamTNT\Stripe\WebhookTester('http://local.dev/stripe/webhooks);
$response = $tester->setVersion('2014-09-08')->triggerEvent('charge.succeeded');

Laravel Integration

To implement this package with Laravel Cashier, you will need to override the eventExistsOnStripe() method in Laravel\Cashier\WebhookController with something like this:

protected function eventExistsOnStripe($id)
{
    if(App::environment() == 'testing' or App::environment() == 'local') {
        return true;
    }
    try {
        return ! is_null(StripeEvent::retrieve($id, Config::get('services.stripe.secret')));
    } catch (Exception $e) {
        return false;
    }
}

Without the environment checks Cashier attempts to verify that the dummy event is a valid webhook with Stripe, which will obviously fail.

Available versions and events

Available versions and events can be found in the webhooks directory

Testing

$ phpunit

Contributing

Please see CONTRIBUTING for details.

Credits

License

The MIT License (MIT). Please see License File for more information.

统计信息

  • 总下载量: 80.31k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 100
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 100
  • Watchers: 3
  • Forks: 25
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2015-03-27

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固