Class: Akatus::Services::Transaction

Inherits:
Akatus::Service show all
Defined in:
lib/akatus/services/transaction.rb

Constant Summary collapse

PATH =
'carrinho'
METHOD =
:post

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Akatus::Service

#send_request

Class Method Details

.create(*args) ⇒ Object



14
15
16
# File 'lib/akatus/services/transaction.rb', line 14

def self.create(*args)
  self.new.create(*args)
end

.form_urlObject



10
11
12
# File 'lib/akatus/services/transaction.rb', line 10

def self.form_url
  Akatus.config.base_url + PATH
end

Instance Method Details

#create(payment) ⇒ Object



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/akatus/services/transaction.rb', line 18

def create(payment)

  @payment = payment

  data = send_request

  @payment.id             = data['carrinho']

  # TODO: improve; use constants?
  @payment.status         = data['status']
  @payment.transaction_id = data['transacao']

  if data['url_retorno']
    @payment.url = data['url_retorno'].sub("https://www.akatus.com/", Akatus.config.base_url)
  end

  @payment

end

#statusObject



38
39
40
# File 'lib/akatus/services/transaction.rb', line 38

def status
  # TODO: implement.
end

#to_payloadObject



42
43
44
# File 'lib/akatus/services/transaction.rb', line 42

def to_payload
  @payment.to_payload
end