Update billing page with special case (#700)

This commit is contained in:
Andy Zhao 2018-09-19 17:36:22 -04:00 committed by Mac Siri
parent b33156a287
commit d8db1be7bd
2 changed files with 16 additions and 3 deletions

View file

@ -109,7 +109,9 @@ class UsersController < ApplicationController
new(access_token: current_user.identities.where(provider: "github").last.token)
end
when "billing"
@customer = Stripe::Customer.retrieve(current_user.stripe_id_code) if current_user.stripe_id_code
stripe_code = current_user.stripe_id_code
return if stripe_code == "special"
@customer = Stripe::Customer.retrieve(stripe_code) if !stripe_code.blank?
when "membership"
if current_user.monthly_dues.zero?
redirect_to "/membership"

View file

@ -1,9 +1,16 @@
<!-- cached at: <%= Time.now %> -->
<h3>Billing Details</h3>
<% if current_user.monthly_dues == 0 %>
<div class="default-billing-message">You will be billed monthly based on your use of <a href="/membership">premium features. 🔒</a></div>
<div class="default-billing-message">
You will be billed monthly based on your use of
<a href="/membership">premium features. 🔒</a>
</div>
<% else %>
<div class="default-billing-message"> You will be billed monthly for your dev.to sustaining membership. To make adjustments, visit your <a href="settings/membership">membership settings</a>.</div>
<div class="default-billing-message">
You will be billed monthly for your dev.to sustaining membership.
To make adjustments, visit your
<a href="/settings/membership">membership settings</a>.
</div>
<% end %>
<% if current_user.stripe_id_code.blank? %>
<%= form_tag stripe_subscriptions_path, id: "credit-card-form" do %>
@ -18,6 +25,10 @@
<button id="custom-stripe-button" class="credit-card-button">+ Add Credit Card</button>
</div>
<% end %>
<% elsif current_user.stripe_id_code == "special" %>
<h3>
Billing questions? Send an email to <a href="mailto:yo@dev.to">yo@dev.to</a>.
</h3>
<% else %>
<div class="billing-history-header">Your Credit Cards</div>
<% @customer.sources.each do |source| %>