Class: Bancard::SingleBuyInit

Inherits:
Object
  • Object
show all
Includes:
Utils
Defined in:
lib/bancard/single_buy_init.rb

Constant Summary collapse

ENDPOINT =
'/vpos/api/0.3/single_buy'

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Utils

#stringify_keys

Constructor Details

#initialize(given_params = {}) ⇒ SingleBuyInit

Returns a new instance of SingleBuyInit.



8
9
10
11
12
# File 'lib/bancard/single_buy_init.rb', line 8

def initialize(given_params = {})
  @given_params = stringify_keys(given_params)
  @public_key   = @given_params.delete('public_key')
  @private_key  = @given_params.delete('private_key')
end

Instance Attribute Details

#given_paramsObject

Returns the value of attribute given_params.



6
7
8
# File 'lib/bancard/single_buy_init.rb', line 6

def given_params
  @given_params
end

#private_keyObject

Returns the value of attribute private_key.



6
7
8
# File 'lib/bancard/single_buy_init.rb', line 6

def private_key
  @private_key
end

#public_keyObject

Returns the value of attribute public_key.



6
7
8
# File 'lib/bancard/single_buy_init.rb', line 6

def public_key
  @public_key
end

Instance Method Details

#operation_paramsObject



21
22
23
24
25
26
27
28
29
30
31
# File 'lib/bancard/single_buy_init.rb', line 21

def operation_params
  {
    amount:          formatted_amount,
    cancel_url:      given_params['cancel_url'],
    currency:        currency,
    description:     given_params['description'],
    return_url:      given_params['return_url'],
    shop_process_id: shop_process_id,
    token:           token,
  }
end

#request_paramsObject



14
15
16
17
18
19
# File 'lib/bancard/single_buy_init.rb', line 14

def request_params
  {
    operation:  operation_params,
    public_key: public_key,
  }
end