-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
27 changed files
with
951 additions
and
61 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
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,5 @@ | ||
pytest-django | ||
flake8 | ||
mypy | ||
python-language-server | ||
|
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,13 @@ | ||
# 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/` | ||
|
||
|
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,13 @@ | ||
from django.http import HttpRequest, HttpResponse | ||
from django.shortcuts import get_object_or_404, redirect | ||
from django.shortcuts import get_object_or_404 | ||
from django.template.response import TemplateResponse | ||
from structlog import get_logger | ||
|
||
from payment.models import Payment | ||
from payment.utils import gateway_capture | ||
|
||
logger = get_logger() | ||
|
||
|
||
def view_payment(request: HttpRequest, payment_id: int) -> HttpResponse: | ||
payment = get_object_or_404(Payment, id=payment_id) | ||
return TemplateResponse(request, 'operation_list.html', {'payment': payment}) | ||
|
||
|
||
def capture(request: HttpRequest, payment_id: int) -> HttpResponse: | ||
payment = get_object_or_404(Payment, id=payment_id) | ||
capture_result = gateway_capture(payment=payment) | ||
logger.info('capture', payment=payment, capture_result=capture_result) | ||
return redirect('view_payment', payment_id=payment_id) |
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,36 @@ | ||
""" | ||
Example views for interactive testing of payment with netaxept. | ||
You should restrict access (maybe with 'staff_member_required') if you choose to add this to your urlconf. | ||
""" | ||
from django.http import HttpRequest, HttpResponse | ||
from django.shortcuts import redirect, get_object_or_404 | ||
from django.urls import path | ||
from structlog import get_logger | ||
|
||
from payment import get_payment_gateway | ||
from payment.gateways.netaxept import actions | ||
from payment.gateways.netaxept import gateway_to_netaxept_config | ||
from payment.gateways.netaxept.netaxept_protocol import get_payment_terminal_url | ||
from payment.models import Payment | ||
|
||
logger = get_logger() | ||
|
||
|
||
def register_and_authorize(request: HttpRequest, payment_id: int) -> HttpResponse: | ||
""" | ||
Register the payment with netaxept, and take the user to the terminal page for payment authorization. | ||
""" | ||
logger.info('netaxept-register-and-authorize', payment_id=payment_id) | ||
|
||
transaction_id = actions.register_payment(payment_id) | ||
|
||
payment = get_object_or_404(Payment, id=payment_id) | ||
payment_gateway, gateway_config = get_payment_gateway(payment.gateway) | ||
netaxept_config = gateway_to_netaxept_config(gateway_config) | ||
return redirect(get_payment_terminal_url(config=netaxept_config, transaction_id=transaction_id)) | ||
|
||
|
||
urls = [ | ||
path('register_and_authorize/<payment_id>', register_and_authorize, name='netaxept_register_and_authorize'), | ||
] |
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.