-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #44 from leonardocintra/payments-leave
Refatoring Payments
- Loading branch information
Showing
13 changed files
with
281 additions
and
149 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,14 @@ | ||
from pagamento.models import PagamentoMercadoPago | ||
|
||
|
||
def atualizar_pagamento_mp(payment, mercado_pago_id, payment_id): | ||
def atualizar_pagamento_mp(payment): | ||
# Atualiza os dados do mercado pago na tabela de pagamento | ||
payment_id = payment['id'] | ||
PagamentoMercadoPago.objects.filter( | ||
mercado_pago_id=mercado_pago_id).update( | ||
payment_id=payment_id).update( | ||
transaction_amount=payment['transaction_amount'], | ||
installments=payment['installments'], | ||
payment_method_id=payment['payment_method_id'], | ||
mercado_pago_status=payment['status'], | ||
mercado_pago_status_detail=payment['status_detail'], | ||
payment_id=payment_id | ||
mercado_pago_status_detail=payment['status_detail'] | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
from django.test import TestCase | ||
from evento.tests.test_model import create_fakes_status | ||
from pagamento.models import PagamentoMercadoPago | ||
|
||
from pedido.business import concluir_pedido | ||
from pedido.models import ItemPedido, Pedido | ||
from pedido.tests.test_model import get_fake_pedido | ||
|
||
|
||
class ConcluirPedidoTest(TestCase): | ||
def setUp(self): | ||
create_fakes_status() | ||
Pedido.objects.all().delete() | ||
ItemPedido.objects.all().delete() | ||
self.pedido = get_fake_pedido() | ||
PagamentoMercadoPago.objects.create( | ||
pedido=self.pedido, | ||
mercado_pago_id='823948asakfjaslkjfalssasa', | ||
payment_id=1240157386, | ||
) | ||
concluir_pedido(self.pedido, 1240157386) | ||
|
||
def test_pedido_existe(self): | ||
self.assertEqual(1, Pedido.objects.count()) | ||
|
||
def test_pedido_seller_foi_gerado(self): | ||
self.assertIsNotNone(self.pedido.request_seller) | ||
|
||
def test_items_do_pedido_criados(self): | ||
items = ItemPedido.objects.filter(pedido=self.pedido) | ||
self.assertEqual(len(items), ItemPedido.objects.count()) | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.