Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changes from upstream #3

Open
wants to merge 14 commits into
base: master
Choose a base branch
from
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,5 @@ test.db
.idea
*.iml

# Code
.vscode/
12 changes: 10 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)

Expand All @@ -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
Expand Down
5 changes: 5 additions & 0 deletions devel-requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
pytest-django
flake8
mypy
python-language-server

2 changes: 1 addition & 1 deletion docs/design.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ is impossible to abstract over the myriad ways the different payment gateways do

Here is a diagram of how the different parts interact:

![payment with stripe sequence diagram](payment-with-stripe.png)
![payment with stripe sequence diagram](stripe-authorization.png)


Our changes
Expand Down
27 changes: 27 additions & 0 deletions docs/netaxept.md
Original file line number Diff line number Diff line change
@@ -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.
15 changes: 15 additions & 0 deletions example_paybox/manage.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/usr/bin/env python
import os
import sys

if __name__ == "__main__":
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "test_payments.settings")
try:
from django.core.management import execute_from_command_line
except ImportError as exc:
raise ImportError(
"Couldn't import Django. Are you sure it's installed and "
"available on your PYTHONPATH environment variable? Did you "
"forget to activate a virtual environment?"
) from exc
execute_from_command_line(sys.argv)
Empty file.
37 changes: 37 additions & 0 deletions example_paybox/paybox_test/exceptions.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
class InvalidPaymentSolutionException(Exception):
"""
An exceptions raised when you attempt operations not allowed
on the payment solution in question.
e.g calling Paybox direct plus only operations on Paybox direct methods.
"""
def __init__(self, message, payload=None):
self.message = message
self.payload = payload

def __str__(self):
return str(self.message)


class InvalidParametersException(Exception):
"""
An exceptions raised when Paybox has issues with parameters
passed for the call.
"""
def __init__(self, message, payload=None):
self.message = message
self.payload = payload

def __str__(self):
return str(self.message)


class PayboxEndpointException(Exception):
"""
An exception raised when Paybox endpoints can't seem to be reached.
"""
def __init__(self, message, payload=None):
self.message = message
self.payload = payload

def __str__(self):
return str(self.message)
Loading