AI update: תיקון דחוף לדף התשלום המשותף: כרגע כשנכנסים לדף עם פרמטרי biz ו-plan, מוטמע iframe עם קישור SmartPay קבוע (hardcoded) שפ

This commit is contained in:
2026-08-20 20:37:15 +00:00
parent d3054f8651
commit 823fa5436e
3 changed files with 148 additions and 76 deletions
+65 -29
View File
@@ -1,16 +1,16 @@
(function() {
'use strict';
// Business configuration with SmartPay iframe URLs
// Business configuration - prices only, payment URLs are generated dynamically
var BUSINESSES = {
sarit: {
name: 'שרית הספרית',
lang: 'he',
plans: {
code: {
url: 'https://pay.smartpay.co.il/v1/iframe/af5cb955-8620-57fa-3b5a-61916e5f',
price: '₪1,490',
title: 'קוד האתר בלבד',
package: 'code',
features: [
'קוד מקור מלא של האתר',
'עיצוב מותאם אישית',
@@ -18,9 +18,9 @@
]
},
full: {
url: 'https://pay.smartpay.co.il/v1/iframe/5ca5e359-9fc8-504b-ce08-6181d906',
price: '₪2,390',
title: 'חבילה מלאה',
package: 'hosting',
badge: 'החבילה המומלצת',
features: [
'קוד מקור מלא של האתר',
@@ -36,9 +36,9 @@
lang: 'he',
plans: {
code: {
url: 'https://pay.smartpay.co.il/v1/iframe/0472462e-8673-5f88-5329-5c54164c',
price: '₪1,490',
title: 'קוד האתר בלבד',
package: 'code',
features: [
'קוד מקור מלא של האתר',
'עיצוב מותאם אישית',
@@ -46,9 +46,9 @@
]
},
full: {
url: 'https://pay.smartpay.co.il/v1/iframe/188c95d1-e760-5640-f05a-562be8fc',
price: '₪2,390',
title: 'חבילה מלאה',
package: 'hosting',
badge: 'החבילה המומלצת',
features: [
'קוד מקור מלא של האתר',
@@ -64,9 +64,9 @@
lang: 'he',
plans: {
code: {
url: 'https://pay.smartpay.co.il/v1/iframe/08825e84-c73d-5737-c77e-950be56e',
price: '₪1,490',
title: 'קוד האתר בלבד',
package: 'code',
features: [
'קוד מקור מלא של האתר',
'עיצוב מותאם אישית',
@@ -74,9 +74,9 @@
]
},
full: {
url: 'https://pay.smartpay.co.il/v1/iframe/56604ea6-6729-51f8-f421-9c3e88c1',
price: '₪2,390',
title: 'חבילה מלאה',
package: 'hosting',
badge: 'החבילה המומלצת',
features: [
'קוד מקור מלא של האתר',
@@ -92,9 +92,9 @@
lang: 'en',
plans: {
code: {
url: 'https://pay.smartpay.co.il/v1/iframe/eb9b2b7a-95f9-5e1c-917c-513bfd99',
price: '₪1,490',
title: 'קוד האתר בלבד',
package: 'code',
features: [
'קוד מקור מלא של האתר',
'עיצוב מותאם אישית',
@@ -102,9 +102,9 @@
]
},
full: {
url: 'https://pay.smartpay.co.il/v1/iframe/ec156279-f214-516e-fe3d-6d462a65',
price: '₪2,390',
title: 'חבילה מלאה',
package: 'hosting',
badge: 'החבילה המומלצת',
features: [
'קוד מקור מלא של האתר',
@@ -120,9 +120,9 @@
lang: 'he',
plans: {
code: {
url: 'https://pay.smartpay.co.il/v1/iframe/08e71a36-b51a-592f-7b9e-d2ef0668',
price: '₪1,490',
title: 'קוד האתר בלבד',
package: 'code',
features: [
'קוד מקור מלא של האתר',
'עיצוב מותאם אישית',
@@ -130,9 +130,9 @@
]
},
full: {
url: 'https://pay.smartpay.co.il/v1/iframe/049867df-8717-5a0b-ca2c-5ae47d74',
price: '₪2,390',
title: 'חבילה מלאה',
package: 'hosting',
badge: 'החבילה המומלצת',
features: [
'קוד מקור מלא של האתר',
@@ -145,6 +145,9 @@
}
};
// Payment API endpoint - generates fresh SmartPay links
var PAYMENT_API_BASE = '/api/pay/go';
// DOM elements
var elements = {
businessTitle: document.getElementById('businessTitle'),
@@ -154,12 +157,19 @@
planTitle: document.getElementById('planTitle'),
planPrice: document.getElementById('planPrice'),
planFeatures: document.getElementById('planFeatures'),
iframeContainer: document.getElementById('iframeContainer'),
iframeLoading: document.getElementById('iframeLoading'),
paymentFrame: document.getElementById('paymentFrame'),
paymentAction: document.getElementById('paymentAction'),
payButton: document.getElementById('payButton'),
errorState: document.getElementById('errorState')
};
// Current checkout state
var currentCheckout = {
bizKey: null,
planKey: null,
business: null,
plan: null
};
// Parse URL parameters
function getUrlParams() {
var params = new URLSearchParams(window.location.search);
@@ -180,7 +190,7 @@
// Show error state
function showError() {
elements.planSection.style.display = 'none';
elements.iframeContainer.style.display = 'none';
elements.paymentAction.style.display = 'none';
elements.errorState.style.display = 'block';
elements.businessTitle.textContent = 'שגיאה';
elements.businessSubtitle.textContent = '';
@@ -195,11 +205,49 @@
return div.innerHTML;
}
// Build payment URL
function buildPaymentUrl(bizKey, plan) {
var params = new URLSearchParams();
params.set('package', plan.package);
params.set('biz', bizKey);
return PAYMENT_API_BASE + '?' + params.toString();
}
// Handle payment button click
function handlePayment() {
if (!currentCheckout.bizKey || !currentCheckout.plan) {
showError();
return;
}
// Set button to loading state
elements.payButton.disabled = true;
elements.payButton.classList.add('loading');
elements.payButton.innerHTML = '<span class="button-spinner"></span><span>מעבר לתשלום...</span>';
// Build the payment URL and navigate to it
var paymentUrl = buildPaymentUrl(currentCheckout.bizKey, currentCheckout.plan);
// Navigate the top window to the payment page
// This ensures we break out of any iframe context
if (window.top !== window.self) {
window.top.location.href = paymentUrl;
} else {
window.location.href = paymentUrl;
}
}
// Render checkout page
function renderCheckout(bizKey, planKey) {
var business = BUSINESSES[bizKey];
var plan = business.plans[planKey];
// Store current checkout state
currentCheckout.bizKey = bizKey;
currentCheckout.planKey = planKey;
currentCheckout.business = business;
currentCheckout.plan = plan;
// Update header
elements.businessTitle.textContent = 'רכישת אתר עבור:';
@@ -225,20 +273,8 @@
.map(function(feature) { return '<li>' + escapeHtml(feature) + '</li>'; })
.join('');
// Load iframe
elements.paymentFrame.src = plan.url;
// Hide loading when iframe loads
function handleLoad() {
elements.iframeLoading.classList.add('hidden');
elements.paymentFrame.removeEventListener('load', handleLoad);
}
elements.paymentFrame.addEventListener('load', handleLoad);
// Fallback: hide loading after timeout
setTimeout(function() {
elements.iframeLoading.classList.add('hidden');
}, 5000);
// Setup payment button
elements.payButton.addEventListener('click', handlePayment);
// Update page title
document.title = 'רכישת אתר - ' + business.name + ' | Emaillion';