From c434ce9125201f5add5230a4012e6bf0f1a96dca Mon Sep 17 00:00:00 2001 From: xecdev Date: Sat, 6 Dec 2025 08:45:13 +0430 Subject: [PATCH 1/8] Improve Content Unlock Speed --- assets/js/paywalled-content.js | 36 +++++++++++++++++++++++++--------- 1 file changed, 27 insertions(+), 9 deletions(-) diff --git a/assets/js/paywalled-content.js b/assets/js/paywalled-content.js index 5027e14..0e69332 100644 --- a/assets/js/paywalled-content.js +++ b/assets/js/paywalled-content.js @@ -95,8 +95,7 @@ jQuery(document).ready(function($) { } // Configure the PayButton like before, but: - // - onSuccess only captures tx data - // - onClose does the secure validate -> mark_payment_successful -> fetch flow + // - onSuccess captures tx data and does the secure validate -> mark_payment_successful -> fetch flow PayButton.render($container[0], { to: configData.to, amount: configData.amount, @@ -117,9 +116,7 @@ jQuery(document).ready(function($) { amount: tx.amount || '', timestamp: tx.timestamp || 0 }; - }, - onClose: function () { if (unlockAddr && unlockTx && unlockTx.hash) { const addrCopy = unlockAddr; const hashCopy = unlockTx.hash; @@ -160,9 +157,26 @@ jQuery(document).ready(function($) { }); } else { if (attempt === 1) { - // Retry once after brief delay - setTimeout(function () { tryValidateUnlock(2); }, 3000); - } else { + // Retry after brief delay + setTimeout(function () { tryValidateUnlock(2); }, 1200); // 1.2s delay to give the PayButton webhook time + console.log('Retrying unlock validation (attempt 2)...'); + } + else if(attempt === 2) { + // Retry after brief delay + setTimeout(function () { tryValidateUnlock(3); }, 1000); // 1s delay to give the PayButton webhook time + console.log('Retrying unlock validation (attempt 3)...'); + } + else if(attempt === 3) { + // Retry after brief delay + setTimeout(function () { tryValidateUnlock(4); }, 1000); // 1s delay to give the PayButton webhook time + console.log('Retrying unlock validation (attempt 4 Last one)...'); + } + else if (attempt === 4) { + // Worst case, one final retry after a longer delay + setTimeout(function () { tryValidateUnlock(5); }, 2000); // 2s delay to give the PayButton webhook time + console.log('Retrying unlock validation (attempt 5 Last one)...'); + } + else { alert('⚠️ Payment could not be verified on-chain. Please try again.'); } } @@ -170,13 +184,17 @@ jQuery(document).ready(function($) { ); } - tryValidateUnlock(1); + // Initial delay before first attempt to give the PayButton webhook time + setTimeout(function () { + tryValidateUnlock(1); + console.log('Attempting unlock validation (attempt 1)...'); + }, 1000); // First attempt, 1s delay (selected experimentally) } // Safe to clear shared state (the flow above uses the copies) unlockAddr = null; unlockTx = null; - } + }, }); }); }); From 9ac38e4a02c47130dce68463c2b0b54b1f136ac0 Mon Sep 17 00:00:00 2001 From: xecdev Date: Sat, 6 Dec 2025 08:50:50 +0430 Subject: [PATCH 2/8] Improve console message Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com> --- assets/js/paywalled-content.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/assets/js/paywalled-content.js b/assets/js/paywalled-content.js index 0e69332..244c31a 100644 --- a/assets/js/paywalled-content.js +++ b/assets/js/paywalled-content.js @@ -169,7 +169,7 @@ jQuery(document).ready(function($) { else if(attempt === 3) { // Retry after brief delay setTimeout(function () { tryValidateUnlock(4); }, 1000); // 1s delay to give the PayButton webhook time - console.log('Retrying unlock validation (attempt 4 Last one)...'); + console.log('Retrying unlock validation (attempt 4)...'); } else if (attempt === 4) { // Worst case, one final retry after a longer delay From 096e556fcfd01819dbee54b5da264d83d5091bdb Mon Sep 17 00:00:00 2001 From: xecdev Date: Sat, 6 Dec 2025 08:51:15 +0430 Subject: [PATCH 3/8] Improve console message 2 Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com> --- assets/js/paywalled-content.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/assets/js/paywalled-content.js b/assets/js/paywalled-content.js index 244c31a..5767f6a 100644 --- a/assets/js/paywalled-content.js +++ b/assets/js/paywalled-content.js @@ -174,7 +174,7 @@ jQuery(document).ready(function($) { else if (attempt === 4) { // Worst case, one final retry after a longer delay setTimeout(function () { tryValidateUnlock(5); }, 2000); // 2s delay to give the PayButton webhook time - console.log('Retrying unlock validation (attempt 5 Last one)...'); + console.log('Retrying unlock validation (attempt 5 - Final attempt)...'); } else { alert('⚠️ Payment could not be verified on-chain. Please try again.'); From 80e004c92b52e0f41d479e18949507e3a19519ce Mon Sep 17 00:00:00 2001 From: xecdev Date: Sat, 6 Dec 2025 09:15:50 +0430 Subject: [PATCH 4/8] responding to bot's feedback - improve console log messaging --- assets/js/paywalled-content.js | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/assets/js/paywalled-content.js b/assets/js/paywalled-content.js index 5767f6a..b99d4f8 100644 --- a/assets/js/paywalled-content.js +++ b/assets/js/paywalled-content.js @@ -125,6 +125,7 @@ jQuery(document).ready(function($) { const postIdCopy = configData.postId; function tryValidateUnlock(attempt) { + console.log('Unlock validation attempt ' + attempt + (attempt === 5 ? ' (final)' : '') + '...'); jQuery.post( PaywallAjax.ajaxUrl, { @@ -159,22 +160,19 @@ jQuery(document).ready(function($) { if (attempt === 1) { // Retry after brief delay setTimeout(function () { tryValidateUnlock(2); }, 1200); // 1.2s delay to give the PayButton webhook time - console.log('Retrying unlock validation (attempt 2)...'); } else if(attempt === 2) { // Retry after brief delay setTimeout(function () { tryValidateUnlock(3); }, 1000); // 1s delay to give the PayButton webhook time - console.log('Retrying unlock validation (attempt 3)...'); } else if(attempt === 3) { // Retry after brief delay setTimeout(function () { tryValidateUnlock(4); }, 1000); // 1s delay to give the PayButton webhook time - console.log('Retrying unlock validation (attempt 4)...'); } else if (attempt === 4) { // Worst case, one final retry after a longer delay setTimeout(function () { tryValidateUnlock(5); }, 2000); // 2s delay to give the PayButton webhook time - console.log('Retrying unlock validation (attempt 5 - Final attempt)...'); + console.log('Retrying unlock validation (attempt 5 Last one)...'); } else { alert('⚠️ Payment could not be verified on-chain. Please try again.'); @@ -187,7 +185,6 @@ jQuery(document).ready(function($) { // Initial delay before first attempt to give the PayButton webhook time setTimeout(function () { tryValidateUnlock(1); - console.log('Attempting unlock validation (attempt 1)...'); }, 1000); // First attempt, 1s delay (selected experimentally) } From 7054650b2f0bcacc640ea3e3c98aa1d7f3d1841e Mon Sep 17 00:00:00 2001 From: xecdev Date: Sat, 6 Dec 2025 09:40:41 +0430 Subject: [PATCH 5/8] remove redundant console log --- assets/js/paywalled-content.js | 1 - 1 file changed, 1 deletion(-) diff --git a/assets/js/paywalled-content.js b/assets/js/paywalled-content.js index b99d4f8..ab55556 100644 --- a/assets/js/paywalled-content.js +++ b/assets/js/paywalled-content.js @@ -172,7 +172,6 @@ jQuery(document).ready(function($) { else if (attempt === 4) { // Worst case, one final retry after a longer delay setTimeout(function () { tryValidateUnlock(5); }, 2000); // 2s delay to give the PayButton webhook time - console.log('Retrying unlock validation (attempt 5 Last one)...'); } else { alert('⚠️ Payment could not be verified on-chain. Please try again.'); From 242e3377a7b0896ded3a114e5925308069aae4d4 Mon Sep 17 00:00:00 2001 From: xecdev Date: Sat, 6 Dec 2025 13:56:01 +0430 Subject: [PATCH 6/8] Refactor unlock retry logic to use loop and comment debug log --- assets/js/paywalled-content.js | 39 ++++++++++++++++++---------------- 1 file changed, 21 insertions(+), 18 deletions(-) diff --git a/assets/js/paywalled-content.js b/assets/js/paywalled-content.js index ab55556..127b66f 100644 --- a/assets/js/paywalled-content.js +++ b/assets/js/paywalled-content.js @@ -125,7 +125,17 @@ jQuery(document).ready(function($) { const postIdCopy = configData.postId; function tryValidateUnlock(attempt) { - console.log('Unlock validation attempt ' + attempt + (attempt === 5 ? ' (final)' : '') + '...'); + const maxAttempts = 4; // total attempts + const baseDelayMs = 1000; // 1.0s + const stepDelayMs = 500; // +0.5s per retry + + // console.log( + // 'Unlock validation attempt ' + + // attempt + + // (attempt === maxAttempts ? ' (final)' : '') + + // '...' + // ); + jQuery.post( PaywallAjax.ajaxUrl, { @@ -157,23 +167,16 @@ jQuery(document).ready(function($) { } }); } else { - if (attempt === 1) { - // Retry after brief delay - setTimeout(function () { tryValidateUnlock(2); }, 1200); // 1.2s delay to give the PayButton webhook time - } - else if(attempt === 2) { - // Retry after brief delay - setTimeout(function () { tryValidateUnlock(3); }, 1000); // 1s delay to give the PayButton webhook time - } - else if(attempt === 3) { - // Retry after brief delay - setTimeout(function () { tryValidateUnlock(4); }, 1000); // 1s delay to give the PayButton webhook time - } - else if (attempt === 4) { - // Worst case, one final retry after a longer delay - setTimeout(function () { tryValidateUnlock(5); }, 2000); // 2s delay to give the PayButton webhook time - } - else { + if (attempt < maxAttempts) { + // Retry after brief delay with incremental backoff: + // 1s, 1.5s, 2s, 2.5s + const nextAttempt = attempt + 1; + const nextDelay = baseDelayMs + (nextAttempt - 1) * stepDelayMs; + + setTimeout(function () { + tryValidateUnlock(nextAttempt); + }, nextDelay); + } else { alert('⚠️ Payment could not be verified on-chain. Please try again.'); } } From d3502713dd838b6d8caeb368b047ad10ad94696b Mon Sep 17 00:00:00 2001 From: xecdev Date: Sat, 6 Dec 2025 17:10:40 +0430 Subject: [PATCH 7/8] remove debugging code --- assets/js/paywalled-content.js | 7 ------- 1 file changed, 7 deletions(-) diff --git a/assets/js/paywalled-content.js b/assets/js/paywalled-content.js index 127b66f..77eb1b9 100644 --- a/assets/js/paywalled-content.js +++ b/assets/js/paywalled-content.js @@ -129,13 +129,6 @@ jQuery(document).ready(function($) { const baseDelayMs = 1000; // 1.0s const stepDelayMs = 500; // +0.5s per retry - // console.log( - // 'Unlock validation attempt ' + - // attempt + - // (attempt === maxAttempts ? ' (final)' : '') + - // '...' - // ); - jQuery.post( PaywallAjax.ajaxUrl, { From 77a12b8e165a969f20a8da1b6394870060297459 Mon Sep 17 00:00:00 2001 From: xecdev Date: Sun, 7 Dec 2025 11:00:27 +0430 Subject: [PATCH 8/8] fix outdated comment --- assets/js/paywalled-content.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/assets/js/paywalled-content.js b/assets/js/paywalled-content.js index 77eb1b9..cb0e8ac 100644 --- a/assets/js/paywalled-content.js +++ b/assets/js/paywalled-content.js @@ -34,7 +34,7 @@ jQuery(document).ready(function($) { } } - // Shared state: user wallet address + unlock tx captured in onSuccess, consumed in onClose. + // Shared state: user wallet address + unlock tx captured in onSuccess. let unlockAddr = null; let unlockTx = null;