?
| Current Path : /home/webyoo/www/backup/allback/docteur-site/cv/sym/a/leumi/site/ |
| Current File : /home/webyoo/www/backup/allback/docteur-site/cv/sym/a/leumi/site/agent-subscribe.php |
<?php
include "start.php";
include "verif_session.php";
// =====================================================================
// โ๏ธ CONFIG PAYPAL โ ร REMPLIR (voir instructions envoyรฉes sรฉparรฉment)
// 1) CLIENT_ID : PayPal Business > Developer > Apps & Credentials (Live)
// 2) PLAN_ID : le plan d'abonnement mensuel 99โช que tu crรฉes dans PayPal
// =====================================================================
$PAYPAL_CLIENT_ID = 'BAAzaApYYAx5QNj4Kb_HeB3gZARKntyYL97XCpDvnb66rF7-2obBll2pBfeuS8HhtEIn4cUt03qskR-4f8'; // LIVE
$PAYPAL_PLAN_ID = 'P-9XC28056D8756602JNJTJMDQ'; // LIVE โ plan test 1โช (remplacer par le plan 99โช aprรจs validation)
$userId = (int)$_SESSION['user']['id'];
$me = mysqli_fetch_assoc(mysqli_query($link, "SELECT fk_type, sub_status, agent_slug, sub_payer_id FROM rent_users WHERE id = ".$userId));
$isAgent = ($me && intval($me['fk_type']) === 3);
$active = ($isAgent && isset($me['sub_status']) && $me['sub_status'] === 'active');
$isPaid = ($active && !empty($me['sub_payer_id'])); // abonnรฉ payant (โ essai gratuit) : lui seul voit "dรฉjร actif"
$slug = ($me && isset($me['agent_slug'])) ? $me['agent_slug'] : '';
?>
<!doctype html>
<html lang="he">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<title>ืื ืื ืืชืืื - ืืฉืืจื</title>
<link href="https://fonts.googleapis.com/css2?family=Poppins:wght@400;500;600;700&display=swap" rel="stylesheet">
<link rel="stylesheet" href="vendors/fontawesome-pro-5/css/all.css">
<link rel="stylesheet" href="css/themes.css">
<link rel="icon" href="images/favicon.ico">
</head>
<body>
<?php include "header.php"; ?>
<div class="container py-9" dir="rtl" style="text-align:right; min-height:55vh">
<div class="row justify-content-center">
<div class="col-lg-7 col-md-9">
<?php if (!$isAgent): ?>
<div class="alert alert-warning text-center">ืขืืื ืื ืืืืขื ืืืชืืืืื ืืืื.</div>
<div class="text-center"><a href="dashboard-home.php" class="btn btn-primary">ืืืจื ืืืืืจ ืืืืฉื</a></div>
<?php elseif ($isPaid): ?>
<div class="card border-0 shadow-sm p-6 text-center">
<i class="fas fa-check-circle text-success" style="font-size:56px"></i>
<h2 class="mt-3 text-heading">ืืื ืื ืฉืื ืืืจ ืคืขืื ๐</h2>
<p class="text-muted">ืขืืื ืืืชืืื ืฉืื ืืืื ืืื ืืกืื ืฉืื ืืกืืื ืื ืืืชืืื.</p>
<div class="mt-2">
<a href="agent.php?a=<?= htmlspecialchars(urlencode($slug), ENT_QUOTES) ?>" target="_blank" class="btn btn-info ml-2"><i class="fas fa-external-link-alt ml-1"></i> ืฆืคื ืืขืืื ืฉืื</a>
<a href="dashboard-home.php" class="btn btn-outline-secondary">ืืืืืจ ืืืืฉื</a>
</div>
</div>
<?php else: ?>
<div class="card border-0 shadow-sm p-6">
<div class="text-center mb-4">
<span class="badge badge-primary mb-2" style="font-size:14px">ืื ืื ืืชืืื</span>
<h2 class="text-heading mb-1">99₪ <span class="fs-16 text-muted font-weight-normal">/ ืืืืืฉ</span></h2>
<p class="text-muted mb-0">ืืืื ืืืืฉื ืืชืืืฉ ยท ื ืืชื ืืืืืื ืืื ืขืช</p>
</div>
<ul class="list-unstyled mb-4" style="line-height:2.1">
<li><i class="fas fa-check text-success ml-2"></i> ืขืืื ืืชืืื ืฆืืืืจื ืืขืืฆื ืืฆืืขื ืืืฉืจื ืฉืื</li>
<li><i class="fas fa-check text-success ml-2"></i> ืชืืืช ืืืืื "ืืชืืื" ืขื ืื ืื ืืกืื ืฉืื</li>
<li><i class="fas fa-check text-success ml-2"></i> ืงืืืื ืืืฉืจื ืืจืืืื ืื ืื ืืกืื ืืขืืื ืืื</li>
</ul>
<div id="paypal-button-container"></div>
<p id="sub-msg" class="text-center mt-3 mb-0" style="font-weight:600"></p>
<p class="text-center text-muted mt-3 mb-0" style="font-size:12px">
<i class="fas fa-lock ml-1"></i> ืืชืฉืืื ืืืืืื ืืจื PayPal
</p>
</div>
<!-- SDK PayPal en mode abonnement (subscription) -->
<script src="https://www.paypal.com/sdk/js?client-id=<?= htmlspecialchars($PAYPAL_CLIENT_ID, ENT_QUOTES) ?>&vault=true&intent=subscription¤cy=ILS"></script>
<script>
paypal.Buttons({
style: { shape: 'pill', color: 'gold', layout: 'vertical', label: 'subscribe' },
createSubscription: function (data, actions) {
return actions.subscription.create({ plan_id: '<?= htmlspecialchars($PAYPAL_PLAN_ID, ENT_QUOTES) ?>' });
},
onApprove: function (data) {
var msg = document.getElementById('sub-msg');
msg.style.color = '#0a7d8a';
msg.innerHTML = '<i class="fas fa-spinner fa-spin ml-1"></i> ืืคืขืื ืืช ืืื ืื...';
fetch('agent-activate-sub.php', {
method: 'POST',
headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
body: 'subscriptionID=' + encodeURIComponent(data.subscriptionID)
}).then(function (r) { return r.text(); }).then(function (resp) {
resp = (resp || '').trim();
if (resp === 'ok') {
msg.style.color = '#28a745';
msg.innerHTML = '<i class="fas fa-check-circle ml-1"></i> ืืื ืื ืืืคืขื! ืืขืืืจ ืืืชื...';
setTimeout(function () { window.location.href = 'dashboard-home.php'; }, 1600);
} else {
msg.style.color = '#dc3545';
msg.innerHTML = resp || 'ืฉืืืื ืืืคืขืืช ืืื ืื';
}
}).catch(function () {
msg.style.color = '#dc3545';
msg.innerHTML = 'ืฉืืืืช ืจืฉืช, ื ืกื ืฉืื';
});
},
onError: function () {
var msg = document.getElementById('sub-msg');
msg.style.color = '#dc3545';
msg.innerHTML = 'ืฉืืืื ืืชืฉืืื, ื ืกื ืฉืื';
}
}).render('#paypal-button-container');
</script>
<?php endif; ?>
</div>
</div>
</div>
<?php include "footer.php"; ?>
</body>
</html>