From d43c3dc9684676dcead20c68c7cc06c0ab872ae9 Mon Sep 17 00:00:00 2001 From: "nicolas.dorier" Date: Tue, 17 Oct 2017 17:04:33 +0900 Subject: [PATCH] generate 7 digit pairing code, notify parent windows of checkout --- BTCPayServer/Authentication/TokenRepository.cs | 8 +++++++- BTCPayServer/wwwroot/js/core.js | 6 ++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/BTCPayServer/Authentication/TokenRepository.cs b/BTCPayServer/Authentication/TokenRepository.cs index 642dbc2b5..e4ad7d9fc 100644 --- a/BTCPayServer/Authentication/TokenRepository.cs +++ b/BTCPayServer/Authentication/TokenRepository.cs @@ -58,7 +58,13 @@ namespace BTCPayServer.Authentication public async Task CreatePairingCodeAsync() { - string pairingCodeId = Encoders.Base58.EncodeData(RandomUtils.GetBytes(6)); + string pairingCodeId = null; + while(true) + { + pairingCodeId = Encoders.Base58.EncodeData(RandomUtils.GetBytes(6)); + if(pairingCodeId.Length == 7) // woocommerce plugin check for exactly 7 digits + break; + } using(var ctx = _Factory.CreateContext()) { var now = DateTime.UtcNow; diff --git a/BTCPayServer/wwwroot/js/core.js b/BTCPayServer/wwwroot/js/core.js index a9ba8c1a7..3f7db71ab 100644 --- a/BTCPayServer/wwwroot/js/core.js +++ b/BTCPayServer/wwwroot/js/core.js @@ -155,9 +155,15 @@ $("#copy-tab").click(function () { // Should connect using webhook ? // If notification received +var oldStatus = status; updateState(status); function updateState(status) { + if (oldStatus != status) + { + oldStatus = status; + window.parent.postMessage({ "invoiceId": invoiceId, "status": status }, "*"); + } if (status == "complete" || status == "paidOver" || status == "confirmed" ||