Download the PHP package vrajroham/laravel-bitpay without Composer
On this page you can find all versions of the php package vrajroham/laravel-bitpay. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download vrajroham/laravel-bitpay
More information about vrajroham/laravel-bitpay
Files in vrajroham/laravel-bitpay
Package laravel-bitpay
Short Description BitPay wrapper for laravel
License MIT
Homepage https://github.com/vrajroham/laravel-bitpay
Informations about the package laravel-bitpay
LaravelBitPay
LaravelBitPay enables you and your business to transact in Bitcoin, Bitcoin Cash and 10+ other BitPay-supported cryptocurrencies within your Laravel application.
Requires PHP 7.4+
:warning: Migration From v4 :warning:
If upgrading from v4, please follow MIGRATION.md
Supported Resources
- :white_check_mark: Invoices
- :white_check_mark: Refunds
- :white_check_mark: Bills
- :white_check_mark: Subscriptions
- :white_check_mark: Settlements
- :white_check_mark: Ledgers
- :white_check_mark: Recipients
- :white_check_mark: Payouts
- :white_check_mark: Currencies
- :white_check_mark: Rates
Contents
- Installation
- Install Package
- Publish config file
- Add configuration values
- Generate Key-Pair and API Token(s)
- 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
- Refunds
- Refund an invoice
- Retrieve a refund request
- Retrieve all refund requests on an invoice
- Cancel a refund request
- Bills
- Create a bill
- Retrieve a bill
- Retrieve a list of existing bills
- Update a bill
- Deliver a bill via email
- Subscriptions
- Create a subscription
- Retrieve a subscription
- Retrieve a list of existing subscriptions
- Update a subscription
- Settlements
- Retrieve settlements
- Retrieve a settlement
- Fetch a reconciliation report
- Ledgers
- Retrieve account balances
- Retrieve ledger entries
- Recipients
- Invite Recipients
- Retrieve a recipient
- Retrieve recipients by status
- Update a recipient
- Remove a recipient
- Request a recipient webhook to be resent
- Payouts
- Create a payout
- Create a payout batch
- Retrieve a payout
- Retrieve a payout batch
- Retrieve payouts based on status
- Retrieve payout batches based on status
- Cancel a payout
- Cancel a payout batch
- Request a payout webhook to be resent
- Request a payout batch webhook to be resent
- Currencies
- Retrieve the supported currencies
- Rates
- Retrieve the exchange rate table maintained by BitPay
- Retrieve all the rates for a given cryptocurrency
- Retrieve the rate for a cryptocurrency / fiat pair
- 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-bitpay.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):
Generate Key-Pair and API Token(s)
The laravel-bitpay:createkeypair
command generates a BitPay API Token and Pairing Code for each enabled facade:
:information_source: By default, the command will use the (valid) existing private key located at
BITPAY_PRIVATE_KEY_PATH
. You may specify the--fresh
or-f
option to explicitly generate a fresh private key, from which tokens are derived.
After successful API Token generation, you will need to approve it by visiting the provided link.
:warning: Note that the payout
facade must be enabled on your BitPay merchant account before you can approve and use
the related API Token. This means you won't be able to perform actions on the Recipients
and Payouts resources. To enable Payouts
functionality, Contact BitPay Support.
Configure Webhooks (Optional)
BitPay resource status updates are completely based on webhooks (IPNs). LaravelBitPay is fully capable of automatically
handling webhook requests. Whenever a webhook is received from BitPay's server, BitpayWebhookReceived
event is
dispatched. Take the following steps to configure your application for webhook listening:
1. Setup your webhook route
Resolve the bitPayWebhook
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 BitPay webhook POST
requests. If none is
provided, it defaults to 'laravel-bitpay/webhook'
:
:information_source: To retrieve your newly created webhook route anywhere in your application, use:
route('laravel-bitpay.webhook.capture')
LaravelBitPay also offers the convenience of auto-populating your configured webhook url on applicable resources. Specifically when:
- Creating an Invoice
- Inviting Recipients
- Creating a Payout Batch
You may enable this feature per-resource by uncommenting the respective entry within the auto_populate_webhook
array
found in the laravel-bitpay.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 BitpayWebhookReceived
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 BitPay, at a locked exchange rate with an expiration time of 15 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
):
: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:
Request an Invoice webhook to be resent
Refunds
Refund requests are full or partial refunds associated to an invoice. Fully paid invoices can be refunded via the merchant's authorization to issue a refund, while underpaid and overpaid invoices are automatically executed by BitPay to issue the underpayment or overpayment amount to the customer.
Refund an invoice
The item Jane purchased was dead on arrival. Give back the lady her crypto:
Retrieve a refund request
Let's periodically retrieve (and check the status of) Jane's refund request:
Retrieve all refund requests on an invoice
In this example we retrieve all refund requests related to Jane's invoice:
Cancel a refund request
Turns out Jane didn't initially follow the instruction manual. The item works and she no longer wants a refund:
Bills
Bills are payment requests addressed to specific buyers. Bill line items have fixed prices, typically denominated in fiat currency.
Create a bill
In the following example, we create a bill that's due in 10 days:
Retrieve a bill
Retrieve a list of existing bills
You can narrow down the retrieved list by specifying a Bill status:
Update a bill
We managed to upsell a product to our client. Let's add an extra line item to their existing Bill:
Deliver a bill via email
Subscriptions
Subscriptions are repeat billing agreements with specific buyers. BitPay sends bill emails to buyers identified in active subscriptions according to the specified schedule.
Create a subscription
Let's create a subscription that's delivered on the 28th of each month and due on the first of the following month, at 9 AM, respectively:
Retrieve a subscription
Retrieve a list of existing subscriptions
You can narrow down the retrieved list by specifying a Subscription status:
Update a subscription
In this example we activate a Subscription by updating its status:
Settlements
Settlements are transfers of payment profits from BitPay to bank accounts and cryptocurrency wallets owned by merchants, partners, etc.
Retrieve settlements
In this example we retrieve completed YTD (Year-To-Date) settlements denominated in Euros (EUR). We only need 100 records, starting from the 5th one:
Retrieve a settlement
Fetch a reconciliation report
A reconciliation report is a detailed report of the activity within the settlement period, in order to reconcile incoming settlements from BitPay.
Ledgers
Ledgers are records of money movement.
Retrieve account balances
Retrieve ledger entries
In this example we retrieve MTD (Month-To-Date) ledger entries denominated in United States Dollars (USD).
Recipients
The Recipient resource allows a merchant to invite their clients to signup for a BitPay personal account.
:warning: Your BitPay Merchant account must be authorized for Payouts functionality. To enable Payouts functionality, Contact BitPay Support.
Invite Recipients
:information_source: It is highly recommended you store the Recipient ID and Token on your internal model(s). The token can come in handy when verifying webhooks.
Retrieve a recipient
Retrieve recipients by status
In this example, we retrieve 100 recipients (starting from the 50th) that have passed the good 'ole Onfido ID verification checks:
Update a recipient
Remove a recipient
Request a recipient webhook to be resent
Payouts
Payouts are individual (or batches of) bitcoin payments to employees, customers, partners, etc.
:warning: Your BitPay Merchant account must be authorized for Payouts functionality. To enable Payouts functionality, Contact BitPay Support.
Create a payout
Let's assume Ada Lovelace accepted our invitation. In this example, we schedule her an individual payout for a 5-star rating she received from a referral:
:information_source: It is highly recommended you store the Payout ID and Token on your internal model(s). The token can come in handy when verifying webhooks.
Create a payout batch
Let's pay our two top-tier affiliates for all their hard work, batching both payments into a single API call, for the efficiency of it.
:information_source: It is highly recommended you store the Payout Batch ID and Token on your internal model(s). The token can come in handy when verifying webhooks.
Retrieve a payout
Retrieve a payout batch
Retrieve payouts based on status
In this example, we retrieve all completed, Year-To-Date (YTD) payouts.
Retrieve payout batches based on status
In this example, we retrieve all cancelled, Year-To-Date (YTD) payout batches.
Cancel a payout
Cancel a payout batch
Request a payout webhook to be resent
Request a payout batch webhook to be resent
Currencies
Currencies are fiat currencies supported by BitPay.
Retrieve the supported currencies
In this example, we retrieve the list of supported BitPay Currency objects.
Rates
Rates are exchange rates, representing the number of fiat currency units equivalent to one BTC.
Retrieve the exchange rate table maintained by BitPay
Retrieve all the rates for a given cryptocurrency
Retrieve the rate for a cryptocurrency / fiat pair
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] or [email protected] instead of using the issue tracker.
Credits
- Vaibhavraj Roham
- Alex Stewart
- All Contributors
License
The MIT License (MIT). Please see License File for more information.