Class: UnionPay::Mobile::Client
- Inherits:
-
Object
- Object
- UnionPay::Mobile::Client
- Includes:
- Core::Logger
- Defined in:
- lib/union-pay/mobile/client.rb
Instance Attribute Summary collapse
-
#config ⇒ Object
readonly
Returns the value of attribute config.
Instance Method Summary collapse
- #async_notice(params) ⇒ Object
-
#consume(other_params) ⇒ Object
默认为人民币 金额填原始值就行, 比如100元,传100过来就行.
-
#initialize(config_or_file) ⇒ Client
constructor
trade_url, query_url, merchant_id, back_end_url, front_end_url, secret_key.
- #query(other_params) ⇒ Object
- #refund(other_params) ⇒ Object
- #undo(other_params) ⇒ Object
Methods included from Core::Logger
Constructor Details
#initialize(config_or_file) ⇒ Client
trade_url, query_url, merchant_id, back_end_url, front_end_url, secret_key
11 12 13 14 15 16 17 |
# File 'lib/union-pay/mobile/client.rb', line 11 def initialize(config_or_file) if config_or_file.is_a?(String) @config = ::UnionPay::Core::Config.mobile_config(config_or_file) else @config = config_or_file end end |
Instance Attribute Details
#config ⇒ Object (readonly)
Returns the value of attribute config.
8 9 10 |
# File 'lib/union-pay/mobile/client.rb', line 8 def config @config end |
Instance Method Details
#async_notice(params) ⇒ Object
42 43 44 45 |
# File 'lib/union-pay/mobile/client.rb', line 42 def async_notice(params) net_log(nil, params, true) ::UnionPay::Core::Response.new(params, @config) end |
#consume(other_params) ⇒ Object
默认为人民币 金额填原始值就行, 比如100元,传100过来就行
21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/union-pay/mobile/client.rb', line 21 def consume(other_params) UnionPay::Core::Utils.check_hash_keys!(other_params, [:orderTime, :orderNumber, :orderAmount]) params = default_params params = params.merge(other_params) params = params.merge({ transType: '01', orderTime: conver_time(other_params[:orderTime]), orderAmount: conver_amount(other_params[:orderAmount]) }) trade(params) end |
#query(other_params) ⇒ Object
47 48 49 50 51 52 53 |
# File 'lib/union-pay/mobile/client.rb', line 47 def query(other_params) UnionPay::Core::Utils.check_hash_keys!(other_params, [:transType, :orderTime, :orderNumber]) params = default_params params = params.merge(other_params) params[:orderTime] = conver_time(other_params[:orderTime]) call_api(@config.query_url, params) end |
#refund(other_params) ⇒ Object
38 39 40 |
# File 'lib/union-pay/mobile/client.rb', line 38 def refund(other_params) undo_and_refund(other_params.merge({transType: '04'})) end |
#undo(other_params) ⇒ Object
34 35 36 |
# File 'lib/union-pay/mobile/client.rb', line 34 def undo(other_params) undo_and_refund(other_params.merge({transType: '31'})) end |