diff --git a/ruby/lib/jam_ruby/models/posa_card.rb b/ruby/lib/jam_ruby/models/posa_card.rb index f099eafed..beb1bfbd4 100644 --- a/ruby/lib/jam_ruby/models/posa_card.rb +++ b/ruby/lib/jam_ruby/models/posa_card.rb @@ -154,6 +154,7 @@ module JamRuby if self.save + UserWhitelist.card_create(user, 'posa') SaleLineItem.associate_user_for_posa(self, user) # when you claim a POSA card, you are also making a LessonPackagePurchase diff --git a/ruby/lib/jam_ruby/models/user_whitelist.rb b/ruby/lib/jam_ruby/models/user_whitelist.rb index d8f496939..7ed8183f6 100644 --- a/ruby/lib/jam_ruby/models/user_whitelist.rb +++ b/ruby/lib/jam_ruby/models/user_whitelist.rb @@ -22,6 +22,14 @@ module JamRuby APP_CONFIG.admin_root_url + "/admin/user_whitelists/" + id end + # if a user claims a gift card or posa card, whitelist their account so they don't get messed with by fraud code + def self.card_create(user, notes) + user_whitelist = UserWhitelist.new + user_whitelist.user = user + user_whitelist.notes = notes + user_whitelist.save + end + def to_s user end diff --git a/web/app/assets/javascripts/react-components/landing/RedeemGiftCardPage.js.jsx.coffee b/web/app/assets/javascripts/react-components/landing/RedeemGiftCardPage.js.jsx.coffee index ddba00fd4..57ca08d88 100644 --- a/web/app/assets/javascripts/react-components/landing/RedeemGiftCardPage.js.jsx.coffee +++ b/web/app/assets/javascripts/react-components/landing/RedeemGiftCardPage.js.jsx.coffee @@ -19,6 +19,10 @@ badCode = 'This is not a valid code. Please carefully re-enter the code and try if errorText? && errorText.indexOf('must already be set') > -1 errorText = 'This card has not been activated by a retailer and cannot currently be used. If you purchased this card from a store, please return to the store and have the store activate the card. Only the store where you purchased this card can activate it.' + + if errorText? && errorText.indexOf('already claimed') > -1 + errorText = 'This card has already been claimed. If you believe this is in error, please email us at support@jamkazam.com to report this problem.' + buttonClassnames = classNames({'redeem-giftcard': true, 'button-orange': true, disabled: @state.processing || @state.done }) diff --git a/web/app/controllers/api_users_controller.rb b/web/app/controllers/api_users_controller.rb index 385e1d575..311d6cbbf 100644 --- a/web/app/controllers/api_users_controller.rb +++ b/web/app/controllers/api_users_controller.rb @@ -1061,6 +1061,7 @@ class ApiUsersController < ApiController return else + UserWhitelist.card_create(current_user, 'giftcard') # apply gift card items to everything in shopping cart current_user.reload ShoppingCart.apply_gifted_jamtracks(current_user) diff --git a/web/config/application.rb b/web/config/application.rb index 98219698c..c9c847f58 100644 --- a/web/config/application.rb +++ b/web/config/application.rb @@ -451,5 +451,7 @@ if defined?(Bundler) # If you want to use the new JSON-based format in your application, you can add an initializer file with the following content: # This would transparently migrate your existing Marshal-serialized cookies into the new JSON-based format. config.action_dispatch.cookies_serializer = :hybrid + + config.jam_class_card_wait_period_year = 1 end end