django-redsys 1.0.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1 @@
1
+
django_redsys/apps.py ADDED
@@ -0,0 +1,9 @@
1
+ from django.apps import AppConfig
2
+
3
+
4
+ class DjangoRedsysConfig(AppConfig):
5
+ name = 'django_redsys'
6
+ verbose_name = 'RedSys'
7
+
8
+ def ready(self):
9
+ from . import checks # noqa: F401
@@ -0,0 +1,44 @@
1
+ from django.conf import settings
2
+ from django.core import checks
3
+ from django.core.exceptions import ImproperlyConfigured
4
+ from redsys import environments
5
+
6
+ from .client import get_client
7
+ from .conf import notification_networks
8
+
9
+
10
+ @checks.register()
11
+ def check_settings(app_configs, **kwargs):
12
+ errors = []
13
+ try:
14
+ get_client()
15
+ except ImproperlyConfigured as error:
16
+ errors.append(checks.Error(str(error), id='django_redsys.E001'))
17
+ try:
18
+ notification_networks()
19
+ except (TypeError, ValueError) as error:
20
+ errors.append(
21
+ checks.Error(
22
+ f'REDSYS_NOTIFICATION_IPS is not valid: {error}',
23
+ hint='List IP addresses or networks, such as "192.0.2.10" or "192.0.2.0/24".',
24
+ id='django_redsys.E002',
25
+ )
26
+ )
27
+ return errors
28
+
29
+
30
+ @checks.register(deploy=True)
31
+ def check_deploy(app_configs, **kwargs):
32
+ try:
33
+ client = get_client()
34
+ except ImproperlyConfigured:
35
+ return []
36
+ if settings.DEBUG or client.environment == environments.PROD:
37
+ return []
38
+ return [
39
+ checks.Warning(
40
+ f'REDSYS_CLIENT targets the {client.environment} environment with DEBUG off.',
41
+ hint='Production payments need environment=PROD (or sandbox=False).',
42
+ id='django_redsys.W001',
43
+ )
44
+ ]
@@ -0,0 +1,20 @@
1
+ from django.conf import settings
2
+ from django.core.exceptions import ImproperlyConfigured
3
+ from redsys.clients import RedirectClient
4
+
5
+
6
+ def get_client(client_class=RedirectClient):
7
+ """A python-redsys client built from the ``REDSYS_CLIENT`` setting.
8
+
9
+ ``REDSYS_CLIENT`` holds the client's keyword options, or ``api_key`` and the remaining
10
+ options for ``from_api_key()``. ``client_class`` takes ``DirectClient`` or ``AsyncDirectClient``.
11
+ """
12
+ options = dict(getattr(settings, 'REDSYS_CLIENT', None) or {})
13
+ if 'api_key' not in options and 'secret_key' not in options:
14
+ raise ImproperlyConfigured('REDSYS_CLIENT must set secret_key or api_key.')
15
+ try:
16
+ if 'api_key' in options:
17
+ return client_class.from_api_key(options.pop('api_key'), **options)
18
+ return client_class(options.pop('secret_key'), **options)
19
+ except (TypeError, ValueError) as error:
20
+ raise ImproperlyConfigured(f'REDSYS_CLIENT is not valid: {error}') from error
django_redsys/conf.py ADDED
@@ -0,0 +1,13 @@
1
+ from ipaddress import ip_network
2
+
3
+ from django.conf import settings
4
+
5
+
6
+ def notification_networks():
7
+ """The networks of ``REDSYS_NOTIFICATION_IPS``, or ``None`` when the setting is absent or empty."""
8
+ entries = getattr(settings, 'REDSYS_NOTIFICATION_IPS', None)
9
+ if not entries:
10
+ return None
11
+ if not isinstance(entries, (list, tuple)) or not all(isinstance(entry, str) for entry in entries):
12
+ raise TypeError('it must be a list of strings.')
13
+ return [ip_network(entry, strict=False) for entry in entries]
@@ -0,0 +1 @@
1
+
@@ -0,0 +1,17 @@
1
+ from django.contrib import admin
2
+
3
+ from .models import Notification
4
+
5
+
6
+ @admin.register(Notification)
7
+ class NotificationAdmin(admin.ModelAdmin):
8
+ list_display = ['order', 'response_code', 'authorized', 'amount', 'currency', 'environment', 'count', 'received_at']
9
+ list_filter = ['authorized', 'environment', 'transaction_type', 'processed_pay_method']
10
+ search_fields = ['order', 'authorization_code']
11
+ date_hierarchy = 'received_at'
12
+
13
+ def has_add_permission(self, request):
14
+ return False
15
+
16
+ def has_change_permission(self, request, obj=None):
17
+ return False
@@ -0,0 +1,9 @@
1
+ from django.apps import AppConfig
2
+
3
+
4
+ class NotificationsConfig(AppConfig):
5
+ name = 'django_redsys.notifications'
6
+ # The default label, "notifications", is common enough to clash with another app.
7
+ label = 'django_redsys_notifications'
8
+ verbose_name = 'RedSys notifications'
9
+ default_auto_field = 'django.db.models.BigAutoField'
@@ -0,0 +1,20 @@
1
+ from datetime import timedelta
2
+
3
+ from django.core.management.base import BaseCommand, CommandError
4
+ from django.utils import timezone
5
+
6
+ from django_redsys.notifications.models import Notification
7
+
8
+
9
+ class Command(BaseCommand):
10
+ help = 'Deletes the RedSys notifications first received more than DAYS days ago.'
11
+
12
+ def add_arguments(self, parser):
13
+ parser.add_argument('--older-than', type=int, required=True, metavar='DAYS')
14
+
15
+ def handle(self, *args, older_than, **options):
16
+ if older_than < 0:
17
+ raise CommandError('--older-than must be 0 or more days.')
18
+ cutoff = timezone.now() - timedelta(days=older_than)
19
+ deleted, _ = Notification.objects.filter(received_at__lt=cutoff).delete()
20
+ self.stdout.write(f'{deleted} notifications deleted.')
@@ -0,0 +1,49 @@
1
+ # Generated by Django 6.1.3 on 2026-11-08 13:16
2
+
3
+ from django.db import migrations, models
4
+
5
+
6
+ class Migration(migrations.Migration):
7
+ initial = True
8
+
9
+ dependencies = []
10
+
11
+ operations = [
12
+ migrations.CreateModel(
13
+ name='Notification',
14
+ fields=[
15
+ ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
16
+ ('digest', models.CharField(max_length=64, unique=True, verbose_name='payload digest')),
17
+ ('order', models.CharField(db_index=True, max_length=32, verbose_name='order')),
18
+ ('response_code', models.IntegerField(blank=True, null=True, verbose_name='response code')),
19
+ ('authorized', models.BooleanField(verbose_name='authorized')),
20
+ (
21
+ 'amount',
22
+ models.DecimalField(blank=True, decimal_places=3, max_digits=15, null=True, verbose_name='amount'),
23
+ ),
24
+ ('currency', models.IntegerField(blank=True, null=True, verbose_name='currency')),
25
+ ('transaction_type', models.CharField(blank=True, max_length=8, verbose_name='transaction type')),
26
+ ('authorization_code', models.CharField(blank=True, max_length=16, verbose_name='authorization code')),
27
+ ('merchant_code', models.CharField(blank=True, max_length=16, verbose_name='merchant code')),
28
+ ('terminal', models.CharField(blank=True, max_length=8, verbose_name='terminal')),
29
+ ('environment', models.CharField(blank=True, max_length=8, verbose_name='environment')),
30
+ ('secure_payment', models.CharField(blank=True, max_length=4, verbose_name='secure payment')),
31
+ (
32
+ 'processed_pay_method',
33
+ models.CharField(blank=True, max_length=8, verbose_name='processed payment method'),
34
+ ),
35
+ ('error_code', models.CharField(blank=True, max_length=16, verbose_name='error code')),
36
+ ('redsys_date', models.CharField(blank=True, max_length=16, verbose_name='RedSys date')),
37
+ ('redsys_hour', models.CharField(blank=True, max_length=16, verbose_name='RedSys hour')),
38
+ ('remote_addr', models.GenericIPAddressField(blank=True, null=True, verbose_name='sender address')),
39
+ ('received_at', models.DateTimeField(db_index=True, verbose_name='received at')),
40
+ ('last_received_at', models.DateTimeField(verbose_name='last received at')),
41
+ ('count', models.PositiveIntegerField(default=1, verbose_name='arrivals')),
42
+ ],
43
+ options={
44
+ 'verbose_name': 'notification',
45
+ 'verbose_name_plural': 'notifications',
46
+ 'ordering': ['-received_at'],
47
+ },
48
+ ),
49
+ ]
@@ -0,0 +1,84 @@
1
+ from hashlib import sha256
2
+ from ipaddress import ip_address
3
+
4
+ from django.db import models
5
+ from django.db.models import F
6
+ from django.utils import timezone
7
+ from django.utils.translation import gettext_lazy as _
8
+
9
+
10
+ def _address(value):
11
+ try:
12
+ return str(ip_address(value))
13
+ except ValueError:
14
+ return None
15
+
16
+
17
+ class NotificationManager(models.Manager):
18
+ def register(self, merchant_parameters, response, environment='', remote_addr=None):
19
+ """Records a verified notification; ``True`` for the first arrival of its payload, ``False`` for a repeat."""
20
+
21
+ def text(name):
22
+ # Values are signed by RedSys but their lengths are not the database's to trust.
23
+ return (getattr(response, name) or '')[: self.model._meta.get_field(name).max_length]
24
+
25
+ now = timezone.now()
26
+ notification, created = self.get_or_create(
27
+ digest=sha256(merchant_parameters.encode()).hexdigest(),
28
+ defaults={
29
+ 'order': text('order'),
30
+ 'response_code': response.response_code,
31
+ 'authorized': response.is_authorized(),
32
+ 'amount': response.amount,
33
+ 'currency': response.currency,
34
+ 'transaction_type': text('transaction_type'),
35
+ 'authorization_code': text('authorization_code'),
36
+ 'merchant_code': text('merchant_code'),
37
+ 'terminal': text('terminal'),
38
+ 'environment': environment or '',
39
+ 'secure_payment': text('secure_payment'),
40
+ 'processed_pay_method': text('processed_pay_method'),
41
+ 'error_code': text('error_code'),
42
+ 'redsys_date': (response.date or '')[:16],
43
+ 'redsys_hour': (response.hour or '')[:16],
44
+ 'remote_addr': _address(remote_addr or ''),
45
+ 'received_at': now,
46
+ 'last_received_at': now,
47
+ },
48
+ )
49
+ if not created:
50
+ self.filter(pk=notification.pk).update(count=F('count') + 1, last_received_at=now)
51
+ return created
52
+
53
+
54
+ class Notification(models.Model):
55
+ digest = models.CharField(_('payload digest'), max_length=64, unique=True)
56
+ order = models.CharField(_('order'), max_length=32, db_index=True)
57
+ response_code = models.IntegerField(_('response code'), null=True, blank=True)
58
+ authorized = models.BooleanField(_('authorized'))
59
+ amount = models.DecimalField(_('amount'), max_digits=15, decimal_places=3, null=True, blank=True)
60
+ currency = models.IntegerField(_('currency'), null=True, blank=True)
61
+ transaction_type = models.CharField(_('transaction type'), max_length=8, blank=True)
62
+ authorization_code = models.CharField(_('authorization code'), max_length=16, blank=True)
63
+ merchant_code = models.CharField(_('merchant code'), max_length=16, blank=True)
64
+ terminal = models.CharField(_('terminal'), max_length=8, blank=True)
65
+ environment = models.CharField(_('environment'), max_length=8, blank=True)
66
+ secure_payment = models.CharField(_('secure payment'), max_length=4, blank=True)
67
+ processed_pay_method = models.CharField(_('processed payment method'), max_length=8, blank=True)
68
+ error_code = models.CharField(_('error code'), max_length=16, blank=True)
69
+ redsys_date = models.CharField(_('RedSys date'), max_length=16, blank=True)
70
+ redsys_hour = models.CharField(_('RedSys hour'), max_length=16, blank=True)
71
+ remote_addr = models.GenericIPAddressField(_('sender address'), null=True, blank=True)
72
+ received_at = models.DateTimeField(_('received at'), db_index=True)
73
+ last_received_at = models.DateTimeField(_('last received at'))
74
+ count = models.PositiveIntegerField(_('arrivals'), default=1)
75
+
76
+ objects = NotificationManager()
77
+
78
+ class Meta:
79
+ ordering = ['-received_at']
80
+ verbose_name = _('notification')
81
+ verbose_name_plural = _('notifications')
82
+
83
+ def __str__(self):
84
+ return f'{self.order} {self.response_code}'
@@ -0,0 +1,8 @@
1
+ from django.dispatch import Signal
2
+
3
+ request_created = Signal()
4
+ notification_received = Signal()
5
+ notification_authorized = Signal()
6
+ notification_denied = Signal()
7
+ notification_invalid = Signal()
8
+ notification_repeated = Signal()
@@ -0,0 +1,15 @@
1
+ {% load i18n %}{% get_current_language as LANGUAGE_CODE %}<!DOCTYPE html>
2
+ <html lang="{{ LANGUAGE_CODE }}">
3
+ <head>
4
+ <meta charset="utf-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1">
6
+ <meta name="robots" content="noindex">
7
+ <title>{% block title %}{% translate "Payment not completed" %}{% endblock %}</title>
8
+ </head>
9
+ <body>
10
+ {% block content %}
11
+ <h1>{% translate "Payment not completed" %}</h1>
12
+ <p>{% blocktranslate with order=redsys_response.order %}Order {{ order }}.{% endblocktranslate %}</p>
13
+ {% endblock %}
14
+ </body>
15
+ </html>
@@ -0,0 +1,15 @@
1
+ {% load i18n %}{% get_current_language as LANGUAGE_CODE %}<!DOCTYPE html>
2
+ <html lang="{{ LANGUAGE_CODE }}">
3
+ <head>
4
+ <meta charset="utf-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1">
6
+ <meta name="robots" content="noindex">
7
+ <title>{% block title %}{% translate "Payment completed" %}{% endblock %}</title>
8
+ </head>
9
+ <body>
10
+ {% block content %}
11
+ <h1>{% translate "Payment completed" %}</h1>
12
+ <p>{% blocktranslate with order=redsys_response.order %}Order {{ order }}.{% endblocktranslate %}</p>
13
+ {% endblock %}
14
+ </body>
15
+ </html>
@@ -0,0 +1,20 @@
1
+ {% load i18n %}{% get_current_language as LANGUAGE_CODE %}<!DOCTYPE html>
2
+ <html lang="{{ LANGUAGE_CODE }}">
3
+ <head>
4
+ <meta charset="utf-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1">
6
+ <meta name="robots" content="noindex">
7
+ <title>{% block title %}{% translate "Redirecting to the payment page" %}{% endblock %}</title>
8
+ {% block head %}{% endblock %}
9
+ </head>
10
+ <body>
11
+ {% block content %}
12
+ <form id="redsys" method="post" action="{{ endpoint }}">
13
+ {% for name, value in fields.items %}<input type="hidden" name="{{ name }}" value="{{ value }}">
14
+ {% endfor %}
15
+ <noscript><button type="submit">{% translate "Continue to the payment page" %}</button></noscript>
16
+ </form>
17
+ <script{% if csp_nonce is not None %} nonce="{{ csp_nonce }}"{% endif %}>document.getElementById('redsys').submit();</script>
18
+ {% endblock %}
19
+ </body>
20
+ </html>
django_redsys/urls.py ADDED
@@ -0,0 +1,10 @@
1
+ from django.urls import path
2
+
3
+ from . import views
4
+
5
+ app_name = 'django_redsys'
6
+ urlpatterns = [
7
+ path('notification/', views.NotificationView.as_view(), name='notification'),
8
+ path('ok/', views.ResultView.as_view(template_name='django_redsys/ok.html'), name='ok'),
9
+ path('ko/', views.ResultView.as_view(template_name='django_redsys/ko.html', authorized=False), name='ko'),
10
+ ]
django_redsys/views.py ADDED
@@ -0,0 +1,169 @@
1
+ from contextlib import nullcontext
2
+ from ipaddress import ip_address
3
+
4
+ from django.apps import apps
5
+ from django.core.exceptions import PermissionDenied, SuspiciousOperation
6
+ from django.db import router, transaction
7
+ from django.http import Http404, HttpResponse
8
+ from django.shortcuts import render
9
+ from django.urls import reverse
10
+ from django.utils.cache import add_never_cache_headers
11
+ from django.utils.decorators import method_decorator
12
+ from django.views.decorators.csrf import csrf_exempt
13
+ from django.views.generic import FormView, TemplateView, View
14
+ from redsys import transactions
15
+ from redsys.clients import MERCHANT_PARAMETERS
16
+
17
+ from .client import get_client
18
+ from .conf import notification_networks
19
+ from .signals import (
20
+ notification_authorized,
21
+ notification_denied,
22
+ notification_invalid,
23
+ notification_received,
24
+ notification_repeated,
25
+ request_created,
26
+ )
27
+
28
+ NOTIFICATIONS_APP = 'django_redsys.notifications'
29
+
30
+
31
+ class RedsysClientMixin:
32
+ def get_redsys_client(self):
33
+ """The python-redsys client of this view; ``get_client()`` unless a subclass picks another account."""
34
+ return get_client()
35
+
36
+
37
+ class RedsysPaymentMixin(RedsysClientMixin):
38
+ """Signs a redirect-connection operation and renders the form that posts it to RedSys."""
39
+
40
+ transaction_type = transactions.AUTHORIZATION
41
+ redirect_template_name = 'django_redsys/redirect.html'
42
+
43
+ def get_redsys_fields(self):
44
+ raise NotImplementedError('get_redsys_fields() must return the operation fields, or None for no order.')
45
+
46
+ def get_redsys_request(self):
47
+ operation_fields = self.get_redsys_fields()
48
+ if not operation_fields:
49
+ raise Http404('No order to pay.')
50
+ fields = {
51
+ 'merchant_url': self.request.build_absolute_uri(reverse('django_redsys:notification')),
52
+ 'url_ok': self.request.build_absolute_uri(reverse('django_redsys:ok')),
53
+ 'url_ko': self.request.build_absolute_uri(reverse('django_redsys:ko')),
54
+ **operation_fields,
55
+ }
56
+ redsys_request = self.get_redsys_client().request(self.transaction_type, **fields)
57
+ request_created.send(sender=type(self), request=self.request, redsys_request=redsys_request, fields=fields)
58
+ return redsys_request
59
+
60
+ def redirect_to_redsys(self):
61
+ redsys_request = self.get_redsys_request()
62
+ context = {'endpoint': redsys_request.endpoint, 'fields': redsys_request.to_dict()}
63
+ response = render(self.request, self.redirect_template_name, context)
64
+ # A cached form would resubmit a used order number (SIS0051).
65
+ add_never_cache_headers(response)
66
+ return response
67
+
68
+
69
+ class RedsysPaymentView(RedsysPaymentMixin, View):
70
+ def get(self, request, *args, **kwargs):
71
+ return self.redirect_to_redsys()
72
+
73
+ def post(self, request, *args, **kwargs):
74
+ return self.redirect_to_redsys()
75
+
76
+
77
+ class RedsysPaymentFormView(RedsysPaymentMixin, FormView):
78
+ def form_valid(self, form):
79
+ self.form = form
80
+ return self.redirect_to_redsys()
81
+
82
+
83
+ @method_decorator(csrf_exempt, name='dispatch')
84
+ class NotificationView(RedsysClientMixin, View):
85
+ """Receives the server-to-server notification RedSys posts to ``merchant_url``."""
86
+
87
+ http_method_names = ['post']
88
+
89
+ def is_allowed_sender(self):
90
+ networks = notification_networks()
91
+ if networks is None:
92
+ return True
93
+ try:
94
+ address = ip_address(self.request.META.get('REMOTE_ADDR', ''))
95
+ except ValueError:
96
+ return False
97
+ return any(address in network for network in networks)
98
+
99
+ def post(self, request, *args, **kwargs):
100
+ if not self.is_allowed_sender():
101
+ error = PermissionDenied('RedSys notification from an address outside REDSYS_NOTIFICATION_IPS.')
102
+ notification_invalid.send(sender=type(self), request=request, error=error)
103
+ raise error
104
+ client = self.get_redsys_client()
105
+ try:
106
+ response = client.parse_response(request.POST.dict())
107
+ # The payload is untrusted input: any failure to parse or verify it makes the notification invalid.
108
+ except Exception as error:
109
+ notification_invalid.send(sender=type(self), request=request, error=error)
110
+ raise SuspiciousOperation('RedSys notification failed verification.') from error
111
+ # Recording and receivers commit together: a receiver that fails leaves the notification unrecorded.
112
+ with self.processing():
113
+ if not self.register_notification(response, client):
114
+ notification_repeated.send(sender=type(self), request=request, response=response)
115
+ return HttpResponse()
116
+ notification_received.send(sender=type(self), request=request, response=response)
117
+ outcome = notification_authorized if response.is_authorized() else notification_denied
118
+ outcome.send(sender=type(self), request=request, response=response)
119
+ return HttpResponse()
120
+
121
+ def recording(self):
122
+ return apps.is_installed(NOTIFICATIONS_APP)
123
+
124
+ def processing(self):
125
+ if not self.recording():
126
+ return nullcontext()
127
+ from .notifications.models import Notification
128
+
129
+ return transaction.atomic(using=router.db_for_write(Notification))
130
+
131
+ def register_notification(self, response, client):
132
+ """Whether the notification is new: always without ``django_redsys.notifications``, else per its record."""
133
+ if not self.recording():
134
+ return True
135
+ from .notifications.models import Notification
136
+
137
+ return Notification.objects.register(
138
+ self.request.POST.get(MERCHANT_PARAMETERS, ''),
139
+ response,
140
+ environment=client.environment,
141
+ remote_addr=self.request.META.get('REMOTE_ADDR'),
142
+ )
143
+
144
+
145
+ class ResultView(RedsysClientMixin, TemplateView):
146
+ """The ``url_ok`` / ``url_ko`` page: 404 unless RedSys appended a verified result with the expected outcome."""
147
+
148
+ authorized = True
149
+
150
+ def get_redsys_response(self):
151
+ payload = self.request.GET.dict()
152
+ if not payload:
153
+ return None
154
+ client = self.get_redsys_client()
155
+ try:
156
+ return client.parse_response(payload)
157
+ except Exception:
158
+ return None
159
+
160
+ def get(self, request, *args, **kwargs):
161
+ self.redsys_response = self.get_redsys_response()
162
+ if self.redsys_response is None or self.redsys_response.is_authorized() != self.authorized:
163
+ raise Http404('No RedSys result to show.')
164
+ return super().get(request, *args, **kwargs)
165
+
166
+ def get_context_data(self, **kwargs):
167
+ context = super().get_context_data(**kwargs)
168
+ context['redsys_response'] = self.redsys_response
169
+ return context
@@ -0,0 +1,239 @@
1
+ Metadata-Version: 2.4
2
+ Name: django-redsys
3
+ Version: 1.0.0
4
+ Summary: Django views, URLs and signals for RedSys TPV Virtual payments, on top of python-redsys.
5
+ Author-email: David Díaz <d.diazp@gmail.com>
6
+ License-Expression: Apache-2.0
7
+ Project-URL: Homepage, https://github.com/ddiazpinto/django-redsys
8
+ Project-URL: Source, https://github.com/ddiazpinto/django-redsys
9
+ Keywords: django,redsys,sermepa,tpv,payments
10
+ Classifier: Environment :: Web Environment
11
+ Classifier: Framework :: Django
12
+ Classifier: Framework :: Django :: 5.2
13
+ Classifier: Framework :: Django :: 6.0
14
+ Classifier: Framework :: Django :: 6.1
15
+ Classifier: Intended Audience :: Developers
16
+ Classifier: Operating System :: OS Independent
17
+ Classifier: Programming Language :: Python :: 3
18
+ Classifier: Programming Language :: Python :: 3.10
19
+ Classifier: Programming Language :: Python :: 3.11
20
+ Classifier: Programming Language :: Python :: 3.12
21
+ Classifier: Programming Language :: Python :: 3.13
22
+ Classifier: Programming Language :: Python :: 3.14
23
+ Classifier: Programming Language :: Python :: 3.15
24
+ Classifier: Topic :: Internet :: WWW/HTTP :: Dynamic Content
25
+ Classifier: Topic :: Office/Business :: Financial
26
+ Requires-Python: >=3.10
27
+ Description-Content-Type: text/markdown
28
+ License-File: LICENSE
29
+ License-File: NOTICE
30
+ Requires-Dist: Django>=5.2
31
+ Requires-Dist: python-redsys>=2.2
32
+ Dynamic: license-file
33
+
34
+ # django-redsys
35
+
36
+ [![CI](https://github.com/ddiazpinto/django-redsys/actions/workflows/ci.yml/badge.svg)](https://github.com/ddiazpinto/django-redsys/actions/workflows/ci.yml) ![Python 3.10+](https://img.shields.io/badge/python-3.10%2B-blue.svg) ![Django 5.2+](https://img.shields.io/badge/django-5.2%2B-blue.svg) [![License: Apache 2.0](https://img.shields.io/badge/license-Apache%202.0-blue.svg)](https://www.apache.org/licenses/LICENSE-2.0)
37
+
38
+ Django views, URLs and signals for RedSys TPV Virtual payments over the *redirect connection*. Signing, verification, parameters, constants and response codes come from [python-redsys](https://github.com/ddiazpinto/python-redsys); this app adds the Django side: the page that sends the cardholder to RedSys, the endpoint that receives RedSys's notification, the OK and KO pages, and signals.
39
+
40
+ ## Installation
41
+
42
+ ```bash
43
+ pip install django-redsys
44
+ ```
45
+
46
+ ```python
47
+ # settings.py
48
+ INSTALLED_APPS = [..., 'django_redsys']
49
+
50
+ REDSYS_CLIENT = {
51
+ 'secret_key': '...',
52
+ 'merchant_code': '999008881',
53
+ 'terminal': 1,
54
+ 'sandbox': True,
55
+ }
56
+
57
+ # urls.py
58
+ urlpatterns = [..., path('redsys/', include('django_redsys.urls'))]
59
+ ```
60
+
61
+ ## Settings
62
+
63
+ | Setting | Use |
64
+ |---|---|
65
+ | `REDSYS_CLIENT` | Required. The account: the keyword options of python-redsys's `RedirectClient`. |
66
+ | `REDSYS_NOTIFICATION_IPS` | Optional. Addresses or networks allowed to post notifications; see [Notification senders](#notification-senders). |
67
+
68
+ The keys of `REDSYS_CLIENT`:
69
+
70
+ | Key | Use |
71
+ |---|---|
72
+ | `secret_key` | Merchant secret key. Required unless `api_key` is set. |
73
+ | `merchant_code`, `terminal` | Merchant code (FUC) and terminal number. |
74
+ | `sandbox` or `environment` | `sandbox=True` targets the test environment; `environment=` takes `redsys.environments.TEST`, `PROD`, `INTE` or `DESA`. Production by default. |
75
+ | `currency` | Default currency (`redsys.currencies`); the euro unless set. |
76
+ | `signature_version` | `HMAC_SHA512_V2` by default. |
77
+ | `module` | `Ds_Merchant_Module` of every request. |
78
+ | `api_key` | A RedSys API key, read with `RedirectClient.from_api_key()`; replaces `secret_key`, `merchant_code`, `terminal` and the environment. |
79
+
80
+ The keys go to the constructor unchanged, so an option a later python-redsys adds works without a django-redsys release. An unknown key, an invalid value, or `api_key` together with the values it replaces raises `ImproperlyConfigured`. See the [python-redsys configuration](https://github.com/ddiazpinto/python-redsys#configuration).
81
+
82
+ `manage.py check` validates both settings (`django_redsys.E001`, `django_redsys.E002`). `manage.py check --deploy` warns when `REDSYS_CLIENT` targets an environment other than production while `DEBUG` is off (`django_redsys.W001`); a staging server that uses the test environment on purpose silences it with `SILENCED_SYSTEM_CHECKS`.
83
+
84
+ ## Payment view
85
+
86
+ A subclass of `RedsysPaymentView` returns the operation fields; the view signs them and renders a form that posts itself to RedSys. It answers GET and POST. A view that stores state, as the one below, is reached through a POST form (a "Pay" button): browsers and crawlers prefetch GET links, and each prefetch would use up an order number.
87
+
88
+ ```python
89
+ from decimal import Decimal
90
+
91
+ from django.shortcuts import get_object_or_404
92
+ from django_redsys.views import RedsysPaymentView
93
+ from redsys import generate_order
94
+
95
+
96
+ class PayOrderView(RedsysPaymentView):
97
+ def get_redsys_fields(self):
98
+ order = get_object_or_404(Order, pk=self.kwargs['pk'], user=self.request.user)
99
+ order.redsys_order = generate_order()
100
+ order.save(update_fields=['redsys_order'])
101
+ return {
102
+ 'order': order.redsys_order,
103
+ 'amount': order.total, # Decimal, in euros unless currency= says otherwise
104
+ 'merchant_data': str(order.pk),
105
+ 'product_description': 'Online order',
106
+ }
107
+ ```
108
+
109
+ | Attribute or method | Use |
110
+ |---|---|
111
+ | `get_redsys_fields()` | Required. The keyword fields of the operation: `order`, `amount` and any other [redirect parameter](https://github.com/ddiazpinto/python-redsys/blob/master/docs/redirect-connection.md). `None` (or `Http404` raised) when there is no order to pay: the view answers `404`. |
112
+ | `get_redsys_client()` | The client that signs, `get_client()` by default. A view that pays through another terminal or merchant returns its own `RedirectClient`; the notification and result views have the same method. |
113
+ | `transaction_type` | `redsys.transactions.AUTHORIZATION` by default; `PREAUTHORIZATION`, `AUTHENTICATION` or `REFUND_WITHOUT_ORIGINAL` for the other redirect operations. |
114
+ | `redirect_template_name` | `django_redsys/redirect.html` by default. |
115
+ | `get_redsys_request()` | Builds and signs the python-redsys `Request`; sends `request_created`. |
116
+
117
+ `merchant_url`, `url_ok` and `url_ko` default to the app's notification, OK and KO URLs; a value returned by `get_redsys_fields()` replaces them. The URLs are absolute, from `request.build_absolute_uri()`; behind a proxy that terminates TLS, `SECURE_PROXY_SSL_HEADER` makes them `https`.
118
+
119
+ The page is sent with `Cache-Control: no-store`: a cached copy would post an order number RedSys already received, which it rejects (SIS0051).
120
+
121
+ `RedsysPaymentFormView` is the same on top of `FormView`: after `form_valid()`, `self.form` holds the validated form for `get_redsys_fields()`. `RedsysPaymentMixin` holds the behavior for other view classes; `redirect_to_redsys()` returns the response.
122
+
123
+ Invalid fields raise python-redsys's `ValueError` subclasses before anything is signed ([errors](https://github.com/ddiazpinto/python-redsys#errors)).
124
+
125
+ ## Notification and signals
126
+
127
+ RedSys posts the result of every operation to `merchant_url`. `NotificationView` (`django_redsys:notification`) verifies the signature, parses the result into a python-redsys `Response` and sends the signals; it answers `200` with an empty body. A payload that fails parsing or verification, whatever the exception, raises `SuspiciousOperation` chained to it: Django answers `400` and logs it on the `django.security` logger.
128
+
129
+ | Signal (`django_redsys.signals`) | Sent | Arguments |
130
+ |---|---|---|
131
+ | `request_created` | A payment view signed a request. | `request`, `redsys_request`, `fields` |
132
+ | `notification_received` | A notification passed verification. | `request`, `response` |
133
+ | `notification_authorized` | After `notification_received`, when `response.is_authorized()`. | `request`, `response` |
134
+ | `notification_denied` | After `notification_received`, otherwise. | `request`, `response` |
135
+ | `notification_invalid` | A notification failed verification or parsing, or came from an address outside `REDSYS_NOTIFICATION_IPS`. | `request`, `error` |
136
+ | `notification_repeated` | With [the notification record](#notification-record), a verified notification whose payload already arrived; sent instead of the three above. | `request`, `response` |
137
+
138
+ `sender` is the view class. The notification is the source of truth for an operation's outcome; the OK and KO pages are not, since the cardholder may never reach them.
139
+
140
+ A valid notification can arrive more than once. The signed result also reaches the cardholder's browser on the redirect to `url_ok` or `url_ko` (when the portal sends it, see below), and a copy posted to the notification URL verifies like the original. Receivers are idempotent: they act on the state of the order, not on the arrival of the signal, and check that the result matches what was asked for.
141
+
142
+ ```python
143
+ from django.db import transaction
144
+ from django.dispatch import receiver
145
+ from django_redsys.signals import notification_authorized
146
+
147
+
148
+ @receiver(notification_authorized)
149
+ def mark_paid(sender, request, response, **kwargs):
150
+ with transaction.atomic():
151
+ order = Order.objects.select_for_update().filter(redsys_order=response.order).first()
152
+ if order is None or order.is_paid or order.total != response.amount:
153
+ return
154
+ order.mark_paid(authorization_code=response.authorization_code)
155
+ ```
156
+
157
+ `response` carries every result field (`order`, `amount`, `response_code`, `authorization_code`, `merchant_data`, `card_country`, ...) and `response.describe(language)` gives the meaning of the code; see the [response parameters](https://github.com/ddiazpinto/python-redsys/blob/master/docs/redirect-connection.md#response-parameters) and [response codes](https://github.com/ddiazpinto/python-redsys/blob/master/docs/response-codes.md). An exception in a receiver propagates, and the notification gets a `500`.
158
+
159
+ ## Notification senders
160
+
161
+ `REDSYS_NOTIFICATION_IPS`, off by default, limits who may post to the notification URL. A request from any other address gets `403` before its payload is parsed, and `notification_invalid` is sent with a `PermissionDenied` error.
162
+
163
+ ```python
164
+ REDSYS_NOTIFICATION_IPS = ['192.0.2.10', '198.51.100.0/24'] # RedSys's addresses, as the bank or RedSys gives them
165
+ ```
166
+
167
+ The address compared is `REMOTE_ADDR`. Behind a proxy or load balancer, `REMOTE_ADDR` is the proxy's unless the server sets it from the forwarded header; a subclass of `NotificationView` can override `is_allowed_sender()` to read it another way. The signature check stays: the list only saves the work of parsing what does not come from RedSys.
168
+
169
+ ## Notification record
170
+
171
+ `django_redsys.notifications`, an optional app, records every verified notification and turns a repeat into `notification_repeated`:
172
+
173
+ ```python
174
+ INSTALLED_APPS = [..., 'django_redsys', 'django_redsys.notifications']
175
+ ```
176
+
177
+ ```bash
178
+ python manage.py migrate
179
+ ```
180
+
181
+ - A notification is a repeat when its `Ds_MerchantParameters` is identical to one already recorded (SHA-256 digest, unique). A new result for the same order is not a repeat. Idempotency per order stays with the receivers.
182
+ - The record and the signals commit in one transaction on the database the model is routed to: a receiver that raises leaves nothing recorded, and the next arrival of the same notification is processed as new.
183
+ - Each record keeps the order, the response code and `SISnnnn` error code, whether it was authorized, the amount and currency, the transaction type, the authorization code, the merchant code, terminal and environment (`TEST`, `PROD`, ...), whether the payment was 3-D Secure authenticated (`Ds_SecurePayment`), the payment method that processed it (`Ds_ProcessedPayMethod`), RedSys's date and hour as sent (`Ds_Date`, `Ds_Hour`), the sender address, the first and last arrival, and the number of arrivals. Card data, stored-card tokens (`Ds_Merchant_Identifier`, `Ds_Merchant_Cof_Txnid`) and `merchant_data` are not stored: a token charges the card again, and `merchant_data` is free text. Invalid notifications are not recorded.
184
+ - The admin lists the records read-only (`django.contrib.admin` installed). `python manage.py purge_redsys_notifications --older-than DAYS` deletes the records first received more than `DAYS` days ago, for a retention period run from cron or a scheduler.
185
+ - The app label is `django_redsys_notifications`.
186
+
187
+ ## OK and KO pages
188
+
189
+ `django_redsys:ok` and `django_redsys:ko` render `django_redsys/ok.html` and `django_redsys/ko.html` through `ResultView`, with the verified result as `redsys_response`. RedSys appends the signed result to the redirect only when the option "Enviar Parámetros en las URLs" is on in its portal. Without a result that verifies, or with an outcome that does not match the page (an authorized result on the KO page, or the reverse), the page answers `404`. With the option off, `url_ok` and `url_ko` point to the project's own views. A template with the same name in the project replaces the app's.
190
+
191
+ ## Templates and Content Security Policy
192
+
193
+ `django_redsys/redirect.html` receives `endpoint` and `fields` (the three `Ds_*` fields) and submits the form with an inline script, with a `<noscript>` button as fallback. With Django's CSP middleware (Django 6.0 and later) and the `django.template.context_processors.csp` context processor, the script carries the request's nonce; the policy then needs `CSP.NONCE` in `script-src` and the RedSys host in `form-action`:
194
+
195
+ ```python
196
+ from django.utils.csp import CSP
197
+
198
+ SECURE_CSP = {
199
+ 'script-src': [CSP.SELF, CSP.NONCE],
200
+ 'form-action': [CSP.SELF, 'https://sis.redsys.es', 'https://sis-t.redsys.es:25443'],
201
+ }
202
+ ```
203
+
204
+ Every template defines a `title` and a `content` block; `redirect.html` also defines `head`.
205
+
206
+ ## Direct operations
207
+
208
+ `django_redsys.client.get_client()` builds the client from `REDSYS_CLIENT`; it takes another client class for the direct connection (`pip install "python-redsys[http]"`):
209
+
210
+ ```python
211
+ from django_redsys.client import get_client
212
+ from redsys.clients import DirectClient
213
+
214
+ response = get_client(DirectClient).refund(order=order.redsys_order, amount=order.total).send()
215
+ response.is_refunded()
216
+ ```
217
+
218
+ ## Compatibility
219
+
220
+ | | |
221
+ |---|---|
222
+ | Version | 1.0.0 |
223
+ | Django | 5.2 LTS, 6.0 and 6.1 |
224
+ | Python | 3.10 to 3.15 (Django 6.0 and later need 3.12) |
225
+ | python-redsys | 2.2 and later |
226
+
227
+ Upgrading from 0.4: [`docs/migration-0.4-to-1.0.md`](docs/migration-0.4-to-1.0.md).
228
+
229
+ ## Development
230
+
231
+ ```bash
232
+ uv sync
233
+ uv run pytest
234
+ uv run ruff check django_redsys tests && uv run ruff format --check django_redsys tests
235
+ ```
236
+
237
+ ## License
238
+
239
+ Apache License 2.0, as python-redsys. See [`LICENSE`](LICENSE) and [`NOTICE`](NOTICE). Releases up to 0.4.2 were published under the MIT License.
@@ -0,0 +1,26 @@
1
+ django_redsys/__init__.py,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
2
+ django_redsys/apps.py,sha256=WTXxE_V-DAug4wqxVbI559kqTHwG57_2_2pKzfB6n8o,193
3
+ django_redsys/checks.py,sha256=LgrAe4r70C1C8vqbxfY0UyKBhlvclzXuMTqZMoPCC9I,1338
4
+ django_redsys/client.py,sha256=3PqfDFcIf6t9bYirrMuT08plefnmKrZaV3czwDXUfN8,987
5
+ django_redsys/conf.py,sha256=_TTzDZRHW57lMFTtEPdxIgYYGnZBhWg6fErBP-GkfTQ,533
6
+ django_redsys/signals.py,sha256=pCNwhYYZxHFs4PLtoW4l4ZaSD6ugZ1s-brMaBE7ykiE,227
7
+ django_redsys/urls.py,sha256=woLggeXUBk39qaYZqEq1gQDNMMiLttBfpuwzRNpSpW4,382
8
+ django_redsys/views.py,sha256=XqodQDfjUk6B9S38Tz6zmZWIlgULQhy-ERDa2UygDMo,6782
9
+ django_redsys/notifications/__init__.py,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
10
+ django_redsys/notifications/admin.py,sha256=hyKZ8Ntrgxj1PxZKc7m62P_vp5ZfxiD9nxT0FYr3K2k,585
11
+ django_redsys/notifications/apps.py,sha256=BB8nz8kWCVER38lF6dl2GAjWmJbfWYZAX2ygtj9I7zY,342
12
+ django_redsys/notifications/models.py,sha256=H2fg9RNoicCsiVZJ3HyJNC9j9i-rnBP1ByzNFX4UzTE,3981
13
+ django_redsys/notifications/management/__init__.py,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
14
+ django_redsys/notifications/management/commands/__init__.py,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
15
+ django_redsys/notifications/management/commands/purge_redsys_notifications.py,sha256=t5oMF6yGm41P1uLYvXGCSp6P7mfC1EdUvRJ_oEoIoAA,789
16
+ django_redsys/notifications/migrations/0001_initial.py,sha256=42cfDo-a6zMdsjq-ta8xSwHdMDqFF-QK76IBDtQcNQQ,2855
17
+ django_redsys/notifications/migrations/__init__.py,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
18
+ django_redsys/templates/django_redsys/ko.html,sha256=EtxglKx1QbnLxD9ZQEWwFlVc1AHU7YHd-IZgSGEPRFE,581
19
+ django_redsys/templates/django_redsys/ok.html,sha256=jeQF3rg1vjjqggsy1_hnta7UE9QsHMZ_IQQMdzrSpEM,573
20
+ django_redsys/templates/django_redsys/redirect.html,sha256=IU6UtTVRD899_egyfDvc-_x6vYdcGocohCeiTUYcGmI,903
21
+ django_redsys-1.0.0.dist-info/licenses/LICENSE,sha256=qsc7MUj20dcRHbyjIJn2jSbGRMaBOuHk8F9leaomY_4,11360
22
+ django_redsys-1.0.0.dist-info/licenses/NOTICE,sha256=QwkHYuPzHIdnNLmmwoqcsrehtIBB76LGdcIwTMiOVbY,201
23
+ django_redsys-1.0.0.dist-info/METADATA,sha256=y6UwMancP6plh3C3hJMvb3dchcYQ5VA0lNnh2pBizos,14695
24
+ django_redsys-1.0.0.dist-info/WHEEL,sha256=mOdXR9C3wMVov7cSY8PY-XCzo3SmmWCHvGQr5csJoao,91
25
+ django_redsys-1.0.0.dist-info/top_level.txt,sha256=Tw9TJXtLISTUIE8Cx_FYmO4h8kzf4DkbJQYTwbsU5to,14
26
+ django_redsys-1.0.0.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (84.2.1)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+
@@ -0,0 +1,202 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ https://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright [yyyy] [name of copyright owner]
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ https://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
@@ -0,0 +1,7 @@
1
+ django-redsys
2
+ Copyright 2016-2026 David Díaz
3
+
4
+ Licensed under the Apache License, Version 2.0 (the "License").
5
+ You may obtain a copy of the License at:
6
+
7
+ https://www.apache.org/licenses/LICENSE-2.0
@@ -0,0 +1 @@
1
+ django_redsys