Add IBAN/BIC fields to bank transfer import API

This commit is contained in:
Raphael Michel
2020-10-24 23:31:38 +02:00
parent 3ced206d04
commit b0bdae33c1
3 changed files with 40 additions and 1 deletions
+6
View File
@@ -34,6 +34,8 @@ transactions list of objects Transactions in
├ payer string Payment source
├ reference string Payment reference
├ amount string Payment amount
├ iban string Payment IBAN
├ bic string Payment BIC
├ date string Payment date (in **user-inputted** format)
├ order string Associated order code (or ``null``)
└ comment string Internal comment
@@ -83,6 +85,8 @@ Endpoints
"date": "26.06.2017",
"payer": "John Doe",
"order": null,
"iban": "",
"bic": "",
"checksum": "5de03a601644dfa63420dacfd285565f8375a8f2",
"reference": "GUTSCHRIFT\r\nSAMPLECONF-NAB12 EREF: SAMPLECONF-NAB12\r\nIBAN: DE1234556…",
"state": "nomatch",
@@ -132,6 +136,8 @@ Endpoints
"comment": "",
"date": "26.06.2017",
"payer": "John Doe",
"iban": "",
"bic": "",
"order": null,
"checksum": "5de03a601644dfa63420dacfd285565f8375a8f2",
"reference": "GUTSCHRIFT\r\nSAMPLECONF-NAB12 EREF: SAMPLECONF-NAB12\r\nIBAN: DE1234556…",
+1 -1
View File
@@ -21,7 +21,7 @@ class BankTransactionSerializer(serializers.ModelSerializer):
class Meta:
model = BankTransaction
fields = ('state', 'message', 'checksum', 'payer', 'reference', 'amount', 'date', 'order',
'comment')
'comment', 'iban', 'bic')
class BankImportJobSerializer(serializers.ModelSerializer):
@@ -5,6 +5,7 @@ from unittest import mock
import pytest
from django.utils.timezone import now
from django_scopes import scopes_disabled
from pytz import UTC
from pretix.base.models import (
@@ -52,6 +53,8 @@ RES_JOB = {
'payer': 'Foo',
'reference': '',
'checksum': '',
'iban': '',
'bic': '',
'amount': '0.00',
'date': 'unknown',
'state': 'error',
@@ -129,3 +132,33 @@ def test_api_create(env, client):
assert rdata['transactions'][0]['checksum']
env[2].refresh_from_db()
assert env[2].status == Order.STATUS_PAID
@pytest.mark.django_db(transaction=True)
def test_api_create_with_iban_bic(env, client):
client.login(email='dummy@dummy.dummy', password='dummy')
r = client.post(
'/api/v1/organizers/{}/bankimportjobs/'.format(env[0].organizer.slug), json.dumps({
'event': 'dummy',
'transactions': [
{
'payer': 'Foo',
'reference': 'DUMMY-1Z3AS',
'amount': '23.00',
'iban': 'NL79RABO5373380466',
'bic': 'GENODEM1GLS',
'date': 'yesterday' # test bogus date format
}
]
}), content_type="application/json"
)
assert r.status_code == 201
rdata = json.loads(r.content.decode('utf-8'))
# This is only because we don't run celery in tests, otherwise it wouldn't be completed yet.
assert rdata['state'] == 'completed'
assert len(rdata['transactions']) == 1
assert rdata['transactions'][0]['checksum']
env[2].refresh_from_db()
assert env[2].status == Order.STATUS_PAID
with scopes_disabled():
assert env[2].payments.first().info_data['iban'] == 'NL79RABO5373380466'