class OffsitePayments::Integrations::Spgateway::Helper
Constants
- FIELDS
Public Class Methods
new(order, account, options = {})
click to toggle source
廠商編號(由 allpay 提供) type: Varchar(10) presense: true example: 2000132 description: mapping :merchant_id, 'MerchantID' mapping :account, 'MerchantID' # AM common
Calls superclass method
# File lib/offsite_payments/integrations/spgateway/helper.rb, line 29 def initialize(order, account, options = {}) super add_field 'Version', OffsitePayments::Integrations::Spgateway::VERSION add_field 'RespondType', OffsitePayments::Integrations::Spgateway::RESPOND_TYPE OffsitePayments::Integrations::Spgateway::CONFIG.each do |field| add_field field, OffsitePayments::Integrations::Spgateway.send(field.underscore.to_sym) end end
Public Instance Methods
encrypted_data()
click to toggle source
# File lib/offsite_payments/integrations/spgateway/helper.rb, line 58 def encrypted_data raw_data = URI.encode_www_form OffsitePayments::Integrations::Spgateway::CHECK_VALUE_FIELDS.sort.map { |field| [field, @fields[field]] } hash_raw_data = "HashKey=#{merchant_hash_key}&#{raw_data}&HashIV=#{merchant_hash_iv}" add_field 'CheckValue', Digest::SHA256.hexdigest(hash_raw_data).upcase end
hash_iv(iv)
click to toggle source
# File lib/offsite_payments/integrations/spgateway/helper.rb, line 42 def hash_iv(iv) @iv = iv end
hash_key(key)
click to toggle source
# File lib/offsite_payments/integrations/spgateway/helper.rb, line 38 def hash_key(key) @key = key end
merchant_hash_iv()
click to toggle source
# File lib/offsite_payments/integrations/spgateway/helper.rb, line 50 def merchant_hash_iv @iv || OffsitePayments::Integrations::Spgateway.hash_iv end
merchant_hash_key()
click to toggle source
# File lib/offsite_payments/integrations/spgateway/helper.rb, line 46 def merchant_hash_key @key || OffsitePayments::Integrations::Spgateway.hash_key end
time_stamp(date)
click to toggle source
# File lib/offsite_payments/integrations/spgateway/helper.rb, line 54 def time_stamp(date) add_field 'TimeStamp', date.to_time.to_i end