Skip to content

Commit

Permalink
Wxpay的初始化中加入了对参数的检查。
Browse files Browse the repository at this point in the history
  • Loading branch information
Stanley Yeh committed Sep 25, 2015
1 parent da6c447 commit 377f6f6
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/offsite_payments/integrations/wxpay.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ class BusinessError < RuntimeError; end
get_brand_wcpay: { helper_type: :GetBrandWCPayHelper, request_url: '' } ,
}

REQUIRED_CREDENTIAL_SETTINGS = [:api_key, :appsecret].freeze
def self.get_helper(api_type, data)
self.const_get(API_CONFIG[api_type][:helper_type]).new(data)
end
Expand Down Expand Up @@ -66,7 +67,8 @@ def self.signed_string(fields)
end

def self.credentials=(cred)
@@key = cred.delete(:key)
(REQUIRED_CREDENTIAL_SETTINGS - cred.keys).tap { |missing_keys| missing_keys.empty? || raise("缺乏必要的账户信息#{missing_keys}。只有#{cred.keys}") }
@@key = cred.delete(:api_key)
@@appsecret = cred.delete(:appsecret)
@@credentials = cred
end
Expand Down

0 comments on commit 377f6f6

Please sign in to comment.