=== GetPay Payment Integration ===
Contributors: citytechglobal
Donate link: https://citytech.global
Tags: getpay, woocommerce, payment, gateway, nepal
Tested up to: 6.8
Requires PHP: 7.4
Stable tag: 1.0.1
License: GPL v2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

A secure payment gateway plugin for WooCommerce using GetPay.

== Description ==
A secure payment gateway plugin for WooCommerce using GetPay.

# GetPay WooCommerce Integration

A secure payment gateway plugin that integrates the **GetPay** payment system with **WooCommerce** for WordPress e-commerce stores.

<!-- TOC -->

## Table of Contents

- [Prerequisites](#prerequisites)
- [Installation](#installation)
- [Configuration](#configuration)
- [Page Setup](#page-setup)
- [Testing](#testing)
- [Troubleshooting](#troubleshooting)
- [Support](#support)
- [Security Notes](#security-notes)
- [Changelog](#changelog)

---

## Prerequisites

Before installing the GetPay plugin, ensure you have:

- ✅ WordPress site with admin access
- ✅ WooCommerce plugin installed and activated
- ✅ GetPay merchant account (credentials from your bank)
- ✅ SSL certificate installed (recommended for security)

---

## Installation

### Step 1: Install WooCommerce

1. Go to **Plugins > Add New**
2. Search for "WooCommerce"
3. Click **Install Now** and then **Activate**
4. Complete the WooCommerce setup wizard

### Step 2: Install GetPay Plugin

#### Option A: From Plugin Directory

1. Go to **Plugins > Add New**
2. Search for **"GetPay"**
3. Click **Install Now** and then **Activate**

#### Option B: Manual Upload

1. Download the `.zip` file of GetPay plugin
2. Go to **Plugins > Add New > Upload Plugin**
3. Select the `.zip` file and click **Install Now**
4. Click **Activate**

---

## Configuration

### Step 1: Access Payment Settings

- Navigate to **WooCommerce > Settings > Payments**
- Locate **GetPay Gateway** in the list
- Click **Manage** or **Set up**

### Step 2: Configure Required Fields

| Field              | Description                                   | Example                                         |
| ------------------ | --------------------------------------------- | ----------------------------------------------- |
| **Enable**         | Check to activate GetPay                      | ☑️                                              |
| **Title**          | Customer-facing payment title                 | GetPay                                          |
| **PAP Info**       | Payment Application Provider info (from bank) | `eyJpbn...`                                     |
| **OPR Key**        | Operational key                               | `4fa4c6b9-...`                                  |
| **INS Key**        | Institution key (if any)                      | (blank)                                         |
| **Website Domain** | Your site domain (with HTTPS)                 | `https://your-site.com`                         |
| **Bundle JS URL**  | GetPay JS bundle                              | `https://minio.finpos.global/.../bundle.min.js` |
| **Success URL**    | Redirect on successful payment                | `https://your-site.com/success`                 |
| **Fail URL**       | Redirect on failed payment                    | `https://your-site.com/fail`                    |
| **Base URL**       | GetPay API base endpoint                      | `https://uat-bank-getpay.nchl.com.np/...`       |

- Click **Save Changes**

---

## Page Setup

### Step 1: Create Pages

Create the following pages via **Pages > Add New**:

#### 🛒 Cart Page

- **Title:** Cart
- **Content:** `[woocommerce_cart]`

#### 💳 Checkout Page

- **Title:** Checkout
- **Content:** `[woocommerce_checkout]`

#### 💰 Payment Page

- **Title:** Payment
- **Content:** Add the following HTML tag to embed the payment interface: `<div id="checkout"></div>`
- **Purpose:** This page serves as the payment processing screen where the GetPay JS bundle will render the secure payment interface.

#### ✅ Success Page

- **Title:** Payment Success
- **Content:** Add the following shortcode in the content area of the page:
  `[getpay_check_success_page]`
- **URL:** The page URL must exactly match the **Success URL** you have configured in the GetPay plugin settings (e.g., `https://your-site.com/success`).
- **Custom Content:** You may add additional messages, images, or layout elements _after_ the shortcode if needed. However, **do not remove or modify the shortcode**, as it is essential for validating and displaying the payment confirmation.

#### ❌ Failure Page

- **Title:** Payment Failed
- **Content:** You can display a custom message such as: `[getpay_check_fail_page]`
- **URL:** The page URL must exactly match the **Fail URL** you have configured in the GetPay plugin settings (e.g., `https://your-site.com/fail`).
- **Custom Content:** You may customize the message or design of this page to fit your site's branding, but make sure the URL is correct to ensure users are properly redirected after a failed transaction.

### Step 2: Assign Pages in WooCommerce

- Go to **WooCommerce > Settings > Advanced**
- Set:
  - **Cart page:** Cart
  - **Checkout page:** Checkout
- Click **Save Changes**

---

## Testing

### Test Mode

- Use **sandbox credentials** from your bank
- Test with provided test card numbers
- Verify flows: ✅ success, ❌ failure, ✋ cancellation

### Live Mode

- Replace test keys with **production credentials**
- Update **Base URL** to production endpoint
- Run small-amount test transactions before going live

---

## Troubleshooting

### Plugin Not Appearing

- Ensure **WooCommerce is activated**
- Check if **GetPay plugin is active**
- Verify **GetPay Gateway is enabled** under payment methods

### Payment Failures

- Double-check **PAP/OPR/INS credentials**
- Ensure **site has valid SSL**
- Check if **JS bundle and API endpoints are accessible**

### Redirect Issues

- Make sure success/fail URLs are correct
- Pages should be **published** and match settings

### Debug Logs

- Go to **WooCommerce > Status > Logs**
- Check logs prefixed with **getpay**
- Look for API errors or response messages

---

## Support

### 🛠️ Plugin Issues

- Contact your plugin development team

### 🏦 Payment Issues

- Contact your bank’s **GetPay support team**

### 📖 WooCommerce

- Refer to [WooCommerce documentation](https://woocommerce.com/documentation/)

---

## Security Notes

- 🔒 Always use HTTPS in production
- 🔁 Keep plugin updated
- 💾 Regularly back up your site
- 🔐 Never share your credentials publicly
- 🧪 Fully test before enabling live payments

---

## Changelog

### Version 1.0.0

- Initial release
- WooCommerce + GetPay basic integration
- Supports:
  - Success & failure redirects
  - Full credential configuration
  - Embedded JS bundle support

---

> © 2025 GetPay Integration Team  
> Securely built for WooCommerce by Citytech Global
