{"id":20023982,"url":"https://github.com/vrajroham/laravel-bitpay","last_synced_at":"2025-07-07T03:09:14.418Z","repository":{"id":32506206,"uuid":"135703907","full_name":"vrajroham/laravel-bitpay","owner":"vrajroham","description":"Laravel BitPay Client | Accept Bitcoin(Ƀ) and Bitcoin Cash for your business with your Laravel application","archived":false,"fork":false,"pushed_at":"2022-12-18T14:28:56.000Z","size":132,"stargazers_count":73,"open_issues_count":1,"forks_count":35,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-05-19T19:08:52.949Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","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/vrajroham.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":".github/FUNDING.yml","license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null},"funding":{"github":["vrajroham","alexstewartja"],"patreon":"vrajroham","custom":["https://www.buymeacoffee.com/asja","https://bit.ly/asja_paypal_lara_bitpay"]}},"created_at":"2018-06-01T10:24:41.000Z","updated_at":"2025-05-11T14:39:28.000Z","dependencies_parsed_at":"2023-01-14T21:26:25.419Z","dependency_job_id":null,"html_url":"https://github.com/vrajroham/laravel-bitpay","commit_stats":null,"previous_names":[],"tags_count":18,"template":false,"template_full_name":null,"purl":"pkg:github/vrajroham/laravel-bitpay","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vrajroham%2Flaravel-bitpay","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vrajroham%2Flaravel-bitpay/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vrajroham%2Flaravel-bitpay/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vrajroham%2Flaravel-bitpay/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/vrajroham","download_url":"https://codeload.github.com/vrajroham/laravel-bitpay/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vrajroham%2Flaravel-bitpay/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":261590228,"owners_count":23181477,"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","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-11-13T08:48:51.253Z","updated_at":"2025-07-07T03:09:14.403Z","avatar_url":"https://github.com/vrajroham.png","language":"PHP","funding_links":["https://github.com/sponsors/vrajroham","https://github.com/sponsors/alexstewartja","https://patreon.com/vrajroham","https://www.buymeacoffee.com/asja","https://bit.ly/asja_paypal_lara_bitpay"],"categories":[],"sub_categories":[],"readme":"# LaravelBitPay\n\n![LaravelBitPay Social Image](https://banners.beyondco.de/LaravelBitPay.png?theme=light\u0026packageManager=composer+require\u0026packageName=vrajroham%2Flaravel-bitpay\u0026pattern=circuitBoard\u0026style=style_1\u0026description=Transact+in+Bitcoin%2C+Bitcoin+Cash+and+10%2B+other+BitPay-supported+cryptocurrencies+within+your+Laravel+application.\u0026md=1\u0026showWatermark=0\u0026fontSize=100px\u0026images=https%3A%2F%2Flaravel.com%2Fimg%2Flogomark.min.svg)\n\n[![Latest Version on Packagist](https://img.shields.io/packagist/v/vrajroham/laravel-bitpay.svg?style=for-the-badge)](https://packagist.org/packages/vrajroham/laravel-bitpay)\n[![Build Status](https://img.shields.io/travis/vrajroham/laravel-bitpay/master.svg?style=for-the-badge)](https://travis-ci.org/vrajroham/laravel-bitpay)\n[![Quality Score](https://img.shields.io/scrutinizer/g/vrajroham/laravel-bitpay.svg?style=for-the-badge)](https://scrutinizer-ci.com/g/vrajroham/laravel-bitpay)\n[![Total Downloads](https://img.shields.io/packagist/dt/vrajroham/laravel-bitpay.svg?style=for-the-badge)](https://packagist.org/packages/vrajroham/laravel-bitpay)\n\nLaravelBitPay enables you and your business to transact in Bitcoin, Bitcoin Cash and 10+ other BitPay-supported\ncryptocurrencies within your Laravel application.\n\n\u003e Requires PHP 7.4+\n\n## :warning: Migration From v4 :warning:\n\nIf upgrading from v4, please follow [MIGRATION.md](./MIGRATION.md)\n\n## Supported Resources\n\n- :white_check_mark: [Invoices](https://bitpay.com/api/#rest-api-resources-invoices)\n- :white_check_mark: [Refunds](https://bitpay.com/api/#rest-api-resources-refunds)\n- :white_check_mark: [Bills](https://bitpay.com/api/#rest-api-resources-bills)\n- :white_check_mark: [Subscriptions](https://bitpay.com/api/#rest-api-resources-subscriptions)\n- :white_check_mark: [Settlements](https://bitpay.com/api/#rest-api-resources-settlements)\n- :white_check_mark: [Ledgers](https://bitpay.com/api/#rest-api-resources-ledgers)\n- :white_check_mark: [Recipients](https://bitpay.com/api/#rest-api-resources-recipients)\n- :white_check_mark: [Payouts](https://bitpay.com/api/#rest-api-resources-payouts)\n- :white_check_mark: [Currencies](https://bitpay.com/api/#rest-api-resources-currencies)\n- :white_check_mark: [Rates](https://bitpay.com/api/#rest-api-resources-rates)\n\n## Contents\n\n- [Installation](#installation)\n    + [Install Package](#install-package)\n    + [Publish config file](#publish-config-file)\n    + [Add configuration values](#add-configuration-values)\n    + [Generate Key-Pair and API Token(s)](#generate-key-pair-and-api-tokens)\n    + [Configure Webhooks (Optional)](#configure-webhooks-optional)\n        + [1. Setup your webhook route](#1-setup-your-webhook-route)\n        + [2. Setup your webhook listener](#2-setup-your-webhook-listener)\n- [Examples](#examples)\n    + [Invoices](#invoices)\n        + [Create an invoice](#create-an-invoice)\n        + [Retrieve an existing invoice](#retrieve-an-existing-invoice)\n        + [Retrieve a list of existing invoices](#retrieve-a-list-of-existing-invoices)\n    + [Refunds](#refunds)\n        + [Refund an invoice](#refund-an-invoice)\n        + [Retrieve a refund request](#retrieve-a-refund-request)\n        + [Retrieve all refund requests on an invoice](#retrieve-all-refund-requests-on-an-invoice)\n        + [Cancel a refund request](#cancel-a-refund-request)\n    + [Bills](#bills)\n        + [Create a bill](#create-a-bill)\n        + [Retrieve a bill](#retrieve-a-bill)\n        + [Retrieve a list of existing bills](#retrieve-a-list-of-existing-bills)\n        + [Update a bill](#update-a-bill)\n        + [Deliver a bill via email](#deliver-a-bill-via-email)\n    + [Subscriptions](#subscriptions)\n        + [Create a subscription](#create-a-subscription)\n        + [Retrieve a subscription](#retrieve-a-subscription)\n        + [Retrieve a list of existing subscriptions](#retrieve-a-list-of-existing-subscriptions)\n        + [Update a subscription](#update-a-subscription)\n    + [Settlements](#settlements)\n        + [Retrieve settlements](#retrieve-settlements)\n        + [Retrieve a settlement](#retrieve-a-settlement)\n        + [Fetch a reconciliation report](#fetch-a-reconciliation-report)\n    + [Ledgers](#ledgers)\n        + [Retrieve account balances](#retrieve-account-balances)\n        + [Retrieve ledger entries](#retrieve-ledger-entries)\n    + [Recipients](#recipients)\n        + [Invite Recipients](#invite-recipients)\n        + [Retrieve a recipient](#retrieve-a-recipient)\n        + [Retrieve recipients by status](#retrieve-recipients-by-status)\n        + [Update a recipient](#update-a-recipient)\n        + [Remove a recipient](#remove-a-recipient)\n        + [Request a recipient webhook to be resent](#request-a-recipient-webhook-to-be-resent)\n    + [Payouts](#payouts)\n        + [Create a payout](#create-a-payout)\n        + [Create a payout batch](#create-a-payout-batch)\n        + [Retrieve a payout](#retrieve-a-payout)\n        + [Retrieve a payout batch](#retrieve-a-payout-batch)\n        + [Retrieve payouts based on status](#retrieve-payouts-based-on-status)\n        + [Retrieve payout batches based on status](#retrieve-payout-batches-based-on-status)\n        + [Cancel a payout](#cancel-a-payout)\n        + [Cancel a payout batch](#cancel-a-payout-batch)\n        + [Request a payout webhook to be resent](#request-a-payout-webhook-to-be-resent)\n        + [Request a payout batch webhook to be resent](#request-a-payout-batch-webhook-to-be-resent)\n    + [Currencies](#currencies)\n        + [Retrieve the supported currencies](#retrieve-the-supported-currencies)\n    + [Rates](#rates)\n        + [Retrieve the exchange rate table maintained by BitPay](#retrieve-the-exchange-rate-table-maintained-by-bitpay)\n        + [Retrieve all the rates for a given cryptocurrency](#retrieve-all-the-rates-for-a-given-cryptocurrency)\n        + [Retrieve the rate for a cryptocurrency / fiat pair](#retrieve-the-rate-for-a-cryptocurrency--fiat-pair)\n- [Testing](#testing)\n- [Changelog](#changelog)\n- [Contributing](#contributing)\n- [Security](#security)\n- [Credits](#credits)\n- [License](#license)\n\n## Installation\n\n### Install package\n\nYou can install the package via composer:\n\n```bash\ncomposer require vrajroham/laravel-bitpay\n```\n\n### Publish config file\n\nPublish config file with:\n\n```bash\nphp artisan vendor:publish --provider=\"Vrajroham\\LaravelBitpay\\LaravelBitpayServiceProvider\"\n```\n\nThis will create a `laravel-bitpay.php` file inside your **config** directory.\n\n### Add configuration values\n\nAdd the following keys to your `.env` file and update the values to match your\npreferences ([read more about configuration](https://support.bitpay.com/hc/en-us/articles/115003001063-How-do-I-configure-the-PHP-BitPay-Client-Library-)):\n\n```dotenv\nBITPAY_PRIVATE_KEY_PATH=\nBITPAY_NETWORK=testnet\nBITPAY_KEY_STORAGE_PASSWORD=RandomPasswordForEncryption\nBITPAY_ENABLE_MERCHANT=true\nBITPAY_ENABLE_PAYOUT=false\nBITPAY_MERCHANT_TOKEN=\nBITPAY_PAYOUT_TOKEN=\n``` \n\n### Generate Key-Pair and API Token(s)\n\nThe `laravel-bitpay:createkeypair` command generates a BitPay API Token and Pairing Code for each enabled facade:\n\n```bash\nphp artisan laravel-bitpay:createkeypair\n```\n\n\u003ccenter\u003e\u003cimg src=\"https://i.ibb.co/JvP3bQb/create-key-pair-command.png\" title=\"Create Key-Pair Command\" alt=\"Create Key-Pair Command\"/\u003e\u003c/center\u003e\n\n\u003e :information_source: By default, the command will use the (valid) existing private key located\n\u003e at `BITPAY_PRIVATE_KEY_PATH`.\n\u003e You may specify the `--fresh` or `-f` option to explicitly generate a fresh private key, from which tokens are\n\u003e derived.\n\nAfter successful API Token generation, you will need to approve it by visiting the provided link.\n\n:warning: **Note that the `payout` facade must be enabled on your BitPay merchant account before you can approve and use\nthe related API Token. This means you won't be able to perform actions on the [Recipients](#recipients)\nand [Payouts](#payouts) resources. To enable Payouts\nfunctionality, [Contact BitPay Support](https://bitpay.com/request-help/wizard?category=merchant).**\n\n### Configure Webhooks (Optional)\n\nBitPay resource status updates are completely based on webhooks (IPNs). LaravelBitPay is fully capable of automatically\nhandling webhook requests. Whenever a webhook is received from BitPay's server, `BitpayWebhookReceived` event is\ndispatched. Take the following steps to configure your application for webhook listening:\n\n#### 1. Setup your webhook route\n\nResolve the `bitPayWebhook` route macro in your desired route file (`web.php` is recommended). The macro accepts a\nsingle, optional argument, which is the URI path at which you want to receive BitPay webhook `POST` requests. If none is\nprovided, it defaults to `'laravel-bitpay/webhook'`:\n\n```php\n// ... your other 'web' routes\n\nRoute::bitPayWebhook(); // https://example.com/laravel-bitpay/webhook\n\n// OR ...\n\nRoute::bitPayWebhook('receive/webhooks/here'); // https://example.com/receive/webhooks/here\n```\n\n\u003e :information_source: To retrieve your newly created webhook route anywhere in your application,\n\u003e use: `route('laravel-bitpay.webhook.capture')`\n\nLaravelBitPay also offers the convenience of auto-populating your configured webhook url on applicable resources.\nSpecifically when:\n\n- [Creating an Invoice](#create-an-invoice)\n- [Inviting Recipients](#invite-recipients)\n- Creating a [Payout](#create-a-payout)/[Payout Batch](#create-a-payout-batch)\n\nYou may enable this feature per-resource by uncommenting the respective entry within the `auto_populate_webhook` array\nfound in the `laravel-bitpay.php` config file.\n\n:warning: **If a value is manually set, most likely via `$resource-\u003esetNotificationURL('https://...')` during resource\ninitialization, auto-population is overridden.**\n\n#### 2. Setup your webhook listener\n\nStart by generating an event listener:\n\n```bash\nphp artisan make:listener BitPayWebhookListener --event=\\Vrajroham\\LaravelBitpay\\Events\\BitpayWebhookReceived\n```\n\nThen, implement your application-specific logic in the `handle(...)` function of the generated listener.\n\nIn the following example, we assume you have previously [created an invoice](#create-an-invoice), storing its `token`\non your internal `Order` model:\n\n```php\n/**\n * Handle the webhook event, keeping in mind that the server doesn't trust the client (us), so neither should\n * we trust the server. Well, trust, but verify.\n *\n * @param BitpayWebhookReceived $event\n * @return void\n */\npublic function handle(BitpayWebhookReceived $event)\n{\n    // Extract event payload\n    $payload = $event-\u003epayload;\n\n    // Verify that webhook is for a BitPay Invoice resource\n    if (in_array($payload['event']['code'], array_keys(BitPayConstants::INVOICE_WEBHOOK_CODES))) {\n        try {\n            // Do not trust the webhook data. Pull the referenced Invoice from BitPay's server\n            $invoice = LaravelBitpay::getInvoice($payload['data']['id']);\n\n            // Now grab our internal Order instance for this supposed Invoice\n            $order = Order::whereOrderId($invoice-\u003egetOrderId())-\u003efirst();\n\n            // Verify Invoice token, previously stored at time of creation\n            // Learn more at: https://github.com/vrajroham/laravel-bitpay#create-an-invoice\n            if ($invoice-\u003egetToken() !== $order-\u003einvoice_token) {\n                return;\n            }\n\n            $invoice_status = $invoice-\u003egetStatus();\n\n            // Do something about the new Invoice status\n            if ($invoice_status === InvoiceStatus::Paid) {\n                $order-\u003eupdate(['status' =\u003e $invoice_status]) \u0026\u0026 OrderStatusChanged::dispatch($order-\u003erefresh());\n            }\n        } catch (BitPayException $e) {\n            Log::error($e);\n        }\n    }\n}\n```\n\nFinally, map your listener to the `BitpayWebhookReceived` event inside the `$listen` array of\nyour `EventServiceProvider`:\n\n```php\n/**\n * The event listener mappings for the application.\n *\n * @var array\n */\nprotected $listen = [\n    // ... other event-listener mappings\n    BitpayWebhookReceived::class =\u003e [\n        BitPayWebhookListener::class,\n    ],\n]\n```\n\n## Examples\n\n### Invoices\n\nInvoices are time-sensitive payment requests addressed to specific buyers. An invoice has a fixed price, typically\ndenominated in fiat currency. It also has an equivalent price in the supported cryptocurrencies, calculated by BitPay,\nat a locked exchange rate with an expiration time of 15 minutes.\n\n#### Create an invoice\n\nIn this example we assume you've already created an instance of your equivalent `Order` model, to be associated with\nthis Invoice (referred to as `$order`):\n\n```php\n// Create instance of Invoice\n$invoice = LaravelBitpay::Invoice(449.99, Currency::USD); // Always use the BitPay Currency model to prevent typos\n\n// Set item details (Only 1 item per Invoice)\n$invoice-\u003esetItemDesc('You \"Joe Goldberg\" Life-Size Wax Figure');\n$invoice-\u003esetItemCode('sku-1234');\n$invoice-\u003esetPhysical(true); // Set to false for digital/virtual items\n\n// Ensure you provide a unique OrderId for each Invoice\n$invoice-\u003esetOrderId($order-\u003eorder_id);\n\n// Create Buyer Instance\n$buyer = LaravelBitpay::Buyer();\n$buyer-\u003esetName('John Doe');\n$buyer-\u003esetEmail('john.doe@example.com');\n$buyer-\u003esetAddress1('2630 Hegal Place');\n$buyer-\u003esetAddress2('Apt 42');\n$buyer-\u003esetLocality('Alexandria');\n$buyer-\u003esetRegion('VA');\n$buyer-\u003esetPostalCode(23242);\n$buyer-\u003esetCountry('US');\n$buyer-\u003esetNotify(true); // Instructs BitPay to email Buyer about their Invoice\n\n// Attach Buyer to Invoice\n$invoice-\u003esetBuyer($buyer);\n\n// Set URL that Buyer will be redirected to after completing the payment, via GET Request\n$invoice-\u003esetRedirectURL(route('your-bitpay-success-url'));\n// Set URL that Buyer will be redirected to after closing the invoice or after the invoice expires, via GET Request\n$invoice-\u003esetCloseURL(route('your-bitpay-cancel-url'));\n$invoice-\u003esetAutoRedirect(true);\n\n// Optional. Learn more at: https://github.com/vrajroham/laravel-bitpay#1-setup-your-webhook-route\n$invoice-\u003esetNotificationUrl('https://example.com/your-custom-webhook-url');\n\n// This is the recommended IPN format that BitPay advises for all new implementations\n$invoice-\u003esetExtendedNotifications(true);\n\n// Create invoice on BitPay's server\n$invoice = LaravelBitpay::createInvoice($invoice);\n\n$invoiceId = $invoice-\u003egetId();\n$invoiceToken = $invoice-\u003egetToken();\n\n// You should save Invoice ID and Token, for your reference\n$order-\u003eupdate(['invoice_id' =\u003e $invoiceId, 'invoice_token' =\u003e $invoiceToken]);\n\n// Redirect user to the Invoice's hosted URL to complete payment\n$paymentUrl = $invoice-\u003egetUrl();\nreturn Redirect::to($paymentUrl);\n```\n\n\u003e :information_source: It is highly recommended you store the Invoice ID and Token on your internal model(s). The token\n\u003e can come in handy when verifying webhooks.\n\n#### Retrieve an existing invoice\n\n```php\n$invoice = LaravelBitpay::getInvoice('invoiceId_sGsdVsgheF');\n```\n\n#### Retrieve a list of existing invoices\n\nIn this example we retrieve all MTD (Month-To-Date) invoices:\n\n```php\n$startDate = date('Y-m-d', strtotime('first day of this month'));\n$endDate = date('Y-m-d');\n\n$invoices = LaravelBitpay::getInvoices($startDate, $endDate);\n```\n\n#### Request an Invoice webhook to be resent\n\n```php\n// True if the webhook has been resent for the current invoice status, false otherwise.\n$webhookResent = LaravelBitpay::requestInvoiceWebhook('invoiceId_sGsdVsgheF');\n```\n\n### Refunds\n\nRefund requests are full or partial refunds associated to an invoice. Fully paid invoices can be refunded via the\nmerchant's authorization to issue a refund, while underpaid and overpaid invoices are automatically executed by BitPay\nto issue the underpayment or overpayment amount to the customer.\n\n#### Refund an invoice\n\nThe item Jane purchased was dead on arrival. Give back the lady her crypto:\n\n```php\n$invoice = LaravelBitpay::getInvoice('invoiceId_sGsdVsgheF');\n\n$refundRequested = LaravelBitpay::createRefund($invoice, 'jane.doe@example.com', 0.016, 'ETH');\n\nif ($refundRequested) {\n    // Don't just sit there. Do something!\n}\n```\n\n#### Retrieve a refund request\n\nLet's periodically retrieve (and check the status of) Jane's refund request:\n\n```php\n$invoice = LaravelBitpay::getInvoice('invoiceId_sGsdVsgheF');\n\n$refund = LaravelBitpay::getRefund($invoice, 'refundId_pUdhjwGjsg');\n```\n\n#### Retrieve all refund requests on an invoice\n\nIn this example we retrieve all refund requests related to Jane's invoice:\n\n```php\n$invoice = LaravelBitpay::getInvoice('invoiceId_sGsdVsgheF');\n\n$refundRequests = LaravelBitpay::getRefunds($invoice);\n```\n\n#### Cancel a refund request\n\nTurns out Jane didn't initially follow the instruction manual. The item works and she no longer wants a refund:\n\n```php\n$invoice = LaravelBitpay::getInvoice('invoiceId_sGsdVsgheF');\n\n$refundRequestCancelled = LaravelBitpay::cancelRefund($invoice-\u003egetId(), 'refundId_pUdhjwGjsg');\n```\n\n### Bills\n\nBills are payment requests addressed to specific buyers. Bill line items have fixed prices, typically denominated in\nfiat currency.\n\n#### Create a bill\n\nIn the following example, we create a bill that's due in 10 days:\n\n```php\n// Initialize Bill\n$billData = LaravelBitpay::Bill();\n$billData-\u003esetNumber('bill1234-EFGH');\n$billData-\u003esetCurrency(Currency::USD); // Always use the BitPay Currency model to prevent typos\n$dueDate = date(BitPayConstants::DATETIME_FORMAT, strtotime('+10 days')); // ISO-8601 formatted date\n$billData-\u003esetDueDate($dueDate);\n$billData-\u003esetPassProcessingFee(true); // Let the recipient shoulder BitPay's processing fee\n\n// Prepare Bill recipient's data\n$billData-\u003esetName('John Doe');\n$billData-\u003esetAddress1('2630 Hegal Place');\n$billData-\u003esetAddress2('Apt 42');\n$billData-\u003esetCity('Alexandria');\n$billData-\u003esetState('VA');\n$billData-\u003esetZip(23242);\n$billData-\u003esetCountry('US');\n$billData-\u003esetEmail('john.doe@example.com');\n$billData-\u003esetCc(['jane.doe@example.com']);\n$billData-\u003esetPhone('555-123-456');\n\n// Prepare Bill's line item(s)\n$itemUno = LaravelBitpay::BillItem();\n$itemUno-\u003esetDescription('Squid Game \"Front Man\" Costume');\n$itemUno-\u003esetPrice(49.99);\n$itemUno-\u003esetQuantity(2);\n\n$itemDos = LaravelBitpay::BillItem();\n$itemDos-\u003esetDescription('GOT \"House Stark\" Sterling Silver Pendant');\n$itemDos-\u003esetPrice(35);\n$itemDos-\u003esetQuantity(1);\n\n$billData-\u003esetItems([$itemUno, $itemDos]);\n\n// Create Bill\n$bill = LaravelBitpay::createBill($billData);\n\n// Store the Bill's BitPay ID and URL for future reference\n$billId = $bill-\u003egetId();\n$billPaymentUrl = $bill-\u003egetUrl();\n\n// OR\n\n// Redirect the recipient to BitPay's hosted Bill payment page\nRedirect::to($billPaymentUrl);\n```\n\n#### Retrieve a bill\n\n```php\n$bill = LaravelBitpay::getBill('bill1234-EFGH');\n```\n\n#### Retrieve a list of existing bills\n\nYou can narrow down the retrieved list by specifying a Bill status:\n\n```php\n$paidBills = LaravelBitpay::getBills(BillStatus::Paid);\n```\n\n#### Update a bill\n\nWe managed to upsell a product to our client. Let's add an extra line item to their existing Bill:\n\n```php\n$existingBill = LaravelBitpay::getBill('bill1234-EFGH');\n$existingItems = $existingBill-\u003egetItems();\n\n$billData = LaravelBitpay::Bill();\n$billData-\u003esetId($existingBill-\u003egetId());\n\n$itemTres = LaravelBitpay::BillItem();\n$itemTres-\u003esetDescription('The Tomorrow War \"White Spike\" Life-Size Wax Figure');\n$itemTres-\u003esetPrice(189.99);\n$itemTres-\u003esetQuantity(1);\n\n$billData-\u003esetItems(array_merge($existingItems, [$itemTres]));\n\n// Update Bill\n$updatedBill = LaravelBitpay::updateBill($billData, $billData-\u003egetId());\n```\n\n#### Deliver a bill via email\n\n```php\n$bill = LaravelBitpay::getBill('bill1234-EFGH');\n\n$billDelivered = LaravelBitpay::deliverBill($bill-\u003egetId(), $bill-\u003egetToken());\n\nif ($billDelivered) {\n    // Bill delivered successfully. Do something about that... or not.\n}\n```\n\n### Subscriptions\n\nSubscriptions are repeat billing agreements with specific buyers. BitPay sends bill emails to buyers identified in\nactive subscriptions according to the specified schedule.\n\n#### Create a subscription\n\nLet's create a subscription that's delivered on the 28th of each month and due on the first of the following month, at 9\nAM, respectively:\n\n```php\n// Initialize Subscription\n$subscriptionData = LaravelBitpay::Subscription();\n$subscriptionData-\u003esetSchedule(BitPayConstants::SUBSCRIPTION_SCHEDULE_MONTHLY);\n\n// Optional recurring bill data\n$billData = [\n    'number'            =\u003e 'subscription1234-ABCD',\n    'name'              =\u003e 'John Doe',\n    'address1'          =\u003e '2630 Hegal Place',\n    'address2'          =\u003e 'Apt 42',\n    'city'              =\u003e 'Alexandria',\n    'state'             =\u003e 'VA',\n    'zip'               =\u003e 23242,\n    'country'           =\u003e 'US',\n    'cc'                =\u003e ['jane.doe@example.com'],\n    'phone'             =\u003e '555-123-456',\n    'passProcessingFee' =\u003e true,\n];\n\n$dueDate = date(BitPayConstants::DATETIME_FORMAT, strtotime('first day of next month 9 AM'));\n\n$billItems = array(\n    LaravelBitpay::SubscriptionItem(100.00, 1, 'Web Hosting - 4 CPUs | 16GB Memory | 400GB SSD'),\n    LaravelBitpay::SubscriptionItem(80.00, 1, 'Basic Website Maintenance'),\n);\n\n// Autofill optional bill data\n$mapper = new JsonMapper();\n$billData = $mapper-\u003emap(\n    $billData,\n    LaravelBitpay::BillData(\n        Currency::USD, // Always use the BitPay Currency model to prevent typos\n        'john.doe@example.com',\n        $dueDate,\n        $billItems\n    )\n);\n\n$subscriptionData-\u003esetBillData($billData);\n\n// A little wizardry to always get the 28th day of the current month (leap year safe)\n$deliveryDate = strtotime('first day of this month 9 AM');\n$deliveryDate = new \\DateTime(\"@$deliveryDate\");\n$deliveryDate = $deliveryDate-\u003emodify('+27 days')-\u003egetTimestamp();\n$deliveryDate = date(BitPayConstants::DATETIME_FORMAT, $deliveryDate);\n\n$subscriptionData-\u003esetNextDelivery($deliveryDate);\n\n// Create the Subscription on BitPay\n$subscription = LaravelBitpay::createSubscription($subscriptionData);\n\n// You may then store the Subscription ID for future reference\n$subscriptionId = $subscription-\u003egetId();\n```\n\n#### Retrieve a subscription\n\n```php\n$subscription = LaravelBitpay::getSubscription('6gqe8y5mkc5Qx2a9zmspgx');\n```\n\n#### Retrieve a list of existing subscriptions\n\nYou can narrow down the retrieved list by specifying a Subscription status:\n\n```php\n$activeSubscriptions = LaravelBitpay::getSubscriptions(SubscriptionStatus::Active);\n```\n\n#### Update a subscription\n\nIn this example we activate a Subscription by updating its status:\n\n```php\n$subscriptionData = LaravelBitpay::Subscription();\n$subscriptionData-\u003esetId('6gqe8y5mkc5Qx2a9zmspgx');\n$subscriptionData-\u003esetStatus(SubscriptionStatus::Active);\n\n$activatedSubscription = LaravelBitpay::updateSubscription($subscriptionData, $subscriptionData-\u003egetId());\n```\n\n### Settlements\n\nSettlements are transfers of payment profits from BitPay to bank accounts and cryptocurrency wallets owned by merchants,\npartners, etc.\n\n#### Retrieve settlements\n\nIn this example we retrieve completed YTD (Year-To-Date) settlements denominated in Euros (EUR). We only need 100\nrecords, starting from the 5th one:\n\n```php\n$startDate = date('Y-m-d', strtotime('first day of this year'));\n$endDate = date('Y-m-d');\n\n$eurSettlements = LaravelBitpay::getSettlements(\n        Currency::EUR,\n        $startDate,\n        $endDate,\n        BitPayConstants::SETTLEMENT_STATUS_COMPLETED,\n        100,\n        4\n    );\n```\n\n#### Retrieve a settlement\n\n```php\n$settlement = LaravelBitpay::getSettlement('settlementId_uidwb3668');\n```\n\n#### Fetch a reconciliation report\n\nA reconciliation report is a detailed report of the activity within the settlement period, in order to reconcile\nincoming settlements from BitPay.\n\n```php\n$settlement = LaravelBitpay::getSettlement('settlementId_uidwb3668');\n\n$settlementReport = LaravelBitpay::getSettlementReconciliationReport($settlement);\n```\n\n### Ledgers\n\nLedgers are records of money movement.\n\n#### Retrieve account balances\n\n```php\n$accountBalances = LaravelBitpay::getLedgers();\n```\n\n#### Retrieve ledger entries\n\nIn this example we retrieve MTD (Month-To-Date) ledger entries denominated in United States Dollars (USD).\n\n```php\n$startDate = date('Y-m-d', strtotime('first day of this month'));\n$endDate = date('Y-m-d');\n\n$usdLedgerEntries = LaravelBitpay::getLedger(Currency::USD, $startDate, $endDate);\n```\n\n### Recipients\n\nThe Recipient resource allows a merchant to invite their clients to signup for a BitPay personal account.\n\n:warning: **Your BitPay Merchant account must be authorized for Payouts functionality. To enable Payouts\nfunctionality, [Contact BitPay Support](https://bitpay.com/request-help/wizard?category=merchant).**\n\n#### Invite Recipients\n\n```php\n// Init individual recipients\n$jane = LaravelBitpay::PayoutRecipient('jane.doe@example.com', 'Plain Jane');\n$ada = LaravelBitpay::PayoutRecipient('ada@cardano.org', 'Ada Lovelace');\n\n// Optional. Learn more at https://github.com/vrajroham/laravel-bitpay#1-setup-your-webhook-route\n$ada-\u003esetNotificationUrl('https://example.com/your-custom-webhook-url');\n\n// Batch all individual recipients\n$recipients = LaravelBitpay::PayoutRecipients([$jane, $ada]);\n\n// Submit invites\n$recipientsInvited = LaravelBitpay::invitePayoutRecipients($recipients);\n\n// Do something with the returned invitees\nforeach ($recipientsInvited as $recipient) {\n    $recipientId = $recipient-\u003egetId();\n    $recipientToken = $recipient-\u003egetToken();\n    \n    // ... store Recipient ID and Token somewhere persistent\n\n    // Perform other desired actions\n    \\App\\Events\\LookOutForAnInviteEmail::dispatch($recipient-\u003egetEmail());\n}\n```\n\n\u003e :information_source: It is highly recommended you store the Recipient ID and Token on your internal model(s). The\n\u003e token can come in handy when verifying webhooks.\n\n#### Retrieve a recipient\n\n```php\n$recipient = LaravelBitpay::getPayoutRecipient('recipientId_adaLovelace')\n```\n\n#### Retrieve recipients by status\n\nIn this example, we retrieve 100 recipients (starting from the 50th) that have passed the good 'ole Onfido ID\nverification checks:\n\n```php\n$verifiedRecipients = LaravelBitpay::getPayoutRecipients(RecipientStatus::VERIFIED, 100, 49);\n```\n\n#### Update a recipient\n\n```php\n$recipient = LaravelBitpay::getPayoutRecipient('recipientId_adaLovelace');\n$recipient-\u003esetLabel('Cardano To The Moon');\n\n$updatedRecipient = LaravelBitpay::updatePayoutRecipient($recipient-\u003egetId(), $recipient);\n```\n\n#### Remove a recipient\n\n```php\n$recipientRemoved = LaravelBitpay::removePayoutRecipient('recipientId_janeDoe');\n```\n\n#### Request a recipient webhook to be resent\n\n```php\n// True if the webhook has been resent for the current recipient status, false otherwise.\n$webhookResent = LaravelBitpay::requestPayoutRecipientWebhook('recipientId_adaLovelace');\n```\n\n### Payouts\n\nPayouts are individual (or batches of) bitcoin payments to employees, customers, partners, etc.\n\n:warning: **Your BitPay Merchant account must be authorized for Payouts functionality. To enable Payouts\nfunctionality, [Contact BitPay Support](https://bitpay.com/request-help/wizard?category=merchant).**\n\n#### Create a payout\n\nLet's assume Ada Lovelace accepted our [invitation](#invite-recipients). In this example, we schedule her an individual\npayout for a 5-star rating she received from a referral:\n\n```php\n// Initialize a Payout\n// Pay Ada in USD and record it on the BTC ledger\n$payoutData = LaravelBitpay::Payout(50.00, Currency::USD, Currency::BTC); \n\n// Set Payout details\n$payoutData-\u003esetRecipientId('recipientId_adaLovelace'); // From previously invited Recipient\n$payoutData-\u003esetReference('1234'); // Uniquely identifies an equivalent payout entry in your system\n$payoutData-\u003esetLabel('5-Star Bonus Affiliate Payment #1234 for Dec 2021');\n$payoutData-\u003esetEffectiveDate('2021-12-31');\n\n// Optional. Learn more at https://github.com/vrajroham/laravel-bitpay#1-setup-your-webhook-route\n$payoutData-\u003esetNotificationURL('https://example.com/your-custom-webhook-url');\n\n// Create Payout on BitPay's server\n$payout = LaravelBitpay::createPayout($payoutData);\n\n$payoutId = $payout-\u003egetId();\n$payoutToken = $payout-\u003egetToken();\n\n// ... store Payout ID and Token somewhere persistent\n```\n\n\u003e :information_source: It is highly recommended you store the Payout ID and Token on your internal model(s). The token\n\u003e can come in handy when verifying webhooks.\n\n#### Create a payout batch\n\nLet's pay our two top-tier affiliates for all their hard work, batching both payments into a single API call, for the\nefficiency of it.\n\n```php\n// Initialize a Payout Batch\n$payoutBatchData = LaravelBitpay::PayoutBatch(Currency::USD); // Pay recipients in USD\n$payoutBatchData-\u003esetLedgerCurrency(Currency::ETH); // Record the payout batch on the ETH ledger\n$payoutBatchData-\u003esetAmount(500.00);\n$payoutBatchData-\u003esetReference('Aff_Jan-Feb_2022'); // Uniquely identifies an equivalent payout batch in your system\n$payoutBatchData-\u003esetLabel('Affiliate Payments for Jan-Feb 2022');\n$payoutBatchData-\u003esetEffectiveDate('2022-02-28');\n\n// Optional. Learn more at https://github.com/vrajroham/laravel-bitpay#1-setup-your-webhook-route\n$payoutBatchData-\u003esetNotificationURL('https://example.com/your-custom-webhook-url');\n\n// Define Instruction(s)\n$payJane = LaravelBitpay::PayoutInstruction(\n    250.00,\n    RecipientReferenceMethod::RECIPIENT_ID,\n    'recipientId_janeDoe'\n);\n$payJane-\u003esetLabel('Affiliate Payment #1234 for Jan-Feb 2022');\n\n$payAda = LaravelBitpay::PayoutInstruction(\n    250.00,\n    RecipientReferenceMethod::RECIPIENT_ID,\n    'recipientId_adaLovelace'\n);\n$payAda-\u003esetLabel('Affiliate Payment #5678 for Jan-Feb 2022');\n\n// Attach Instruction(s) to Payout Batch\n$payoutBatchData-\u003esetInstructions([$payJane, $payAda]);\n\n// Create Payout Batch on BitPay's server\n$payoutBatch = LaravelBitpay::createPayoutBatch($payoutBatchData);\n\n$payoutBatchId = $payoutBatch-\u003egetId();\n$payoutBatchToken = $payoutBatch-\u003egetToken();\n\n// ... store Payout Batch ID and Token somewhere persistent\n```\n\n\u003e :information_source: It is highly recommended you store the Payout Batch ID and Token on your internal model(s).\n\u003e The token can come in handy when verifying webhooks.\n\n#### Retrieve a payout\n\n```php\n$payout = LaravelBitpay::getPayout('payoutId_jws43dbnfpg');\n```\n\n#### Retrieve a payout batch\n\n```php\n$payoutBatch = LaravelBitpay::getPayoutBatch('payoutBatchId_jws43dbnfpg');\n```\n\n#### Retrieve payouts based on status\n\nIn this example, we retrieve all completed, Year-To-Date (YTD) payouts.\n\n```php\n$startDate = date('Y-m-d', strtotime('first day of this year'));\n$endDate   = date('Y-m-d');\n\n$completedPayouts = LaravelBitpay::getPayouts($startDate, $endDate, PayoutStatus::Complete);\n```\n\n#### Retrieve payout batches based on status\n\nIn this example, we retrieve all cancelled, Year-To-Date (YTD) payout batches.\n\n```php\n$startDate = date('Y-m-d', strtotime('first day of this year'));\n$endDate   = date('Y-m-d');\n\n$cancelledPayoutBatches = LaravelBitpay::getPayoutBatches($startDate, $endDate, PayoutStatus::Cancelled);\n```\n\n#### Cancel a payout\n\n```php\n$payoutCancelled = LaravelBitpay::cancelPayout('payoutId_jws43dbnfpg');\n```\n\n#### Cancel a payout batch\n\n```php\n$payoutBatchCancelled = LaravelBitpay::cancelPayoutBatch('payoutBatchId_jws43dbnfpg');\n```\n\n#### Request a payout webhook to be resent\n\n```php\n// True if the webhook has been resent for the current payout status, false otherwise.\n$webhookResent = LaravelBitpay::requestPayoutWebhook('payoutId_jws43dbnfpg');\n```\n\n#### Request a payout batch webhook to be resent\n\n```php\n// True if the webhook has been resent for the current payout batch status, false otherwise.\n$webhookResent = LaravelBitpay::requestPayoutBatchWebhook('payoutBatchId_jws43dbnfpg');\n```\n\n### Currencies\n\nCurrencies are fiat currencies supported by BitPay.\n\n#### Retrieve the supported currencies\n\nIn this example, we retrieve the list of supported BitPay Currency objects.\n\n```php\n$supportedCurrencies = LaravelBitpay::getCurrencies();\n```\n\n### Rates\n\nRates are exchange rates, representing the number of fiat currency units equivalent to one BTC.\n\n#### Retrieve the exchange rate table maintained by BitPay\n\n```php\n$rates = LaravelBitpay::getRates();\n\n$btcToUsdRate = $rates-\u003egetRate(Currency::USD); // Always use the BitPay Currency model to prevent typos\n```\n\n#### Retrieve all the rates for a given cryptocurrency\n\n```php\n$ethRates = LaravelBitpay::getCurrencyRates(Currency::ETH);\n\n$ethToUsdRate = $ethRates-\u003egetRate(Currency::USD);\n```\n\n#### Retrieve the rate for a cryptocurrency / fiat pair\n\n```php\n$dogeToUsdRate = LaravelBitpay::getCurrencyPairRate(Currrency::DOGE, Currency::USD);\n```\n\n## Testing\n\n```bash\ncomposer test\n```\n\n## Changelog\n\nPlease see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.\n\n## Contributing\n\nPlease see [CONTRIBUTING](CONTRIBUTING.md) for details.\n\n## Security\n\nIf you discover any security related issues, please email vaibhavraj@vrajroham.me or iamalexstewart@gmail.com instead of\nusing the issue tracker.\n\n## Credits\n\n- [Vaibhavraj Roham](https://github.com/vrajroham)\n- [Alex Stewart](https://github.com/alexstewartja)\n- [All Contributors](../../contributors)\n\n## License\n\nThe MIT License (MIT). Please see [License File](LICENSE.md) for more information.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvrajroham%2Flaravel-bitpay","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvrajroham%2Flaravel-bitpay","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvrajroham%2Flaravel-bitpay/lists"}