Class: OffsitePayments::Integrations::Pay2go::Helper

Inherits:
Helper
  • Object
show all
Defined in:
lib/offsite_payments/integrations/pay2go.rb

Constant Summary collapse

FIELDS =
%w(
  MerchantID LangType MerchantOrderNo Amt ItemDesc TradeLimit ExpireDate ReturnURL NotifyURL CustomerURL ClientBackURL Email EmailModify LoginType OrderComment CREDIT CreditRed InstFlag UNIONPAY WEBATM VACC CVS BARCODE CUSTOM TokenTerm
)

Instance Method Summary collapse

Constructor Details

#initialize(order, account, options = {}) ⇒ Helper



59
60
61
62
63
64
65
66
# File 'lib/offsite_payments/integrations/pay2go.rb', line 59

def initialize(order, , options = {})
  super
  add_field 'Version', OffsitePayments::Integrations::Pay2go::VERSION
  add_field 'RespondType', OffsitePayments::Integrations::Pay2go::RESPOND_TYPE
  OffsitePayments::Integrations::Pay2go::CONFIG.each do |field|
    add_field field, OffsitePayments::Integrations::Pay2go.send(field.underscore.to_sym)
  end
end

Instance Method Details

#encrypted_dataObject



72
73
74
75
76
77
78
79
# File 'lib/offsite_payments/integrations/pay2go.rb', line 72

def encrypted_data
  raw_data = URI.encode_www_form OffsitePayments::Integrations::Pay2go::CHECK_VALUE_FIELDS.sort.map { |field|
    [field, @fields[field]]
  }

  hash_raw_data = "HashKey=#{OffsitePayments::Integrations::Pay2go.hash_key}&#{raw_data}&HashIV=#{OffsitePayments::Integrations::Pay2go.hash_iv}"
  add_field 'CheckValue', Digest::SHA256.hexdigest(hash_raw_data).upcase
end

#time_stamp(date) ⇒ Object



68
69
70
# File 'lib/offsite_payments/integrations/pay2go.rb', line 68

def time_stamp(date)
  add_field 'TimeStamp', date.to_time.to_i
end