Add a model to store the status of user upgrades. * Store the upgrade purchaser and the upgrade receiver (these are different for a gifted upgrade, the same for a self upgrade). * Store the upgrade type: gold, platinum, or gold-to-platinum upgrades. * Store the upgrade status: ** pending: User is still on the Stripe checkout page, no payment received yet. ** processing: User has completed checkout, but the checkout status in Stripe is still 'unpaid'. ** complete: We've received notification from Stripe that the payment has gone through and the user has been upgraded. * Store the Stripe checkout ID, to cross-reference the upgrade record on Danbooru with the checkout record on Stripe. This is the upgrade flow: * When the user clicks the upgrade button on the upgrade page, we call POST /user_upgrades and create a pending UserUpgrade. * We redirect the user to the checkout page on Stripe. * When the user completes checkout on Stripe, Stripe sends us a webhook notification at POST /webhooks/receive. * When we receive the webhook, we check the payment status, and if it's paid we mark the UserUpgrade as complete and upgrade the user. * After Stripe sees that we have successfully processed the webhook, they redirect the user to the /user_upgrades/:id page, where we show the user their upgrade receipt.
48 lines
1.7 KiB
Plaintext
48 lines
1.7 KiB
Plaintext
<% page_title "User Upgrade Status" %>
|
|
<%= render "users/secondary_links" %>
|
|
|
|
<div id="c-user-upgrades">
|
|
<div id="a-show">
|
|
<h1>User Upgrade</h1>
|
|
|
|
<p>
|
|
<ul>
|
|
<li>
|
|
<strong>Purchased</strong>
|
|
<%= time_ago_in_words_tagged @user_upgrade.updated_at %>
|
|
by <%= link_to_user @user_upgrade.purchaser %>
|
|
<% if @user_upgrade.is_gift? %>
|
|
for <%= link_to_user @user_upgrade.recipient %>
|
|
<% end %>
|
|
</li>
|
|
<li>
|
|
<strong>Upgrade Type</strong>
|
|
<%= @user_upgrade.upgrade_type.humanize %>
|
|
</li>
|
|
<li>
|
|
<strong>Status</strong>
|
|
<%= @user_upgrade.status.humanize %>
|
|
</li>
|
|
</ul>
|
|
</p>
|
|
|
|
<% if @user_upgrade.status == "complete" %>
|
|
<% if @user_upgrade.is_gift? && CurrentUser.user == @user_upgrade.recipient %>
|
|
<p><%= link_to_user @user_upgrade.purchaser %> has upgraded your account to <%= @user_upgrade.level_string %>. Enjoy your new account!</p>
|
|
<% elsif @user_upgrade.is_gift? && CurrentUser.user == @user_upgrade.purchaser %>
|
|
<p><%= link_to_user @user_upgrade.recipient %> is now a <%= @user_upgrade.level_string %> user. Thanks for supporting the site!</p>
|
|
<% else %>
|
|
<p>You are now a <%= @user_upgrade.level_string %> user. Thanks for supporting the site!</p>
|
|
<% end %>
|
|
|
|
<p><%= link_to "Go back to #{Danbooru.config.canonical_app_name}", "https://danbooru.donmai.us" %> to continue using the site.</p>
|
|
<% else %>
|
|
<%= content_for :html_header do %>
|
|
<meta http-equiv="refresh" content="5">
|
|
<% end %>
|
|
|
|
<p>This order is still being processed. You will be notified as soon as the order is complete.</p>
|
|
<% end %>
|
|
</div>
|
|
</div>
|