# Walkthrough - Gravity Forms Redsys Integration (Advanced)

## Overview
This plugin integrates Redsys with Gravity Forms, offering a seamless "PayPal-style" experience using a custom field and a modal redirection overlay.

## Features Implemented
### 1. Custom Field "Redsys"
- **Class**: `GF_Field_Redsys` in `includes/class-gf-field-redsys.php`.
- **Function**: Acts as a trigger in the form.
- **Usage**: Drag "Redsys" from the Pricing Fields group into your form.

### 2. Modal Redirection
- **Experience**: When the user submits the form, instead of a blank redirect page, they see a styled overlay on the same page.
- **Implementation**: JS/CSS injected via `enqueue_frontend_scripts` in `GF_Redsys` class.
- **Visuals**: "Conectando con Redsys..." message with a spinner.

### 3. Core Logic & Security
- **Redsys API**: `includes/class-redsys-api.php` handles HMAC SHA-256 signatures.
- **Order ID**: Generates unique IDs using `MinutesSeconds` (4 digits) + `EntryID` to prevent "Repeated Order" errors (SIS0019).
- **Signature**: Uses `openssl_encrypt` with `DES-EDE3-CBC` (SIS0042 fix).

### 4. Quick Pay Shortcode
- **Shortcode**: `[redsys_quick_pay]`
- **File**: `includes/class-redsys-quick-pay.php`
- **Use Case**: Simple payment buttons without full GF forms.

## Files Structure
- `gf-redsys-integration.php`: Main entry point.
- `includes/class-gf-redsys.php`: Main Add-On class (Settings, Feeds, IPN).
- `includes/class-gf-field-redsys.php`: Custom Field definition.
- `includes/class-redsys-api.php`: Crypto & Params helper.
- `includes/class-redsys-quick-pay.php`: Standalone shortcode.

## How to Configure
1.  **Settings**: Go to *Forms > Settings > Redsys* and enter FUC, Terminal, and Secret.
2.  **Form Setup**:
    - Add a "Product" field.
    - Add the **"Redsys"** field (Pricing group).
3.  **Feed**: Go to *Form Settings > Redsys* and create a feed to map the transaction.

