# CODPartner Plugin

WordPress plugin for CODPartner API integration with secure credential management.

## ⚠️ Secure Credential Configuration Required

**IMPORTANT**: This plugin supports multiple methods for credential management. **Environment variables are recommended for production**.

### Quick Setup

#### Method 1: Environment Variables (Most Secure) ✅

**For Apache (.htaccess):**
```apache
SetEnv CODPARTNER_CLIENT_ID "your_client_id_here"
SetEnv CODPARTNER_CLIENT_SECRET "your_client_secret_here"
```

**For Nginx:**
```nginx
fastcgi_param CODPARTNER_CLIENT_ID "your_client_id_here";
fastcgi_param CODPARTNER_CLIENT_SECRET "your_client_secret_here";
```

**For Docker:**
```dockerfile
ENV CODPARTNER_CLIENT_ID=your_client_id_here
ENV CODPARTNER_CLIENT_SECRET=your_client_secret_here
```

#### Method 2: WordPress Constants (wp-config.php)

```php
define( 'CODPARTNER_CLIENT_ID', 'your_client_id_here' );
define( 'CODPARTNER_CLIENT_SECRET', 'your_client_secret_here' );
```

#### Method 3: WordPress Filters

```php
add_filter( 'codpartner_client_id', function() {
    return 'your_client_id_here';
});
```

### Complete Documentation

See the [SECURITY.md](SECURITY.md) file for complete security and configuration documentation.

## Features

- OAuth2 integration with CODPartner API
- Automatic access token management
- Secure lead data transmission
- Multiple credential management methods
- WordPress admin interface
- Detailed API interaction logs

## Security

- ✅ **Environment Variables**: Most secure method
- ✅ **WordPress Constants**: Good for development
- ✅ **WordPress Filters**: Flexible configuration
- ✅ **Automatic Detection**: Plugin detects best available method
- ✅ **Fallback Support**: Works even without configuration

## Credential Priority

The plugin checks for credentials in this order:

1. **Environment Variables** (most secure)
2. **WordPress Constants** (wp-config.php)
3. **WordPress Filters** (functions.php)
4. **Fallback Values** (least secure, for development only)

## Support

For credential setup or any questions, contact the CODPartner team.

## License

This plugin is distributed under the GPL v2 or later license.

## Description

CODPartner is a comprehensive logistics solution for Cash on Delivery (COD) e-commerce sellers. The plugin integrates with WooCommerce to provide seamless access to multiple markets and streamline your logistics operations.

## Requirements

- WordPress 5.0 or higher
- WooCommerce 3.0 or higher
- PHP 7.4 or higher
- MySQL 5.6 or higher

## Installation

1. Upload the `codpartner` folder to the `/wp-content/plugins/` directory
2. Activate the plugin through the 'Plugins' menu in WordPress
3. Go to CODPartner settings to configure your API credentials
4. Start managing your COD orders efficiently

## Configuration

1. Navigate to WooCommerce > CODPartner
2. Enter your API credentials
3. Configure your preferred settings
4. Save changes

## Security

- All API communications are encrypted
- Secure token management
- Input validation and sanitization
- Regular security updates

## Contributing

We welcome contributions! Please read our [contributing guidelines](https://codpartner.com/contributing) before submitting pull requests.

## Changelog

### 1.0.0
- Initial release
- Basic integration with WooCommerce
- API connection setup
- Lead management system
- Custom order columns 