-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
71 lines (63 loc) · 2.72 KB
/
index.html
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>PayPal Payment</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<div id="smart-button-container">
<div class="paypal-buttons" style="text-align: center;">
<div id="paypal-button-container"></div>
</div>
</div>
<script src="https://www.paypal.com/sdk/js?client-id=Af86oh67wBWBu03Q08NNfFV6r3lsueBzbgY1wULiyvpjSRGEsghJoBj5DukFV2B-gZNG_HZAPQbdObxJ&enable-funding=venmo¤cy=USD" data-sdk-integration-source="button-factory"></script>
<script>
function initPayPalButton() {
paypal.Buttons({
style: {
shape: 'pill',
color: 'gold',
layout: 'vertical',
label: 'paypal',
},
createOrder: function(data, actions) {
const urlParams = new URLSearchParams(window.location.search);
const price = urlParams.get('price');
const amount = urlParams.get('amount');
var value = price * amount
return actions.order.create({
purchase_units: [{"amount":{"currency_code":"USD","value":value}}]
});
},
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');
const urlParams = new URLSearchParams(window.location.search);
const bot_username = urlParams.get('bot');
const payment_id = urlParams.get('payment_id');
const amount = urlParams.get('amount');
window.location.replace(`https://t.me/${bot_username}?start=payment_success-buy_amount=${amount}-payment_id=${payment_id}`);
});
},
onError: function(err) {
console.log(err);
const urlParams = new URLSearchParams(window.location.search);
const bot_username = urlParams.get('bot');
const payment_id = urlParams.get('payment_id');
const amount = urlParams.get('amount');
window.location.replace(`https://t.me/${bot_username}?start=payment_success-buy_amount=${amount}-payment_id=${payment_id}`);
}
}).render('#paypal-button-container');
}
initPayPalButton();
</script>
</body>
</html>