# RedPay

A WooCommerce payment gateway that integrates with RedPay to accept cards, bank transfers, and more. Get paid from Africa and worldwide.

## Features

- **Secure payments** via RedPay
- **RedPay POP (Payment on Page)** — modal payment window, customers stay on your site
- **Multiple payment methods** — cards, bank transfers, and more
- **Test mode** for safe development and testing
- **Refund support** — full and partial refunds from WooCommerce
- **Webhooks** — real-time payment status updates
- **Mobile responsive** checkout

## Requirements

- WordPress 5.0 or higher
- WooCommerce 5.0 or higher
- PHP 7.4 or higher
- SSL certificate (for live payments)
- RedPay merchant account

## Installation

1. Download the plugin zip or clone the repository.
2. Upload to `/wp-content/plugins/redpay-payment-gateway/` or install via Plugins > Add New > Upload Plugin.
3. Activate the plugin.
4. Go to **WooCommerce > Settings > Payments**.
5. Click **RedPay** and configure your settings.

## Configuration

### Basic setup

1. **Enable the gateway** in the RedPay settings.
2. Set the **title** and **description** customers see at checkout.
3. Turn **Test Mode** on for testing, off for live payments.

### API credentials

Get your API keys from RedPay:

- **Sign up:** https://gateway-merchant.redpay.africa/onboard/signup
- **API keys:** https://gateway-merchant.redpay.africa/app/api-keys
- **Test Public Key** and **Test Secret Key** — for test mode.
- **Live Public Key** and **Live Secret Key** — for production.

### Webhook

1. In your RedPay dashboard, add webhook URL: `https://yoursite.com/wc-api/redpay_payment_gateway`
2. Copy the webhook secret into the plugin settings.

## RedPay POP (Payment on Page)

- Customers stay on your site; payment runs in a secure modal.
- No redirect; real-time verification and order completion.

### Flow

1. Customer clicks **Place Order** at checkout.
2. RedPay POP modal opens.
3. Customer pays; plugin verifies and completes the order.
4. Customer is redirected to the thank you page.

## External services

The plugin uses **RedPay** as its only external service for payments.

- **What it is and what it’s used for:** RedPay provides the payment infrastructure. The plugin sends payment and refund requests to RedPay and loads the checkout experience (payment form/modal) from RedPay so that card and payment details are handled by RedPay, not by your server.

- **What data is sent and when:**
  - **At checkout:** Order total (amount), currency, customer email, first name, last name, and your store’s public API key are sent so RedPay can display the correct amount and complete the payment.
  - **After payment:** The plugin may verify the transaction with RedPay using the transaction reference.
  - **Refunds:** When you process a refund from WooCommerce, the transaction reference and refund amount are sent to RedPay.
  - **Webhooks:** RedPay may send webhook notifications to your site (to the URL in the plugin settings) to report payment status; the payload is defined by RedPay.

- **Terms and privacy:**
  - [Terms of use](https://gateway-merchant.redpay.africa/onboard/terms-of-use)
  - [Privacy policy](https://gateway-merchant.redpay.africa/onboard/privacy-policy)

## Testing

Enable **Test Mode** in the plugin to use test keys and avoid real charges. Use test cards provided by RedPay in your test environment.

## Security

- Use HTTPS on live sites.
- Keep API keys secure; never commit them.
- Use a strong webhook secret.
- Card details are not stored on your site; they are processed by RedPay.

## Support and documentation

- **Documentation:** https://gateway-documentation.redpay.africa/#/
- **Support:** https://redpay.africa/
- **Merchant signup:** https://gateway-merchant.redpay.africa/onboard/signup
- **API keys:** https://gateway-merchant.redpay.africa/app/api-keys
- **Terms of use:** https://gateway-merchant.redpay.africa/onboard/terms-of-use
- **Privacy policy:** https://gateway-merchant.redpay.africa/onboard/privacy-policy

## License

GPL v2 or later.

## Changelog

### 1.0.0
- Initial release
- RedPay payment processing and POP integration
- Test mode, refunds, webhooks
- Admin configuration
