class TinggAdapter::Encryption

@!scope

Public Class Methods

new(iv_key, secret_key, **args) click to toggle source
# File lib/qatingg.rb, line 9
def initialize(iv_key, secret_key, **args)
  @iv_key = iv_key
  @secret_key = secret_key
  @access_key = args[:access_key]
  @url = args[:url]
  @path = args[:path]
  @checkout_type = args[:checkout_type]
end

Public Instance Methods

encryption(**args) click to toggle source
# File lib/qatingg.rb, line 18
def encryption(**args)
  @due_date = args[:due_date]
  @country_code = args[:country_code]

  if args[:due_date].nil? || args[:due_date] == ''
    time = Time.now + 36_000
    @due_date = time.strftime('%Y-%m-%d %H:%M:%S')
  end

  payload = { merchantTransactionID: args[:transaction_id],
              customerFirstName: args[:customer_first_name],
              customerLastName: args[:customer_last_name],
              MSISDN: args[:msisdn],
              customerEmail: args[:customer_email],
              amount: args[:amount],
              currencyCode: args[:currency_code],
              accountNumber: Time.now,
              serviceCode: args[:service_code],
              dueDate: @due_date,
              serviceDescription: args[:description],
              countryCode: args[:country_code],
              payerClientCode: args[:payer_client_code],
              languageCode: args[:language_code],
              successRedirectUrl: '',
              failRedirectUrl: '',
              paymentWebhookUrl: args[:callback_url] }
  init = TinggEncryption::Encryption.new(@secret_key, @iv_key)
  encrypted = init.encrypt(payload)
  @url + @path + @checkout_type +
    "?params=#{encrypted}" \
  "&accessKey=#{@access_key}" + \
    +"&countryCode=#{@country_code}"
end