forked from PolyLAN/polybanking
-
Notifications
You must be signed in to change notification settings - Fork 0
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
10 changed files
with
227 additions
and
2 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
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,3 +1,38 @@ | ||
<h3>PolyBanking Test/Demo client</h3> | ||
|
||
We're back. {% if result %}Status seem ok{% else %}Status seem err{%endif %} | ||
We're back. {% if result %}Status seem ok{% else %}Status seem err{%endif %}<br /><br /> | ||
|
||
Last transactions: | ||
|
||
<ul> | ||
{% for t in last_transactions %} | ||
<li>{{t}}</li> | ||
{% endfor %} | ||
</ul> | ||
|
||
|
||
{% if last_transaction_detail %} | ||
Last transaction details: | ||
|
||
<ul> | ||
{% for key,val in last_transaction_detail.items() %} | ||
<li><b>{{key}}</b>: {{val}}</li> | ||
{% endfor %} | ||
</ul> | ||
|
||
{% endif %} | ||
|
||
|
||
{% if last_transaction_logs %} | ||
Last transaction logs: | ||
|
||
<ul> | ||
{% for log in last_transaction_logs %} | ||
<li> | ||
{% for key,val in log.items() %} | ||
<b>{{key}}</b>: {{val}}, | ||
{% endfor %} | ||
</li> | ||
{% endfor %} | ||
</ul> | ||
{% endif %} |
Empty file.
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,3 @@ | ||
from django.db import models | ||
|
||
# Create your models here. |
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,16 @@ | ||
""" | ||
This file demonstrates writing tests using the unittest module. These will pass | ||
when you run "manage.py test". | ||
Replace this with more appropriate tests for your application. | ||
""" | ||
|
||
from django.test import TestCase | ||
|
||
|
||
class SimpleTest(TestCase): | ||
def test_basic_addition(self): | ||
""" | ||
Tests that 1 + 1 always equals 2. | ||
""" | ||
self.assertEqual(1 + 1, 2) |
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,14 @@ | ||
# -*- coding: utf-8 -*- | ||
|
||
from django.conf.urls import patterns, url | ||
|
||
urlpatterns = patterns( | ||
'api.views', | ||
|
||
|
||
url(r'^transactions/$', 'transactions_list'), | ||
|
||
url(r'^transactions/(?P<reference>.*)/logs/$', 'transactions_show_logs'), | ||
url(r'^transactions/(?P<reference>.*)/$', 'transactions_show'), | ||
|
||
) |
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,68 @@ | ||
# -*- coding: utf-8 -*- | ||
|
||
from django.shortcuts import get_object_or_404, render_to_response, redirect | ||
from django.template import RequestContext | ||
from django.core.context_processors import csrf | ||
from django.views.decorators.csrf import csrf_exempt | ||
from django.http import Http404, HttpResponse, HttpResponseForbidden, HttpResponseNotFound | ||
from django.utils.encoding import smart_str | ||
from django.conf import settings | ||
from django.contrib.admin.views.decorators import staff_member_required | ||
from django.contrib.auth.decorators import login_required, user_passes_test | ||
from django.http import HttpResponseRedirect | ||
from django.db import connections | ||
from django.core.paginator import InvalidPage, EmptyPage, Paginator | ||
from django.core.cache import cache | ||
from django.core.urlresolvers import reverse | ||
from django.contrib import messages | ||
from django.utils.translation import ugettext_lazy as _ | ||
|
||
|
||
import json | ||
|
||
|
||
from configs.models import Config | ||
from paiements.models import Transaction, TransactionLog | ||
|
||
|
||
@csrf_exempt | ||
def transactions_list(request): | ||
"""Return the list of transaction""" | ||
|
||
config = get_object_or_404(Config, pk=request.POST.get('config_id', -1), key_api=request.POST.get('secret', '#')) | ||
|
||
max_transaction = int(request.POST.get('max_transaction', '100')) | ||
|
||
retour = [] | ||
|
||
for transaction in config.transaction_set.order_by('-creation_date').all()[:max_transaction]: | ||
retour.append({'reference': transaction.reference}) | ||
|
||
return HttpResponse(json.dumps({'result': 'ok', 'data': retour})) | ||
|
||
|
||
@csrf_exempt | ||
def transactions_show(request, reference): | ||
"""Return details of a transaction""" | ||
|
||
config = get_object_or_404(Config, pk=request.POST.get('config_id', -1), key_api=request.POST.get('secret', '#')) | ||
|
||
transaction = get_object_or_404(Transaction, config=config, reference=reference) | ||
|
||
return HttpResponse(json.dumps({'result': 'ok', 'data': transaction.dump_api()})) | ||
|
||
|
||
@csrf_exempt | ||
def transactions_show_logs(request, reference): | ||
"""Return logs of a transaction""" | ||
|
||
config = get_object_or_404(Config, pk=request.POST.get('config_id', -1), key_api=request.POST.get('secret', '#')) | ||
|
||
transaction = get_object_or_404(Transaction, config=config, reference=reference) | ||
|
||
retour = [] | ||
|
||
for log in transaction.transactionlog_set.order_by('-when').all(): | ||
retour.append(log.dump_api()) | ||
|
||
return HttpResponse(json.dumps({'result': 'ok', 'data': retour})) |
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