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:
41
test/unit/user_upgrade_test.rb
Normal file
41
test/unit/user_upgrade_test.rb
Normal file
@@ -0,0 +1,41 @@
|
||||
require 'test_helper'
|
||||
|
||||
class UserUpgradeTest < ActiveSupport::TestCase
|
||||
context "UserUpgrade:" do
|
||||
context "the #process_upgrade! method" do
|
||||
setup do
|
||||
@user = create(:user)
|
||||
@user_upgrade = UserUpgrade.new(recipient: @user, purchaser: @user, level: User::Levels::GOLD)
|
||||
end
|
||||
|
||||
should "update the user's level" do
|
||||
@user_upgrade.process_upgrade!
|
||||
assert_equal(User::Levels::GOLD, @user.reload.level)
|
||||
end
|
||||
|
||||
should "log an account upgrade modaction" do
|
||||
assert_difference("ModAction.user_account_upgrade.count") do
|
||||
@user_upgrade.process_upgrade!
|
||||
end
|
||||
end
|
||||
|
||||
should "send the user a dmail" do
|
||||
assert_difference("@user.dmails.received.count") do
|
||||
@user_upgrade.process_upgrade!
|
||||
end
|
||||
end
|
||||
|
||||
context "for an upgrade for a user above Platinum level" do
|
||||
should "not demote the user" do
|
||||
@user.update!(level: User::Levels::BUILDER)
|
||||
|
||||
assert_raise(User::PrivilegeError) do
|
||||
@user_upgrade.process_upgrade!
|
||||
end
|
||||
|
||||
assert_equal(true, @user.reload.is_builder?)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user