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
27 lines
493 B
Ruby
27 lines
493 B
Ruby
class UserUpgradesController < ApplicationController
|
|
helper_method :user
|
|
respond_to :js, :html
|
|
|
|
def create
|
|
@user_upgrade = UserUpgrade.new(recipient: user, purchaser: CurrentUser.user, level: params[:level].to_i)
|
|
@checkout = @user_upgrade.create_checkout
|
|
|
|
respond_with(@user_upgrade)
|
|
end
|
|
|
|
def new
|
|
end
|
|
|
|
def show
|
|
authorize User, :upgrade?
|
|
end
|
|
|
|
def user
|
|
if params[:user_id]
|
|
User.find(params[:user_id])
|
|
else
|
|
CurrentUser.user
|
|
end
|
|
end
|
|
end
|