Compare commits

...

5 Commits
v2.0.2 ... main

Author SHA1 Message Date
021-projects
446f102455 refactor: cleanup 2025-09-06 19:31:07 +03:00
021-projects
6056be8cff feat: provide item description for btcpay invoice 2025-09-06 19:28:01 +03:00
021-projects
32196a9245 chore(addon.json): bump version + update meta 2025-08-11 20:31:47 +03:00
021-projects
6adfda68f8 feat: show invoice window on process payment 2025-08-09 00:34:57 +03:00
021-projects
4d4e727708 chore: bump version 2025-03-05 15:34:33 +02:00
3 changed files with 58 additions and 13 deletions

View File

@ -8,7 +8,16 @@
const id = btcpay.xfRegistry.nextInvoiceId
if (!id) return
setTimeout(this.closeOverlay)
btcpay.xfRegistry.nextInvoiceId = ''
btcpay.showInvoice(id)
},
closeOverlay () {
const overlays = document.querySelectorAll('.overlay-container.is-active')
if (overlays.length === 0) return
const lastOverlay = overlays[overlays.length - 1]
const overlay = lastOverlay.querySelector('.overlay')
@ -17,9 +26,6 @@
} else {
overlay.dispatchEvent(new Event('overlay:hide'))
}
btcpay.xfRegistry.nextInvoiceId = ''
btcpay.showInvoice(id)
}
}

View File

@ -38,7 +38,7 @@ class BTCPayServer extends AbstractProvider
$purchaseRequest->fastUpdate('provider_metadata', $invoice->getId());
$scriptUrl = $purchaseRequest->PaymentProfile->options['host'] . '/modal/btcpay.js';
$scriptUrl = $this->modalJsUrl($purchaseRequest->PaymentProfile);
if ($purchaseRequest->PaymentProfile->options['invoice_alert'] ?? false) {
$this->sendAlertWithInvoice($purchase, $invoice, $scriptUrl);
@ -51,6 +51,32 @@ class BTCPayServer extends AbstractProvider
);
}
public function processPayment(
Controller $controller,
PurchaseRequest $purchaseRequest,
PaymentProfile $paymentProfile,
Purchase $purchase
) {
$invoice = $this->getInvoice($purchaseRequest->provider_metadata, $paymentProfile);
if (! $invoice) {
throw $controller->exception($controller->noPermission());
}
$scriptUrl = $this->modalJsUrl($paymentProfile);
return $controller->view(
'BS\BtcPayServer:Initiate\BTCPayServer',
'btcpay_show_invoice',
compact('purchaseRequest', 'invoice', 'scriptUrl')
);
}
protected function modalJsUrl(PaymentProfile $paymentProfile): string
{
return $paymentProfile->options['host'].'/modal/btcpay.js';
}
protected function sendAlertWithInvoice(
Purchase $purchase,
InvoiceResult $invoice,
@ -99,6 +125,7 @@ class BTCPayServer extends AbstractProvider
[
'request_key' => $purchaseRequest->request_key,
'purchase_request_id' => $purchaseRequest->purchase_request_id,
'itemDesc' => $purchase->title,
],
$checkoutOptions
);
@ -109,6 +136,16 @@ class BTCPayServer extends AbstractProvider
}
}
protected function getInvoice(string $invoiceId, PaymentProfile $paymentProfile): ?InvoiceResult
{
$invoiceClient = new Invoice($paymentProfile->options['host'], $paymentProfile->options['api_key']);
try {
return $invoiceClient->getInvoice($paymentProfile->options['store_id'], $invoiceId);
} catch (\Exception $e) {
return null;
}
}
/**
* @inheritDoc
*/
@ -217,7 +254,6 @@ class BTCPayServer extends AbstractProvider
$apiKey = $options['api_key'] ?? '';
$storeId = $options['store_id'] ?? '';
$secret = $options['secret'] ?? '';
$invoiceAlert = (bool) ($options['invoice_alert'] ?? false);
$host = $options['host'] = rtrim($host, '/');

View File

@ -1,14 +1,17 @@
{
"legacy_addon_id": "",
"title": "[021] BTCPay Provider",
"title": "BTCPay Provider",
"description": "Payment provider for BTCPay Server.",
"version_id": 2000170,
"version_string": "2.0.1",
"dev": "021",
"dev_url": "https://devsell.io/",
"version_id": 2000370,
"version_string": "2.0.3",
"dev": "Genesis\u2122",
"dev_url": "https://gnz.is",
"faq_url": "",
"support_url": "https://devsell.io/",
"extra_urls": [],
"support_url": "",
"extra_urls": {
"Discover more amazing add-ons": "https://gnz.is",
"Order custom services": "https://gnz.is/go/customdev"
},
"require": {
"XF": [
2020070,
@ -17,4 +20,4 @@
},
"icon": "icon.png",
"composer_autoload": "vendor/composer"
}
}