-
Notifications
You must be signed in to change notification settings - Fork 15
/
sample.html
148 lines (133 loc) · 4.19 KB
/
sample.html
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
<!DOCTYPE html>
<html>
<head>
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css">
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>Spreedly Express Demo Page</title>
<script src="https://core.spreedly.com/iframe/express-3.min.js" id="express-script"></script>
<script type="text/javascript">
var environmentKey= "TbWAYgG7qaagGBh7hPjXQxS4DM4"
var options = {
company_name: "Food 'n Stuff",
sidebar_top_description: "This is where you can buy all your food and most of your stuff",
sidebar_bottom_description: "2 ground beef </br> 2 crows"}
var enableButton = function(){
document.getElementById("ready-to-pay").disabled = false;
}
SpreedlyExpress.onInit(enableButton);
var handlePaymentToken = function(token, formData) {
var form = document.getElementById('payment-form')
var input = document.createElement("input");
input.type = "text";
input.name = "payment_method_token";
input.value = token;
form.appendChild(input)
form.submit();
}
SpreedlyExpress.onPaymentMethod(handlePaymentToken);
SpreedlyExpress.init(environmentKey,options);
var validateBeforeOpeningExpress = function() {
var valid_form = document.getElementById('payment-form').checkValidity();
if(!valid_form) {
return;
}
var name = document.getElementById('full_name').value;
var displayOptions = {
'amount' : "$24.24"
}
if (name !== ''){
displayOptions['full_name'] = name;
}
SpreedlyExpress.setDisplayOptions(displayOptions);
var paymentMethodParameters = {};
var fieldsToAddToExpress = ["address1","city","state","zip",]
for ( var i = 0 ; i < fieldsToAddToExpress.length ; i ++){
options[fieldsToAddToExpress[i]] = document.getElementById(fieldsToAddToExpress[i]).value;
}
SpreedlyExpress.openView();
return false;
}
</script>
<style>
#content{
width:500px;
margin:0 auto;
}
</style>
</head>
<body>
<div class="container" id="content">
<h1> Food and Stuff </h1>
<h2> Invoice</h2>
<table class="table table-bordered table-striped table-hover table-condensed">
<tr>
<th>Item Number</th>
<th>Description</th>
<th>Quantity</th>
<th>Price</th>
<th>Total</th>
</tr>
<tr>
<td>F-01</td>
<td>Ground Beef</td>
<td>2</td>
<td>10.12</td>
<td>10.12</td>
</tr>
<tr>
<td>S-03</td>
<td>Crow</td>
<td>2</td>
<td>2.00</td>
<td>4.00</td>
</tr>
<tr>
<td>Total</td>
<td></td>
<td>4 items</td>
<td></td>
<td>24.24</td>
</tr>
</table>
<br/>
<div class="form-group">
<form class="form-horizontal" role="form" action="/sampleresult.html" method="GET" id="payment-form" onsubmit="return false;" >
<div class="form-group">
<label class="control-label col-sm-1" for="full_name">Name</label>
<div class="col-sm-8">
<input class="form-control" type="text" id="full_name" name="full_name" required>
</div>
</div>
<div class="form-group">
<label class="control-label col-sm-1" for="address1">Street</label>
<div class="col-sm-8">
<input class="form-control" type="text" id="address1" name="address1" required>
</div>
</div>
<div class="form-group">
<label class="control-label col-sm-1" for="city">City</label>
<div class="col-sm-8">
<input class="form-control" type="text" id="city" name="city" required>
</div>
</div>
<div class="form-group">
<label class="control-label col-sm-1" for="state"">State</label>
<div class="col-sm-2">
<input class="form-control" type="text" id="state"" name="state" required>
</div>
<label class="control-label col-sm-1" for="zip">Zip</label>
<div class="col-sm-3">
<input class="form-control" type="text" id="zip" name="zip">
</div>
</div>
<div class="col-sm-offset-2 col-sm-4">
<button id="ready-to-pay" onclick="validateBeforeOpeningExpress();" class="btn btn-primary btn-block" disabled="true">Continue</button>
</div>
</script>
</form>
</div>
</div>
</body>
</html>