# AstroPay WooCommerce Plugin

Payment gateway plugin for WooCommerce that integrates with AstroPay's payment platform.

## Version 2.0 - New API Integration

This version uses AstroPay's latest API endpoints for improved performance and features.

## Requirements

- WordPress 5.8+
- WooCommerce 6.0+
- PHP 7.4+

## Installation

1. Upload plugin to `/wp-content/plugins/astropay-woocommerce`
2. Activate through WordPress admin
3. Configure in WooCommerce > Settings > Payments > AstroPay

## Local Development

### Prerequisites
- Docker Desktop

### Setup

```bash
# 1. Start WordPress + MySQL
docker compose up -d

# 2. Install WooCommerce and activate plugin (wait ~30s for WP to initialize)
./bin/setup-local.sh

# 3. Open WordPress admin
open http://localhost:8080/wp-admin
```

WordPress auto-generates an admin password on first run. Get it with:
```bash
docker compose logs wordpress | grep "Admin password"
```

### Configure the Plugin

1. Go to **WooCommerce > Settings > Payments > AstroPay**
2. Enable the gateway
3. Set environment to **Sandbox**
4. Add your sandbox Client ID and Client Secret from the [AstroPay Partners dashboard](https://merchants-stg.astropay.com)
5. Save

### Test a Payment

1. Go to `http://localhost:8080/shop`
2. Add a product to cart
3. Checkout → select AstroPay → Place Order
4. Complete payment in AstroPay sandbox

### Webhook Testing

Webhooks need a public URL. Use ngrok:

```bash
# Install ngrok (if needed)
brew install ngrok

# Expose local WordPress
ngrok http 8080

# Use the ngrok URL in AstroPay merchant portal as webhook URL:
# https://xxxx.ngrok.io/?wc-api=astropay_webhook
```

### Stop

```bash
docker compose down
```
