diff --git a/app.rb b/app.rb index 75595d52..364d3212 100644 --- a/app.rb +++ b/app.rb @@ -271,30 +271,43 @@ post '/plan/update' do require_login DB.transaction do - 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 parent_site.stripe_subscription_id + customer = Stripe::Customer.retrieve parent_site.stripe_customer_id + subscription = customer.subscriptions.retrieve parent_site.stripe_subscription_id + subscription.plan = params[:plan_type] + subscription.save - parent_site.update( - stripe_customer_id: customer.id, - plan_ended: false, - plan_type: params[:plan_type] - ) + parent_site.update( + plan_ended: false, + 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 - 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]) - }) + parent_site.update( + stripe_customer_id: customer.id, + stripe_subscription_id: customer.subscriptions.first.id, + plan_ended: false, + plan_type: params[:plan_type] + ) 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' end diff --git a/migrations/048_add_subscription_id_to_sites.rb b/migrations/048_add_subscription_id_to_sites.rb new file mode 100644 index 00000000..099f9eee --- /dev/null +++ b/migrations/048_add_subscription_id_to_sites.rb @@ -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 \ No newline at end of file diff --git a/sass/_project-sass/_project-Main.scss b/sass/_project-sass/_project-Main.scss index 368a72e5..0193b42e 100644 --- a/sass/_project-sass/_project-Main.scss +++ b/sass/_project-sass/_project-Main.scss @@ -55,7 +55,7 @@ padding-right: 6%; } .content.misc-page { - background: #FAF6F1; + background: #FFFFFF; -moz-box-shadow: 0px 1px 1px 1px rgba(0,0,0,0.10); -webkit-box-shadow: 0px 1px 1px 1px rgba(0,0,0,0.10); box-shadow: 0px 1px 1px 1px rgba(0,0,0,0.10); diff --git a/views/_team.erb b/views/_team.erb new file mode 100644 index 00000000..fa6db8bd --- /dev/null +++ b/views/_team.erb @@ -0,0 +1,33 @@ +
+
+

The Neocities Team

+ +
+ + + +
+
+ +
+
+

Follow us on Twitter

+
\ No newline at end of file diff --git a/views/about.erb b/views/about.erb index 86c53652..60bb09c1 100644 --- a/views/about.erb +++ b/views/about.erb @@ -48,38 +48,5 @@ If you share our values, we would love your support. Spread the word! We also have a supporter plan to help pay for the site, and we accept donations through multiple options (including Bitcoin... and Dogecoin).

-
-
-

The Neocities Team

- -
- - - -
-
- -
-
-

Follow us on Twitter

-
- + <%== erb :'_team', layout: false %> diff --git a/views/plan/_pricing.erb b/views/plan/_pricing.erb index 1e084b42..fb3b914c 100644 --- a/views/plan/_pricing.erb +++ b/views/plan/_pricing.erb @@ -332,7 +332,7 @@ It's affordable. As low as $<%= Site::PLAN_FEATURES[:supporter][:price] %>/month (billed once every year). Higher tiers are optional (and appreciated!)
  • - You can cancel anytime. + You can cancel or change plans anytime. If you do, we'll refund/prorate the amount you didn't use.
  • @@ -375,7 +375,10 @@