diff --git a/.gitignore b/.gitignore index 1cfadd7..7e4efba 100644 --- a/.gitignore +++ b/.gitignore @@ -17,3 +17,5 @@ test.db .idea *.iml +# Code +.vscode/ diff --git a/README.md b/README.md index bc18ba6..7799264 100644 --- a/README.md +++ b/README.md @@ -54,6 +54,13 @@ This module provides implementations for the following payment-gateways: [More Stripe information](docs/stripe.md) +### Netaxept +Implemented features: +- Authorization +- Capture +- Refund + +[More Netaxept information](docs/netaxept.md) ## The example project The source distribution includes an example project that lets one exercise @@ -75,7 +82,7 @@ Install the django-payment dependencies (the example project has identical depen Then point your browser to: - http://127.0.0.1:8000/admin + http://127.0.0.1:8000/admin/ Create a new payment (make sure the captured amount currency is the same as the total currency) @@ -94,7 +101,8 @@ To run unit tests: pip install pytest-django pytest -To lint, typecheck, test, and verify you didn't forget to create a migration: +To lint, typecheck, test on all supported versions of python and django. +Also to verify you didn't forget to create a migration: pip install tox tox diff --git a/devel-requirements.txt b/devel-requirements.txt new file mode 100644 index 0000000..3623ebe --- /dev/null +++ b/devel-requirements.txt @@ -0,0 +1,5 @@ +pytest-django +flake8 +mypy +python-language-server + diff --git a/docs/netaxept.md b/docs/netaxept.md new file mode 100644 index 0000000..906c0b3 --- /dev/null +++ b/docs/netaxept.md @@ -0,0 +1,27 @@ +# Netaxept + +## Configuration + +In the PAYMENT_GATEWAYS setting, configure the netaxept connection params: + +`merchant_id`, `secret`, `base_url`, and `after_terminal_url`. + +The production base_url is: + +`https://epayment.nets.eu/` + + +## Design + +Netaxept works by taking the user to a hosted page and then redirecting the user to the merchant in order to finish +processing the payment. +We chose not to provide such a view in the payment application (we do provide an example view in the example_project), +This means a project that uses netaxept payment will have to implement its own after_terminal view. + +- The first reason is that it's not possible to design a simple, generic response that we can show to users of the +application (because we don't know anything about the application) +- The second reason is that after a successful payment something more than just acknowledging the payment +usually needs to happen in the application (for instance setting the status of an order, sending an email, etc). + +It's not impossible to solve those two problems with configuration, application-provided functions, and signals +but it doesn't seem like all this complexity is worth it, compared to reimplementing a simple, straightforward webhook. diff --git a/example_project/settings.py b/example_project/settings.py index 8b26572..708f39b 100644 --- a/example_project/settings.py +++ b/example_project/settings.py @@ -59,6 +59,8 @@ def abspath(*args): ROOT_URLCONF = 'urls' +DATETIME_FORMAT = "Y-m-d @ H:i:s e" + TEMPLATES = [ { 'BACKEND': 'django.template.backends.django.DjangoTemplates', @@ -80,14 +82,16 @@ def abspath(*args): DATETIME_FORMAT = 'Y-m-d @ H:i:s e' # Enable specific currencies (djmoney) -CURRENCIES = ['USD', 'EUR', 'JPY', 'GBP', 'CAD', 'CHF'] +CURRENCIES = ['USD', 'EUR', 'JPY', 'GBP', 'CAD', 'CHF', 'NOK'] DUMMY = 'dummy' STRIPE = 'stripe' +NETAXEPT = 'netaxept' CHECKOUT_PAYMENT_GATEWAYS = { DUMMY: 'Dummy gateway', STRIPE: 'Stripe', + NETAXEPT: 'Netaxept', } PAYMENT_GATEWAYS = { @@ -117,4 +121,17 @@ def abspath(*args): }, }, }, + NETAXEPT: { + 'module': 'payment.gateways.netaxept', + 'config': { + 'auto_capture': True, + 'template_path': 'payment/netaxept.html', + 'connection_params': { + 'base_url': os.environ.get('NETAXEPT_BASE_URL') or 'https://test.epayment.nets.eu', + 'after_terminal_url': 'http://localhost:8000/example/netaxept/after_terminal', + 'merchant_id': os.environ.get('NETAXEPT_MERCHANT_ID'), + 'secret': os.environ.get('NETAXEPT_SECRET'), + } + } + }, } diff --git a/example_project/templates/operation_list.html b/example_project/templates/operation_list.html index 935aa2f..4206c31 100644 --- a/example_project/templates/operation_list.html +++ b/example_project/templates/operation_list.html @@ -12,7 +12,6 @@