-
Notifications
You must be signed in to change notification settings - Fork 72
Expand file tree
/
Copy pathdonation.php
More file actions
379 lines (352 loc) · 20 KB
/
Copy pathdonation.php
File metadata and controls
379 lines (352 loc) · 20 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
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
<script>
function send(type, method, amount, currency) {
if (method == "github") {
if (type == "sponsor") {
window.location = "https://github.com/sponsors/FreeCAD?frequency=recurring&amount=" + amount;
} else {
window.location = "https://github.com/sponsors/FreeCAD?frequency=one-time&amount=" + amount;
}
} else if (method == "opencollective") {
if (type == "sponsor") {
window.location = "https://opencollective.com/freecad/donate?interval=month&amount=" + amount;
} else {
window.location = "https://opencollective.com/freecad/donate?interval=oneTime&amount=" + amount;
}
} else if (method == "paypal") {
window.location = "https://www.paypal.com/donate/?hosted_button_id=M3Z8BGW6DB69Q";
} else if (method == "stripe") {
var checkoutUrl = new URL("stripe-checkout-session.php", window.location.href);
checkoutUrl.searchParams.set("amount", amount);
checkoutUrl.searchParams.set("currency", currency);
window.location = checkoutUrl.toString();
}
}
document.addEventListener('DOMContentLoaded', function() {
var typesRadios = document.getElementById("types");
var presetsRadios = document.getElementById("presets");
var methodSelect = document.getElementById("method");
var currencySelect = document.getElementById("currency");
var sepainfo = document.getElementById("sepainfo");
var stripeinfo = document.getElementById("stripeinfo");
var paypalinfo = document.getElementById("paypalinfo");
var submitButton = document.getElementById("submit");
var amountInput = document.getElementById("amount");
var donateModal = document.getElementById('donateModal');
var donationInfo = document.getElementById("donationInfo");
var sponsorInfo = document.getElementById("sponsorInfo");
var presetValues = {
"preset5": "5.00",
"preset10": "10.00",
"preset25": "25.00",
"preset100": "100.00",
"preset200": "200.00"
};
var currencySymbols = {
"eur": "€",
"usd": "$"
};
function updateCurrencyDisplay(currency) {
var symbol = currencySymbols[currency] || currencySymbols[defaultCurrency];
Object.keys(presetValues).forEach(function(key) {
var label = document.querySelector("label[for='" + key + "']");
var presetAmount = parseFloat(presetValues[key]);
if (label) {
label.textContent = " " + symbol + (Number.isInteger(presetAmount) ? presetAmount : presetAmount.toFixed(2)) + " ";
}
});
}
function methodProcess(method) {
if (method == "sepa") {
sepainfo.classList.remove("hidden");
submitButton.classList.add("disabled");
stripeinfo.classList.add("hidden");
paypalinfo.classList.add("hidden");
}else if(method == "stripe" && type == "sponsor") {
sepainfo.classList.add("hidden");
submitButton.classList.add("disabled");
stripeinfo.classList.remove("hidden");
paypalinfo.classList.add("hidden");
}else if(method == "paypal") {
submitButton.classList.remove("disabled");
sepainfo.classList.add("hidden");
stripeinfo.classList.add("hidden");
paypalinfo.classList.remove("hidden");
}else {
sepainfo.classList.add("hidden");
submitButton.classList.remove("disabled");
stripeinfo.classList.add("hidden");
paypalinfo.classList.add("hidden");
}
}
function typeProcess(type) {
if (type == "sponsor") {
sponsorInfo.classList.remove("hidden");
donationInfo.classList.add("hidden");
} else {
sponsorInfo.classList.add("hidden");
donationInfo.classList.remove("hidden");
}
}
function presetProcess(preset) {
if (preset === "other") {
amountInput.value = "";
amountInput.focus();
} else {
amountInput.value = preset;
}
}
function amountProcess(amount) {
var parsedAmount = parseFloat(String(amount).trim());
if (isNaN(parsedAmount)) {
return;
}
var numericAmount = parsedAmount.toFixed(2);
var matchedPreset = Object.keys(presetValues).find(key => presetValues[key] === numericAmount);
if (matchedPreset) {
document.getElementById(matchedPreset).checked = true;
} else {
document.getElementById("presetother").checked = true;
}
}
function showAccordion(amount) {
amount = parseFloat(amount);
var accordions = document.querySelectorAll('.accordion-collapse');
accordions.forEach(accordion => {
new bootstrap.Collapse(accordion, { toggle: false }).hide();
});
var targetAccordion = null;
if (amount >= 25 && amount < 100) {
targetAccordion = document.getElementById('collapseBronze');
} else if (amount >= 100 && amount < 200) {
targetAccordion = document.getElementById('collapseSilver');
} else if (amount >= 200) {
targetAccordion = document.getElementById('collapseGold');
} else {
targetAccordion = document.getElementById('collapseNormal');
}
if (targetAccordion) {
new bootstrap.Collapse(targetAccordion).show();
}
}
var type = document.querySelector('input[name="type"]:checked').id;
var method = methodSelect.value;
var amount = amountInput.value;
var currency = currencySelect.value;
updateCurrencyDisplay(currency);
methodProcess(method);
typeProcess(type);
amountProcess(amount);
showAccordion(amount)
typesRadios.addEventListener("change", function() {
type = document.querySelector('input[name="type"]:checked').id;
typeProcess(type);
methodProcess(method);
});
presetsRadios.addEventListener("change", function () {
var selectedPreset = document.querySelector("input[name='preset']:checked");
var preset;
if (selectedPreset.id === "presetother") {
preset = "other";
} else {
preset = presetValues[selectedPreset.id];
amount = preset;
}
presetProcess(preset);
showAccordion(preset)
});
methodSelect.addEventListener('change', function() {
method = methodSelect.value;
methodProcess(method);
});
currencySelect.addEventListener('change', function() {
currency = currencySelect.value || defaultCurrency;
updateCurrencyDisplay(currency);
});
amountInput.addEventListener("input", function() {
amount = amountInput.value;
if (amount === "" || isNaN(amount)) {
amountInput.reportValidity();
return;
}
amountProcess(amount);
showAccordion(amount)
});
submitButton.addEventListener('click', function() {
if (submitButton.classList.contains("disabled")) {
return;
}
send(type, method, amount, currency);
});
donateModal.addEventListener('show.bs.modal', function(event) {
var modalToogle = event.relatedTarget;
var typeAttribute = modalToogle.getAttribute('data-bs-type');
var amountAttribute = modalToogle.getAttribute('data-bs-amount');
var methodAttribute = modalToogle.getAttribute('data-bs-method');
if (typeAttribute) {
document.getElementById(typeAttribute).checked = true;
type = typeAttribute;
typeProcess(type);
}
if (amountAttribute) {
amountInput.value = amountAttribute;
amount = amountAttribute;
amountProcess(amount);
showAccordion(amount)
}
if (methodAttribute) {
methodSelect.value = methodAttribute;
method = methodAttribute;
methodProcess(method);
}
});
});
</script>
<div class="modal fade" id="donateModal" tabindex="-1">
<div class="modal-dialog modal-xl">
<div class="modal-content bg-dark">
<div class="modal-header border-secondary">
<h1 class="modal-title fs-5" id="donateModalLabel"> <?php echo _('Donate'); ?> </h1>
<button type="button" class="btn-close btn-close-white" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body">
<div class="container-fluid">
<div class="row">
<div class="col-lg-5 mb-3">
<div class="btn-group d-flex flex-wrap" role="group" aria-label="type" id="types">
<input type="radio" class="btn-check" name="type" id="donation" autocomplete="off" checked>
<label class="btn btn-outline-light text-center flex-fill" for="donation"> <?php echo _('One-Time'); ?> </label>
<input type="radio" class="btn-check" name="type" id="sponsor" autocomplete="off">
<label class="btn btn-outline-light text-center flex-fill" for="sponsor"> <?php echo _('Monthly'); ?> </label>
</div>
<div role="group" aria-label="preset" id="presets" class="d-flex flex-wrap mt-3 row-cols-4 gap-2">
<input type="radio" class="btn-check" name="preset" id="preset5" autocomplete="off" checked=>
<label class="btn btn-outline-light text-center flex-fill col" for="preset5"> €5 </label>
<input type="radio" class="btn-check" name="preset" id="preset10" autocomplete="off">
<label class="btn btn-outline-light text-center flex-fill col" for="preset10"> €10 </label>
<input type="radio" class="btn-check" name="preset" id="preset25" autocomplete="off">
<label class="btn btn-outline-light text-center flex-fill col" for="preset25"> €25 </label>
<input type="radio" class="btn-check" name="preset" id="preset100" autocomplete="off">
<label class="btn btn-outline-light text-center flex-fill col" for="preset100"> €100 </label>
<input type="radio" class="btn-check" name="preset" id="preset200" autocomplete="off">
<label class="btn btn-outline-light text-center flex-fill col" for="preset200"> €200 </label>
<input type="radio" class="btn-check" name="preset" id="presetother" autocomplete="off">
<label class="btn btn-outline-light text-center flex-fill col" for="presetother"> Other </label>
</div>
<div class="input-group mt-3">
<select class="form-select bg-dark text-light border-secondary border-end-0 rounded-end-0 w-auto" id="currency" name="currency" aria-label="Currency" title="Currency">
<option value="eur" selected>€</option>
<option value="usd">$</option>
</select>
<input type="number" class="form-control bg-dark text-light border-secondary border-start-0 rounded-start-0 form-control-lg" name="amount" id="amount" min="0" step="0.01" value="5.00">
</div>
<div class="input-group mt-3">
<select class="form-select bg-dark text-light border-secondary" id="method" name="method">
<option value="stripe" selected title="<?php echo _('Credit card payment via Stripe'); ?>"> <?php echo _('Credit card (Stripe)'); ?> </option>
<option value="sepa" title="<?php echo _('Direct SEPA bank transfer using your own bank apps'); ?>"> <?php echo _('SEPA bank transfer'); ?> </option>
<option value="paypal" title="<?php echo _('Paypal allows to donate using your Paypal account, or a credit card') ?>"> <?php echo _('Paypal'); ?> </option>
<option value="github" title="<?php echo _('GitHub allows you to sponsor your favorite projects using your GitHub account, and a credit card') ?>"> <?php echo _('GitHub'); ?> </option>
<option value="opencollective" title="<?php echo _('OpenCollective acts as a fiscal host for open-source projects. You can donate with a credit card or bank account.') ?>"> <?php echo _('OpenCollective'); ?> </option>
</select>
<button class="btn btn-outline-light input-group-text" value="Submit" id="submit" type="button"> <?php echo _('Donate'); ?> </button>
</div>
<div class="sepainfo hidden" id="sepainfo">
<table class="table table-dark table-borderless">
<thead>
<tr>
<th colspan="2" class="fw-bold">
<?php echo _('SEPA Information'); ?>
</th>
</tr>
</thead>
<tbody>
<tr>
<td colspan="2"> <?php echo _('Please set up your SEPA bank transfer to'); ?>: </td>
</tr>
<tr>
<td><?php echo _('Beneficiary'); ?>:</td>
<td>The FreeCAD project association</td>
</tr>
<tr>
<td><?php echo _('Address'); ?>:</td>
<td>Rue Docteur Kuborn 31/46, 1070 Anderlecht, Belgium</td>
</tr>
<tr>
<td>IBAN:</td>
<td><b>BE04 0019 2896 4531</b></td>
</tr>
<tr>
<td>BIC/SWIFT:</td>
<td>GEBABEBBXXX</td>
</tr>
<tr>
<td><?php echo _('Bank agency'); ?>:</td>
<td>BNP Paribas Fortis</td>
<td>Rue de la Station 64, 1360 Perwez, Belgium</td>
</tr>
</tbody>
</table>
</div>
<div class="stripeinfo hidden mt-3" id="stripeinfo">
<p><?php echo _("While Stripe doesn't support monthly donations, you can still become a sponsor! Simply make a one-time donation equivalent to 12 months of support, and you'll gain access to the corresponding sponsoring tier. It's an easy and flexible way to contribute."); ?></p>
</div>
<div class="paypalinfo hidden mt-3" id="paypalinfo">
<p><?php echo _("Paypal charges up to 35% fee for transactions under $5. For small donations we recommend using other methods."); ?></p>
</div>
</div>
<div class="col-lg-7 text-light text-center text-lg-start px-md-4 ">
<div id="donationInfo">
<p> <?php echo _('If you are not sure or not able to commit to a regular donation, but still want to help the project, you can do a one-time donation, of any amount.'); ?> </p>
<p> <?php echo _('Choose freely the amount you wish to donate one time only.'); ?> </p>
</div>
<div id="sponsorInfo" class="hidden">
<p> <?php echo _('You can support FreeCAD by sponsoring it as an individual or organization through various platforms. Sponsorship provides a steady income for developers, allowing the FPA to plan ahead and enabling greater investment in FreeCAD. To encourage sponsorship, we offer different tiers, and unless you choose to remain anonymous, your name or company logo will be featured on our website accordingly.'); ?> </p>
<div class="accordion accordion-dark bg-dark text-white" id="sponsorAccordion">
<div class="accordion-item">
<h2 class="accordion-header" id="headingNormal">
<button class="accordion-button text-white bg-dark border-0" type="button" data-bs-toggle="collapse" data-bs-target="#collapseNormal" aria-expanded="true" aria-controls="collapseNormal"> ♥ <b class="normal"> <?php echo _('Normal sponsor'); ?> </b>
</button>
</h2>
<div id="collapseNormal" class="accordion-collapse collapse show" aria-labelledby="headingNormal" data-bs-parent="#sponsorAccordion">
<div class="accordion-body"> <?php echo _('from 1 USD / 1 EUR per month. You will not have your name displayed here, but you will have helped the project a lot anyway. Together, normal sponsors maintain the project on its feet as much as the bigger sponsors.'); ?> </div>
</div>
</div>
<div class="accordion-item">
<h2 class="accordion-header" id="headingBronze">
<button class="accordion-button text-white bg-dark border-0" type="button" data-bs-toggle="collapse" data-bs-target="#collapseBronze" aria-expanded="false" aria-controls="collapseBronze"> 🥉 <b class="bronze"> <?php echo _('Bronze sponsor'); ?> </b>
</button>
</h2>
<div id="collapseBronze" class="accordion-collapse collapse" aria-labelledby="headingBronze" data-bs-parent="#sponsorAccordion">
<div class="accordion-body"> <?php echo _('from 25 USD / 25 EUR per month. Your name or company name is displayed on this page.'); ?> </div>
</div>
</div>
<div class="accordion-item">
<h2 class="accordion-header" id="headingSilver">
<button class="accordion-button text-white bg-dark border-0" type="button" data-bs-toggle="collapse" data-bs-target="#collapseSilver" aria-expanded="false" aria-controls="collapseSilver"> 🥈 <b class="silver"> <?php echo _('Silver sponsor'); ?> </b>
</button>
</h2>
<div id="collapseSilver" class="accordion-collapse collapse" aria-labelledby="headingSilver" data-bs-parent="#sponsorAccordion">
<div class="accordion-body"> <?php echo _('from 100 USD / 100 EUR per month. Your name or company name is displayed on this page, with a link to your website, and a one-line description text.'); ?> </div>
</div>
</div>
<div class="accordion-item">
<h2 class="accordion-header" id="headingGold">
<button class="accordion-button text-white bg-dark border-0" type="button" data-bs-toggle="collapse" data-bs-target="#collapseGold" aria-expanded="false" aria-controls="collapseGold"> 🥇 <b class="gold"> <?php echo _('Gold sponsor'); ?> </b>
</button>
</h2>
<div id="collapseGold" class="accordion-collapse collapse" aria-labelledby="headingGold" data-bs-parent="#sponsorAccordion">
<div class="accordion-body"> <?php echo _('from 200 USD / 200 EUR per month. Your name or company name and logo displayed on this page, with a link to your website and a custom description text. Companies that have helped FreeCAD early on also appear under Gold sponsors.'); ?> </div>
</div>
</div>
</div>
<p> <?php echo _("The FPA's <a href=\"https://fpa.freecad.org/handbook/process/accepting-donations.html\">donation rules</a> apply to all donations."); ?> </p>
<p> <?php echo _("Instead of donating each month, you might find it more comfortable to make a one-time donation that, when divided by twelve, would give you right to enter a sponsoring tier. Don't hesitate to do so!"); ?> </p>
<p> <?php echo _('Choose freely the amount you wish to donate each month.'); ?> </p>
<p> <?php echo _('Please inform your forum name or twitter handle as a note in your transfer, or <a href=mailto:fpa@freecad.org>reach to us</a>, so we can give you proper credits!'); ?> </p>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>