Class: Reapal::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/reapal/client.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options_arg) ⇒ Client

Returns a new instance of Client.



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/reapal/client.rb', line 9

def initialize(options_arg)
  options = Utils.symbolize_keys(options_arg)
  @config = {
    server_url: options[:server_url],
    partner_id: options[:partner_id],
    merchant_id: options[:merchant_id],
    md5_key: options[:md5_key],
    private_key: OpenSSL::PKey::RSA.new(options[:private_key], options[:private_key_pwd]),
    public_key: OpenSSL::X509::Certificate.new(options[:public_key]).public_key,
  }

  # 自动 include api 下的模块
  recursive_include_api('Reapal::Api')
  # 自动 include form 下的模块
  recursive_include_api('Reapal::Form')
end

Instance Attribute Details

#configObject

Returns the value of attribute config.



7
8
9
# File 'lib/reapal/client.rb', line 7

def config
  @config
end

Instance Method Details

#decode_notify_data(encryptkey, data) ⇒ Object



31
32
33
# File 'lib/reapal/client.rb', line 31

def decode_notify_data(encryptkey, data)
  ::Reapal::Http::Decode.decode_notify_data(encryptkey, data, @config)
end

#platform_contractObject



26
27
28
29
# File 'lib/reapal/client.rb', line 26

def platform_contract
  # R+PARTNER
  "R#{@config[:partner_id]}"
end