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,24 +1,4 @@
|
||||
module UserUpgradesHelper
|
||||
def stripe_button(desc, cost, user)
|
||||
html = %{
|
||||
<form action="#{user_upgrade_path}" method="POST" class="stripe">
|
||||
<input type="hidden" name="authenticity_token" value="#{form_authenticity_token}">
|
||||
#{hidden_field_tag(:desc, desc)}
|
||||
#{hidden_field_tag(:user_id, user.id)}
|
||||
<script
|
||||
src="https://checkout.stripe.com/checkout.js" class="stripe-button"
|
||||
data-key="#{Danbooru.config.stripe_publishable_key}"
|
||||
data-name="#{Danbooru.config.canonical_app_name}"
|
||||
data-description="#{desc}"
|
||||
data-label="#{desc}"
|
||||
data-amount="#{cost}">
|
||||
</script>
|
||||
</form>
|
||||
}
|
||||
|
||||
raw(html)
|
||||
end
|
||||
|
||||
def cents_to_usd(cents)
|
||||
number_to_currency(cents / 100, precision: 0)
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user