class OffsitePayments::Integrations::Newebpay::Helper
The Helper
to build payment form
@since 0.1.0
Public Class Methods
new(order, account, options = {})
click to toggle source
@see OffsitePayments::Helper#initialize
@since 0.1.0
Calls superclass method
# File lib/offsite_payments/integrations/newebpay/helper.rb, line 13 def initialize(order, account, options = {}) super add_field('RespondType', 'JSON') add_field('TimeStamp', Time.now.to_i) add_field('Version', VERSION) add_field('ItemDesc', options[:description]) end
Public Instance Methods
form_fields()
click to toggle source
Fields to build form
@return [Hash]
@since 0.1.0
# File lib/offsite_payments/integrations/newebpay/helper.rb, line 57 def form_fields fields.merge('TradeInfo' => trade_info, 'TradeSha' => trade_sha) end
params()
click to toggle source
The content of trade information
@return [String]
@since 0.1.0
# File lib/offsite_payments/integrations/newebpay/helper.rb, line 48 def params URI.encode_www_form(fields) end
trade_info()
click to toggle source
The encrypted trade information
@return [String]
@since 0.1.0
# File lib/offsite_payments/integrations/newebpay/helper.rb, line 66 def trade_info ::Newebpay::Cipher.encrypt(params) end
trade_sha()
click to toggle source
The checksum for trade info
@return [String]
@since 0.1.0
# File lib/offsite_payments/integrations/newebpay/helper.rb, line 75 def trade_sha Digest::SHA256 .hexdigest("HashKey=#{::Newebpay::Config.hash_key}&#{trade_info}&HashIV=#{::Newebpay::Config.hash_iv}") .upcase end