Class: MyMoip::PaymentRequest
- Inherits:
-
Request
- Object
- Request
- MyMoip::PaymentRequest
show all
- Defined in:
- lib/mymoip/requests/payment_request.rb
Constant Summary
collapse
- HTTP_METHOD =
:get
- PATH =
"/rest/pagamento?callback=?"
- REQUIRES_AUTH =
false
- FORMAT =
:json
- PAYMENT_SLIP_PATH =
"/Instrucao.do?token="
Instance Attribute Summary collapse
Attributes inherited from Request
#id, #response
Instance Method Summary
collapse
Methods inherited from Request
#initialize
Instance Attribute Details
#token ⇒ Object
Returns the value of attribute token.
10
11
12
|
# File 'lib/mymoip/requests/payment_request.rb', line 10
def token
@token
end
|
Instance Method Details
#api_call(data, opts) ⇒ Object
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
# File 'lib/mymoip/requests/payment_request.rb', line 12
def api_call(data, opts)
@token = opts[:token]
opts[:referer_url] ||= MyMoip.default_referer_url
opts[:parser] ||= MyMoip::JsonParser
json = JSON.generate({
pagamentoWidget: {
referer: opts[:referer_url],
token: token,
dadosPagamento: data.to_json
}
})
params = {
query: { pagamentoWidget: json },
http_method: HTTP_METHOD,
requires_auth: REQUIRES_AUTH,
path: PATH,
format: FORMAT
}
params[:parser] = opts.delete(:parser) unless opts[:parser].nil?
super(params, opts)
end
|
#code ⇒ Object
46
47
48
49
50
|
# File 'lib/mymoip/requests/payment_request.rb', line 46
def code
@response["CodigoMoIP"]
rescue NoMethodError => e
nil
end
|
#success? ⇒ Boolean
38
39
40
|
# File 'lib/mymoip/requests/payment_request.rb', line 38
def success?
@response && @response["StatusPagamento"] == "Sucesso"
end
|