-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathexample.html
More file actions
252 lines (216 loc) · 12 KB
/
Copy pathexample.html
File metadata and controls
252 lines (216 loc) · 12 KB
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
<html>
<head>
<title>Generate a Payment Link</title>
<link rel="canonical" href="https://paygate.to/payment-link/" />
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.2/css/all.min.css" integrity="sha512-SnH5WK+bZxgPHs44uWIX+LLJAJ9/2PkPKZ5QiAj6Ta86w+fsb2TkcmfRyVX3pBnMFcV7oQPJkl9QevSCWr3W6A==" crossorigin="anonymous" referrerpolicy="no-referrer" />
</head>
<body>
<div class="vce-col vce-element--has-background vce-col--md-auto vce-col--xs-1 vce-col--xs-last vce-col--xs-first vce-col--sm-last vce-col--sm-first vce-col--md-first vce-col--lg-first vce-col--xl-first" id="el-b0c2d469"><div class="vce-col-inner" data-vce-do-apply="border margin background el-b0c2d469"><div class="vce-content-background-container"></div><div class="vce-col-content" data-vce-element-content="true" data-vce-do-apply="padding el-b0c2d469"><div class="vce-text-block"><div class="vce-text-block-wrapper vce" id="el-1657c0bf" data-vce-do-apply="all el-1657c0bf"><h2 style="text-align: center;"><strong>Generate a Payment Link Without KYC</strong></h2><p>The payment link generation is intended for merchants and freelancers who don't have a website and want to get paid instantly in USDC without a bank or a merchant account.</p><p>⚠️ Warning: Your wallet should be USDC (Polygon) compatible wallet to receive the payment successfully.</p></div></div><div class="vce-raw-html"><div class="vce-raw-html-wrapper" id="el-ff361561" data-vce-do-apply="all el-ff361561"><style>.copy-text{position:relative;padding:5px;background:#fff;border:2px solid #000;border-radius:10px;display:flex;margin-top:5px;}.copy-text input.text{width:85%;padding:5px;font-size:18px;color:#555;border:none;outline:none}.copy-text button{padding:10px;background:#000;color:#fff;font-size:18px;border:none;outline:none;border-radius:10px;cursor:pointer}.copy-text button:active{background:#000}.copy-text button:before{content:"Copied";position:absolute;top:-45px;right:0;background:#000;padding:8px 10px;border-radius:20px;font-size:15px;display:none}.copy-text button:after{content:"";position:absolute;top:-20px;right:25px;width:10px;height:10px;background:#000;transform:rotate(45deg);display:none}.copy-text.active button:before,.copy-text.active button:after{display:block}</style>
<h1>Generate a Payment Link</h1>
<form id="transaction-form">
<label for="wallet_address">Merchant or Freelancer Wallet Address (Receiver):</label><br>
<input type="text" id="wallet_address" name="wallet_address" required=""><br><br>
<label for="email_address">Customer or Payer Email:</label><br>
<input type="text" id="email_address" name="email_address" required=""><br><br>
<label for="amount">Amount to pay:</label><br>
<input type="number" step="0.01" id="amount" name="amount" required=""><br><br>
<label for="currency">Currency:</label><br>
<select id="currency" name="currency" required="">
<option value="USD">USD</option>
<option value="EUR">EUR</option>
<option value="CAD">CAD</option>
<option value="INR">INR</option>
<option value="SEK">SEK</option>
</select><br>
<label for="provider">Provider:</label><br>
<select id="provider" name="provider" required="">
<option value="hosted">Multi Hosted Providers</option>
</select><br><br>
<input style="border-radius:7px;" type="submit" value="Submit">
</form>
<div id="loading-spinner" style="display:none; text-align:center; margin-top:10px;">
<div class="spinner"></div>
</div>
<div id="payment-link"></div>
<style>
.spinner {
width: 48px;
height: 48px;
margin: 0 auto;
background: transparent url('data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSI0OCIgaGVpZ2h0PSI0OCIgdmlld0JveD0iMCAwIDQ4IDQ4IiBzdHJva2U9IiMwMDAwMDAiIHN0cm9rZS13aWR0aD0iNCIgZmlsbD0ibm9uZSIgc3Ryb2tlLW9wYWNpdHk9IjAuMyI+CiAgPGNpcmNsZSBjeD0iMjQiIGN5PSIyNCIgcj0iMjAiLz4KICA8cGF0aCBkPSJNNDQgMjRhMjAgMjAgMCAwIDEtMjAgMjAiPgogICAgPGFuaW1hdGVUcmFuc2Zvcm0gYXR0cmlidXRlTmFtZT0idHJhbnNmb3JtIiB0eXBlPSJyb3RhdGUiIGZyb209IjAgMjQgMjQiIHRvPSIzNjAgMjQgMjQiIGR1cj0iMXMiIHJlcGVhdENvdW50PSJpbmRlZmluaXRlIi8+CiAgPC9wYXRoPgo8L3N2Zz4=') center center no-repeat;
background-size: 40px 40px;
}
</style>
<script>
const form = document.getElementById('transaction-form');
const paymentLinkDiv = document.getElementById('payment-link');
const providerSelect = document.getElementById('provider');
const minAmounts = {
'hosted': 1
};
// Fetch provider status
async function loadActiveProviders() {
try {
const res = await fetch('https://api.paygate.to/control/provider-status/');
const data = await res.json();
if (!data.providers) return;
data.providers.forEach(provider => {
if (provider.status === 'active') {
// Save minimum dynamically
minAmounts[provider.id] = provider.minimum_amount;
// Create option
const option = document.createElement('option');
option.value = provider.id;
option.textContent = provider.provider_name;
providerSelect.appendChild(option);
}
});
} catch (e) {
console.error('Failed to load providers', e);
}
}
// Load providers on page load
loadActiveProviders();
form.addEventListener('submit', async (event) => {
event.preventDefault();
const spinner = document.getElementById('loading-spinner');
paymentLinkDiv.innerHTML = ''; // clear previous results
spinner.style.display = 'block'; // show spinner
const walletAddress = document.getElementById('wallet_address').value;
const emailAddress = document.getElementById('email_address').value;
const amount = parseFloat(document.getElementById('amount').value);
const provider = document.getElementById('provider').value;
const currency = document.getElementById('currency').value;
if (!walletAddress || !emailAddress || !amount || !provider) {
paymentLinkDiv.innerHTML = '<p style="color: red;">Please fill out all fields.</p>';
return;
}
if (amount < minAmounts[provider]) {
paymentLinkDiv.innerHTML = `<p style="color: red;">Minimum amount for ${provider} is $${minAmounts[provider]}</p>`;
spinner.style.display = 'none';
return;
}
if (currency !== 'USD' && (provider === 'wert' || provider === 'transfi' || provider === 'robinhood')) {
paymentLinkDiv.innerHTML = `<p style="color: red;">${provider} supports USD currency only.</p>`;
spinner.style.display = 'none';
return;
}
if (currency !== 'USD' && currency !== 'EUR' && provider === 'stripe') {
paymentLinkDiv.innerHTML = `<p style="color: red;">${provider} supports USD and EUR currencies only.</p>`;
spinner.style.display = 'none';
return;
}
if (currency !== 'INR' && (provider === 'upi')) {
paymentLinkDiv.innerHTML = `<p style="color: red;">${provider} supports INR currency only.<\/p>`;
spinner.style.display = 'none';
return;
}
if (currency !== 'CAD' && (provider === 'interac')) {
paymentLinkDiv.innerHTML = `<p style="color: red;">${provider} supports CAD currency only.<\/p>`;
spinner.style.display = 'none';
return;
}
if (currency !== 'SEK' && (provider === 'klarna')) {
paymentLinkDiv.innerHTML = `<p style="color: red;">${provider} supports SEK currency only.<\/p>`;
spinner.style.display = 'none';
return;
}
if (currency !== 'EUR' && (provider === 'ideal')) {
paymentLinkDiv.innerHTML = `<p style="color: red;">${provider} supports EUR currency only.<\/p>`;
spinner.style.display = 'none';
return;
}
const payoutTrackingId = `https://paygate.to/payment-link/invoice.php?payment=${Date.now()}_${Math.floor(Math.random() * 9000000) + 1000000}`;
const callback = encodeURIComponent(payoutTrackingId);
try {
const response = await fetch(`https://api.paygate.to/control/wallet.php?address=${walletAddress}&callback=${callback}`);
const data = await response.json();
spinner.style.display = 'none'; // hide spinner
if (data && data.address_in) {
const addressIn = data.address_in;
const callbackUrl = data.callback_url;
const customerEmail = encodeURIComponent(emailAddress);
let paymentLink;
if (provider === 'hosted') {
paymentLink = `https://checkout.paygate.to/pay.php?address=${addressIn}&amount=${amount}&provider=${provider}&email=${customerEmail}¤cy=${currency}`;
} else {
paymentLink = `https://checkout.paygate.to/process-payment.php?address=${addressIn}&amount=${amount}&provider=${provider}&email=${customerEmail}¤cy=${currency}`;
}
// Create a container div for the payment link
const paymentLinkContainer = document.createElement('div');
paymentLinkContainer.classList.add('payment-link-container');
// Create a label for the payment link
const paymentLinkLabel = document.createElement('label');
paymentLinkLabel.textContent = 'Payment Link: ';
paymentLinkContainer.appendChild(paymentLinkLabel);
// Create the copiable field for the payment link
const copyText = document.createElement('div');
copyText.classList.add('copy-text');
const input = document.createElement('input');
input.type = 'text';
input.classList.add('text');
input.value = paymentLink;
input.readOnly = true;
const button = document.createElement('button');
button.innerHTML = '<i class="fas fa-copy"></i>';
copyText.appendChild(input);
copyText.appendChild(button);
paymentLinkContainer.appendChild(copyText);
// Create a container div for the address_in
const addressInContainer = document.createElement('div');
addressInContainer.classList.add('address-in-container');
// Create a label for the address_in
const addressInLabel = document.createElement('label');
addressInLabel.textContent = 'Tracking Number: ';
addressInContainer.appendChild(addressInLabel);
// Create the copiable field for the address_in
const addressInCopyText = document.createElement('div');
addressInCopyText.classList.add('copy-text');
const addressInInput = document.createElement('input');
addressInInput.type = 'text';
addressInInput.classList.add('text');
addressInInput.value = addressIn;
addressInInput.readOnly = true;
const addressInButton = document.createElement('button');
addressInButton.innerHTML = '<i class="fas fa-copy"></i>';
addressInCopyText.appendChild(addressInInput);
addressInCopyText.appendChild(addressInButton);
addressInContainer.appendChild(addressInCopyText);
// Append the containers to the payment link div
paymentLinkDiv.appendChild(paymentLinkContainer);
paymentLinkDiv.appendChild(addressInContainer);
// Add click event listener for the payment link copy button
button.addEventListener('click', function () {
let input = copyText.querySelector('input.text');
input.select();
document.execCommand('copy');
copyText.classList.add('active');
window.getSelection().removeAllRanges();
setTimeout(function () {
copyText.classList.remove('active');
}, 2500);
});
// Add click event listener for the address_in copy button
addressInButton.addEventListener('click', function () {
let input = addressInCopyText.querySelector('input.text');
input.select();
document.execCommand('copy');
addressInCopyText.classList.add('active');
window.getSelection().removeAllRanges();
setTimeout(function () {
addressInCopyText.classList.remove('active');
}, 2500);
});
} else {
spinner.style.display = 'none';
paymentLinkDiv.innerHTML = '<p style="color: red;">Invalid payout wallet. Please insert a valid USDC (Polygon) wallet address.</p>';
}
} catch (error) {
spinner.style.display = 'none';
console.error('Error:', error);
paymentLinkDiv.innerHTML = '<p style="color: red;">An error occurred while processing the request. Make sure your wallet is valid.</p>';
}
});
</script></div></div></div></div></div>
</body>
</html>