Class: PuntoPagos::Request

Inherits:
Object
  • Object
show all
Defined in:
lib/puntopagos/request.rb

Instance Method Summary collapse

Constructor Details

#initialize(env = nil) ⇒ Request

Returns a new instance of Request.



13
14
15
16
17
18
# File 'lib/puntopagos/request.rb', line 13

def initialize env = nil
  @env = env
  @@config ||= PuntoPagos::Config.new(@env)
  @@puntopagos_base_url ||= @@config.puntopagos_base_url
  @@function = "transaccion/crear"
end

Instance Method Details

#create(trx_id, amount, payment_type = nil) ⇒ Object

Raises:



24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/puntopagos/request.rb', line 24

def create trx_id, amount, payment_type = nil
  raise NoDataError unless trx_id and amount
  data = create_data trx_id, amount, payment_type

  timestamp = get_timestamp

  message = create_message(data['trx_id'], data['monto'], timestamp)
  authorization = PuntoPagos::Authorization.new(@env)
  signature = authorization.sign(message)
  executioner = PuntoPagos::Executioner.new(@env)

  response_data = executioner.call_api(data, @@function, :post, signature, timestamp)
  PuntoPagos::Response.new(response_data, @env)
end

#validateObject



20
21
22
# File 'lib/puntopagos/request.rb', line 20

def validate
  #TODO validate JSON must have monto and trx_id
end