mirror of
https://github.com/neocities/neocities.git
synced 2025-04-24 17:22:35 +02:00
track subscription ids
This commit is contained in:
parent
5235286d8a
commit
609cee1c17
6 changed files with 147 additions and 86 deletions
51
app.rb
51
app.rb
|
@ -271,30 +271,43 @@ post '/plan/update' do
|
||||||
require_login
|
require_login
|
||||||
|
|
||||||
DB.transaction do
|
DB.transaction do
|
||||||
customer = Stripe::Customer.create(
|
if parent_site.stripe_subscription_id
|
||||||
card: params[:stripe_token],
|
customer = Stripe::Customer.retrieve parent_site.stripe_customer_id
|
||||||
description: "#{parent_site.username} - #{parent_site.id}",
|
subscription = customer.subscriptions.retrieve parent_site.stripe_subscription_id
|
||||||
email: (current_site.email || parent_site.email),
|
subscription.plan = params[:plan_type]
|
||||||
plan: params[:plan_type]
|
subscription.save
|
||||||
)
|
|
||||||
|
|
||||||
parent_site.update(
|
parent_site.update(
|
||||||
stripe_customer_id: customer.id,
|
plan_ended: false,
|
||||||
plan_ended: false,
|
plan_type: params[:plan_type]
|
||||||
plan_type: params[:plan_type]
|
)
|
||||||
)
|
else
|
||||||
|
customer = Stripe::Customer.create(
|
||||||
|
card: params[:stripe_token],
|
||||||
|
description: "#{parent_site.username} - #{parent_site.id}",
|
||||||
|
email: (current_site.email || parent_site.email),
|
||||||
|
plan: params[:plan_type]
|
||||||
|
)
|
||||||
|
|
||||||
if current_site.email || parent_site.email
|
parent_site.update(
|
||||||
EmailWorker.perform_async({
|
stripe_customer_id: customer.id,
|
||||||
from: 'web@neocities.org',
|
stripe_subscription_id: customer.subscriptions.first.id,
|
||||||
reply_to: 'contact@neocities.org',
|
plan_ended: false,
|
||||||
to: current_site.email || parent_site.email,
|
plan_type: params[:plan_type]
|
||||||
subject: "[Neocities] You've become a supporter!",
|
)
|
||||||
body: Tilt.new('./views/templates/email_subscription.erb', pretty: true).render(self, plan_name: Site::PLAN_FEATURES[params[:plan_type].to_sym][:name])
|
|
||||||
})
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if current_site.email || parent_site.email
|
||||||
|
EmailWorker.perform_async({
|
||||||
|
from: 'web@neocities.org',
|
||||||
|
reply_to: 'contact@neocities.org',
|
||||||
|
to: current_site.email || parent_site.email,
|
||||||
|
subject: "[Neocities] You've become a supporter!",
|
||||||
|
body: Tilt.new('./views/templates/email_subscription.erb', pretty: true).render(self, plan_name: Site::PLAN_FEATURES[params[:plan_type].to_sym][:name])
|
||||||
|
})
|
||||||
|
end
|
||||||
|
|
||||||
redirect '/plan/thanks'
|
redirect '/plan/thanks'
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
9
migrations/048_add_subscription_id_to_sites.rb
Normal file
9
migrations/048_add_subscription_id_to_sites.rb
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
Sequel.migration do
|
||||||
|
up {
|
||||||
|
DB.add_column :sites, :stripe_subscription_id, :text
|
||||||
|
}
|
||||||
|
|
||||||
|
down {
|
||||||
|
DB.drop_column :sites, :stripe_subscription_id
|
||||||
|
}
|
||||||
|
end
|
33
views/_team.erb
Normal file
33
views/_team.erb
Normal file
|
@ -0,0 +1,33 @@
|
||||||
|
<hr />
|
||||||
|
<section>
|
||||||
|
<h1 class="beta txt-Center">The Neocities Team</h1>
|
||||||
|
|
||||||
|
<div class="row txt-Center">
|
||||||
|
<div class="col col-33">
|
||||||
|
<a href="https://kyledrake.neocities.org" title="Visit Kyle's Website">
|
||||||
|
<img src="https://0.gravatar.com/avatar/62a43048a3c2c688654274abdc0ecb9c?d=https%3A%2F%2Fidenticons.github.com%2Ffde07ba82b25f95afa9d080819f95717.png&r=x&s=440" alt="kyle drake" class="pic-Rounded" />
|
||||||
|
</a>
|
||||||
|
<br />
|
||||||
|
<a href="https://kyledrake.neocities.org" title="Kyle Drake" class="eps">Kyle Drake</a>
|
||||||
|
</div>
|
||||||
|
<div class="col col-33">
|
||||||
|
<a href="https://victoria.neocities.org" title="Visit Victoria's Website">
|
||||||
|
<img src="https://1.gravatar.com/avatar/2b577f8b3e5ab79bc927ed5185c0eae0?d=https%3A%2F%2Fidenticons.github.com%2Fe03006819f4a835afa237716f6701c95.png&r=x&s=440" alt="Victoria Wang" class="pic-Rounded" />
|
||||||
|
</a>
|
||||||
|
<br />
|
||||||
|
<a href="https://victoria.neocities.org" title="Visit Victoria's Website" class="eps">Victoria Wang</a>
|
||||||
|
</div>
|
||||||
|
<div class="col col-33">
|
||||||
|
<a href="http://scottohara.neocities.org" title="Visit Scott's Website">
|
||||||
|
<img src="https://0.gravatar.com/avatar/6ade16e6184b3efb573ee91255ff7abe?d=https%3A%2F%2Fidenticons.github.com%2Fa6362986538cdcb93a8b04f6c3f66b5e.png&r=x&s=440" alt="Scott O'Hara" class="pic-Rounded" />
|
||||||
|
</a>
|
||||||
|
<br />
|
||||||
|
<a href="http://scottohara.neocities.org" title="Visit Scott's Website" class="eps">Scott O'Hara</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
|
||||||
|
<hr />
|
||||||
|
<section>
|
||||||
|
<h2 class="txt-Center"><a href="https://twitter.com/neocitiesweb">Follow us on Twitter</a></h2>
|
||||||
|
</section>
|
|
@ -48,38 +48,5 @@
|
||||||
If you share our values, we would love your support. Spread the word! We also have a <a href="/plan">supporter plan</a> to help pay for the site, and we accept <a href="/donate">donations</a> through multiple options (including Bitcoin... and Dogecoin).
|
If you share our values, we would love your support. Spread the word! We also have a <a href="/plan">supporter plan</a> to help pay for the site, and we accept <a href="/donate">donations</a> through multiple options (including Bitcoin... and Dogecoin).
|
||||||
</p>
|
</p>
|
||||||
</article>
|
</article>
|
||||||
<hr />
|
<%== erb :'_team', layout: false %>
|
||||||
<section>
|
|
||||||
<h1 class="beta txt-Center">The Neocities Team</h1>
|
|
||||||
|
|
||||||
<div class="row txt-Center">
|
|
||||||
<div class="col col-33">
|
|
||||||
<a href="https://kyledrake.neocities.org" title="Visit Kyle's Website">
|
|
||||||
<img src="https://0.gravatar.com/avatar/62a43048a3c2c688654274abdc0ecb9c?d=https%3A%2F%2Fidenticons.github.com%2Ffde07ba82b25f95afa9d080819f95717.png&r=x&s=440" alt="kyle drake" class="pic-Rounded" />
|
|
||||||
</a>
|
|
||||||
<br />
|
|
||||||
<a href="https://kyledrake.neocities.org" title="Kyle Drake" class="eps">Kyle Drake</a>
|
|
||||||
</div>
|
|
||||||
<div class="col col-33">
|
|
||||||
<a href="https://victoria.neocities.org" title="Visit Victoria's Website">
|
|
||||||
<img src="https://1.gravatar.com/avatar/2b577f8b3e5ab79bc927ed5185c0eae0?d=https%3A%2F%2Fidenticons.github.com%2Fe03006819f4a835afa237716f6701c95.png&r=x&s=440" alt="Victoria Wang" class="pic-Rounded" />
|
|
||||||
</a>
|
|
||||||
<br />
|
|
||||||
<a href="https://victoria.neocities.org" title="Visit Victoria's Website" class="eps">Victoria Wang</a>
|
|
||||||
</div>
|
|
||||||
<div class="col col-33">
|
|
||||||
<a href="http://scottohara.neocities.org" title="Visit Scott's Website">
|
|
||||||
<img src="https://0.gravatar.com/avatar/6ade16e6184b3efb573ee91255ff7abe?d=https%3A%2F%2Fidenticons.github.com%2Fa6362986538cdcb93a8b04f6c3f66b5e.png&r=x&s=440" alt="Scott O'Hara" class="pic-Rounded" />
|
|
||||||
</a>
|
|
||||||
<br />
|
|
||||||
<a href="http://scottohara.neocities.org" title="Visit Scott's Website" class="eps">Scott O'Hara</a>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</section>
|
|
||||||
|
|
||||||
<hr />
|
|
||||||
<section>
|
|
||||||
<h2 class="txt-Center"><a href="https://twitter.com/neocitiesweb">Follow us on Twitter</a></h2>
|
|
||||||
</section>
|
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -332,7 +332,7 @@
|
||||||
<strong>It's affordable.</strong> As low as <strong>$<%= Site::PLAN_FEATURES[:supporter][:price] %>/month</strong> (billed once every year). Higher tiers are optional (and appreciated!)
|
<strong>It's affordable.</strong> As low as <strong>$<%= Site::PLAN_FEATURES[:supporter][:price] %>/month</strong> (billed once every year). Higher tiers are optional (and appreciated!)
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<strong>You can cancel anytime.</strong>
|
<strong>You can cancel or change plans anytime.</strong> If you do, we'll refund/prorate the amount you didn't use.
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
|
@ -375,7 +375,10 @@
|
||||||
</div>
|
</div>
|
||||||
<div class="modal-body">
|
<div class="modal-body">
|
||||||
<div>
|
<div>
|
||||||
You are <% if current_site && parent_site.plan_type == 'free' %>upgrading<%else%>changing<%end%> to the <strong><span id="upgradeFormPlanName"></span> Plan</strong>. You will be charged <span id="upgradeFormPlanPrice"></span>. Please enter your Credit Card number:
|
You are <% if current_site && parent_site.plan_type == 'free' %>upgrading<%else%>changing<%end%> to the <strong><span id="upgradeFormPlanName"></span> Plan</strong>. You will be charged <span id="upgradeFormPlanPrice"></span>.
|
||||||
|
<% unless current_site && parent_site.stripe_customer_id %>
|
||||||
|
Please enter your Credit Card number:
|
||||||
|
<% end %>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<input id="stripe_token" name="stripe_token" type="hidden" value="<%= params[:stripe_token] %>">
|
<input id="stripe_token" name="stripe_token" type="hidden" value="<%= params[:stripe_token] %>">
|
||||||
|
@ -383,38 +386,40 @@
|
||||||
<div style="margin-top: 30px">
|
<div style="margin-top: 30px">
|
||||||
<div id="plan_error" class="alert alert-block alert-error" style="display:none"></div>
|
<div id="plan_error" class="alert alert-block alert-error" style="display:none"></div>
|
||||||
|
|
||||||
<% if params[:stripe_token] %>
|
<% unless params[:stripe_token] || (current_site && parent_site.stripe_customer_id) %>
|
||||||
<p>Billing information has been saved, thank you!</p>
|
<div class="credit-card-input no-js" id="skeuocard" style="margin-left: auto; margin-right: auto; margin-bottom: 20px">
|
||||||
<% else %>
|
<p class="no-support-warning"></p>
|
||||||
<div class="credit-card-input no-js" id="skeuocard" style="margin-left: auto; margin-right: auto; margin-bottom: 20px">
|
<label for="cc_type">Card Type</label>
|
||||||
<p class="no-support-warning"></p>
|
<select name="cc_type">
|
||||||
<label for="cc_type">Card Type</label>
|
<option value="">...</option>
|
||||||
<select name="cc_type">
|
<option value="visa">Visa</option>
|
||||||
<option value="">...</option>
|
<option value="discover">Discover</option>
|
||||||
<option value="visa">Visa</option>
|
<option value="mastercard">MasterCard</option>
|
||||||
<option value="discover">Discover</option>
|
<option value="maestro">Maestro</option>
|
||||||
<option value="mastercard">MasterCard</option>
|
<option value="jcb">JCB</option>
|
||||||
<option value="maestro">Maestro</option>
|
<option value="unionpay">China UnionPay</option>
|
||||||
<option value="jcb">JCB</option>
|
<option value="amex">American Express</option>
|
||||||
<option value="unionpay">China UnionPay</option>
|
<option value="dinersclubintl">Diners Club</option>
|
||||||
<option value="amex">American Express</option>
|
</select>
|
||||||
<option value="dinersclubintl">Diners Club</option>
|
<label for="cc_number">Card Number</label>
|
||||||
</select>
|
<input type="text" name="cc_number" id="cc_number" placeholder="XXXX XXXX XXXX XXXX" maxlength="19" size="19">
|
||||||
<label for="cc_number">Card Number</label>
|
<label for="cc_exp_month">Expiration Month</label>
|
||||||
<input type="text" name="cc_number" id="cc_number" placeholder="XXXX XXXX XXXX XXXX" maxlength="19" size="19">
|
<input type="text" name="cc_exp_month" id="cc_exp_month" placeholder="00">
|
||||||
<label for="cc_exp_month">Expiration Month</label>
|
<label for="cc_exp_year">Expiration Year</label>
|
||||||
<input type="text" name="cc_exp_month" id="cc_exp_month" placeholder="00">
|
<input type="text" name="cc_exp_year" id="cc_exp_year" placeholder="00">
|
||||||
<label for="cc_exp_year">Expiration Year</label>
|
<label for="cc_name">Cardholder's Name</label>
|
||||||
<input type="text" name="cc_exp_year" id="cc_exp_year" placeholder="00">
|
<input type="text" name="cc_name" id="cc_name" placeholder="John Doe">
|
||||||
<label for="cc_name">Cardholder's Name</label>
|
<label for="cc_cvc">Card Validation Code</label>
|
||||||
<input type="text" name="cc_name" id="cc_name" placeholder="John Doe">
|
<input type="text" name="cc_cvc" id="cc_cvc" placeholder="123" maxlength="3" size="3">
|
||||||
<label for="cc_cvc">Card Validation Code</label>
|
</div>
|
||||||
<input type="text" name="cc_cvc" id="cc_cvc" placeholder="123" maxlength="3" size="3">
|
|
||||||
</div>
|
|
||||||
<% end %>
|
<% end %>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<p><strong>Don't have a Credit Card?</strong> We support Bitcoin and Paypal! <a href="/donate" target="_blank">Click here</a> for more information.</p>
|
<% unless params[:stripe_token] || (current_site && parent_site.stripe_customer_id) %>
|
||||||
|
<p>
|
||||||
|
<strong>Don't have a Credit Card?</strong> We support Bitcoin and Paypal! <a href="/donate" target="_blank">Click here</a> for more information.
|
||||||
|
</p>
|
||||||
|
<% end %>
|
||||||
</div>
|
</div>
|
||||||
<div class="modal-footer">
|
<div class="modal-footer">
|
||||||
<button class="btn" data-dismiss="modal" aria-hidden="true">Cancel</button>
|
<button class="btn" data-dismiss="modal" aria-hidden="true">Cancel</button>
|
||||||
|
@ -441,11 +446,14 @@
|
||||||
if($('#stripe_token').val() != '')
|
if($('#stripe_token').val() != '')
|
||||||
return true
|
return true
|
||||||
|
|
||||||
console.log(event)
|
var signupform = $(event.target)
|
||||||
|
|
||||||
|
<% if current_site && parent_site.stripe_subscription_id %>
|
||||||
|
return true
|
||||||
|
<% end %>
|
||||||
|
|
||||||
var planError = $('#plan_error')
|
var planError = $('#plan_error')
|
||||||
planError.css('display', 'none')
|
planError.css('display', 'none')
|
||||||
var signupform = $(event.target)
|
|
||||||
signupform.find(':submit').prop('disabled', true)
|
signupform.find(':submit').prop('disabled', true)
|
||||||
|
|
||||||
Stripe.card.createToken({
|
Stripe.card.createToken({
|
||||||
|
|
31
views/plan/thanks.erb
Normal file
31
views/plan/thanks.erb
Normal file
|
@ -0,0 +1,31 @@
|
||||||
|
<div class="header-Outro">
|
||||||
|
<div class="row content single-Col">
|
||||||
|
<h1>Thank You!</h1>
|
||||||
|
<h3 class="subtitle">Your support means a lot to us.</h3>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="content single-Col misc-page">
|
||||||
|
<h3></h3>
|
||||||
|
<article>
|
||||||
|
<div class="txt-Center"><img src="/img/heartcat.png"></div>
|
||||||
|
|
||||||
|
<h1 class="txt-Center">Thank you for your support.</h1>
|
||||||
|
<p>
|
||||||
|
Your support allows Neocities to continue our project to bring back the web. We will do our best to ensure that the site remains a great place for people to express themselves - one web page at a time.
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
If you need anything, please don't hesitate to <a href="/contact">contact us</a>!
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
On behalf of Penelope (the Neocities' cat) and everyone else at Neocities, thank you.
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
<a href="/">Get Started</a>
|
||||||
|
</p>
|
||||||
|
</article>
|
||||||
|
<%== erb :'_team', layout: false %>
|
||||||
|
</div>
|
Loading…
Add table
Reference in a new issue