Class: Cieloz::RequisicaoTransacao::FormaPagamento
- Inherits:
-
Object
- Object
- Cieloz::RequisicaoTransacao::FormaPagamento
show all
- Includes:
- Helpers
- Defined in:
- lib/cieloz/requisicao_transacao/forma_pagamento.rb
Constant Summary
collapse
- DEBITO =
"A"
- CREDITO =
1
- PARCELADO_LOJA =
2
- PARCELADO_ADM =
3
- BANDEIRAS_DEBITO =
[ Cieloz::Bandeiras::VISA, Cieloz::Bandeiras::MASTERCARD ]
- SUPORTAM_AUTENTICACAO =
BANDEIRAS_DEBITO
- BANDEIRAS_PARCELAMENTO =
Cieloz::Bandeiras::ALL - [Cieloz::Bandeiras::DISCOVER]
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Methods included from Helpers
#attributes=, #dasherize_attr, included, #initialize
Instance Attribute Details
#bandeira ⇒ Object
Returns the value of attribute bandeira.
15
16
17
|
# File 'lib/cieloz/requisicao_transacao/forma_pagamento.rb', line 15
def bandeira
@bandeira
end
|
#parcelas ⇒ Object
Returns the value of attribute parcelas.
15
16
17
|
# File 'lib/cieloz/requisicao_transacao/forma_pagamento.rb', line 15
def parcelas
@parcelas
end
|
#produto ⇒ Object
Returns the value of attribute produto.
15
16
17
|
# File 'lib/cieloz/requisicao_transacao/forma_pagamento.rb', line 15
def produto
@produto
end
|
Class Method Details
.map_credito(source, opts = {}) ⇒ Object
41
42
43
44
|
# File 'lib/cieloz/requisicao_transacao/forma_pagamento.rb', line 41
def self.map_credito(source, opts={})
bandeira = attrs_from source, opts, :bandeira
new(source: source, opts: opts).credito bandeira
end
|
.map_debito(source, opts = {}) ⇒ Object
36
37
38
39
|
# File 'lib/cieloz/requisicao_transacao/forma_pagamento.rb', line 36
def self.map_debito(source, opts={})
bandeira = attrs_from source, opts, :bandeira
new(source: source, opts: opts).debito bandeira
end
|
.map_parcelado(source, opts = {}) ⇒ Object
46
47
48
49
|
# File 'lib/cieloz/requisicao_transacao/forma_pagamento.rb', line 46
def self.map_parcelado source, opts={}
bandeira, parcelas = attrs_from source, opts, :bandeira, :parcelas
new(source: source, opts: opts).parcelado bandeira, parcelas
end
|
Instance Method Details
#attributes ⇒ Object
51
52
53
54
55
56
57
|
# File 'lib/cieloz/requisicao_transacao/forma_pagamento.rb', line 51
def attributes
{
bandeira: @bandeira,
produto: @produto,
parcelas: @parcelas
}
end
|
#credito(bandeira) ⇒ Object
71
72
73
|
# File 'lib/cieloz/requisicao_transacao/forma_pagamento.rb', line 71
def credito bandeira
set_attrs bandeira, CREDITO, 1
end
|
#debito(bandeira) ⇒ Object
63
64
65
|
# File 'lib/cieloz/requisicao_transacao/forma_pagamento.rb', line 63
def debito bandeira
set_attrs bandeira, DEBITO, 1
end
|
#debito? ⇒ Boolean
67
68
69
|
# File 'lib/cieloz/requisicao_transacao/forma_pagamento.rb', line 67
def debito?
@produto == DEBITO
end
|
#metodo_autorizacao ⇒ Object
84
85
86
|
# File 'lib/cieloz/requisicao_transacao/forma_pagamento.rb', line 84
def metodo_autorizacao
@metodo_autorizacao || :autorizacao_direta
end
|
#parcelado(bandeira, parcelas) ⇒ Object
75
76
77
78
79
80
81
82
|
# File 'lib/cieloz/requisicao_transacao/forma_pagamento.rb', line 75
def parcelado bandeira, parcelas
max, max_adm = Cieloz::Configuracao.max_parcelas, Cieloz::Configuracao.max_adm_parcelas
produto = case parcelas
when (1..max) then PARCELADO_LOJA
when (max+1..max_adm) then PARCELADO_ADM
end
parcelar bandeira, produto, parcelas
end
|
#suporta_autenticacao? ⇒ Boolean
59
60
61
|
# File 'lib/cieloz/requisicao_transacao/forma_pagamento.rb', line 59
def suporta_autenticacao?
SUPORTAM_AUTENTICACAO.include? @bandeira
end
|