-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpaypal.php
104 lines (96 loc) · 4.09 KB
/
paypal.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
<!DOCTYPE html>
<html lang="ar" dir="rtl">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>عملية الدفع عبر PayPal</title>
<!-- إضافة Bluma CSS -->
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/css/bulma.min.css">
</head>
<body>
<section class="section">
<div class="container">
<h1 class="title">عملية الدفع عبر PayPal</h1>
<?php
// تضمين ملف config.php للحصول على معرف العميل المشفر
include 'config.php';
// استقبال معلومات المنتج من الرابط
if(isset($_GET['product']) && isset($_GET['price']) && isset($_GET['price'])){
$productName = $_GET['product'];
$balName = $_GET['bal'];
$productPrice = $_GET['price'];
// حساب السعر الإجمالي بعد إضافة الرسوم
$totalPrice = calculateTotalPrice($productPrice);
}
// حساب السعر الإجمالي بعد إضافة الرسوم
function calculateTotalPrice($price){
// اضافة الرسوم (4.9% + $0.60)
$feePercentage = 4.9 / 100;
$fixedFee = 0.65;
$totalPrice = $price + ($price * $feePercentage) + $fixedFee;
return $totalPrice;
}
?>
<div class="columns">
<div class="column is-half">
<table class="table is-bordered">
<tbody>
<tr>
<td>باقة 6 جيجا فور جي </td>
</tr>
</table>
<table class="table is-bordered">
<tbody>
<tr>
<td>المنتج:</td>
<td><?php echo $productName; ?></td>
</tr>
<tr>
<td>الرصيد:</td>
<td><?php echo $balName; ?></td>
</tr>
<tr>
<td>السعر:</td>
<td>$<?php echo $productPrice; ?></td>
</tr>
<tr>
<td>الرسوم:</td>
<td>4.9% + $0.65</td>
</tr>
<tr>
<td>السعر الإجمالي:</td>
<td>$<?php echo number_format($totalPrice, 2); ?></td>
</tr>
</tbody>
</table>
<div id="paypal-button-container"></div>
</div>
</div>
</div>
</section>
<!-- إضافة PayPal Checkout SDK -->
<script src="https://www.paypal.com/sdk/js?client-id=<?php echo $clientId; ?>"></script>
<!-- تهيئة PayPal Checkout SDK -->
<script>
paypal.Buttons({
createOrder: function(data, actions) {
return actions.order.create({
purchase_units: [{
description: '<?php echo $productName; ?>',
amount: {
value: '<?php echo $totalPrice; ?>',
currency_code: 'USD'
}
}]
});
},
onApprove: function(data, actions) {
return actions.order.capture().then(function(details) {
alert('تم استكمال عملية الدفع بنجاح!');
window.location.href = 'https://example.com/success.php';
});
}
}).render('#paypal-button-container');
</script>
</body>
</html>