-
-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #46 from alexstewartja/6.0.x
+ Release 6.0.0 - Updated BitPay client dependency to v7.1.0 - Bumped minimum PHP version to 7.4 - Implemented the invoice webhook/notification resend action - Isolated implementation of the `Refunds` resource
- Loading branch information
Showing
9 changed files
with
193 additions
and
110 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,7 +10,7 @@ | |
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.3+ | ||
> Requires PHP 7.4+ | ||
## :warning: Migration From v4 :warning: | ||
|
||
|
@@ -19,6 +19,7 @@ If upgrading from v4, please follow [MIGRATION.md](./MIGRATION.md) | |
## Supported Resources | ||
|
||
- :white_check_mark: [Invoices](https://bitpay.com/api/#rest-api-resources-invoices) | ||
- :white_check_mark: [Refunds](https://bitpay.com/api/#rest-api-resources-refunds) | ||
- :white_check_mark: [Bills](https://bitpay.com/api/#rest-api-resources-bills) | ||
- :white_check_mark: [Subscriptions](https://bitpay.com/api/#rest-api-resources-subscriptions) | ||
- :white_check_mark: [Settlements](https://bitpay.com/api/#rest-api-resources-settlements) | ||
|
@@ -43,6 +44,7 @@ If upgrading from v4, please follow [MIGRATION.md](./MIGRATION.md) | |
+ [Create an invoice](#create-an-invoice) | ||
+ [Retrieve an existing invoice](#retrieve-an-existing-invoice) | ||
+ [Retrieve a list of existing invoices](#retrieve-a-list-of-existing-invoices) | ||
+ [Refunds](#refunds) | ||
+ [Refund an invoice](#refund-an-invoice) | ||
+ [Retrieve a refund request](#retrieve-a-refund-request) | ||
+ [Retrieve all refund requests on an invoice](#retrieve-all-refund-requests-on-an-invoice) | ||
|
@@ -141,8 +143,10 @@ php artisan laravel-bitpay:createkeypair | |
|
||
<center><img src="https://i.ibb.co/JvP3bQb/create-key-pair-command.png" title="Create Key-Pair Command" alt="Create Key-Pair Command"/></center> | ||
|
||
> :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. | ||
> :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. | ||
|
||
|
@@ -173,7 +177,8 @@ Route::bitPayWebhook(); // https://example.com/laravel-bitpay/webhook | |
Route::bitPayWebhook('receive/webhooks/here'); // https://example.com/receive/webhooks/here | ||
``` | ||
|
||
> :information_source: To retrieve your newly created webhook route anywhere in your application, use: `route('laravel-bitpay.webhook.capture')` | ||
> :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: | ||
|
@@ -345,6 +350,19 @@ $endDate = date('Y-m-d'); | |
$invoices = LaravelBitpay::getInvoices($startDate, $endDate); | ||
``` | ||
|
||
#### Request an Invoice webhook to be resent | ||
|
||
```php | ||
// True if the webhook has been resent for the current invoice status, false otherwise. | ||
$webhookResent = LaravelBitpay::requestInvoiceWebhook('invoiceId_sGsdVsgheF'); | ||
``` | ||
|
||
### 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: | ||
|
@@ -921,7 +939,8 @@ Please see [CONTRIBUTING](CONTRIBUTING.md) for details. | |
|
||
## Security | ||
|
||
If you discover any security related issues, please email [email protected] or [email protected] instead of using the issue tracker. | ||
If you discover any security related issues, please email [email protected] or [email protected] instead of | ||
using the issue tracker. | ||
|
||
## Credits | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
<?php | ||
|
||
namespace Vrajroham\LaravelBitpay\Actions; | ||
|
||
use BitPaySDK\Exceptions\BitPayException; | ||
use BitPaySDK\Exceptions\RefundCancellationException; | ||
use BitPaySDK\Model\Invoice\Invoice; | ||
use BitPaySDK\Model\Invoice\Refund; | ||
|
||
|
||
trait ManageRefunds | ||
{ | ||
|
||
/** | ||
* Get BitPay refund instance. | ||
* | ||
* @return Refund | ||
*/ | ||
public static function Refund(): Refund | ||
{ | ||
return new Refund(); | ||
} | ||
|
||
/** | ||
* Create a BitPay refund. | ||
* | ||
* @link https://bitpay.com/api/#rest-api-resources-invoices-refund-an-invoice | ||
* | ||
* @param $invoice Invoice A BitPay invoice object for which a refund request should be made. Must have | ||
* been obtained using the merchant facade. | ||
* @param $refundEmail string The email of the buyer to which the refund email will be sent | ||
* @param $amount float The amount of money to refund. If zero then a request for 100% of the invoice | ||
* value is created. | ||
* @param $currency string The three digit currency code specifying the exchange rate to use when | ||
* calculating the refund bitcoin amount. If this value is "BTC" then no exchange rate | ||
* calculation is performed. | ||
* | ||
* @return bool True if the refund was successfully created, false otherwise. | ||
* @throws BitPayException BitPayException class | ||
*/ | ||
public static function createRefund( | ||
Invoice $invoice, | ||
string $refundEmail, | ||
float $amount, | ||
string $currency | ||
): bool { | ||
return (new self())->client->createRefund($invoice, $refundEmail, $amount, $currency); | ||
} | ||
|
||
/** | ||
* Retrieve all refund requests on a BitPay invoice. | ||
* | ||
* @link https://bitpay.com/api/#rest-api-resources-invoices-retrieve-all-refund-requests-on-an-invoice | ||
* | ||
* @param $invoice Invoice The BitPay invoice having the associated refunds. | ||
* | ||
* @return Refund[] An array of BitPay refund object with the associated Refund object updated. | ||
* @throws BitPayException BitPayException class | ||
*/ | ||
public static function getRefunds(Invoice $invoice): array | ||
{ | ||
return (new self())->client->getRefunds($invoice); | ||
} | ||
|
||
/** | ||
* Retrieve a previously made refund request on a BitPay invoice. | ||
* | ||
* @link https://bitpay.com/api/#rest-api-resources-invoices-retrieve-a-refund-request | ||
* | ||
* @param $invoice Invoice The BitPay invoice having the associated refund. | ||
* @param $refundId string The refund id for the refund to be updated with new status. | ||
* | ||
* @return Refund A BitPay refund object with the associated Refund object updated. | ||
* @throws BitPayException BitPayException class | ||
*/ | ||
public static function getRefund(Invoice $invoice, string $refundId): Refund | ||
{ | ||
return (new self())->client->getRefund($invoice, $refundId); | ||
} | ||
|
||
/** | ||
* Cancel a previously submitted refund request on a BitPay invoice. | ||
* | ||
* @link https://bitpay.com/api/#rest-api-resources-invoices-cancel-a-refund-request | ||
* | ||
* @param $invoiceId string The refund id for the refund to be canceled. | ||
* @param $refund Refund The BitPay invoice having the associated refund to be canceled. | ||
* Must have been obtained using the merchant facade. | ||
* | ||
* @return bool True if the refund was successfully canceled, false otherwise. | ||
* @throws RefundCancellationException RefundCancellationException class | ||
*/ | ||
public static function cancelRefund(string $invoiceId, Refund $refund): bool | ||
{ | ||
return (new self())->client->cancelRefund($invoiceId, $refund); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.