lingo: attached BasketItem to transaction (#14023)
This commit is contained in:
parent
c05de8b898
commit
578c763a83
|
@ -429,7 +429,15 @@ class CallbackView(View):
|
|||
pass
|
||||
if transaction.remote_items:
|
||||
for item_id in transaction.remote_items.split(','):
|
||||
remote_item = regie.get_invoice(user=transaction.user, invoice_id=item_id)
|
||||
regie.pay_invoice(item_id, transaction.order_id, transaction.end_date)
|
||||
local_item = BasketItem.objects.create(user=transaction.user,
|
||||
regie=regie,
|
||||
subject=remote_item.display_id,
|
||||
source_url=regie.webservice_url + '/invoice/%s/' % item_id,
|
||||
amount=remote_item.amount,
|
||||
payment_date=transaction.end_date)
|
||||
transaction.items.add(local_item)
|
||||
|
||||
return HttpResponse()
|
||||
|
||||
|
|
|
@ -12,7 +12,7 @@ from django.utils import timezone
|
|||
|
||||
from combo.utils import check_query, aes_hex_encrypt
|
||||
from combo.data.models import Page
|
||||
from combo.apps.lingo.models import Regie, ActiveItems, SelfDeclaredInvoicePayment
|
||||
from combo.apps.lingo.models import Regie, ActiveItems, SelfDeclaredInvoicePayment, Transaction, BasketItem
|
||||
|
||||
pytestmark = pytest.mark.django_db
|
||||
|
||||
|
@ -149,6 +149,17 @@ def test_anonymous_successful_item_payment(mock_get, mock_pay_invoice, app, remo
|
|||
assert urlparse.urlparse(resp.url).path == '/'
|
||||
# simulate successful call to callback URL
|
||||
resp = app.get(reverse('lingo-callback', kwargs={'regie_pk': remote_regie.id}), args)
|
||||
trans = Transaction.objects.all()
|
||||
b_item = BasketItem.objects.all()
|
||||
|
||||
assert trans
|
||||
assert b_item
|
||||
trans = trans[0]
|
||||
b_item = b_item[0]
|
||||
assert b_item.subject == INVOICES[0]['display_id']
|
||||
assert b_item.amount == Decimal(INVOICES[0]['amount'])
|
||||
assert b_item in trans.items.all()
|
||||
|
||||
assert resp.status_code == 200
|
||||
|
||||
@mock.patch('combo.apps.lingo.models.requests.get')
|
||||
|
|
Loading…
Reference in New Issue