Skip to content
This repository has been archived by the owner on Nov 9, 2017. It is now read-only.

Commit

Permalink
Do better job of disabling/enabling stripe button.
Browse files Browse the repository at this point in the history
  • Loading branch information
bsimpson63 authored and chromakode committed Mar 9, 2013
1 parent c32fdd1 commit baf4897
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 9 deletions.
5 changes: 3 additions & 2 deletions r2/r2/controllers/ipn.py
Expand Up @@ -749,12 +749,12 @@ def POST_goldcharge(self, form, jquery, token, passthrough, pennies, months):
customer['active_card']['address_zip_check'] == 'fail'):
form.set_html('.status',
_('error: address verification failed'))
form.find('.stripe-submit').removeClass("disabled").end()
form.find('.stripe-submit').removeAttr('disabled').end()
return

if customer['active_card']['cvc_check'] == 'fail':
form.set_html('.status', _('error: cvc check failed'))
form.find('.stripe-submit').removeClass("disabled").end()
form.find('.stripe-submit').removeAttr('disabled').end()
return

charge = stripe.Charge.create(
Expand All @@ -765,6 +765,7 @@ def POST_goldcharge(self, form, jquery, token, passthrough, pennies, months):
)
except stripe.CardError as e:
form.set_html('.status', 'error: %s' % e.message)
form.find('.stripe-submit').removeAttr('disabled').end()
except stripe.InvalidRequestError as e:
form.set_html('.status', _('invalid request'))
except stripe.APIConnectionError as e:
Expand Down
2 changes: 1 addition & 1 deletion r2/r2/public/static/css/reddit.less
Expand Up @@ -5435,7 +5435,7 @@ body:not(.gold) .allminus-link {
text-shadow: 0px 1px 0px hsla(0,0%,100%,.7);
}

.gold-button.disabled {
.gold-button.disabled, .gold-button:disabled {
color: #999;
background-color: #ccc;
border-color: #aaa;
Expand Down
9 changes: 3 additions & 6 deletions r2/r2/public/static/js/gold.js
Expand Up @@ -134,9 +134,8 @@ r.gold = {
cardZip = form.find('.card-address_zip').val()

var stripeResponseHandler = function(status, response) {
window.clearTimeout(workingTimer)
if (response.error) {
submit.removeClass("disabled")
submit.removeAttr('disabled')
status.html(response.error.message)
} else {
token.val(response.id)
Expand Down Expand Up @@ -164,10 +163,8 @@ r.gold = {
status.text(r.strings('missing_credit_zip'))
} else {

var workingTimer = setTimeout(function () {
submit.addClass('disabled')
}, 200)

status.text('')
submit.attr('disabled', 'disabled')
Stripe.createToken({
name: cardName,
number: cardNumber,
Expand Down

0 comments on commit baf4897

Please sign in to comment.