{"id":17133227,"url":"https://github.com/cronick/stripe-php-webhook","last_synced_at":"2025-09-04T09:37:23.614Z","repository":{"id":166147306,"uuid":"140199434","full_name":"Cronick/Stripe-PHP-WebHook","owner":"Cronick","description":":credit_card: Respond to Stripe WebHooks like jQuery events - Simple and elegant.","archived":false,"fork":false,"pushed_at":"2018-07-08T20:14:55.000Z","size":4,"stargazers_count":2,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-08-31T18:49:13.719Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Cronick.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2018-07-08T20:14:15.000Z","updated_at":"2019-12-07T00:22:12.000Z","dependencies_parsed_at":null,"dependency_job_id":"e417c896-fc3b-4402-a9b1-020e2ff2fc21","html_url":"https://github.com/Cronick/Stripe-PHP-WebHook","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/Cronick/Stripe-PHP-WebHook","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Cronick%2FStripe-PHP-WebHook","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Cronick%2FStripe-PHP-WebHook/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Cronick%2FStripe-PHP-WebHook/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Cronick%2FStripe-PHP-WebHook/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Cronick","download_url":"https://codeload.github.com/Cronick/Stripe-PHP-WebHook/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Cronick%2FStripe-PHP-WebHook/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":273585516,"owners_count":25132365,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-09-04T02:00:08.968Z","response_time":61,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-14T19:29:35.899Z","updated_at":"2025-09-04T09:37:23.590Z","avatar_url":"https://github.com/Cronick.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Stripe PHP Webhook\n\nRespond to [Stripe](https://stripe.com) webhooks like jQuery events — simple and elegant.\n\n## Usage\n\nEvent handlers can be added in jQuery style using `S::on()`:\n\n```php\nS::on('charge.succeeded', function($charge, $event) {\n\t/* … */\n});\n```\n\nUse `S::onSecure()` if you'd like to have the event data retrieved from Stripe:\n\n```php\nS::onSecure('charge.succeeded', function($charge, $event) {\n\t/* Now $charge and $event are retrieved from Stripe */\n});\n```\n\nOne handler can respond to multiple event types (both methods are equivalent):\n\n```php\nS::on('charge.succeeded charge.failed', function($charge, $event) {\n\t/* … */\n});\n\nS::on(['charge.succeeded', 'charge.failed'], function($charge, $event) {\n\t/* … */\n});\n```\n\n## Examples\n\nHere are two examples from [handlers.php](handlers.php):\n\n```php\n// This handler sends a \"Thank you\" message when a charge was successful.\nS::on('charge.succeeded', function($charge) {\n\t$customer = \\Stripe\\Customer::retrieve($charge-\u003ecustomer);\n\tmail($customer-\u003eemail, 'Thanks you', 'Thanks for your payment! \u003c3');\n});\n\n// This handler sends an angry message when a customer disputes a charge.\n// (You should probably not use this in production.)\nS::onSecure('charge.dispute.created charge.dispute.updated', function($dispute) {\n\t$charge = \\Stripe\\Charge::retrieve($dispute-\u003echarge);\n\t$customer = \\Stripe\\Customer::retrieve($charge-\u003ecustomer);\n\tmail($customer-\u003eemail, '#@%\u0026@', 'WHY U DISPUTE?', $photo_of_dead_horse_head);\n});\n```\n\n## Installation\n\n1. Add (the code from) this repository to your project.\n2. Adjust the path to [stripe-php](https://github.com/stripe/stripe-php) and your Stripe API key in [webhook.php](webhook.php).\n3. Create some event handlers and make sure they get loaded by [webhook.php](webhook.php).\n4. Make [webhook.php](webhook.php) publicly accessible and add it's URL to your [Stripe webhooks](https://manage.stripe.com/account/webhooks).\n\n## Handler Closure Format\n\nHandlers are implemented using [PHP closures](http://www.php.net/manual/en/functions.anonymous.php). When your handler is executed, it receives two arguments:\n\n1. The object as defined by `$event-\u003edata-\u003eobject`; and\n2. The event itself.\n\nFor a handler `function ($object, $event)`, `$object === $event-\u003edata-\u003eobject` by definition.\n\nHandler closures are not required to expect two arguments; it's fine if your handler expects one argument, like `function ($object)`, or no argument at all, like `function ()`.\n\nThe return value of your handler closures is not considered currently. This might change in future versions.\n\n## Compatibility\n\nThis code has been tested with [stripe-php v3.17.0](https://github.com/stripe/stripe-php/tree/v3.17.0) and PHP 7. In theory, it should work with PHP 5.4 and newer.\n\n## License\n\nThis code is licensed under MIT license. See [LICENSE](LICENSE) for details.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcronick%2Fstripe-php-webhook","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcronick%2Fstripe-php-webhook","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcronick%2Fstripe-php-webhook/lists"}