Skip to content

Commit

Permalink
artisan lmsqueezy:listen (#54)
Browse files Browse the repository at this point in the history
* Add lmsqueezy:listen command

* wip

* wip

* wip

* wip

---------

Co-authored-by: Dries Vints <dries@vints.be>
  • Loading branch information
DanielHudson and driesvints authored Dec 12, 2023
1 parent adcb473 commit d6fd098
Show file tree
Hide file tree
Showing 6 changed files with 425 additions and 3 deletions.
20 changes: 18 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -119,9 +119,25 @@ Lemon Squeezy uses its own JavaScript library to initiate its checkout widget. W

### Webhooks

Finally, make sure to set up incoming webhooks. This is both needed in development as in production. Go to [your Lemon Squeezy's webhook settings](https://app.lemonsqueezy.com/settings/webhooks) and point the url to your exposed local app. You can use [Ngrok](https://ngrok.com/), [Expose](https://github.com/beyondcode/expose) or another tool of your preference for this. Laravel also has solutions for sharing your site with [Valet](https://laravel.com/docs/valet#sharing-sites), [Sail](https://laravel.com/docs/10.x/sail#sharing-your-site) and [Herd](https://herd.laravel.com).
Finally, make sure to set up incoming webhooks. This is both needed in development as in production. The easiest way to set this up is with the `php artisan lmsqueezy:listen` command that ships with this package. This command will setup a webhook through the Lemon Squeezy API, start listening for any events and remove the webhook when quitting the command. Currently, this command supports [Ngrok](https://ngrok.com/) and [Expose](https://github.com/beyondcode/expose).

Make sure to select all event types. The path you should point to is `/lemon-squeezy/webhook` by default. **We also very much recommend to [verify webhook signatures](#verifying-webhook-signatures).**
```bash
php artisan lmsqueezy:listen
```

Although this command should always cleanup the webhook after itself, you may wish to cleanup any lingering webhooks with the `--cleanup` flag:

```bash
php artisan lmsqueezy:listen --cleanup
```

**We also very much recommend to [verify webhook signatures](#verifying-webhook-signatures) in production.**

#### Manual Webhooks Setup

Alternatively you may setup webhooks manually. Go to [your Lemon Squeezy's webhook settings](https://app.lemonsqueezy.com/settings/webhooks) and point the url to your exposed local app. You can use [Ngrok](https://ngrok.com/), [Expose](https://github.com/beyondcode/expose) or another tool of your preference for this. Laravel also has solutions for sharing your site with [Valet](https://laravel.com/docs/valet#sharing-sites), [Sail](https://laravel.com/docs/10.x/sail#sharing-your-site) and [Herd](https://herd.laravel.com).

Make sure to select all event types. The path you should point to is `/lemon-squeezy/webhook` by default.

#### Webhooks & CSRF Protection

Expand Down
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
"php": "~8.1.0|~8.2.0|~8.3.0",
"guzzlehttp/guzzle": "^7.0",
"laravel/framework": "^10.0",
"laravel/prompts": "^0.1",
"moneyphp/money": "^4.0",
"nesbot/carbon": "^2.0"
},
Expand Down
Loading

0 comments on commit d6fd098

Please sign in to comment.