Skip to content

Commit

Permalink
Fix: stripe payment without coupon.
Browse files Browse the repository at this point in the history
  • Loading branch information
dblock committed Jun 30, 2016
1 parent e0c1714 commit 422cd63
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 7 deletions.
1 change: 1 addition & 0 deletions public/css/agency.css
Original file line number Diff line number Diff line change
Expand Up @@ -160,3 +160,4 @@ section img { max-width: 100%; }
a.sponsor img { margin: 15px; }
.up { color: #33CC00; }
.down { color: #FF6600; }
.has-error { color: #FF6600; }
2 changes: 2 additions & 0 deletions public/js/playplay.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ var PlayPlay = {};
$(document).ready(function() {

PlayPlay.message = function(text) {
$('#messages').removeClass('has-error');
$('#messages').fadeOut('slow', function() {
$('#messages').fadeIn('slow').html(text)
});
Expand Down Expand Up @@ -30,5 +31,6 @@ $(document).ready(function() {
}

PlayPlay.message(message || xhr.statusText || xhr.responseText || 'Unexpected Error');
$('#messages').addClass('has-error');
};
});
19 changes: 12 additions & 7 deletions public/upgrade.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -81,16 +81,21 @@
image: '/img/<%= game ? game.name : 'pong' %>.png',
locale: 'auto',
token: function(token) {
data = {
stripe_email: token.email,
stripe_token: token.id,
stripe_token_type: token.type,
team_id: team.id
};

if (coupon.code) {
data.stripe_coupon = coupon.code;
};

$.ajax({
type: 'POST',
url: '/api/subscriptions',
data: {
stripe_email: token.email,
stripe_token: token.id,
stripe_token_type: token.type,
stripe_coupon: coupon.code,
team_id: team.id
},
data: data,
success: function(data) {
PlayPlay.message('Team <b>' + team.name + '</b> successfully upgraded to premium <b>' + team.game + '</b>.<br><br>Thank you for your support!');
$('#subscribeButton').remove();
Expand Down

0 comments on commit 422cd63

Please sign in to comment.