user upgrades: upgrade to new Stripe checkout system.
This upgrades from the legacy version of Stripe's checkout system to the new version: > The legacy version of Checkout presented customers with a modal dialog > that collected card information, and returned a token or a source to > your website. In contrast, the new version of Checkout is a smart > payment page hosted by Stripe that creates payments or subscriptions. It > supports Apple Pay, Dynamic 3D Secure, and many other features. Basic overview of the new system: * We send the user to a checkout page on Stripe. * Stripe collects payment and sends us a webhook notification when the order is complete. * We receive the webhook notification and upgrade the user. Docs: * https://stripe.com/docs/payments/checkout * https://stripe.com/docs/payments/checkout/migration#client-products * https://stripe.com/docs/payments/handling-payment-events * https://stripe.com/docs/payments/checkout/fulfill-orders
This commit is contained in:
@@ -1,10 +0,0 @@
|
||||
<div class="section">
|
||||
<p>You can pay with a credit or debit card. Safebooru uses <a href="https://www.stripe.com">Stripe</a> as a payment intermediary so none of your personal information will be stored on the site.</p>
|
||||
|
||||
<% if user.level < User::Levels::GOLD %>
|
||||
<%= stripe_button("Upgrade to Gold", UserUpgrade.gold_price, user) %>
|
||||
<%= stripe_button("Upgrade to Platinum", UserUpgrade.platinum_price, user) %>
|
||||
<% elsif user.level < User::Levels::PLATINUM %>
|
||||
<%= stripe_button("Upgrade Gold to Platinum", UserUpgrade.upgrade_price, user) %>
|
||||
<% end %>
|
||||
</div>
|
||||
@@ -1,3 +0,0 @@
|
||||
<div class="section">
|
||||
<p>You can pay with a credit or debit card on <%= link_to "Safebooru", new_user_upgrade_url(host: "safebooru.donmai.us", protocol: "https") %>. Your account will then also be upgraded on Danbooru. You can login to Safebooru with the same username and password you use on Danbooru.</p>
|
||||
</div>
|
||||
2
app/views/user_upgrades/create.js.erb
Normal file
2
app/views/user_upgrades/create.js.erb
Normal file
@@ -0,0 +1,2 @@
|
||||
var stripe = Stripe("<%= j UserUpgrade.stripe_publishable_key %>");
|
||||
stripe.redirectToCheckout({ sessionId: "<%= j @checkout.id %>" });
|
||||
@@ -1,5 +1,6 @@
|
||||
<% page_title "Account Upgrade" %>
|
||||
<% meta_description "Upgrade to a Gold or Platinum account on #{Danbooru.config.app_name}." %>
|
||||
<% meta_description "Upgrade to a Gold or Platinum account." %>
|
||||
<script src="https://js.stripe.com/v3/"></script>
|
||||
|
||||
<%= render "users/secondary_links" %>
|
||||
|
||||
@@ -96,9 +97,24 @@
|
||||
<% if CurrentUser.is_anonymous? %>
|
||||
<p><%= link_to "Sign up", new_user_path %> or <%= link_to "login", login_path(url: new_user_upgrade_path) %> first to upgrade your account.</p>
|
||||
<% elsif CurrentUser.safe_mode? %>
|
||||
<%= render "stripe_payment" %>
|
||||
<div class="section">
|
||||
<p>You can pay with a credit or debit card. Safebooru uses <a href="https://www.stripe.com">Stripe</a>
|
||||
as a payment intermediary so none of your personal information will be stored on the site.</p>
|
||||
|
||||
<% if user.level < User::Levels::GOLD %>
|
||||
<p><%= button_to "Upgrade to Gold", user_upgrade_path(user_id: user.id, level: User::Levels::GOLD), remote: true, disable_with: "Redirecting..." %></p>
|
||||
<p><%= button_to "Upgrade to Platinum", user_upgrade_path(user_id: user.id, level: User::Levels::PLATINUM), remote: true, disable_with: "Redirecting..." %></p>
|
||||
<% elsif user.level < User::Levels::PLATINUM %>
|
||||
<p><%= button_to "Upgrade Gold to Platinum", user_upgrade_path(user_id: user.id, level: User::Levels::PLATINUM), remote: true, disable_with: "Redirecting..." %></p>
|
||||
<% end %>
|
||||
</div>
|
||||
<% else %>
|
||||
<%= render "stripe_payment_safebooru" %>
|
||||
<div class="section">
|
||||
<p>You can pay with a credit or debit card on
|
||||
<%= link_to "Safebooru", new_user_upgrade_url(user_id: user.id, host: "safebooru.donmai.us", protocol: "https") %>.
|
||||
Your account will then also be upgraded on Danbooru. You can login to
|
||||
Safebooru with the same username and password you use on Danbooru.</p>
|
||||
</div>
|
||||
<% end %>
|
||||
<% end %>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user