Class: MostOts::Service

Inherits:
Object
  • Object
show all
Includes:
Logging
Defined in:
lib/most_ots/service.rb

Overview

Most Money HTTP Service Wrapper

Constant Summary collapse

ENCRYPTED_FIELDS =

Fields that needs to be encrypted

i[traceNo qrAccountNumber qrCode srcMsisdn tan].freeze
PROTOCOL_VERSION =

Current Protocol Version

'05'.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Logging

#logger

Constructor Details

#initialize(options = {}) ⇒ Service

Returns a new instance of Service.

Parameters:

  • options (Hash) (defaults to: {})


35
36
37
38
39
40
41
42
# File 'lib/most_ots/service.rb', line 35

def initialize(options = {})
  logger.debug('MostOts Service API Initializing')
  setup_base_params(options)
  self.certificate = options.fetch(:most_cert_file)
  self.api_host    = options.fetch(:host) { 'http://202.131.242.165:9089' }
  self.cipher_key  = options[:cipher_key]
  self.cipher_iv   = options.fetch(:cipher_iv)
end

Instance Attribute Details

#api_hostString

Most API Endpoint

Returns:

  • (String)

    MOST Service HOST



32
33
34
# File 'lib/most_ots/service.rb', line 32

def api_host
  @api_host
end

#base_paramsHash

Base Parameters

Returns:

  • (Hash)


24
25
26
# File 'lib/most_ots/service.rb', line 24

def base_params
  @base_params
end

#certificateFile

Most Provided Public Key

Returns:

  • (File)

    or [String] certificate_string



28
29
30
# File 'lib/most_ots/service.rb', line 28

def certificate
  @certificate
end

#cipher_ivArray

Returns cipher IV binary.

Returns:

  • (Array)

    cipher IV binary



20
21
22
# File 'lib/most_ots/service.rb', line 20

def cipher_iv
  @cipher_iv
end

#cipher_keyString

Returns 16byte key string.

Returns:

  • (String)

    16byte key string



17
18
19
# File 'lib/most_ots/service.rb', line 17

def cipher_key
  @cipher_key
end

Instance Method Details

#check_qr_payment(params) ⇒ JSON

Returns response.

Parameters:

  • params (Hash)

Returns:

  • (JSON)

    response



79
80
81
82
83
84
85
86
# File 'lib/most_ots/service.rb', line 79

def check_qr_payment(params)
  logger.debug('MostOts Service Check QR Payment Called')
  # Mandatory Fields
  mf = i[srcInstId channel lang traceNo qrCode payeeId posNo billId isCheckQr]
  # Optional Fields
  of = i[deviceIP deviceMac deviceName]
  api_request('/api/mapi/TT3065', configure_params(params, mf, of))
end

#check_qr_payment_batch(params) ⇒ JSON

Returns response.

Parameters:

  • params (Hash)

Returns:

  • (JSON)

    response



90
91
92
93
94
95
96
97
# File 'lib/most_ots/service.rb', line 90

def check_qr_payment_batch(params)
  logger.debug('MostOts Service Check QR Payment Called')
  # Mandatory Fields
  mf = i[srcInstId channel lang traceNo qrCode payeeId posNo isCheckQr]
  # Optional Fields
  of = i[deviceIP deviceMac deviceName]
  api_request('/api/mapi/TT3066', configure_params(params, mf, of))
end

#purchase_qr(params) ⇒ JSON

Returns response.

Parameters:

  • params (Hash)

Returns:

  • (JSON)

    response



46
47
48
49
50
51
52
53
# File 'lib/most_ots/service.rb', line 46

def purchase_qr(params)
  logger.debug('MostOts Service Purchase QR Called')
  # Mandatory Fields
  mf = i[srcInstId channel lang traceNo payeeId posNo tranAmount tranCur tranDesc qrPaidLimit]
  # Optional Fields 
  of = i[billId deviceIP deviceMac deviceName]
  api_request('/api/mapi/TT3051', configure_params(params, mf, of))
end

#purchase_tan(params) ⇒ JSON

Returns response.

Parameters:

  • params (Hash)

Returns:

  • (JSON)

    response



101
102
103
104
105
106
107
108
# File 'lib/most_ots/service.rb', line 101

def purchase_tan(params)
  logger.debug('MostOts Service Purchase Tan Called')
  # Mandatory Fields
  mf = i[srcInstId channel lang traceNo payeeId posNo srcMsisdn tan tranAmount tranCur]
  # Optional Fields
  of = i[billId tranDesc deviceIP deviceMac deviceName]
  api_request('/api/mapi/TT1608', configure_params(params, mf, of))
end

#transfer_qr(params) ⇒ JSON

Returns response.

Parameters:

  • params (Hash)

Returns:

  • (JSON)

    response



57
58
59
60
61
62
63
64
# File 'lib/most_ots/service.rb', line 57

def transfer_qr(params)
  logger.debug('MostOts Service Transfer QR Called')
  # Mandatory Fields
  mf = i[srcInstId channel lang traceNo qrBankCode qrAccountName qrAccountNumber tranAmount tranCur]
  # Optional Fields
  of = i[tranDesc]
  api_request('/api/mapi/TT3061', configure_params(params, mf, of))
end

#wait_payment_response(params) ⇒ JSON

Returns response.

Parameters:

  • params (Hash)

Returns:

  • (JSON)

    response



68
69
70
71
72
73
74
75
# File 'lib/most_ots/service.rb', line 68

def wait_payment_response(params)
  logger.debug('MostOts Service Waiting Payment Response')
  # Mandatory Fields
  mf = i[srcInstId channel lang qrBankCode qrAccountName qrAccountNumber tranAmount tranCur]
  # Optional Fields
  of = i[tranDesc]
  api_request('/api/mapi/TT3064', configure_params(params, mf, of))
end