Skip to content

Commit

Permalink
Otimização no código e correção de formatação
Browse files Browse the repository at this point in the history
  • Loading branch information
rafaelfranca committed Nov 30, 2010
1 parent 7547e98 commit 177b093
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions lib/moip/direct_payment.rb
Expand Up @@ -9,17 +9,18 @@ class << self

# Cria uma instrução de pagamento direto
def body(attributes = {})
raise(StandardError, "É necessário informar a razão do pagamento") if attributes[:razao].nil?
raise(StandardError, "É obrigatório passar as informações do pagador") if attributes[:pagador].nil?

builder = Nokogiri::XML::Builder.new(:encoding => "UTF-8") do |xml|

# Identificador do tipo de instrução
xml.EnviarInstrucao {
xml.InstrucaoUnica {
# Dados da transação

raise(StandardError,"É necessário informar a razão do pagamento") if attributes[:razao].nil?

# Dados da transação
xml.Razao {
xml.text attributes[:razao]
xml.text attributes[:razao]
}
xml.Valores {
xml.Valor(:moeda => "BRL") {
Expand Down Expand Up @@ -48,7 +49,6 @@ def body(attributes = {})
xml.Instituicao {
xml.text attributes[:instituicao]
}

xml.CartaoCredito {
xml.Numero {
xml.text attributes[:numero]
Expand Down Expand Up @@ -86,7 +86,6 @@ def body(attributes = {})
}

# Dados do pagador
raise(StandardError, "É obrigatório passar as informações do pagador") if attributes[:pagador].nil?
xml.Pagador {
xml.Nome { xml.text attributes[:pagador][:nome] }
xml.LoginMoIP { xml.text attributes[:pagador][:login_moip] }
Expand Down Expand Up @@ -126,11 +125,12 @@ def body(attributes = {})
}
}
end

builder.to_xml
end

end

end

end

0 comments on commit 177b093

Please sign in to comment.