-
Notifications
You must be signed in to change notification settings - Fork 0
/
Payment.php
271 lines (217 loc) · 11.4 KB
/
Payment.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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
<?php
session_start();
// echo $_SESSION['id'];
// die;
include "ProductDetails.php";
if(isset($_SESSION['id'])){
$product=new ProductDetails();
$details =$product->buynow($_SESSION['id']);
}
?>
<html>
<head>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>Payment page</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet">
<link rel="stylesheet" href="./assets/css/all.min.css">
<link rel="stylesheet" href="./assets/css/styles.css">
<link rel="stylesheet" href="./assets/css/slick.css">
<link rel="stylesheet" href="css/font-awesome.min.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/slick-carousel/1.9.0/slick.min.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/slick-carousel/1.9.0/slick-theme.min.css">
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css">
</head>
<body>
<div class='container d-flex'>
<div class="h4">
<span>Fabulous Sectioned Shopify Theme</span>
</div>
</div>
<div class='container d-flex'>
<div class="ms-5" style="color:gray">
<div class="container d-flex ">
<div>
<?php
foreach($details as $result){
$images = explode(",", $result->getImage());
foreach($images as $image){
}
echo"<img src='uploads/$image' width=200px height=200px>";
}
?>
</div>
<div class="container mt-4">
<div class="">
<span><?php echo "Price - $" . $result->getProductPrice();?></span>
</div>
<div>
<span><?php echo "Color -" . $_SESSION['color']; ?></span>
</div>
<div>
<span><?php echo "Size -" . $_SESSION['size']; ?></span>
</div>
<div>
<span><?php echo "Quantity -" . $_SESSION['quantity']; ?></span>
</div>
</div>
</div>
<div class="container d-flex">
<div class="mt-4">
<span>Sub Total</span>
</div>
<div class="mt-4">
<span class="ms-5"><?php echo "$" . $result->getProductPrice() * $_SESSION['quantity'];?></span>
</div>
</div>
<div class="container d-flex">
<div class="mt-4">
<span>Shipping</span>
</div>
<div class="mt-4">
<span class="ms-5">Calculated at next step</span>
</div>
</div>
<div class="container d-flex">
<div class="mt-4">
<span>Taxes (estimated)</span>
</div>
<div class="mt-4">
<span class="ms-5">$4.32</span>
</div>
</div>
<div class="container d-flex">
<div class="mt-4">
<span>Total</span>
</div>
<div class="mt-4">
<span class="ms-5"><?php echo" USD $ "; echo $result->getProductPrice()*$_SESSION['quantity'] + 4.32;?></span>
</div>
</div>
</div>
<div>
<div style='padding-left:12rem; text-align:center;' id="smart-button-container">
<div style="text-align: center">
<label for="description"></label>
<input type="text" name="descriptionInput" id="description" maxlength="127" value="">
</div>
<p id="descriptionError" style="visibility: hidden; color:red; text-align: center;">Please enter a description</p>
<div style="text-align: center">
<label for="amount"> </label>
<input name="amountInput" type="number" id="amount" value="<?php echo $result->getProductPrice()*$_SESSION['quantity'] + 4.32;?>" >
<span> USD</span></div>
<p id="priceLabelError" style="visibility: hidden; color:red; text-align: center;">Please enter a price</p>
<div id="invoiceidDiv" style="text-align: center; display: none;"><label for="invoiceid"> </label><input name="invoiceid" maxlength="127" type="text" id="invoiceid" value="" ></div>
<p id="invoiceidError" style="visibility: hidden; color:red; text-align: center;">Please enter an Invoice ID</p>
<div style="text-align: center; margin-top: 0.625rem;" id="paypal-button-container"></div>
</div>
<script src="https://www.paypal.com/sdk/js?client-id=sb&enable-funding=venmo¤cy=USD" data-sdk-integration-source="button-factory"></script>
<script>
function initPayPalButton() {
var description = document.querySelector('#smart-button-container #description');
var amount = document.querySelector('#smart-button-container #amount');
var descriptionError = document.querySelector('#smart-button-container #descriptionError');
var priceError = document.querySelector('#smart-button-container #priceLabelError');
var invoiceid = document.querySelector('#smart-button-container #invoiceid');
var invoiceidError = document.querySelector('#smart-button-container #invoiceidError');
var invoiceidDiv = document.querySelector('#smart-button-container #invoiceidDiv');
var elArr = [description, amount];
if (invoiceidDiv.firstChild.innerHTML.length > 1) {
invoiceidDiv.style.display = "block";
}
var purchase_units = [];
purchase_units[0] = {};
purchase_units[0].amount = {};
function validate(event) {
return event.value.length > 0;
}
paypal.Buttons({
style: {
color: 'gold',
shape: 'pill',
label: 'paypal',
layout: 'vertical',
},
onInit: function (data, actions) {
actions.disable();
if(invoiceidDiv.style.display === "block") {
elArr.push(invoiceid);
}
elArr.forEach(function (item) {
item.addEventListener('keyup', function (event) {
var result = elArr.every(validate);
if (result) {
actions.enable();
} else {
actions.disable();
}
});
});
},
onClick: function () {
if (description.value.length < 1) {
descriptionError.style.visibility = "visible";
} else {
descriptionError.style.visibility = "hidden";
}
if (amount.value.length < 1) {
priceError.style.visibility = "visible";
} else {
priceError.style.visibility = "hidden";
}
if (invoiceid.value.length < 1 && invoiceidDiv.style.display === "block") {
invoiceidError.style.visibility = "visible";
} else {
invoiceidError.style.visibility = "hidden";
}
purchase_units[0].description = description.value;
purchase_units[0].amount.value = amount.value;
if(invoiceid.value !== '') {
purchase_units[0].invoice_id = invoiceid.value;
}
},
createOrder: function (data, actions) {
return actions.order.create({
purchase_units: purchase_units,
});
},
onApprove: function (data, actions) {
return actions.order.capture().then(function (orderData) {
// Full available details
console.log('Capture result', orderData, JSON.stringify(orderData, null, 2));
// Show a success message within this page, e.g.
const element = document.getElementById('paypal-button-container');
element.innerHTML = '';
element.innerHTML = '<h3>Thank you for your payment!</h3>';
// Or go to another URL: actions.redirect('thank_you.html');
});
},
onError: function (err) {
console.log(err);
}
}).render('#paypal-button-container');
}
initPayPalButton();
</script>
</div>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.5.1/jquery.min.js" integrity="sha512-bLT0Qm9VnAYZDflyKcBaQ2gg0hSYNQrJ8RilYldYQ1FxQYoCLtUjuuRuZo+fjqhx/qtq/1itJ0C2ejDxltZVFg==" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"></script>
<script src='./assets/js/slick.min.js'></script>
<script src="./assets/js/code.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/slick-carousel/1.9.0/slick.min.js"></script>
</body>
</html>
<!-- <form action="https://www.paypal.com/cgi-bin/webscr" method="post" target="_top">
<input type="hidden" name="cmd" value="_xclick">
<input type="hidden" name="business" value="9HT9TNERMVY3G">
<input type="hidden" name="lc" value="IN">
<input type="hidden" name="item_name" value="orders">
<input type="hidden" name="button_subtype" value="services">
<input type="hidden" name="no_note" value="1">
<input type="hidden" name="no_shipping" value="1">
<input type="hidden" name="currency_code" value="USD">
<input type="hidden" name="bn" value="PP-BuyNowBF:btn_buynowCC_LG.gif:NonHosted">
<input type="image" src="https://www.paypalobjects.com/en_GB/i/btn/btn_buynowCC_LG.gif" style='border=0;' name="submit" alt="PayPal - The safer, easier way to pay online!">
<img alt="" style = 'border=0;' src="https://www.paypalobjects.com/en_GB/i/scr/pixel.gif" width="1" height="1">
</form> -->