<commit_before>module CatarsePagarme
  class CreditCardTransaction < TransactionBase
    def charge!
      self.transaction = PagarMe::Transaction.new(self.attributes)
      self.transaction.charge

      change_contribution_state
      self.transaction
    end
  end
end<commit_msg>when transaction is refused raise a pagarme error<commit_after>module CatarsePagarme
  class CreditCardTransaction < TransactionBase
    def charge!
      self.transaction = PagarMe::Transaction.new(self.attributes)
      self.transaction.charge

      if self.transaction.status == 'refused'
        raise ::PagarMe::PagarMeError.new(I18n.t('projects.contributions.edit.transaction_error'))
      end

      change_contribution_state
      self.transaction
    end
  end
end
{'fraction_non_alphanumeric': 0.06992084432717678, 'fraction_numerical': 0.002638522427440633, 'mean_word_length': 3.7142857142857144, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, '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': '6884173', 'n_tokens_mistral': 215, 'n_tokens_neox': 205, 'n_words': 42}