Skip to main content

Redsys support for guillotina

Project description

Redsys (Sermepa) REST + 3-D Secure 2.x integration for the Guillotina framework.

This package provides:

  • A Guillotina utility to orchestrate Redsys REST calls.

  • Pydantic v1 models for merchant parameters, EMV3DS, final authorization, and errors.

  • An async HTTP client (aiohttp + tenacity) with retries.

  • Mandatory Redis usage to correlate and finish 3-DS flows (stores threeDSCompInd and CRES).

  • Guillotina services (endpoints) to start transactions, run AuthenticationData, and handle ACS callbacks.

Requirements

  • Python 3.9+

  • Guillotina

  • aiohttp, tenacity, pydantic==1.*

  • Redis via guillotina.contrib.redis

  • Redsys merchant credentials (FUC, Terminal, Secret Key)

Installation

pip install guillotina_redsys

Configuration

Enable the app and configure the utility in Guillotina settings. The Redis add-on must be enabled.

Example (pseudocode):

apps = ["guillotina.contrib.redis", "guillotina_redsys"]
app_settings = {
    "applications": apps,
    "load_utilities": {
        "redsys": {
            "provides": "guillotina_redsys.interfaces.IRedsysUtility",
            "factory": "guillotina_redsys.utility.RedsysUtility",
            "settings": {
                "merchant_code": os.environ["REDSYS_MERCHANT_CODE"],
                "terminal": os.environ.get("REDSYS_TERMINAL", "001"),
                "secret_key": os.environ["REDSYS_SECRET_KEY"],
                "url_redsys": os.environ.get(
                    "REDSYS_URL", "https://sis-t.redsys.es:25443/sis/rest"
                ),
                "container_url": os.environ["REDSYS_CONTAINER_URL"],
            },
        }
    },
}

Suggested environment variables:

export REDSYS_MERCHANT_CODE=999008881
export REDSYS_TERMINAL=001
export REDSYS_SECRET_KEY=...
export REDSYS_URL=https://sis-t.redsys.es:25443/sis/rest
export REDSYS_CONTAINER_URL=https://your.app/db/container

Exposed services (HTTP)

Resource-scoped:

  • POST @initTransactionRedsys: calls iniciaPeticionREST; returns decoded payload and a prebuilt payload for 3DS Method.

  • POST @initThreeDS: helper to initiate 3DS Method (mainly for testing; in production the browser posts the form).

  • POST @initTrataPeticion: builds AuthenticationData; returns either (acsURL + creq) for challenge or a final frictionless result.

Container-scoped (callbacks and finalization):

  • POST @notificationRedsys3DS/{order_id}/{three_dss_trans_id}: stores threeDSCompInd in Redis (TTL 15m).

  • GET @getnotificationRedsys3DS/{order_id}/{three_dss_trans_id}: reads threeDSCompInd.

  • POST @notificationRedsysChallenge/{order_id}/{three_dss_trans_id}: stores raw CRES in Redis (TTL 30m).

  • POST @performNotificationRedsysChallenge/{order_id}/{three_dss_trans_id}: reads CRES and finalizes with ChallengeResponse; returns final authorization result.

Redis keys

  • notification_3DS:{order}:{sid}"Y" or "N" (TTL 15 minutes)

  • notification_CRES:{order}:{sid} → base64url CRES (TTL 30 minutes)

Flow summary

  1. Start: backend calls Redsys iniciaPeticionREST (CardData).

  2. Optional 3DS Method: browser posts threeDSMethodData; backend receives method callback and records threeDSCompInd in Redis.

  3. AuthenticationData: backend calls Redsys trataPeticionREST; either gets (acsURL + creq) for challenge or a frictionless final result.

  4. Challenge: browser posts creq to ACS; ACS posts CRES to backend callback.

  5. Finalization: backend reads CRES from Redis and calls Redsys trataPeticionREST with threeDSInfo="ChallengeResponse"; returns final authorization.

Security notes

  • Use HTTPS for all public endpoints.

  • Do not log PAN/CVV.

  • If you store card data yourself, encrypt and keep a short TTL; purge after finalization.

  • Ensure unique order ids to avoid Redsys duplicate-order errors (e.g. SIS0051).

1.0.0 (2025-11-19)

  • Initial public release of guillotina_redsys.

  • Core Redsys REST + 3DS v2 flow.

  • Guillotina endpoints added.

  • Utility added (async client + orchestration).

  • Pydantic models added.

  • Redis used to store short-lived threeDSCompInd and CRES.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

guillotina_redsys-1.0.0.tar.gz (29.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

guillotina_redsys-1.0.0-py3-none-any.whl (30.7 kB view details)

Uploaded Python 3

File details

Details for the file guillotina_redsys-1.0.0.tar.gz.

File metadata

  • Download URL: guillotina_redsys-1.0.0.tar.gz
  • Upload date:
  • Size: 29.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.4

File hashes

Hashes for guillotina_redsys-1.0.0.tar.gz
Algorithm Hash digest
SHA256 89dd1a093eb521f3f2e96f5ed97676c8c621c45c0f27ea8dc5eec28d52b1d281
MD5 aaebb966b4974f6bcbce8e11b0eebaa6
BLAKE2b-256 06330fd08097be45d1937f67566b17c3a4618186d614187f6bc0c3ec2fa3ac48

See more details on using hashes here.

File details

Details for the file guillotina_redsys-1.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for guillotina_redsys-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 0c7074e3ac13970ab14fe51517d72e9206c1e602c43f00bf5e6b29f19e7b0b0a
MD5 8468e1b4b246a0ccac52a1d1715caa55
BLAKE2b-256 60fc15999b7a3b89454407c723e779922157118444bf31c74899d6ff816eed37

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page