Download the PHP package petzsch/laravel-btcpay without Composer
On this page you can find all versions of the php package petzsch/laravel-btcpay. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download petzsch/laravel-btcpay
More information about petzsch/laravel-btcpay
Files in petzsch/laravel-btcpay
Package laravel-btcpay
Short Description BtcPay wrapper for laravel
License MIT
Homepage https://github.com/petzsch/laravel-btcpay
Informations about the package laravel-btcpay
This project is not maintained anymore. And therefore was archived.
LaravelBtcPay
LaravelBtcPay enables you and your business to transact in Bitcoin, Litecoin and 10+ other BtcPay-supported cryptocurrencies within your Laravel application.
Requires PHP ^7.3
Supported Resources
- :white_check_mark: Invoices
Contents
- Installation
- Install Package
- Publish config file
- Add configuration values
- Configure Webhooks (Optional)
- 1. Setup your webhook route
- 2. Setup your webhook listener
- Examples
- Invoices
- Create an invoice
- Retrieve an existing invoice
- Retrieve a list of existing invoices
- Invoices
- Testing
- Changelog
- Contributing
- Security
- Credits
- License
Installation
Install package
You can install the package via composer:
Publish config file
Publish config file with:
This will create a laravel-btcpay.php
file inside your config directory.
Add configuration values
Add the following keys to your .env
file and update the values to match your
preferences (read more about configuration):
Configure Webhooks (Optional)
BtcPay resource status updates are completely based on webhooks (IPNs). LaravelBtcPay is fully capable of automatically
handling webhook requests. Whenever a webhook is received from BtcPay's server, BtcpayWebhookReceived
event is
dispatched. Take the following steps to configure your application for webhook listening:
1. Setup your webhook route
Resolve the btcPayWebhook
route macro in your desired route file (web.php
is recommended). The macro accepts a
single, optional argument, which is the URI path at which you want to receive BtcPay webhook POST
requests. If none is
provided, it defaults to 'laravel-btcpay/webhook'
:
:information_source: To retrieve your newly created webhook route anywhere in your application, use:
route('laravel-btcpay.webhook.capture')
LaravelBtcPay also offers the convenience of auto-populating your configured webhook url on applicable resources. Specifically when:
- Creating an Invoice
You may enable this feature per-resource by uncommenting the respective entry within the auto_populate_webhook
array
found in the laravel-btcpay.php
config file.
:warning: If a value is manually set, most likely via $resource->setNotificationURL('https://...')
during resource
initialization, auto-population is overridden.
2. Setup your webhook listener
Start by generating an event listener:
Then, implement your application-specific logic in the handle(...)
function of the generated listener.
In the following example, we assume you have previously created an invoice, storing its token
on your internal Order
model:
Finally, map your listener to the BtcpayWebhookReceived
event inside the $listen
array of
your EventServiceProvider
:
Examples
Invoices
Invoices are time-sensitive payment requests addressed to specific buyers. An invoice has a fixed price, typically denominated in fiat currency. It also has an equivalent price in the supported cryptocurrencies, calculated by BtcPay, at a locked exchange rate with an expiration time of 15(or whatever you configured) minutes.
Create an invoice
In this example we assume you've already created an instance of your equivalent Order
model, to be associated with
this Invoice (referred to as $order
):
TODO: Check if all of this works with the invoice object exposed by greenfield!!!
:information_source: It is highly recommended you store the Invoice ID and Token on your internal model(s). The token can come in handy when verifying webhooks.
Retrieve an existing invoice
Retrieve a list of existing invoices
In this example we retrieve all MTD (Month-To-Date) invoices: TODO: unsupported by Greenfield!!!
Refund an invoice
TODO: Add support for pull payments to implement refunds (not currently included)
Testing
Changelog
Please see CHANGELOG for more information on what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security
If you discover any security related issues, please email [email protected] instead of using the issue tracker.
Credits
- Vaibhavraj Roham
- Alex Stewart
- Markus Petzsch
- All Contributors
License
The MIT License (MIT). Please see License File for more information.