class EpayTools::Calculator

Attributes

epay_md5_key[R]
epay_merchant_number[R]
params[R]

Public Class Methods

new(epay_md5_key:, params:) click to toggle source
# File lib/epay_tools/calculator.rb, line 4
def initialize(epay_md5_key:, params:)
  @epay_md5_key = epay_md5_key
  @params = params
end

Public Instance Methods

execute!() click to toggle source
# File lib/epay_tools/calculator.rb, line 9
def execute!
  epay_params = {}
  EpayTools::OrderedParameters::ORDERED_PARAMETERS.each do |ordered_parameter|
    epay_params[ordered_parameter] = params.fetch(ordered_parameter)
  end

  epay_hash = EpayTools::HashGenerator.execute!(epay_md5_key: epay_md5_key, params: epay_params).result
  epay_params_with_hash = epay_params.merge("hash" => epay_hash)

  ServicePattern::Response.new(
    result: {
      epay_params: epay_params,
      epay_hash: epay_hash,
      epay_params_with_hash: epay_params_with_hash
    }
  )
end