Class: OffsitePayments::Integrations::Pay2goPeriod::Helper

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

Constant Summary collapse

FIELDS =
%w(
  MerchantID MerchantOrderNo PeriodAmt ProdDesc PeriodAmtMode PeriodType PeriodPoint PeriodStartType
  PeriodTimes ReturnURL ProDetail PeriodMemo PaymentInfo OrderInfo InvoiceInfo NotifyURL
)

Instance Method Summary collapse

Constructor Details

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



52
53
54
55
56
57
# File 'lib/offsite_payments/integrations/pay2go_period.rb', line 52

def initialize(order, , options = {})
  super
  add_field 'MerchantID', OffsitePayments::Integrations::Pay2go.merchant_id
  add_field 'Version', OffsitePayments::Integrations::Pay2goPeriod::VERSION
  add_field 'RespondType', OffsitePayments::Integrations::Pay2goPeriod::RESPOND_TYPE
end

Instance Method Details

#encrypted_dataObject



63
64
65
66
67
68
69
70
# File 'lib/offsite_payments/integrations/pay2go_period.rb', line 63

def encrypted_data
  raw_data = URI.encode_www_form OffsitePayments::Integrations::Pay2goPeriod::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



59
60
61
# File 'lib/offsite_payments/integrations/pay2go_period.rb', line 59

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