app/controllers/ishapi/payments_controller.rb in ishapi-0.1.8.195 vs app/controllers/ishapi/payments_controller.rb in ishapi-0.1.8.196

- old
+ new

@@ -49,11 +49,11 @@ ## ## @TODO: cannot proceed if already is_purchasing? ## def create2 authorize! :create, ::Ish::Payment - current_user.profile.update_attributes({ is_purchasing: true }) + @current_profile.update_attributes({ is_purchasing: true }) begin amount_cents = params[:amount_cents].to_i # @TODO: change ::Stripe.api_key = ::STRIPE_SK @@ -63,13 +63,13 @@ metadata: { integration_check: "accept_a_payment" }, }) payment = Ish::Payment.create!( client_secret: intent.client_secret, - email: current_user.email, + email: @current_profile.email, payment_intent_id: intent.id, - profile_id: current_user.profile.id, + profile_id: @current_profile.id, ) render json: { client_secret: intent.client_secret } rescue Mongoid::Errors::DocumentNotFound => e puts! e, '#create2 Mongoid::Errors::DocumentNotFound' @@ -108,21 +108,21 @@ def unlock authorize! :unlock, ::Ish::Payment item = Object::const_get(params['kind']).find params['id'] - existing = Purchase.where( user_profile: @current_user.profile, item: item ).first + existing = Purchase.where( user_profile: @current_profile, item: item ).first if existing render status: 200, json: { status: :ok, message: 'already purchased' } return end - @current_user.profile.inc( n_unlocks: -item.premium_tier ) + @current_profile.inc( n_unlocks: -item.premium_tier ) - purchase = ::Gameui::PremiumPurchase.create!( item: item, user_profile: @current_user.profile, ) + purchase = ::Gameui::PremiumPurchase.create!( item: item, user_profile: @current_profile, ) - @profile = @current_user.profile - render 'ishapi/users/account' + @profile = @current_profile + render 'ishapi/user_profiles/account' end end end