<commit_before>class Esewa
  attr_accessor :service_code, :product_id, :url, :service_type, :amount, :txtAmt, :total_amount, :service_charge, :delivery_charge,  :success_url, :failure_url
  def initialize(service_code, product_id, service_type = "demo")
    @service_code = service_code
    @product_id = product_id
    @service_type = service_type
  end

  def set_data(amount, txtAmt=0, service_charge=0, delivery_charge=0, success_url='', failure_url='')
    @amount = amount
    @txtAmt = txtAmt
    @service_charge = service_charge
    @delivery_charge = delivery_charge
    @success_url = success_url
    @failure_url = failure_url
  end

  def payment
    calculate_total_amount
    get_url
    response = RestClient.post( @url, tAmt: @total_amount, amt: @amount, txtAmt: @txtAmt, psc: @service_charge, pdc: @delivery_charge, scd: @service_code, pid: @product_id, su: @success_url, fu: @failure_url) do |response, request, result, &block|
      puts response
      if [301, 302, 307].include? response.code
        redirected_url = response.headers[:location]
      else
        response.return!(request, result, &block)
      end
    end
  end

  private
  def get_url
    @url = @service_type.downcase == 'live' ? "https://esewa.com.np/epay/main" : "http://dev.esewa.com.np/epay/main"
  end

  def calculate_total_amount
    @total_amount = @amount + @txtAmt + @service_charge + @delivery_charge
  end
end<commit_msg>Moved palyment code from esewa library to payment module<commit_after>
module Esewa
  class Base
    attr_accessor :service_code, :product_id
    def initialize(service_code, product_id)
      @service_code = service_code
      @product_id = product_id
    end
  end
end

require 'esewa/payment'
{'fraction_non_alphanumeric': 0.10226612434631029, 'fraction_numerical': 0.006972690296339338, 'mean_word_length': 4.109792284866469, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 1, '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': '5671820', 'n_tokens_mistral': 597, 'n_tokens_neox': 586, 'n_words': 137}