Skip to content

Commit

Permalink
Merge pull request #16 from ndeet/fix-webhook-dos
Browse files Browse the repository at this point in the history
Fix bug creating new webhook on each order
  • Loading branch information
woutersamaey authored Jun 16, 2023
2 parents 2356aa3 + 3e09dad commit 2675d25
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions Model/BTCPay/BTCPayService.php
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,7 @@ public function updateInvoice(string $btcPayStoreId, string $invoiceId, $logPaym
if ($autoCancel) {
$btcpayInvoices = $this->getInvoicesByOrderIds($magentoStoreId, [$order->getIncrementId()]);
$isEverythingExpired = true;
foreach ($btcpayInvoices->getInvoices() as $invoice) {
foreach ($btcpayInvoices->all() as $invoice) {
if (!$invoice->isExpired()) {
$isEverythingExpired = false;
break;
Expand Down Expand Up @@ -662,7 +662,7 @@ public function getWebhooksForStore(int $magentoStoreId, $btcPayStoreId, string

$url = $this->getWebhookUrl($magentoStoreId);

foreach ($webhooks as $webhook) {
foreach ($webhooks->all() as $webhook) {
$data = $webhook->getData();
if ($data['url'] === $url) {
return $data;
Expand Down
4 changes: 2 additions & 2 deletions Observer/CheckOrderStatus.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public function execute(Observer $observer)
//Check Order Status
$invoices = $this->btcService->getInvoicesByOrderIds($currentStoreId, $orderIdArr);

$invoices = $invoices->getInvoices();
$invoices = $invoices->all();
if (count($invoices) !== 0) {
$invoice = $invoices[0];

Expand All @@ -65,7 +65,7 @@ public function execute(Observer $observer)
//Only cancel when no other open invoices for the same orderId
$btcpayInvoices = $this->btcService->getInvoicesByOrderIds($currentStoreId, [$order->getIncrementId()]);
$isEverythingNew = true;
foreach ($btcpayInvoices->getInvoices() as $invoice) {
foreach ($btcpayInvoices->all() as $invoice) {
if (!$invoice->isNew()) {
$isEverythingNew = false;
break;
Expand Down

0 comments on commit 2675d25

Please sign in to comment.