Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
446f102455 | ||
|
|
6056be8cff | ||
|
|
32196a9245 | ||
|
|
6adfda68f8 | ||
|
|
4d4e727708 |
@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -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, '/');
|
||||
|
||||
|
||||
@ -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"
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user