class MundipaggClient::Operations::Charges::Create
Public Instance Methods
execute()
click to toggle source
# File lib/mundipagg_client/operations/charges/create.rb, line 23 def execute raise "Invalid Mundipagg operation" unless request.success? JSON.parse(request.body) end
Private Instance Methods
charge_params()
click to toggle source
# File lib/mundipagg_client/operations/charges/create.rb, line 37 def charge_params {}.tap do |hash| hash[:amount] = params[:amount] hash[:customer_id] = params[:customer_id] payment_params(hash) credit_card_params(hash) end end
credit_card_params(hash)
click to toggle source
# File lib/mundipagg_client/operations/charges/create.rb, line 58 def credit_card_params(hash) if params[:card_id].present? hash[:payment][:credit_card][:card_id] = params[:card_id] else hash[:payment][:credit_card][:card] = { number: params[:card_number], holder_name: params[:card_holder_name], exp_month: params[:card_exp_month], exp_year: params[:card_exp_year], cvv: params[:card_cvv] } end end
payment_params(hash)
click to toggle source
# File lib/mundipagg_client/operations/charges/create.rb, line 46 def payment_params(hash) hash[:payment] = { payment_method: "credit_card", credit_card: { capture: true, recurrence: true, installments: params[:installments], statement_descriptor: params[:statement_descriptor] } } end
request()
click to toggle source
# File lib/mundipagg_client/operations/charges/create.rb, line 31 def request @request ||= connection.post("#{BASE_URL}/charges") do |req| req.body = charge_params.to_json end end