class Bancard::SingleBuyInit
Constants
- ENDPOINT
Attributes
given_params[RW]
private_key[RW]
public_key[RW]
Public Class Methods
new(given_params = {})
click to toggle source
# 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
Public Instance Methods
operation_params()
click to toggle source
# 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_params()
click to toggle source
# File lib/bancard/single_buy_init.rb, line 14 def request_params { operation: operation_params, public_key: public_key, } end
Private Instance Methods
amount()
click to toggle source
# File lib/bancard/single_buy_init.rb, line 43 def amount given_params['amount_in_cents'].to_i / 100.0 end
currency()
click to toggle source
# File lib/bancard/single_buy_init.rb, line 35 def currency given_params['currency'] || Bancard::DEFAULT_CURRENCY end
formatted_amount()
click to toggle source
# File lib/bancard/single_buy_init.rb, line 39 def formatted_amount sprintf('%.2f', amount) end
shop_process_id()
click to toggle source
# File lib/bancard/single_buy_init.rb, line 47 def shop_process_id given_params['shop_process_id'] end
token()
click to toggle source
# File lib/bancard/single_buy_init.rb, line 51 def token Digest::MD5.hexdigest [private_key, shop_process_id, formatted_amount, currency].join('') end