Skip to content

Commit dba4e2a

Browse files
author
Tim Messerschmidt
committed
Adds sandbox environment for generator
This adds enabling sandbox mode for testing. The functionality was already existing but not added to the generator yet.
1 parent 0bca6d0 commit dba4e2a

2 files changed

Lines changed: 62 additions & 7 deletions

File tree

index.html

Lines changed: 49 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,15 @@ <h3 id="custom">Customize your button</h3>
8989
<input type="text" id="buyNowCallback" name="callback" placeholder="http://mysite.com/callback" value="" autocomplete="off" />
9090
</div>
9191
</div>
92+
<div class="control-group">
93+
<label class="control-label" for="environment">Environment</label>
94+
<div class="controls">
95+
<label class="checkbox">
96+
<input type="checkbox" name="env" value="sandbox">
97+
Sandbox
98+
</label>
99+
</div>
100+
</div>
92101
</form>
93102

94103
<div class="modal-footer">
@@ -166,6 +175,15 @@ <h3 id="custom">Customize your button</h3>
166175
<input type="text" id="buyNowCallback" name="callback" value="" autocomplete="off" placeholder="http://mysite.com/callback" />
167176
</div>
168177
</div>
178+
<div class="control-group">
179+
<label class="control-label" for="environment">Environment</label>
180+
<div class="controls">
181+
<label class="checkbox">
182+
<input type="checkbox" name="env" value="sandbox">
183+
Sandbox
184+
</label>
185+
</div>
186+
</div>
169187
</form>
170188
<div class="modal-footer">
171189
<button class="btn" data-dismiss="modal">Close</button>
@@ -239,6 +257,15 @@ <h3 id="custom">Customize your button</h3>
239257
<input type="text" id="buyNowCallback" name="callback" placeholder="http://mysite.com/callback" value="" autocomplete="off" />
240258
</div>
241259
</div>
260+
<div class="control-group">
261+
<label class="control-label" for="environment">Environment</label>
262+
<div class="controls">
263+
<label class="checkbox">
264+
<input type="checkbox" name="env" value="sandbox">
265+
Sandbox
266+
</label>
267+
</div>
268+
</div>
242269
</form>
243270

244271
<div class="modal-footer">
@@ -315,6 +342,15 @@ <h3 id="custom">Customize your button</h3>
315342
<input type="text" id="buyNowCallback" name="callback" placeholder="http://mysite.com/callback" value="" autocomplete="off" />
316343
</div>
317344
</div>
345+
<div class="control-group">
346+
<label class="control-label" for="environment">Environment</label>
347+
<div class="controls">
348+
<label class="checkbox">
349+
<input type="checkbox" name="env" value="sandbox">
350+
Sandbox
351+
</label>
352+
</div>
353+
</div>
318354
</form>
319355

320356
<div class="modal-footer">
@@ -393,6 +429,15 @@ <h3 id="custom">Customize your button</h3>
393429
<input type="text" id="buyNowCallback" name="callback" placeholder="http://mysite.com/callback" value="" autocomplete="off" />
394430
</div>
395431
</div>
432+
<div class="control-group">
433+
<label class="control-label" for="environment">Environment</label>
434+
<div class="controls">
435+
<label class="checkbox">
436+
<input type="checkbox" name="env" value="sandbox">
437+
Sandbox
438+
</label>
439+
</div>
440+
</div>
396441
</form>
397442

398443
<div class="modal-footer">
@@ -412,7 +457,7 @@ <h3 id="custom">Customize your button</h3>
412457
</div>
413458

414459
</div>
415-
<p><em>Important:</em> Payments made using this code will be live and not test payments.</p>
460+
<p><em>Important:</em> Unless you enable the sandbox environment all payments made using this code will be live and not test payments.</p>
416461

417462

418463
<h3 id="addbutton">Add the button to your site</h3>
@@ -443,10 +488,12 @@ <h3 id="addbutton">Add the button to your site</h3>
443488
<p>Copy and paste the HTML snippet you customized above, and you're ready to start selling!</p>
444489
</li>
445490
</ol>
491+
492+
<h3>Environment</h3>
493+
<p>In order to test your implementation before going live you can use our sandbox environment. Please check the <a href="http://developer.paypal.com/">Developer Portal</a> for further information.</p>
446494

447495
<h3>Callback</h3>
448496
<p>On completion of a transaction you can get a payment notification (<a href="https://www.x.com/developers/paypal/documentation-tools/ipn/integration-guide/IPNIntro">IPN</a>) on a callback URL you specify using the callback attribute. An IPN simulator is <a href="https://developer.paypal.com/webapps/developer/applications/ipn_simulator">available on the sandbox</a> to help you test your integration.</p>
449-
450497
<h3>Customization</h3>
451498
<p>For advanced needs, there's a JavaScript API that can be used to pragmatically create buttons, localization support, and the ability to create user-editable inputs. Find out how in the <a href="https://github.com/paypal/JavaScriptButtons#editable-fields">README</a> file.
452499

js/app.js

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,18 @@
4141
// Build a map out of the form data
4242
for (i = 0, len = inputs.length; i < len; i++) {
4343
input = $(inputs[i]);
44-
45-
data[input.attr('name')] = {
46-
value: input.val()
47-
};
44+
45+
if(input.is(':checkbox')) {
46+
if(input.is(':checked')) {
47+
data[input.attr('name')] = {
48+
value: input.val()
49+
};
50+
}
51+
} else {
52+
data[input.attr('name')] = {
53+
value: input.val()
54+
};
55+
}
4856
}
4957

5058
// Create a script tag to use as the HTML
@@ -81,4 +89,4 @@
8189
modal.modal('hide');
8290
});
8391

84-
}());
92+
}());

0 commit comments

Comments
 (0)