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.
- Python 3.9+
- Guillotina
- aiohttp, tenacity, pydantic==1.*
- Redis via guillotina.contrib.redis
- Redsys merchant credentials (FUC, Terminal, Secret Key)
pip install guillotina_redsysEnable 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/containerResource-scoped:
- POST
@initTransactionRedsys: callsiniciaPeticionREST; 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}: storesthreeDSCompIndin Redis (TTL 15m). - GET
@getnotificationRedsys3DS/{order_id}/{three_dss_trans_id}: readsthreeDSCompInd. - 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.
notification_3DS:{order}:{sid}→"Y"or"N"(TTL 15 minutes)notification_CRES:{order}:{sid}→ base64url CRES (TTL 30 minutes)
- Start: backend calls Redsys
iniciaPeticionREST(CardData). - Optional 3DS Method: browser posts
threeDSMethodData; backend receives method callback and recordsthreeDSCompIndin Redis. - AuthenticationData: backend calls Redsys
trataPeticionREST; either gets (acsURL + creq) for challenge or a frictionless final result. - Challenge: browser posts
creqto ACS; ACS postsCRESto backend callback. - Finalization: backend reads
CRESfrom Redis and calls RedsystrataPeticionRESTwiththreeDSInfo="ChallengeResponse"; returns final authorization.
- 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).