<commit_before>require 'net/http'

module ActiveMerchant #:nodoc:
  module Billing #:nodoc:
    module Integrations #:nodoc:
      module Doku
        # # Example:****
        # ## app/controllers/doku_controller.rb
        # class DokuController < ApplicationController
        #   include ActiveMerchant::Billing::Integrations
        #
        #   def notify
        #     parser = Doku::Notification.new(request.raw_post)
        #     order = Order.find_by_order_number(parser.item_id)
        #     if order && order.total == parser.gross
        #       # update order status according to parser.status (Success | Fail)
        #       render text: 'Continue'
        #     else
        #       render text: 'Stop'
        #     end
        #   end
        # end
        #

        class Notification < ActiveMerchant::Billing::Integrations::Notification

          self.production_ips = ['172.16.17.32', '192.168.127.12']

          def complete?
            status.present?
          end

          def item_id
            params['TRANSIDMERCHANT']
          end

          def gross
            params['AMOUNT']
          end

          def status
            case params['RESULT']
            when 'Success'
              'Completed'
            when 'Fail'
              'Failed'
            end
          end

          def currency
            'IDR'
          end

          def acknowledge(authcode = nil)
            true
          end

          def test?
            false
          end

          private

          def parse(post)
            @raw = post.to_s
            for line in @raw.split('&')
              key, value = *line.scan( %r{^([A-Za-z0-9_.]+)\=(.*)$} ).flatten
              params[key] = CGI.unescape(value)
            end
          end

        end
      end
    end
  end
end
<commit_msg>notification is typed and forces WORDS check<commit_after>require 'net/http'

module ActiveMerchant #:nodoc:
  module Billing #:nodoc:
    module Integrations #:nodoc:
      module Doku
        # # Example:****
        # ## app/controllers/doku_controller.rb
        # class DokuController < ApplicationController
        #   include ActiveMerchant::Billing::Integrations
        #
        #   def notify
        #     parser = Doku::Notification.new(request.raw_post)
        #     order = Order.find_by_order_number(parser.item_id)
        #     if order && order.total == parser.gross
        #       # update order status according to parser.status (Success | Fail)
        #       render text: 'Continue'
        #     else
        #       render text: 'Stop'
        #     end
        #   end
        # end
        #

        class Notification < ActiveMerchant::Billing::Integrations::Notification

          self.production_ips = ['172.16.17.32', '192.168.127.12']

          def complete?
            status.present?
          end

          def item_id
            params['TRANSIDMERCHANT']
          end

          def gross
            params['AMOUNT']
          end

          def status
            case params['RESULT']
            when 'Success'
              'Completed'
            when 'Fail'
              'Failed'
            end
          end

          def currency
            'IDR'
          end

          def words
            params['WORDS']
          end

          def type
            if words
              'verify'
            elsif status
              'notify'
            else
              false
            end
          end

          def acknowledge(authcode = nil)
            case type
            when 'verify'
              words == Digest::SHA1.hexdigest("#{gross}#{@options[:credential2]}#{item_id}")
            when 'notify'
              true
            else
              false
            end
          end
        end
      end
    end
  end
end

{'fraction_non_alphanumeric': 0.08725182863113898, 'fraction_numerical': 0.011494252873563218, 'mean_word_length': 1.2444314185228604, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 4, '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': '3434377', 'n_tokens_mistral': 1049, 'n_tokens_neox': 1002, 'n_words': 239}