<commit_before>class Donation < ActiveRecord::Base
  belongs_to :round
  attr_accessible :amount, :email, :name, :stripe_token, :round

  validates :email, :presence => true

  after_initialize do |donation|
    if amount.nil?
      self.amount = rand(0.0..Rails.application.config.max_donation)
    end
    if secret.nil?
      self.secret = SecureRandom.hex(16)
    end
    save
  end

  def gravatar_url
    Rails.application.config.gravatar_url % Digest::MD5.hexdigest(email)
  end

  def token
    Digest::SHA1.hexdigest(secret+email)
  end
end
<commit_msg>Use stripe to process donation<commit_after>class Donation < ActiveRecord::Base
  belongs_to :round
  attr_accessible :amount, :email, :name, :stripe_token, :round

  validates :email, :presence => true

  after_initialize do |donation|
    if amount.nil?
      self.amount = rand(0.0..Rails.application.config.max_donation)
    end
    if secret.nil?
      self.secret = SecureRandom.hex(16)
    end
    save
  end

  def gravatar_url
    Rails.application.config.gravatar_url % Digest::MD5.hexdigest(email)
  end

  def token
    Digest::SHA1.hexdigest(secret+email)
  end

  def charge
    cents = (amount*100).round

    charge = Stripe::Charge.create(
      :amount => cents,
      :currency => "usd",
      :card => stripe_token,
      :description => email
    )
  end
end

{'fraction_non_alphanumeric': 0.10581222056631892, 'fraction_numerical': 0.011177347242921014, 'mean_word_length': 3.2365930599369084, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2811536', 'n_tokens_mistral': 474, 'n_tokens_neox': 449, 'n_words': 99}