# Configuration Guide

This guide covers all configuration options for Antom Payments for WooCommerce.

## Core Settings

The core settings are accessed via **WooCommerce → Settings → Checkout → Antom Payment Gateway**.

| Setting | Required | Description |
|---|---|---|
| **Enable/Disable** | Yes | Toggle the Antom Payment Gateway on/off |
| **Title** | No | Display name shown at checkout (default: "Antom Payments") |
| **Description** | No | Description shown at checkout |
| **Client ID** | **Yes** | Your Antom merchant Client ID |
| **Private Key** | **Yes** | Your RSA private key for request signing (PKCS#8 format) |
| **Public Key** | **Yes** | Antom's RSA public key for response verification |
| **Domain** | No | Custom API domain (overrides default Antom API endpoint) |
| **Test Mode** | No | Enable/disable sandbox environment (1 = enabled, 0 = disabled) |
| **Settlement Currency** | No | Currency for fund settlement |

### Client ID

Your unique merchant identifier provided by Antom. Found in the **Antom Merchant Portal** under account settings.

### Key Management

The plugin uses RSA-SHA256 for API request signing:

- **Private Key** — Your merchant private key. Used to sign outgoing API requests. Must be in PKCS#8 format.
- **Public Key** — Antom's public key. Used to verify incoming API responses and webhook notifications.

**⚠️ Security Note:** Keep your private key secure. Never share it or commit it to version control.

### Test Mode

When enabled, all payment requests are sent to the Antom sandbox environment. Use sandbox credentials (separate Client ID and keys) obtained from your Antom Merchant Portal.

When test mode is active, a **"Test Mode (Antom Sandbox)"** warning is displayed on the checkout page.

### Custom Domain

If you have a dedicated API domain from Antom, you can configure it here. Leave empty to use the default endpoint.

## Per-Method Settings

Each payment method has its own settings page under **WooCommerce → Settings → Checkout**:

| Setting | Description |
|---|---|
| **Enable/Disable** | Toggle this specific payment method |
| **Title** | Custom display name for this method |
| **Description** | Custom description shown at checkout |
| **Test Mode** | Override test mode for this specific method |

### Currency Filtering

Payment methods automatically filter based on the store's currency. Only methods that support the current currency are shown at checkout.

For example:
- **NAVER Pay** only supports KRW (Korean Won)
- **Alipay CN** supports 17 currencies including CNY, USD, EUR, JPY
- **Credit Card** supports 10 major currencies

See the [Payment Methods](payment-methods.md) document for the complete currency support matrix.

## Webhook Configuration

The webhook URL handles asynchronous payment notifications from Antom.

### Webhook URL

```
https://your-store.com/?wc-api=antom_payment_notify
```

Configure this URL in your [Antom Merchant Portal](https://dashboard.alipay.com/global-payments/home).

### Webhook Events

The plugin handles the following payment notification events:

| Event | Description |
|---|---|
| **Payment Success** | Order marked as "Processing" or "Completed" |
| **Payment Failure** | Order status updated to "Failed" with error details |
| **Payment Cancelled** | Order status updated accordingly |

### Webhook Security

Webhook requests are verified using:
1. **Signature Verification** — Antom's signature is validated using the configured Public Key
2. **Response Processing** — Only properly signed notifications are processed

## Payment Flow

### Standard Payment (Digital Wallets)

1. Customer selects a payment method at checkout
2. WooCommerce creates an order with "Pending Payment" status
3. Customer is redirected to Antom's Cashier Payment page (CKP) or stays on checkout
4. After payment completion, Antom sends a webhook notification
5. Order status is updated based on payment result

### Card Payment (Antom Elements)

1. Customer enters card details in embedded fields (Antom Elements SDK)
2. Card data is encrypted client-side (RSA + AES)
3. A payment session is created via AJAX
4. Customer confirms payment
5. Payment result is processed

### Re-payment

Customers can retry payment for failed orders via the **Order Pay** page.

## Refund Configuration

Refunds can be processed from the WooCommerce order admin page:

1. Go to **WooCommerce → Orders**
2. Click the order to refund
3. Click **Refund**
4. Enter the refund amount (full or partial)
5. Submit — the refund is processed via the Antom API

## Order Status Mapping

| Payment Result | WooCommerce Status |
|---|---|
| Success | Processing / Completed |
| Failure | Failed |
| Pending | Pending Payment |
| Cancelled | Cancelled |

## HPOS Compatibility

The plugin fully supports WooCommerce High-Performance Order Storage (HPOS). Ensure HPOS is enabled in **WooCommerce → Settings → Advanced → Features**.

## See Also

- [Installation Guide](installation.md) — Initial setup instructions
- [Webhook & API Reference](webhook-api.md) — Technical webhook details
- [Architecture Overview](architecture.md) — System architecture