2012-08-16 21:11:32 +00:00
|
|
|
{% extends "basepledge.html" %}
|
|
|
|
{% load humanize %}
|
|
|
|
|
|
|
|
{% block title %}Stripe{% endblock %}
|
|
|
|
|
|
|
|
{% block extra_extra_head %}
|
2012-09-26 22:03:46 +00:00
|
|
|
<link href="/static/stripe/tag.css" rel="stylesheet" type="text/css">
|
2012-08-16 21:11:32 +00:00
|
|
|
|
2012-09-26 20:52:36 +00:00
|
|
|
<script type="text/javascript" src="https://js.stripe.com/v1/"></script>
|
2012-08-16 21:11:32 +00:00
|
|
|
|
2012-09-10 20:17:30 +00:00
|
|
|
|
2012-09-26 20:52:36 +00:00
|
|
|
<script type="text/javascript">
|
|
|
|
// this identifies your website in the createToken call below
|
|
|
|
Stripe.setPublishableKey('{{STRIPE_PK}}');
|
|
|
|
</script>
|
2012-08-16 21:11:32 +00:00
|
|
|
|
2012-09-10 20:17:30 +00:00
|
|
|
<script type="application/x-javascript">
|
|
|
|
|
|
|
|
var $j = jQuery.noConflict();
|
|
|
|
|
|
|
|
|
2012-09-26 20:52:36 +00:00
|
|
|
function stripeResponseHandler(status, response) {
|
|
|
|
if (response.error) {
|
|
|
|
// re-enable the submit button
|
|
|
|
$j('.submit-button').removeAttr("disabled");
|
|
|
|
// show the errors on the form
|
|
|
|
$j(".payment-errors").html(response.error.message);
|
|
|
|
} else {
|
|
|
|
var form$ = $j("#payment-form");
|
|
|
|
// token contains id, last4, and card type
|
|
|
|
var token = response['id'];
|
|
|
|
// insert the token into the form so it gets submitted to the server
|
2012-09-26 22:03:46 +00:00
|
|
|
form$.append("<input type='hidden' name='stripe_token' value='" + token + "' />");
|
2012-09-26 20:52:36 +00:00
|
|
|
// and submit
|
|
|
|
form$.get(0).submit();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
$j().ready(function() {
|
|
|
|
$j("#payment-form").submit(function(event) {
|
|
|
|
// disable the submit button to prevent repeated clicks
|
|
|
|
$j('.submit-button').attr("disabled", "disabled");
|
|
|
|
|
|
|
|
Stripe.createToken({
|
|
|
|
number: $j('.card-number').val(),
|
|
|
|
cvc: $j('.card-cvc').val(),
|
|
|
|
exp_month: $j('.card-expiry-month').val(),
|
|
|
|
exp_year: $j('.card-expiry-year').val()
|
|
|
|
}, stripeResponseHandler);
|
|
|
|
|
|
|
|
// prevent the form from submitting with the default action
|
|
|
|
return false;
|
|
|
|
});
|
|
|
|
});
|
2012-09-10 20:17:30 +00:00
|
|
|
</script>
|
2012-09-26 20:52:36 +00:00
|
|
|
{% endblock %}
|
|
|
|
|
|
|
|
{% block doccontent %}
|
|
|
|
Stripe Test:
|
|
|
|
|
|
|
|
<span class="payment-errors"></span>
|
|
|
|
<form action="" method="POST" id="payment-form">
|
|
|
|
{% csrf_token %}
|
|
|
|
<div class="form-row">
|
|
|
|
<label>Card Number</label>
|
2012-10-15 14:28:31 +00:00
|
|
|
<input type="text" size="20" autocomplete="off" class="card-number" />
|
2012-09-26 20:52:36 +00:00
|
|
|
</div>
|
|
|
|
<div class="form-row">
|
|
|
|
<label>CVC</label>
|
2012-10-15 14:28:31 +00:00
|
|
|
<input type="text" size="4" autocomplete="off" class="card-cvc" />
|
2012-09-26 20:52:36 +00:00
|
|
|
</div>
|
|
|
|
<div class="form-row">
|
|
|
|
<label>Expiration (MM/YYYY)</label>
|
2012-10-15 14:28:31 +00:00
|
|
|
<input type="text" size="2" class="card-expiry-month" />
|
2012-09-26 20:52:36 +00:00
|
|
|
<span> / </span>
|
2012-10-15 14:28:31 +00:00
|
|
|
<input type="text" size="4" class="card-expiry-year" />
|
2012-09-26 20:52:36 +00:00
|
|
|
</div>
|
|
|
|
<button type="submit" class="submit-button">Submit Payment</button>
|
|
|
|
</form>
|
2012-08-29 14:34:20 +00:00
|
|
|
|
2012-08-16 21:11:32 +00:00
|
|
|
{% endblock %}
|
|
|
|
|