This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision Next revision Both sides next revision | ||
tickets [2021/11/15 23:00] conan |
tickets [2021/11/29 19:24] conan |
||
---|---|---|---|
Line 25: | Line 25: | ||
Event 6 will now take place on the 15th-17th of July 2022 at Consall Scout Camp in Staffordshire. Early booking ends 27th of May. | Event 6 will now take place on the 15th-17th of July 2022 at Consall Scout Camp in Staffordshire. Early booking ends 27th of May. | ||
+ | <html><div id="smart-button-container"> | ||
+ | <div style="text-align: center;"> | ||
+ | <div style="margin-bottom: 1.25rem;"> | ||
+ | <p>Ticket for OSLRP Event 6</p> | ||
+ | <select id="item-options"><option value="Early Bird Adult Ticket" price="85">Early Bird Adult Ticket - 85 GBP</option><option value="Young Person (12-15) Ticket" price="20">Young Person (12-15) Ticket - 20 GBP</option><option value="Young Person (7-11) Ticket" price="15">Young Person (7-11) Ticket - 15 GBP</option><option value="Young Person (under 7) Ticket" price="5">Young Person (under 7) Ticket - 5 GBP</option><option value="Redeem 2020 Event Ticket" price="0">Redeem 2020 Event Ticket - 0 GBP</option></select> | ||
+ | <select style="visibility: hidden" id="quantitySelect"></select> | ||
+ | </div> | ||
+ | <div id="paypal-button-container"></div> | ||
+ | </div> | ||
+ | </div> | ||
+ | <script src="https://www.paypal.com/sdk/js?client-id=sb&enable-funding=venmo¤cy=GBP" data-sdk-integration-source="button-factory"></script> | ||
+ | <script> | ||
+ | function initPayPalButton() { | ||
+ | var shipping = 0; | ||
+ | var itemOptions = document.querySelector("#smart-button-container #item-options"); | ||
+ | var quantity = parseInt(); | ||
+ | var quantitySelect = document.querySelector("#smart-button-container #quantitySelect"); | ||
+ | if (!isNaN(quantity)) { | ||
+ | quantitySelect.style.visibility = "visible"; | ||
+ | } | ||
+ | var orderDescription = 'Ticket for OSLRP Event 6'; | ||
+ | if(orderDescription === '') { | ||
+ | orderDescription = 'Item'; | ||
+ | } | ||
+ | paypal.Buttons({ | ||
+ | style: { | ||
+ | shape: 'rect', | ||
+ | color: 'gold', | ||
+ | layout: 'vertical', | ||
+ | label: 'buynow', | ||
+ | | ||
+ | }, | ||
+ | createOrder: function(data, actions) { | ||
+ | var selectedItemDescription = itemOptions.options[itemOptions.selectedIndex].value; | ||
+ | var selectedItemPrice = parseFloat(itemOptions.options[itemOptions.selectedIndex].getAttribute("price")); | ||
+ | var tax = (0 === 0 || false) ? 0 : (selectedItemPrice * (parseFloat(0)/100)); | ||
+ | if(quantitySelect.options.length > 0) { | ||
+ | quantity = parseInt(quantitySelect.options[quantitySelect.selectedIndex].value); | ||
+ | } else { | ||
+ | quantity = 1; | ||
+ | } | ||
+ | |||
+ | tax *= quantity; | ||
+ | tax = Math.round(tax * 100) / 100; | ||
+ | var priceTotal = quantity * selectedItemPrice + parseFloat(shipping) + tax; | ||
+ | priceTotal = Math.round(priceTotal * 100) / 100; | ||
+ | var itemTotalValue = Math.round((selectedItemPrice * quantity) * 100) / 100; | ||
+ | |||
+ | return actions.order.create({ | ||
+ | purchase_units: [{ | ||
+ | description: orderDescription, | ||
+ | amount: { | ||
+ | currency_code: 'GBP', | ||
+ | value: priceTotal, | ||
+ | breakdown: { | ||
+ | item_total: { | ||
+ | currency_code: 'GBP', | ||
+ | value: itemTotalValue, | ||
+ | }, | ||
+ | shipping: { | ||
+ | currency_code: 'GBP', | ||
+ | value: shipping, | ||
+ | }, | ||
+ | tax_total: { | ||
+ | currency_code: 'GBP', | ||
+ | value: tax, | ||
+ | } | ||
+ | } | ||
+ | }, | ||
+ | items: [{ | ||
+ | name: selectedItemDescription, | ||
+ | unit_amount: { | ||
+ | currency_code: 'GBP', | ||
+ | value: selectedItemPrice, | ||
+ | }, | ||
+ | quantity: quantity | ||
+ | }] | ||
+ | }] | ||
+ | }); | ||
+ | }, | ||
+ | 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></html> | ||
==== Event 7 Tickets ==== | ==== Event 7 Tickets ==== | ||
Line 30: | Line 132: | ||
Event 7 takes place on the 2nd-4th of October 2020 at Barnswood Scout Camp near Macclesfield. Early booking ends 21st of August. | Event 7 takes place on the 2nd-4th of October 2020 at Barnswood Scout Camp near Macclesfield. Early booking ends 21st of August. | ||
+ | <html><div id="smart-button-container"> | ||
+ | <div style="text-align: center;"> | ||
+ | <div style="margin-bottom: 1.25rem;"> | ||
+ | <p>Ticket for OSLRP Event 7</p> | ||
+ | <select id="item-options"><option value="Early Bird Adult Ticket" price="85">Early Bird Adult Ticket - 85 GBP</option><option value="Young Person (12-15) Ticket" price="20">Young Person (12-15) Ticket - 20 GBP</option><option value="Young Person (7-11) Ticket" price="15">Young Person (7-11) Ticket - 15 GBP</option><option value="Young Person (under 7) Ticket" price="5">Young Person (under 7) Ticket - 5 GBP</option><option value="Redeem 2020 Event Ticket" price="0">Redeem 2020 Event Ticket - 0 GBP</option></select> | ||
+ | <select style="visibility: hidden" id="quantitySelect"></select> | ||
+ | </div> | ||
+ | <div id="paypal-button-container"></div> | ||
+ | </div> | ||
+ | </div> | ||
+ | <script src="https://www.paypal.com/sdk/js?client-id=sb&enable-funding=venmo¤cy=GBP" data-sdk-integration-source="button-factory"></script> | ||
+ | <script> | ||
+ | function initPayPalButton() { | ||
+ | var shipping = 0; | ||
+ | var itemOptions = document.querySelector("#smart-button-container #item-options"); | ||
+ | var quantity = parseInt(); | ||
+ | var quantitySelect = document.querySelector("#smart-button-container #quantitySelect"); | ||
+ | if (!isNaN(quantity)) { | ||
+ | quantitySelect.style.visibility = "visible"; | ||
+ | } | ||
+ | var orderDescription = 'Ticket for OSLRP Event 7'; | ||
+ | if(orderDescription === '') { | ||
+ | orderDescription = 'Item'; | ||
+ | } | ||
+ | paypal.Buttons({ | ||
+ | style: { | ||
+ | shape: 'rect', | ||
+ | color: 'gold', | ||
+ | layout: 'vertical', | ||
+ | label: 'buynow', | ||
+ | | ||
+ | }, | ||
+ | createOrder: function(data, actions) { | ||
+ | var selectedItemDescription = itemOptions.options[itemOptions.selectedIndex].value; | ||
+ | var selectedItemPrice = parseFloat(itemOptions.options[itemOptions.selectedIndex].getAttribute("price")); | ||
+ | var tax = (0 === 0 || false) ? 0 : (selectedItemPrice * (parseFloat(0)/100)); | ||
+ | if(quantitySelect.options.length > 0) { | ||
+ | quantity = parseInt(quantitySelect.options[quantitySelect.selectedIndex].value); | ||
+ | } else { | ||
+ | quantity = 1; | ||
+ | } | ||
+ | |||
+ | tax *= quantity; | ||
+ | tax = Math.round(tax * 100) / 100; | ||
+ | var priceTotal = quantity * selectedItemPrice + parseFloat(shipping) + tax; | ||
+ | priceTotal = Math.round(priceTotal * 100) / 100; | ||
+ | var itemTotalValue = Math.round((selectedItemPrice * quantity) * 100) / 100; | ||
+ | |||
+ | return actions.order.create({ | ||
+ | purchase_units: [{ | ||
+ | description: orderDescription, | ||
+ | amount: { | ||
+ | currency_code: 'GBP', | ||
+ | value: priceTotal, | ||
+ | breakdown: { | ||
+ | item_total: { | ||
+ | currency_code: 'GBP', | ||
+ | value: itemTotalValue, | ||
+ | }, | ||
+ | shipping: { | ||
+ | currency_code: 'GBP', | ||
+ | value: shipping, | ||
+ | }, | ||
+ | tax_total: { | ||
+ | currency_code: 'GBP', | ||
+ | value: tax, | ||
+ | } | ||
+ | } | ||
+ | }, | ||
+ | items: [{ | ||
+ | name: selectedItemDescription, | ||
+ | unit_amount: { | ||
+ | currency_code: 'GBP', | ||
+ | value: selectedItemPrice, | ||
+ | }, | ||
+ | quantity: quantity | ||
+ | }] | ||
+ | }] | ||
+ | }); | ||
+ | }, | ||
+ | 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></html> | ||
+ | |||
+ | <html><-- | ||
=== Event 5 Meal Tickets === | === Event 5 Meal Tickets === |