def test_basic_usage(self): moip = MoIP(razao="Razao",valor="150.00") self.failUnlessEqual(moip.get_xml(),'<EnviarInstrucao><InstrucaoUnica><Razao>Razao</Razao><Valores><Valor moeda="BRL">150.00</Valor></Valores></InstrucaoUnica></EnviarInstrucao>')
def moipSend(request, id_book): book_selecionado = Book.objects.get(id=id_book) value = str(book_selecionado.value) razao = str(book_selecionado.name) url_moip = "https://desenvolvedor.moip.com.br/sandbox/Instrucao.do?token=" #creating obj of Purchase purchase = Purchase(state="0", value=book_selecionado.value, book=book_selecionado, user=request.user) purchase.save() moip = MoIP(razao=razao, valor=value) #credenciais de dev #moip.set_credenciais(token="IZXOTSU5G1ZXWZQRO4ZCDOOXGDWPBRTE",key="3T366IZHB8F7YZ22PMCJW5UXZNCDAXU7JVYH8IZY") #credenciais de prod if settings.MOIP_PROD: moip.set_credenciais(token="DWGPNCYU8W3W6QRFFVO0RWBUAZNMQU7A", key="RWGTYI6JHVAQ9BHQFL7LGDUIMPCP2VZFALN858AH") #so habilitar o ambiente em prod moip.set_ambiente('producao') url_moip = "https://www.moip.com.br/Instrucao.do?token=" moip.set_id_proprio(str(purchase.id)) moip.envia() resposta = moip.get_resposta() return HttpResponseRedirect(url_moip + str(resposta['token']))
def index(request): moip = MoIP(razao="Razao",valor="150.00") moip.set_credenciais(token="seu_token",key="sua_key") moip.envia() resposta = moip.get_resposta() return HttpResponse("Token retornado: "+resposta['token'])