<commit_before>module CatarsePagarme
  class TransactionBase
    attr_accessor :attributes, :contribution,
      :transaction, :user, :subscription

    def initialize(attributes, contribution)
      self.attributes = attributes
      self.contribution = contribution
      self.user = contribution.user
    end

    def change_contribution_state
      self.contribution.update_attributes(attributes_to_contribution)
      self.contribution.payment_notifications.create(extra_data: self.transaction.to_json)
      delegator.change_status_by_transaction(self.transaction.status)
    end

    def payment_method
      PaymentType::CREDIT_CARD
    end

    def attributes_to_contribution
      {
        payment_choice: payment_method,
        payment_service_fee: delegator.get_fee(payment_method, self.transaction.acquirer_name),
        payment_id: self.transaction.id,
        payment_method: 'Pagarme',
        slip_url: self.transaction.boleto_url,
        installments: (self.transaction.installments || 1),
        installment_value: (delegator.value_with_installment_tax(self.transaction.installments || 1) / 100),
        acquirer_name: self.transaction.acquirer_name,
        acquirer_tid: self.transaction.tid
      }
    end

    def delegator
      self.contribution.pagarme_delegator
    end
  end
end
<commit_msg>should be a float to get cents<commit_after>module CatarsePagarme
  class TransactionBase
    attr_accessor :attributes, :contribution,
      :transaction, :user, :subscription

    def initialize(attributes, contribution)
      self.attributes = attributes
      self.contribution = contribution
      self.user = contribution.user
    end

    def change_contribution_state
      self.contribution.update_attributes(attributes_to_contribution)
      self.contribution.payment_notifications.create(extra_data: self.transaction.to_json)
      delegator.change_status_by_transaction(self.transaction.status)
    end

    def payment_method
      PaymentType::CREDIT_CARD
    end

    def attributes_to_contribution
      {
        payment_choice: payment_method,
        payment_service_fee: delegator.get_fee(payment_method, self.transaction.acquirer_name),
        payment_id: self.transaction.id,
        payment_method: 'Pagarme',
        slip_url: self.transaction.boleto_url,
        installments: (self.transaction.installments || 1),
        installment_value: (delegator.value_with_installment_tax(self.transaction.installments || 1) / 100.0).to_f,
        acquirer_name: self.transaction.acquirer_name,
        acquirer_tid: self.transaction.tid
      }
    end

    def delegator
      self.contribution.pagarme_delegator
    end
  end
end

{'fraction_non_alphanumeric': 0.07100149476831091, 'fraction_numerical': 0.004110612855007474, 'mean_word_length': 3.4840871021775546, 'pattern_counts': {'":': 0, '<': 3, '<?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': '520093', 'n_tokens_mistral': 797, 'n_tokens_neox': 768, 'n_words': 130}