=== GreenPay Payment Service ===

Contributors: GreenPay Developers Team

Tags: credit card, greenpay, payment, checkout, woocommerce

Requires at least: 6.8

Tested up to: 6.8

Requires PHP: 7.4

Stable tag: 1.0.3

License: GPLv3

License URI: https://www.gnu.org/licenses/gpl-3.0.html

Accept card payments directly on your WooCommerce store with GreenPay Payment Service.

== Description ==

**Accept card payments directly on your WooCommerce store with GreenPay Payment Service.**

GreenPay Payment Service is a comprehensive payment gateway plugin that allows you to accept credit and debit card payments in Central America. The plugin integrates seamlessly with WooCommerce to provide a secure, PCI-compliant payment solution.

= Key Features =

- **Multiple Card Types Support**

  - Visa
  - MasterCard
  - American Express
  - Credix (installment payments)

- **Advanced Security**

  - 3D Secure (3DS) authentication
  - Tokenization for saved payment methods
  - PCI-compliant payment processing
  - Encrypted data transmission

- **Multi-Currency Support**

  - USD (United States Dollar)
  - CRC (Costa Rican Colón)
  - GTQ (Guatemalan Quetzal)
  - NIO (Nicaraguan Córdoba)
  - PAB (Panamanian Balboa)

- **WooCommerce Subscriptions Integration**

  - Supports simple subscriptions
  - Automatic recurring payments
  - Payment method updates
  - Subscription renewals

- **Special Features**

  - Tasa 0 (0% interest installment payments)
  - Save cards for future purchases
  - One-click checkout for returning customers
  - Multiple terminal IDs per currency

- **Developer Friendly**
  - REST API endpoints
  - WooCommerce Blocks support
  - Webhook notifications
  - Extensive filter hooks
  - Detailed logging

= External Services =

This plugin connects to external services provided by GreenPay to process payments securely. By using this plugin, you acknowledge and agree that the following external resources are loaded and data is transmitted to GreenPay servers.

**JavaScript Libraries Loaded:**

The plugin automatically loads the following JavaScript libraries from GreenPay's CDN during the checkout process:

1. **AES Encryption Library** (`static.greenpay.me/aes-js`)
   - **Purpose:** Encrypts sensitive credit card data (card number, CVV, expiration date) before transmission
   - **When loaded:** On checkout pages when payment form is displayed
   - **Data sent:** Encrypted credit card information, no plaintext card data ever leaves the browser unencrypted

2. **JSEncrypt Library** (`static.greenpay.me/jsencrypt`)
   - **Purpose:** RSA public key encryption for secure communication with GreenPay payment servers
   - **When loaded:** On checkout pages when payment form is displayed
   - **Data sent:** Public key encrypted payment credentials and session tokens

3. **GDataCollector** (`static.greenpay.me/collector/GDataCollector.min.js`)
   - **Purpose:** Collects device fingerprinting data for fraud detection and prevention
   - **When loaded:** On checkout pages when payment form is displayed
   - **Data sent:** Browser metadata (user agent, screen resolution, timezone, language), device information, IP address (collected by GreenPay servers)

4. **GreenPay Data Collector** (`script-collector.greenpay.me/gpDataCollector.min.js`)
   - **Purpose:** Additional fraud prevention and risk assessment data collection
   - **When loaded:** On checkout pages when payment form is displayed
   - **Data sent:** Transaction metadata, session information, and anonymized behavioral analytics

**What Data is Transmitted:**

When a customer makes a payment, the following data is sent to GreenPay servers:
- Encrypted credit card details (card number, CVV, expiration date, cardholder name)
- Order amount and currency
- Customer billing information (name, address, email)
- Device fingerprinting data for fraud prevention
- Transaction metadata (order ID, merchant ID, terminal ID)

**When Data is Sent:**

Data transmission occurs:
- When customer loads the checkout page (device fingerprinting scripts)
- When customer submits payment information (encrypted payment data)
- When webhooks are triggered for payment status updates (order information)

**Privacy and Legal Information:**

This service is provided by GreenPay, a payment processor operating in Central America.

- **Service Provider:** GreenPay (greenpay.me)
- **Terms of Service:** https://greenpay.me/terms
- **Privacy Policy:** https://greenpay.me/privacy
- **Data Processing:** All payment data is processed in accordance with PCI DSS standards
- **Data Storage:** Payment tokens and transaction records are stored securely by GreenPay

By using this plugin, you agree to GreenPay's terms and acknowledge that customer payment data will be transmitted to and processed by GreenPay's servers. You are responsible for informing your customers about this data transmission in your site's privacy policy.

= Supported Countries =

GreenPay operates in the following Central American countries:

- Costa Rica
- Guatemala
- Panama
- Nicaragua

= Requirements =

- WordPress 6.8 or higher
- WooCommerce 9.5 or higher
- PHP 8.2 or higher
- SSL certificate (recommended)
- GreenPay merchant account ([Sign up here](https://greenpay.me))

== Installation ==

= Automatic Installation =

1. Log in to your WordPress admin panel
2. Go to **Plugins > Add New**
3. Search for "GreenPay Payment Service"
4. Click **Install Now** button
5. Click **Activate** button

= Manual Installation =

1. Download the plugin ZIP file
2. Log in to your WordPress admin panel
3. Go to **Plugins > Add New > Upload Plugin**
4. Choose the downloaded ZIP file
5. Click **Install Now**
6. Click **Activate Plugin**

= Configuration =

**1. Obtain GreenPay Credentials**

Before configuring the plugin, you need:

- **Merchant ID** - Your unique merchant identifier
- **Secret Key** - Your merchant secret key
- **Public Key** - Your public encryption key
- **Terminal IDs** - One or more terminal IDs for different currencies

**Sandbox credentials:** [Sign up here](https://sandbox-dashboard.greenpay.me/merchants/new)
**Production credentials:** [Contact sales](mailto:ventas@greenpay.me)

**2. Configure Plugin Settings**

1. Go to **WooCommerce > Settings > Payments**
2. Find **GreenPay Payment Service** and click **Manage**
3. Configure the following settings:

**General Settings:**

- Enable/Disable - Check to enable the payment method
- **Title** - Name displayed to customers (default: "Credit/Debit Card")
- **Description** - Payment method description shown at checkout

**API Credentials:**

- **Environment** - Select Sandbox (testing) or Production (live)
- **Merchant ID** - Enter your merchant ID
- **Secret Key** - Enter your secret key
- **Public Key** - Enter your public key

**Terminal Configuration:**
For each currency you want to accept:

- **Terminal ID (USD)** - Terminal for US Dollar transactions
- **Terminal ID (CRC)** - Terminal for Costa Rican Colón
- **Terminal ID (GTQ)** - Terminal for Guatemalan Quetzal
- **Terminal ID (NIO)** - Terminal for Nicaraguan Córdoba
- **Terminal ID (PAB)** - Terminal for Panamanian Balboa

**Advanced Settings:**

- **Enable 3D Secure** - Recommended for fraud protection
- **Enable Saved Cards** - Allow customers to save cards
- **Enable Credix** - Allow Credix installment payments
- **Enable Tasa 0** - Allow 0% interest installments
- **Enable Logging** - Log transactions for debugging

4. Click **Save changes**

**3. Test the Integration**

1. Set **Environment** to **Sandbox**
2. Use test card numbers (provided by GreenPay)
3. Place a test order
4. Verify payment processes correctly
5. Check WooCommerce order status updates

**4. Go Live**

1. Obtain production credentials from GreenPay
2. Set **Environment** to **Production**
3. Enter production Merchant ID, Secret Key, and Public Key
4. Configure production Terminal IDs
5. Test with a small real transaction
6. Monitor first few live transactions

= WooCommerce Subscriptions Setup =

If using WooCommerce Subscriptions:

1. Install and activate **WooCommerce Subscriptions** plugin
2. Ensure **Enable Saved Cards** is checked in GreenPay settings
3. Create subscription products in WooCommerce
4. Customers can now subscribe with saved cards
5. Renewals will process automatically

**Note:** Credix cards are not supported for subscriptions.

== Frequently Asked Questions ==

= Does this require an SSL certificate? =

While not strictly required, an SSL certificate is **highly recommended** for security. GreenPay provides additional JavaScript encryption for card data, but SSL ensures all communication between your site and customers is secure.

= Does this support recurring payments and subscriptions? =

Yes! The plugin fully supports **WooCommerce Subscriptions** extension for:

- Simple subscriptions
- Automatic recurring payments
- Payment method changes
- Subscription renewals

= What card types are supported? =

- Visa
- MasterCard
- American Express
- Credix (for Costa Rica, Guatemala, Nicaragua)

= Can customers save their cards for future purchases? =

Yes! Enable the **"Enable Saved Cards"** option in plugin settings. Customers can then:

- Save cards during checkout
- Manage saved cards in **My Account**
- Use saved cards for one-click checkout
- Set a default payment method

**Security:** Cards are tokenized through GreenPay - your site never stores actual card numbers.

= Does this support 3D Secure authentication? =

Yes! Enable **"Enable 3D Secure"** in settings for additional fraud protection. When enabled:

- Customers may need to verify with their bank
- Reduces chargebacks
- Required by some card issuers

= What currencies are supported? =

The plugin supports multiple currencies based on your terminal configuration:

- USD (US Dollar)
- CRC (Costa Rican Colón)
- GTQ (Guatemalan Quetzal)
- NIO (Nicaraguan Córdoba)
- PAB (Panamanian Balboa)

= Is there a test mode for development? =

Yes! Select **Sandbox** environment in plugin settings. Use these test credentials:

- Sandbox dashboard: https://sandbox-dashboard.greenpay.me
- Test cards: Provided by GreenPay support

= How do I handle refunds? =

Refunds must be processed through the **GreenPay merchant dashboard**:

1. Log in to your GreenPay dashboard
2. Find the transaction
3. Initiate refund
4. Manually update WooCommerce order status

**Note:** Automatic refunds from WooCommerce are not currently supported.

= Where can I see transaction logs? =

Enable **"Enable Logging"** in plugin settings. Logs are saved to:
`WooCommerce > Status > Logs > greenpay-xxx.log`

= Does this work with WooCommerce Blocks checkout? =

Yes! The plugin supports:

- Classic WooCommerce checkout
- WooCommerce Block-based checkout (Cart and Checkout blocks)

= What is Credix and Tasa 0? =

**Credix:** An installment payment service available in Central America. Customers can split purchases into monthly payments.

**Tasa 0:** 0% interest installment plans offered by participating banks. Customers pay in installments without interest.

Both can be enabled/disabled in plugin settings.

= Can I use multiple terminal IDs? =

Yes! You can configure different terminal IDs for:

- Different currencies
- Different payment types (regular vs Credix)
- Different business locations

= Is this compatible with HPOS (High-Performance Order Storage)? =

Yes! The plugin declares compatibility with WooCommerce custom order tables (HPOS).

= Where can I get support? =

- **Documentation:** https://support.greenpay.me/portal/kb/articles/plugin-para-woocommerce
- **Support Tickets:** https://support.greenpay.me/portal/es/newticket
- **Sales Inquiries:** ventas@greenpay.me

= How do I report bugs or request features? =

For plugin-specific issues, please contact GreenPay support. For general WooCommerce issues, consult WooCommerce documentation.

== Screenshots ==

1. **Plugin Settings** - WooCommerce payment gateway configuration page
2. **Checkout Form** - Customer view of payment form with card fields
3. **3D Secure Modal** - Bank verification popup for 3DS authentication
4. **Saved Payment Methods** - Customer account page showing saved cards
5. **Admin Order View** - Transaction details in WooCommerce orders
6. **Terminal Configuration** - Multi-currency terminal ID setup

== Changelog ==

= 1.0.2 - 2025-11-06 =

- Compliance: Added comprehensive external services documentation
- Compliance: Updated hook prefixes from wc_greenpay_* to gpservice_* for unique naming
- Security: Enhanced nonce verification logic with separate validation checks
- Security: Added sanitization for $_SERVER variables in webhook handler
- Security: Added extensive documentation for encrypted payment data handling
- Security: Added validation for form field arrays before processing
- Compatibility: Replaced deprecated FILTER_SANITIZE_STRING with WordPress sanitization functions
- Enhancement: Improved code documentation explaining security exceptions
- Fix: All WordPress.org plugin review issues addressed

= 1.0.1 - 2025-11-05 =

- Security: Added proper input sanitization for nonce verification
- Security: Added JSON decode validation for webhook data
- Security: Added ABSPATH protection to all PHP files
- Fix: Updated AJAX action names to use unique prefix
- Enhancement: Improved README documentation
- Compliance: Updated class naming to meet WordPress.org standards

= 1.0.0 - 2025-10-14 =

- Initial release of GreenPay Payment Service
- Renamed from GreenPay Payment Gateway to GreenPay Payment Service
- Updated all class names, function names, and text domains
- Complete refactoring of plugin structure
- Added WooCommerce Blocks support
- Added 3D Secure authentication
- Added tokenization for saved cards
- Added WooCommerce Subscriptions support
- Added multi-currency support
- Added Credix and Tasa 0 features
