<commit_before>module SecupayRuby
  class Payment
    module Types
      DEBIT = "debit"
      PREPAY = "prepay"
    end

    attr_reader :api_key, :response, :amount, :payment_type, :demo

    INIT_FIELDS = {
      hash: "hash",
      iframe_url: "iframe_url",
      purpose: "purpose",
      payment_data: "payment_data"
    }
    attr_reader(*(INIT_FIELDS.keys))

    STATUS_FIELDS = {
      payment_status:   "payment_status",
      status:           "status",
      created_at:       "created",
      demo:             "demo",
      amount:           "amount",
      payment_details:  "opt",
      transaction_id:   "trans_id"
    }
    attr_reader(*(STATUS_FIELDS.keys))

    def initialize(api_key: SecupayRuby::ApiKey::MasterKey.new, hash: nil)
      @api_key = api_key
      @hash = hash
    end

    def hash?
      !hash.nil?
    end

    def init(amount:, payment_type:, demo: 1)
      @response = nil

      @amount = amount
      @payment_type = payment_type
      @demo = demo

      raise_if_payment_not_initiated
      raise_if_payment_type_invalid

      params = {
        amount: amount,
        demo: demo,
        payment_type: payment_type
      }

      @response = SecupayRuby::Requests::Init.post(api_key: api_key,
                                                   payment: self,
                                                   body: params)<commit_msg>turn of demo mode for payments<commit_after>module SecupayRuby
  class Payment
    module Types
      DEBIT = "debit"
      PREPAY = "prepay"
    end

    attr_reader :api_key, :response, :amount, :payment_type, :demo

    INIT_FIELDS = {
      hash: "hash",
      iframe_url: "iframe_url",
      purpose: "purpose",
      payment_data: "payment_data"
    }
    attr_reader(*(INIT_FIELDS.keys))

    STATUS_FIELDS = {
      payment_status:   "payment_status",
      status:           "status",
      created_at:       "created",
      demo:             "demo",
      amount:           "amount",
      payment_details:  "opt",
      transaction_id:   "trans_id"
    }
    attr_reader(*(STATUS_FIELDS.keys))

    def initialize(api_key: SecupayRuby::ApiKey::MasterKey.new, hash: nil)
      @api_key = api_key
      @hash = hash
    end

    def hash?
      !hash.nil?
    end

    def init(amount:, payment_type:, demo: 0)
      @response = nil

      @amount = amount
      @payment_type = payment_type
      @demo = demo

      raise_if_payment_not_initiated
      raise_if_payment_type_invalid

      params = {
        amount: amount,
        demo: demo,
        payment_type: payment_type
      }

      @response = SecupayRuby::Requests::Init.post(api_key: api_key,
                                                   payment: self,
                                                   body: params)
{'fraction_non_alphanumeric': 0.0955803090190442, 'fraction_numerical': 0.0007186489399928135, 'mean_word_length': 1.7951807228915662, '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': 8, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4092524', 'n_tokens_mistral': 884, 'n_tokens_neox': 836, 'n_words': 176}