63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
|
# File 'app/models/payable/gateway_payment.rb', line 63
def payable_checkout
builder = Nokogiri::XML::Builder.new(:encoding => "UTF-8") do |xml|
xml.EnviarInstrucao {
xml.InstrucaoUnica(:TipoValidacao => "Transparente") {
xml.Razao{xml.text "Pagamento #{payable.payable_name} ##{self.id}"}
xml.Valores{
xml.Valor(:moeda => "BRL"){ xml.text payable.payable_value.to_f }
}
xml.IdProprio{ xml.text "#{('aa'..'zz').to_a.sample}-#{self.id}-#{rand(1000)}" }
xml.Pagador{
xml.IdPagador { xml.text payable.payable_user.id }
xml.Nome { xml.text payable.payable_user.name }
xml.Email { xml.text payable.payable_user.email }
xml.EnderecoCobranca {
addr = payable.payable_user.billing_address
xml.Logradouro { xml.text addr.address}
xml.Numero { xml.text addr.number}
xml.Complemento { xml.text addr.complement}
xml.Bairro { xml.text addr.district}
xml.Cidade { xml.text addr.city_name}
xml.Estado { xml.text addr.state_name}
xml.Pais { xml.text addr.country_name}
xml.CEP { xml.text addr.zip}
xml.TelefoneFixo{ xml.text addr.phone}
}
}
xml.Parcelamentos{
xml.Parcelamento{
xml.MinimoParcelas{ xml.text 2}
xml.MaximoParcelas{ xml.text 99}
xml.Repassar{ xml.text 'true' }
}
}
}
}
end
response = HTTParty.post('https://desenvolvedor.moip.com.br/sandbox/ws/alpha/EnviarInstrucao/Unica',
:body => builder.to_xml,
:basic_auth => {:username => 'E6T1EBOPOMQ62CXJI4PGKPETAPROIEJD',
:password => 'FELWDIWMPL7QPFABGZHH0OFF24BGL2ZGDSDYCS3A'}).parsed_response
self.config ||= {}
self.config[:response] = response["EnviarInstrucaoUnicaResponse"]["Resposta"]
end
|