Class: Redex::Request::TransactionRequest

Inherits:
BaseRequest
  • Object
show all
Defined in:
lib/redex/request/transaction_request.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from BaseRequest

#authorization_params, client, #result, #sanitize

Constructor Details

#initialize(params = {}) ⇒ TransactionRequest

Returns a new instance of TransactionRequest.



10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/redex/request/transaction_request.rb', line 10

def initialize(params = {})
				@order_id = params[:order_id]
				@amount = params[:amount]
				@installments = params.fetch(:installments, 1)
				@invoice_note = params[:invoice_note]
				@card_number = params[:card_number]
				@card_cvv = params[:card_cvv]
				@card_holder_name = params[:card_holder_name]
				@card_expiration_month = params[:card_expiration_month]
				@card_expiration_year = params[:card_expiration_year]
				@auto_capture = params.fetch(:auto_capture, true)
  @recorrence = params.fetch(:recorrence, false)
  @origin = 1
end

Instance Attribute Details

#amountObject

Returns the value of attribute amount.



4
5
6
# File 'lib/redex/request/transaction_request.rb', line 4

def amount
  @amount
end

#auto_captureObject

Returns the value of attribute auto_capture.



4
5
6
# File 'lib/redex/request/transaction_request.rb', line 4

def auto_capture
  @auto_capture
end

#card_cvvObject

Returns the value of attribute card_cvv.



4
5
6
# File 'lib/redex/request/transaction_request.rb', line 4

def card_cvv
  @card_cvv
end

#card_expiration_monthObject

Returns the value of attribute card_expiration_month.



4
5
6
# File 'lib/redex/request/transaction_request.rb', line 4

def card_expiration_month
  @card_expiration_month
end

#card_expiration_yearObject

Returns the value of attribute card_expiration_year.



4
5
6
# File 'lib/redex/request/transaction_request.rb', line 4

def card_expiration_year
  @card_expiration_year
end

#card_holder_nameObject

Returns the value of attribute card_holder_name.



4
5
6
# File 'lib/redex/request/transaction_request.rb', line 4

def card_holder_name
  @card_holder_name
end

#card_numberObject

Returns the value of attribute card_number.



4
5
6
# File 'lib/redex/request/transaction_request.rb', line 4

def card_number
  @card_number
end

#installmentsObject

Returns the value of attribute installments.



4
5
6
# File 'lib/redex/request/transaction_request.rb', line 4

def installments
  @installments
end

#invoice_noteObject

Returns the value of attribute invoice_note.



4
5
6
# File 'lib/redex/request/transaction_request.rb', line 4

def invoice_note
  @invoice_note
end

#order_idObject

Returns the value of attribute order_id.



4
5
6
# File 'lib/redex/request/transaction_request.rb', line 4

def order_id
  @order_id
end

#originObject (readonly)

Returns the value of attribute origin.



8
9
10
# File 'lib/redex/request/transaction_request.rb', line 8

def origin
  @origin
end

#recorrenceObject (readonly)

Returns the value of attribute recorrence.



8
9
10
# File 'lib/redex/request/transaction_request.rb', line 8

def recorrence
  @recorrence
end

Instance Method Details

#sanitized_fieldsObject



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/redex/request/transaction_request.rb', line 25

def sanitized_fields
	{
		NumPedido: sanitize(:order_id),
		Total: sanitize(:amount),
		Parcelas: sanitize(:installments),
		IdentificacaoFatura: sanitize(:invoice_note),
		Nrcartao: sanitize(:card_number),
		Cvc2: sanitize(:card_cvv),
		Portador: sanitize(:card_holder_name),
		Mes: sanitize(:card_expiration_month),
		Ano: sanitize(:card_expiration_year),
		Recorrente: sanitize(:recorrence),
		Origem: sanitize(:origin),
		Transacao: transaction_type
	}.merge(authorization_params).sort.to_h.select { |k, v| !v.to_s.empty?  }
end