From 422cd632746d6ad3f349216c99a69f873527aa46 Mon Sep 17 00:00:00 2001 From: dblock Date: Thu, 30 Jun 2016 09:48:51 +0100 Subject: [PATCH] Fix: stripe payment without coupon. --- public/css/agency.css | 1 + public/js/playplay.js | 2 ++ public/upgrade.html.erb | 19 ++++++++++++------- 3 files changed, 15 insertions(+), 7 deletions(-) diff --git a/public/css/agency.css b/public/css/agency.css index 15d8fb90..ba6e0867 100755 --- a/public/css/agency.css +++ b/public/css/agency.css @@ -160,3 +160,4 @@ section img { max-width: 100%; } a.sponsor img { margin: 15px; } .up { color: #33CC00; } .down { color: #FF6600; } +.has-error { color: #FF6600; } diff --git a/public/js/playplay.js b/public/js/playplay.js index e605a031..925ea7b2 100644 --- a/public/js/playplay.js +++ b/public/js/playplay.js @@ -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) }); @@ -30,5 +31,6 @@ $(document).ready(function() { } PlayPlay.message(message || xhr.statusText || xhr.responseText || 'Unexpected Error'); + $('#messages').addClass('has-error'); }; }); diff --git a/public/upgrade.html.erb b/public/upgrade.html.erb index ec86203b..089c0593 100644 --- a/public/upgrade.html.erb +++ b/public/upgrade.html.erb @@ -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 ' + team.name + ' successfully upgraded to premium ' + team.game + '.

Thank you for your support!'); $('#subscribeButton').remove();