Module: Transbank::Webpay::Params

Includes:
Helper
Included in:
Api
Defined in:
lib/transbank/webpay/params.rb

Constant Summary

Constants included from Helper

Helper::XS_DATE_TIME, Helper::XS_INTEGER

Instance Method Summary collapse

Methods included from Helper

#camelcase, #typecasting, #underscore, #xml_to_hash

Instance Method Details

#build_init_transaction_params(underscore_params = {}) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/transbank/webpay/params.rb', line 6

def build_init_transaction_params(underscore_params = {})
  camelcase_params = {
    wSTransactionType: 'TR_NORMAL_WS',
    buyOrder: underscore_params[:buy_order],
    sessionId: underscore_params[:session_id],
    returnURL: underscore_params[:return_url],
    finalURL: underscore_params[:final_url],
    transactionDetails: {
      amount: underscore_params[:amount],
      commerceCode: Transbank::Webpay.configuration.commerce_code,
      buyOrder: underscore_params[:buy_order]
    }
  }

  { wsInitTransactionInput: camelcase_params }
end

#build_nullify_params(underscore_params = {}) ⇒ Object



23
24
25
26
27
28
29
30
31
32
# File 'lib/transbank/webpay/params.rb', line 23

def build_nullify_params(underscore_params = {})
  camelcase_params = underscore_params.each_with_object({}) do |(key, value), hash|
    new_key = camelcase(key).to_sym
    hash[new_key] = value
  end

  camelcase_params[:commerceId] = Transbank::Webpay.configuration.commerce_code

  { nullificationInput: camelcase_params }
end