# Clip Redirect Plugin Documentation

This documentation provides a comprehensive overview of the Clip Redirect for WooCommerce plugin flows and architecture.

## Contents

1. [Onboarding Flow](./onboarding-flow.md) - Initial setup and credential configuration
2. [Checkout and Payment Flow](./checkout-payment-flow.md) - Order processing and payment creation
3. [Configuration Flow](./configuration-flow.md) - Settings management and customization
4. [Webhook Flow](./webhook-flow.md) - Payment status updates via webhooks
5. [Architecture Overview](./architecture.md) - Plugin structure and components

## Quick Overview

The **Clip Redirect** plugin integrates Clip payment gateway with WooCommerce, providing:

- **Redirect-based payments**: Customers are redirected to Clip's hosted checkout page
- **Multiple payment methods**: Cards (credit/debit) and cash
- **Customizable checkout**: Configure payment methods, card brands, and installments
- **Webhook notifications**: Real-time payment status updates
- **Refund support**: Process refunds directly from WooCommerce

## Key Components

### Main Classes

- **ClipRedirect**: Main plugin class, handles initialization and hooks
- **WC_ClipRedirect**: WooCommerce payment gateway implementation
- **ClipRedirectSdk**: API communication layer
- **Helper**: Utility class with traits for various functionality
- **Onboarding\Main**: Handles initial plugin setup
- **Webhooks**: Processes payment status notifications

### Plugin Constants

```php
GATEWAY_ID: 'wc_clipredirect'
META_ORDER_PAYMENT_ID: '_CLIPREDIRECT_PAYMENT_ID'
META_CLIPREDIRECT_PAYMENT_STATUS: '_CLIPREDIRECT_PAYMENT_STATUS'
META_CLIPREDIRECT_RECEIPT_NO: '_CLIPREDIRECT_RECEIPT_NO'
```

## API Endpoints

### Plugin Endpoints (WordPress)

- `/wc-api/wc-clip` - Webhook listener for payment status updates
- `/wp-admin/admin-ajax.php?action=clip_save_settings` - Save onboarding credentials
- `/wp-admin/admin-ajax.php?action=clip_request_deposit_action` - Create payment checkout

### Clip API Endpoints

- `POST /v2/checkout` - Create payment checkout
- `GET /v2/checkout/{payment_request_id}` - Get payment status
- `POST /refunds/` - Request refund

## Getting Started

1. Start with [Onboarding Flow](./onboarding-flow.md) to understand initial setup
2. Review [Checkout and Payment Flow](./checkout-payment-flow.md) for payment processing
3. Check [Configuration Flow](./configuration-flow.md) for customization options
4. Understand [Webhook Flow](./webhook-flow.md) for payment status updates

## Environment Configuration

The plugin supports two environments:

- **Production**: `https://api.payclip.com` and `https://plugin-onboarding.payclip.com`
- **Development**: `https://stage-api.payclip.com` and `https://stage-plugin-onboarding.payclip.com`

Current environment is configured via the `CLIPREDIRECT_ENVIRONMENT` constant in the main plugin file.
