Class: ActiveMerchant::Billing::Integrations::Tenpay::Return

Inherits:
Return
  • Object
show all
Defined in:
lib/active_merchant/billing/integrations/tenpay/return.rb

Instance Method Summary collapse

Instance Method Details

#accountObject



9
10
11
# File 'lib/active_merchant/billing/integrations/tenpay/return.rb', line 9

def 
  @params["bargainor_id"]
end

#amountObject



17
18
19
# File 'lib/active_merchant/billing/integrations/tenpay/return.rb', line 17

def amount
  @params["total_fee"]
end

#messageObject



40
41
42
# File 'lib/active_merchant/billing/integrations/tenpay/return.rb', line 40

def message
  @message || @params['pay_info']
end

#orderObject



13
14
15
# File 'lib/active_merchant/billing/integrations/tenpay/return.rb', line 13

def order
  @params["sp_billno"]
end

#success?Boolean

Returns:

  • (Boolean)


21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/active_merchant/billing/integrations/tenpay/return.rb', line 21

def success?
  return false unless @params["pay_info"] == "OK" && @params["pay_result"] == "0"
  unless  == ACCOUNT
    @message = "Tenpay Error: INCORRECT_ACCOUNT"
    return false
  end

  hash_keys = %w(cmdno pay_result date transaction_id sp_billno total_fee fee_type attach)

  md5_string = hash_keys.inject([]){|array, key| array << "#{key}=#{@params[key]}"}.join("&")

  unless Digest::MD5.hexdigest(md5_string+"&key=#{KEY}") == @params["sign"].downcase
    @message = "Tenpay Error: ILLEGAL_SIGN"
    return false
  end

  return true
end