|
25 | 25 | <div class="dropdown_frame"> |
26 | 26 | <select id="donation_amount" class="dropdown"> |
27 | 27 | <option value="100">$1.00</option> |
28 | | - <option value="200">$2.00</option> |
29 | | - <option value="404">$4.04</option> |
30 | | - <option value="502">$5.02</option> |
| 28 | + <option value="500">$5.00</option> |
31 | 29 | <option value="1000">$10.00</option> |
32 | | - <option value="1337">$13.37</option> |
33 | | - <option value="2500">$25.00</option> |
34 | | - <option value="9001">$90.01</option> |
| 30 | + <option value="1500">$15.00</option> |
| 31 | + <option value="2000">$20.00</option> |
| 32 | + <option value="5000">$50.00</option> |
| 33 | + <option value="10000">$100.00</option> |
35 | 34 | </select> |
36 | 35 | </div> |
37 | 36 | <button id="donate_button" class="button">Donate Now</button> |
38 | 37 | </div> |
39 | 38 |
|
40 | 39 | <script> |
41 | 40 | var handler = StripeCheckout.configure({ |
42 | | - key: 'pk_migDTfk5iGQSrQE0ONijdnKXB0P5Z', |
43 | | - image: 'img/donate_small.png', |
44 | | - token: function(token, args) { |
45 | | - } |
| 41 | + key: '<%=stripePublishKey%>', |
| 42 | + image: 'img/donate_small.png', |
| 43 | + token: function(token, args) { |
| 44 | + token.price = Number(document.getElementById('donation_amount').value); |
| 45 | +
|
| 46 | + $.ajax({ |
| 47 | + type: 'POST', |
| 48 | + url: '/donate', |
| 49 | + data: { data: JSON.stringify(token) }, |
| 50 | + success: function(data) { |
| 51 | + window.alert("Thanks for your donation!"); |
| 52 | + }, |
| 53 | + error: function(data) { |
| 54 | + window.alert("There was a problem processing your donation. Please make sure your card information is valid and try again."); |
| 55 | + } |
| 56 | + }); |
| 57 | + } |
46 | 58 | }); |
| 59 | +
|
47 | 60 | document.getElementById('donate_button').addEventListener('click', function(e) { |
48 | | - handler.open({ |
49 | | - name: 'Random User API', |
50 | | - description: 'Thanks for donating!', |
51 | | - amount: document.getElementById('donation_amount').value |
52 | | - }); |
53 | | - e.preventDefault(); |
| 61 | + handler.open({ |
| 62 | + name: 'Random User API', |
| 63 | + description: 'Thanks for donating!', |
| 64 | + amount: Number(document.getElementById('donation_amount').value) |
| 65 | + }); |
| 66 | + e.preventDefault(); |
54 | 67 | }); |
55 | 68 | </script> |
56 | 69 |
|
57 | | - <p style="text-align: center;">Don't have your card details handy? <a href="https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=QBRGZ79MNX9W6" target="_blank">Click here to donate via PayPal</a></p> |
| 70 | + <%//<p style="text-align: center;">Don't have your card details handy? <a href="https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=QBRGZ79MNX9W6" target="_blank">Click here to donate via PayPal</a></p>%> |
| 71 | +
|
58 | 72 |
|
59 | 73 | </section> |
60 | 74 |
|
|
0 commit comments