<commit_before><!DOCTYPE html>
<!--suppress JSUnresolvedLibraryURL -->
<html>
<head>
	<title>Static</title>
	<meta name="viewport" content="width=device-width, initial-scale=1.0">
	<link rel="stylesheet" type="text/css" href="webjars/bootstrap/3.3.7/css/bootstrap.min.css"/>
	<link rel="stylesheet" href="styles.css"/>
</head>
<body>

<script src="https://checkout.stripe.com/checkout.js"></script>
<script type="text/javascript" src="https://js.stripe.com/v2/"></script>

<div class="container">
	<div id="alertTop" class="alert-top" role="alert"></div>
	<div class="donation-selection">
		<p>Donate:</p>
		<button id="donateButton_5" class="btn btn-primary express-button">$5</button>
		<button id="donateButton_10" class="btn btn-primary express-button">$10</button>
		<button id="donateButton_25" class="btn btn-primary express-button">$25</button>
		<button id="donateButton_50" class="btn btn-primary express-button">$50</button>
		<button id="donateButton_100" class="btn btn-primary express-button">$100</button>
		<br/>
		<br/>
		<p>Or, donate a specific amount:</p>
		<form>
			<fieldset class="form-group">
				<div class="input-group">
					<span class="input-group-addon">$</span>
					<input type="number" class="form-control" id="donationAmount" name="amount" placeholder="Enter amount" style="width:150px">
					<button id="donateButton_custom" class="btn btn-primary" style="margin-left: -2px;">Donate</button>
				</div>
			</fieldset>
		</form>
	</div>

	<div class="multi-pay-options">
		<h3 align="center">Choose payment method</h3>
		<h4 align="center">(Apple Pay or Credit Card)</h4>
		<br/>
		<button id="apple-pay-button" class="apple-pay-button"></button>
		<br/>
		<button id="credit-pay-button" type="button" class="credit-pay-button btn btn-default" aria-label="Center Align">
			<span class="glyphicon glyphicon-credit-card" aria-hidden="true"></span>
			Credit Card
		</button>
		<br/>
		<button id="cancel-button" type="button" class="credit-pay-button btn btn-default" aria-label="Center Align">
			<!--<span class="glyphicon" aria-hidden="true"></span>-->
			Cancel
		</button>
		<br/>
		<br/>
		<div id="donationAmountAlert" class="alert alert-info" role="alert"></div>
	</div>

</div>

<div id="errorDialog" class="modal fade" tabindex="-1" role="dialog">
	<div class="modal-dialog" role="document">
		<div class="modal-content">
			<div class="modal-header">
				<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
				<h4 class="modal-title">Payment Failed</h4>
			</div>
			<div class="modal-body">
				<p id="errorMessage"></p>
			</div>
			<div class="modal-footer">
				<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
			</div>
		</div>
	</div>
</div>

<script type="text/javascript" src="webjars/jquery/2.0.3/jquery.min.js"></script>

<script>
	"use strict";

	function init(publishableKey, organizationDisplayName, applyPayEnabledConfigured) {
		var submittedAmount = 0;
		var submittedAmountStr = "";
		var applePayEnabled = false;

		function doSuccess(amount, email) {
			var loc = "successfulPayment?amount=" + amount;
			if (email) {
				loc += "&email=" + email;
			}
			window.location = loc;
		}

		function errorDialog(errorMessage) {
			$("#errorMessage").text(errorMessage);
			$('#errorDialog').modal();
		}

		var handler = StripeCheckout.configure({
			key: publishableKey,
			image: 'https://stripe.com/img/documentation/checkout/marketplace.png',
			locale: 'auto',
			currency: 'usd',
			token: function(token) {
				// You can access the token ID with `token.id`.
				// Get the token ID to your server-side code for use.
				var param = {
					id: token.id,
					currency: 'usd',
					amount: submittedAmount,
					description: token.email,
					token: token
				};
				// console.log(param);
				$.ajax({
					type: 'POST',
					url: 'submitPayment',
					data: JSON.stringify(param),
					contentType: "application/json",
					dataType: 'json'
				}).done(function(data) {
					console.log(data);
					if (!data.error) {
						doSuccess(data.amount, data.email);
					} else {
						errorDialog(data.errorMessage);
					}
				}).fail(function(jqXHR, textStatus, errorThrown) {
					errorDialog(textStatus + ": " + errorThrown);
				});
			}
		});

		function beginApplePay() {
			var paymentRequest = {
				requiredShippingContactFields: ['email'],
				countryCode: 'US',
				currencyCode: 'USD',
				total: {
					label: organizationDisplayName,
					amount: submittedAmountStr
				}
			};
			var session = Stripe.applePay.buildSession(paymentRequest,
				function(result, completion) {

					$.post('submitPayment', {token: result.token.id, description: result.shippingContact.emailAddress, logData: JSON.stringify(result)}).done(function() {
						completion(ApplePaySession.STATUS_SUCCESS);
						// You can now redirect the user to a receipt page, etc.
						doSuccess(submittedAmount, null);
					}).fail(function(x, textStatus, errorThrown) {
						completion(ApplePaySession.STATUS_FAILURE);
						errorDialog(textStatus + ": " + errorThrown);
					});

				}, function(error) {
					console.log(error.message);
					errorDialog(error.message);
				});

			session.begin();
		}<commit_msg>Show modal dialog while processing payment<commit_after><!DOCTYPE html>
<!--suppress JSUnresolvedLibraryURL -->
<html>
<head>
	<title>Static</title>
	<meta name="viewport" content="width=device-width, initial-scale=1.0">
	<link rel="stylesheet" type="text/css" href="webjars/bootstrap/3.3.7/css/bootstrap.min.css"/>
	<link rel="stylesheet" href="styles.css"/>
</head>
<body>

<script src="https://checkout.stripe.com/checkout.js"></script>
<script type="text/javascript" src="https://js.stripe.com/v2/"></script>

<div class="container">
	<div id="alertTop" class="alert-top" role="alert"></div>
	<div class="donation-selection">
		<p>Donate:</p>
		<button id="donateButton_5" class="btn btn-primary express-button">$5</button>
		<button id="donateButton_10" class="btn btn-primary express-button">$10</button>
		<button id="donateButton_25" class="btn btn-primary express-button">$25</button>
		<button id="donateButton_50" class="btn btn-primary express-button">$50</button>
		<button id="donateButton_100" class="btn btn-primary express-button">$100</button>
		<br/>
		<br/>
		<p>Or, donate a specific amount:</p>
		<form>
			<fieldset class="form-group">
				<div class="input-group">
					<span class="input-group-addon">$</span>
					<input type="number" class="form-control" id="donationAmount" name="amount" placeholder="Enter amount" style="width:150px">
					<button id="donateButton_custom" class="btn btn-primary" style="margin-left: -2px;">Donate</button>
				</div>
			</fieldset>
		</form>
	</div>

	<div class="multi-pay-options">
		<h3 align="center">Choose payment method</h3>
		<h4 align="center">(Apple Pay or Credit Card)</h4>
		<br/>
		<button id="apple-pay-button" class="apple-pay-button"></button>
		<br/>
		<button id="credit-pay-button" type="button" class="credit-pay-button btn btn-default" aria-label="Center Align">
			<span class="glyphicon glyphicon-credit-card" aria-hidden="true"></span>
			Credit Card
		</button>
		<br/>
		<button id="cancel-button" type="button" class="credit-pay-button btn btn-default" aria-label="Center Align">
			<!--<span class="glyphicon" aria-hidden="true"></span>-->
			Cancel
		</button>
		<br/>
		<br/>
		<div id="donationAmountAlert" class="alert alert-info" role="alert"></div>
	</div>

</div>

<div id="errorDialog" class="modal fade" tabindex="-1" role="dialog">
	<div class="modal-dialog" role="document">
		<div class="modal-content">
			<div class="modal-header">
				<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
				<h4 class="modal-title">Payment Failed</h4>
			</div>
			<div class="modal-body">
				<p id="errorMessage"></p>
			</div>
			<div class="modal-footer">
				<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
			</div>
		</div>
	</div>
</div>

<div id="processingPaymentDialog" class="modal fade" tabindex="-1" role="dialog">
	<div class="modal-dialog" role="document">
		<div class="modal-content">
			<div class="modal-header">
				<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
				<h4 class="modal-title">Processing your payment...</h4>
			</div>
			<!--
			<div class="modal-body">
			</div>
			-->
		</div>
	</div>
</div>

<script type="text/javascript" src="webjars/jquery/2.0.3/jquery.min.js"></script>

<script>
	"use strict";

	function init(publishableKey, organizationDisplayName, applyPayEnabledConfigured) {
		var submittedAmount = 0;
		var submittedAmountStr = "";
		var applePayEnabled = false;

		function doSuccess(amount, email) {
			var loc = "successfulPayment?amount=" + amount;
			if (email) {
				loc += "&email=" + email;
			}
			window.location = loc;
		}

		function errorDialog(errorMessage) {
			$("#errorMessage").text(errorMessage);
			$('#errorDialog').modal();
		}

		var handler = StripeCheckout.configure({
			key: publishableKey,
			image: 'https://stripe.com/img/documentation/checkout/marketplace.png',
			locale: 'auto',
			currency: 'usd',
			token: function(token) {
				// You can access the token ID with `token.id`.
				// Get the token ID to your server-side code for use.
				var param = {
					id: token.id,
					currency: 'usd',
					amount: submittedAmount,
					description: token.email,
					token: token
				};
				// console.log(param);
				$('#processingPaymentDialog').modal();
				$.ajax({
					type: 'POST',
					url: 'submitPayment',
					data: JSON.stringify(param),
					contentType: "application/json",
					dataType: 'json'
				}).done(function(data) {
					$('#processingPaymentDialog').modal('hide');
					console.log(data);
					if (!data.error) {
						doSuccess(data.amount, data.email);
					} else {
						errorDialog(data.errorMessage);
					}
				}).fail(function(jqXHR, textStatus, errorThrown) {
					$('#processingPaymentDialog').modal('hide');
					errorDialog(textStatus + ": " + errorThrown);
				}).always(function() {
					$('#processingPaymentDialog').modal('hide');
				});
			}
		});

		function beginApplePay() {
			var paymentRequest = {
				requiredShippingContactFields: ['email'],
				countryCode: 'US',
				currencyCode: 'USD',
				total: {
					label: organizationDisplayName,
					amount: submittedAmountStr
				}
			};
			var session = Stripe.applePay.buildSession(paymentRequest,
				function(result, completion) {
					$('#processingPaymentDialog').modal();
					$.post('submitPayment', {token: result.token.id, description: result.shippingContact.emailAddress, logData: JSON.stringify(result)}).done(function() {
						completion(ApplePaySession.STATUS_SUCCESS);
						// You can now redirect the user to a receipt page, etc.
						doSuccess(submittedAmount, null);
					}).fail(function(x, textStatus, errorThrown) {
						completion(ApplePaySession.STATUS_FAILURE);
						errorDialog(textStatus + ": " + errorThrown);
					}).always(function() {
						$('#processingPaymentDialog').modal('hide');
					});


				}, function(error) {
					$('#processingPaymentDialog').modal('hide');
					console.log(error.message);
					errorDialog(error.message);
				});

			session.begin();
		}
{'fraction_non_alphanumeric': 0.1806880854416528, 'fraction_numerical': 0.007441127549680469, 'mean_word_length': 4.079590929301912, 'pattern_counts': {'":': 4, '<': 214, '<?xml version=': 0, '>': 214, 'https://': 6, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3382184', 'n_tokens_mistral': 4420, 'n_tokens_neox': 3679, 'n_words': 724}