user upgrades: fix checkout form leaking recipient's email.

The checkout form should be prefilled with the purchaser's email
address, not the recipient's.
This commit is contained in:
evazion
2020-12-25 02:01:42 -06:00
parent e030a07816
commit d9db32640a
2 changed files with 15 additions and 1 deletions

View File

@@ -166,7 +166,7 @@ class UserUpgrade < ApplicationRecord
success_url: Routes.user_upgrade_url(self),
cancel_url: Routes.new_user_upgrade_url(user_id: recipient.id),
client_reference_id: "user_upgrade_#{id}",
customer_email: recipient.email_address&.address,
customer_email: purchaser.email_address&.address,
payment_method_types: ["card"],
line_items: [{
price_data: {

View File

@@ -45,5 +45,19 @@ class UserUpgradeTest < ActiveSupport::TestCase
end
end
end
context "the #create_checkout! method" do
context "for a gifted upgrade" do
context "to Gold" do
should "prefill the Stripe checkout page with the purchaser's email address" do
@user = create(:user, email_address: build(:email_address))
@user_upgrade = create(:gift_gold_upgrade, purchaser: @user)
@checkout = @user_upgrade.create_checkout!
assert_equal(@user.email_address.address, @checkout.customer_email)
end
end
end
end
end
end