class ApiStripeController < ApiController

  before_filter :api_signed_in_user
  respond_to :json

  def store
    data = current_user.payment_update(params)

    if current_user.errors.any?
      respond_with current_user, status: :unprocessable_entity, layout: nil
    elsif data[:purchase] && data[:purchase].errors.any?
      respond_with data[:purchase], status: :unprocessable_entity, layout: nil
    else
      @lesson = data[:lesson]
      @test_drive = data[:test_drive]
      @normal = data[:normal]
      @lesson_package_type = data[:lesson_package_type]
      @uncollectables = data[:uncollectables]
      @package = data[:package]
    end

  end
end
