Class: ActiveMerchant::Billing::Integrations::Bill99Card::Helper

Inherits:
Helper
  • Object
show all
Defined in:
lib/active_merchant/billing/integrations/bill99_card/helper.rb

Instance Method Summary collapse

Constructor Details

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

Returns a new instance of Helper.



16
17
18
19
20
21
22
23
24
25
# File 'lib/active_merchant/billing/integrations/bill99_card/helper.rb', line 16

def initialize(order, , options = {})
  options[:amount] = (options[:amount] * 100).to_i
  super(order, , options)
  add_field('version', 'v2.0')
  add_field('language', '1')
  add_field('signType', '1')
  add_field('payType', '42')
  add_field('fullAmountFlag', '0')
  add_field('orderTime', DateTime.now.strftime("%Y%m%d%H%M%S"))
end

Instance Method Details

#form_fieldsObject



27
28
29
# File 'lib/active_merchant/billing/integrations/bill99_card/helper.rb', line 27

def form_fields
  @fields.merge('signMsg' => sign)
end

#signObject



31
32
33
34
35
36
# File 'lib/active_merchant/billing/integrations/bill99_card/helper.rb', line 31

def sign
  Digest::MD5.hexdigest(%w(inputCharset bgUrl pageUrl version language signType merchantAcctId payerName payerContactType payerContact
       orderId orderAmount payType fullAmountFlag orderTime productName productNum productId productDesc ext1 ext2 bossType).collect{
      |name| @fields[name].blank? ? "" : "#{name}=#{@fields[name]}"
    }.select{|s| !s.blank? }.join('&') + "&key=#{KEY[@fields['bossType']]}").upcase
end