Add a system for upgrading accounts using upgrade codes. Users purchase an upgrade code off-site then redeem it on-site to upgrade their account to Gold. Upgrade codes are randomly pre-generated and are one time use only. Codes have enough randomness that guessing a code is infeasible.
19 lines
1001 B
Plaintext
19 lines
1001 B
Plaintext
<% if @user_upgrade.stripe? %>
|
|
var stripe = Stripe("<%= j Danbooru.config.stripe_publishable_key %>");
|
|
stripe.redirectToCheckout({ sessionId: "<%= j @checkout.id %>" });
|
|
<% elsif @user_upgrade.authorize_net? %>
|
|
$(function() {
|
|
var url = "<%= j @checkout[0] %>";
|
|
var token = "<%= j @checkout[1] %>";
|
|
|
|
var $form = $('<form method="POST">').attr("action", url)
|
|
var $input = $('<input type="hidden" name="token">').val(token);
|
|
$form.append($input).appendTo("body").submit();
|
|
});
|
|
<% elsif @user_upgrade.shopify? %>
|
|
window.history.pushState({}, "", location.href);
|
|
window.location.assign("<%= j Danbooru.config.shopify_purchase_url %>?attributes[user_upgrade_id]=<%= @user_upgrade.id %>&attributes[purchaser_id]=<%= @user_upgrade.purchaser_id %>&attributes[purchaser_name]=<%= @user_upgrade.purchaser.name %>&checkout[email]=<%= @user_upgrade.purchaser&.email_address&.address %>");
|
|
<% else %>
|
|
<% raise NotImplementedError, "payment method not implemented" %>
|
|
<% end %>
|