I have a Google Form which I have created for class registrations. I'm writing my first Google script (based on what I've learned from the Google tutorial material) to call an HTML page when the onSubmit event is triggered by the user clicking the Submit button.
The reason for calling the HTML page is to direct the user to select PayPal options contained within the page. I couldn't see a way to add them to the Settings page displayed after submission. or to the form itself, so I decided to create second page.
The code I've cobbled together (yes, I'm a noob) is
function goToPayment() {
//onSubmit, goes to the PayPal payment page so
//that users pay for the class
function doGet(request) {
return HtmlService.createTemplateFromFile('PayPayPayment.html')
.evaluate()
.setSandboxMode(HtmlService.SandboxMode.IFRAME);
}
function include(filename) {
return HtmlService.createHtmlOutputFromFile(filename)
.getContent();
}
}
The page that this calls is:
<!DOCTYPE html>
<html>
<head>
<base target="_top">
</head>
<body>
<h1>Payment</h1>
<p>
Complete registration for the Introduction to Arduino
class by paying for it with PayPal. All major credit
cards accepted.
</p>
<form action="https://www.paypal.com/cgi-bin/webscr" method="post" target="_top">
<input type="hidden" name="cmd" value="_s-xclick">
<input type="hidden" name="hosted_button_id" value="PutValueHere">
<table>
<tr><td><input type="hidden" name="on0" value="Early bird pricing!">Early bird pricing!</td></tr><tr><td><select name="os0">
<option value="Member price (before May 11th) - kit, instruction, lunch">Member price (before May 11th) - kit, instruction, lunch $145.00 USD</option>
<option value="Member price (before May 11th) - instruction, lunch">Member price (before May 11th) - instruction, lunch $50.00 USD</option>
<option value="Non-member price (before May 11th) - kit, instruction, lunch">Non-member price (before May 11th) - kit, instruction, lunch $165.00 USD</option>
<option value="Non-member price (before May 11th) - instruction, lunch">Non-member price (before May 11th) - instruction, lunch $60.00 USD</option>
</select> </td></tr>
</table>
<input type="hidden" name="currency_code" value="USD">
<input type="image" src="https://www.paypalobjects.com/en_US/i/btn/btn_paynow_SM.gif" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!">
<img alt="" border="0" src="https://www.paypalobjects.com/en_US/i/scr/pixel.gif" width="1" height="1">
</form>
</body>
</html>
The script passes unit tests but is not being called when I test the form. Any ideas or suggestions as to how to complete this task? Open to suggestions as to work-arounds as well as to where I should fix my code.
doGet()
function is inside of thegoToPayment(
function block. It that intentional? Is thegoToPayment(
function, the function that is being triggered by the "On Form Submit" event? – Alan Wells