From 9aed4b0e87cac10c55eb2a2973a8197265a931bd Mon Sep 17 00:00:00 2001 From: Kukks Date: Mon, 21 Sep 2020 12:32:52 +0200 Subject: [PATCH] Allow receiving events from the BTCPay modal library --- BTCPayServer/wwwroot/modal/btcpay.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/BTCPayServer/wwwroot/modal/btcpay.js b/BTCPayServer/wwwroot/modal/btcpay.js index 358ec14ef..14a64d69f 100644 --- a/BTCPayServer/wwwroot/modal/btcpay.js +++ b/BTCPayServer/wwwroot/modal/btcpay.js @@ -56,6 +56,7 @@ var onModalWillEnterMethod = function () { }; var onModalWillLeaveMethod = function () { }; + var onModalReceiveMessageMethod = function (event) { }; function showFrame() { if (window.document.getElementsByName('btcpay').length === 0) { @@ -80,6 +81,10 @@ onModalWillLeaveMethod = customOnModalWillLeave; } + function onModalReceiveMessage(customOnModalReceiveMessage) { + onModalReceiveMessageMethod = customOnModalReceiveMessage; + } + function receiveMessage(event) { var uri; @@ -101,6 +106,7 @@ window.location = uri; } } + onModalReceiveMessageMethod(event); } function showInvoice(invoiceId, params) { @@ -134,7 +140,8 @@ showInvoice: showInvoice, onModalWillEnter: onModalWillEnter, onModalWillLeave: onModalWillLeave, - setApiUrlPrefix: setApiUrlPrefix + setApiUrlPrefix: setApiUrlPrefix, + onModalReceiveMessage: onModalReceiveMessage }; })();