=== Loka Pay ===
Contributors: danitex24
Tags: payments, nigeria, paystack, flutterwave, woocommerce
Requires at least: 6.0
Tested up to: 7.1
Requires PHP: 8.0
Stable tag: 1.0.0
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Accept Nigerian payments through Paystack, Flutterwave, Monnify and more — for WooCommerce, LMS, memberships, events and custom forms.

== Description ==

Loka Pay brings Nigeria's leading payment gateways together in one WordPress plugin. Connect one or several providers, manage every transaction from a single dashboard, and take payments through WooCommerce, popular LMS and membership plugins, or your own payment forms.

= Supported payment gateways =

* Paystack
* Flutterwave
* Monnify
* Interswitch (WebPAY)
* Remita
* OPay
* Squad
* Paga

You need a merchant account with each gateway you enable. Loka Pay does not process payments itself — it connects your site to the provider you choose.

= Features =

* **Payment forms** — build as many forms as you need with the drag-and-drop builder (text, email, phone, dropdowns, radio buttons, checkboxes, amounts and more). Each form has its own shortcode, and customers' answers are saved with each transaction. Dropdown and radio options can carry a price, for example "Gold — ₦5,000".
* **Payment links** — shareable, hosted payment pages with optional usage limits and expiry dates.
* **WooCommerce** — a full payment gateway with order sync and refunds.
* **Subscriptions** — recurring billing with automatic retries and dunning emails.
* **Invoices** — create, send and download invoices as PDFs.
* **Customer portal** — customers can view their payments, invoices and subscriptions with `[loka_pay_account]`.
* **Refunds** — issue full or partial refunds from the transaction screen.
* **Split payments** — revenue sharing for LMS instructors and marketplace vendors, using Paystack and Flutterwave sub-accounts.
* **Smart routing** — send each payment to the gateway with the best recent success rate.
* **Fraud screening** — rule-based risk scoring with an admin review queue.
* **Offline bank transfers** — record and approve manual bank payments.
* **Webhook monitoring** — signature-verified webhooks with health tracking and an automatic retry queue.
* **Analytics and reports** — revenue, success-rate and gateway charts, plus CSV export.
* **Email notifications** — receipts, invoices, failed-payment and renewal emails.
* **Test mode** — use each gateway's sandbox keys before going live.
* **White-label** — rebrand the admin screens through filters.

= Integrations =

Loka Pay adds a payment option to these plugins when they are active:

* WooCommerce
* LearnDash, LifterLMS, Tutor LMS, LearnPress
* Paid Memberships Pro, MemberPress, Restrict Content Pro
* The Events Calendar, Event Espresso, WP Event Manager
* Dokan, WC Vendors
* Page builders: Block Editor, Elementor, Divi, Beaver Builder

= Shortcodes =

* `[loka_pay_form id="123"]` — a form built in **Loka Pay → Forms** (copy the shortcode from the forms list).
* `[loka_pay_form]` — a simple name, email and amount form.
* Optional attributes: `amount` (fixed amount in Naira), `gateway`, `redirect`, `title`, `button_text`.
* `[loka_pay_account]` — the customer portal.
* `[loka_pay_status]` — a payment status lookup.

== External services ==

Loka Pay relies on third-party payment gateways to take payments. It connects only to the gateways you enable. **No data is sent to a gateway until you enable it in Loka Pay → Gateways and enter your own API keys.** In Test Mode, the gateway's sandbox address is used instead of the live one.

Customers enter card and bank details on the gateway's own payment page, so those details never pass through your site. Every request to a gateway is authenticated with the API keys you entered. Each gateway also sends payment notifications (webhooks) to your site's webhook URL.

= Paystack =

Provided by Paystack Payments Ltd. Used to take, verify and refund payments, charge subscription renewals and set up split payments.

* When a customer pays with Paystack, the plugin sends the transaction reference, amount, currency, the customer's email address and name, and your site's return URL to `https://api.paystack.co/transaction/initialize`.
* After the customer returns, or when a webhook arrives, the payment is checked at `https://api.paystack.co/transaction/verify/{reference}`.
* When you issue a refund, the transaction reference and refund amount are sent to `https://api.paystack.co/refund`.
* When a subscription renews, the customer's email, the amount, currency, reference and the saved Paystack authorization code are sent to `https://api.paystack.co/transaction/charge_authorization`.
* When you set up split payments for a vendor or instructor, their business name, settlement bank, account number and percentage share are sent to `https://api.paystack.co/subaccount`, and the split rules to `https://api.paystack.co/split`.
* [Terms of Service](https://paystack.com/terms), [Privacy Policy](https://paystack.com/privacy/merchant)

= Flutterwave =

Provided by Flutterwave Inc. Used to take, verify and refund payments, charge subscription renewals and set up split payments.

* When a customer pays with Flutterwave, the plugin sends the transaction reference, amount, currency, the customer's email address, name and phone number, and your site's return URL to `https://api.flutterwave.com/v3/payments`.
* Payments are verified at `https://api.flutterwave.com/v3/transactions/{reference}/verify`, and refunds are sent to `https://api.flutterwave.com/v3/transactions/{id}/refund`.
* When a subscription renews, the customer's email, the amount, currency, reference and the saved card token are sent to `https://api.flutterwave.com/v3/tokenized-charges`.
* When you set up split payments, the vendor's settlement details and share are sent to `https://api.flutterwave.com/v3/subaccounts`.
* [Terms of Service](https://flutterwave.com/ng/terms), [Privacy Policy](https://flutterwave.com/ng/privacy-policy)

= Monnify =

Provided by Moniepoint Inc. Used to take, verify and refund payments.

* Requests go to `https://api.monnify.com` (live) or `https://sandbox.monnify.com` (test mode).
* Your API key and secret key are exchanged for an access token at `/api/v1/auth/login`.
* When a customer pays with Monnify, the transaction reference, amount, currency, the customer's name and email address, and your site's return URL are sent to `/api/v1/merchant/transactions/init-transaction`.
* Payments are verified at `/api/v2/transactions/{reference}`, and refunds are sent to `/api/v1/refunds/initiate-refund`.
* [Terms of Service](https://monnify.com/terms), [Privacy Policy](https://monnify.com/privacy)

= Interswitch WebPAY =

Provided by Interswitch Group. Used to take and verify payments.

* When a customer pays with Interswitch, their browser is sent to `https://webpay.interswitchng.com/collections/w/pay` (live) or `https://sandbox.interswitchng.com/collections/w/pay` (test mode), with the transaction reference, amount, currency, the customer's name and email address, your merchant code and pay item ID, and your site's return URL.
* The payment is then verified by sending the reference and amount to `https://webpay.interswitchng.com/collections/api/v1/gettransaction.json` (live) or `https://sandbox.interswitchng.com/collections/api/v1/gettransaction.json` (test mode).
* [Terms of Use](https://www.interswitchgroup.com/terms-of-use), [Privacy Policy](https://www.interswitchgroup.com/privacy-policy)

= Remita =

Provided by SystemSpecs Ltd. Used to take and verify payments.

* Requests go to `https://login.remita.net/remita` (live) or `https://remitademo.net/remita` (test mode).
* When a customer pays with Remita, the transaction reference, amount, the payer's name, email address and phone number, and your site's return URL are sent to `/ecomm/split/payment/init`. The customer then completes payment at `/ecomm/finalize.reg`.
* Payments are verified at `/ecomm/split/payment/query/{RRR}`.
* [Terms and Conditions](https://www.remita.net/terms-and-conditions), [Privacy Policy](https://www.remita.net/privacy-policy)

= OPay =

Provided by OPay Digital Services Ltd. Used to take and verify payments.

* Requests go to `https://api.opayweb.com` (live) or `https://sandboxapi.opayweb.com` (test mode).
* When a customer pays with OPay, the transaction reference, amount, currency, the customer's name, email address and phone number, and your site's return URL are sent to `/api/cashier/initialize`.
* Payments are verified at `/api/cashier/query`.
* [Terms of Service](https://www.opayweb.com/terms-of-service), [Privacy Policy](https://www.opayweb.com/privacy-policy)

= Squad =

Provided by HabariPay Ltd. Used to take, verify and refund payments.

* Requests go to `https://api-d.squadco.com` (live) or `https://sandbox-api-d.squadco.com` (test mode).
* When a customer pays with Squad, the transaction reference, amount, currency, the customer's name and email address, and your site's return URL are sent to `/transaction/initiate`.
* Payments are verified at `/transaction/verify/{reference}`, and refunds are sent to `/transaction/refund`.
* [Terms and Conditions](https://habaripay.com/terms.pdf), [Privacy Policy](https://habaripay.com/privacy.pdf) (HabariPay Ltd. operates Squad)

= Paga =

Provided by Pagatech Ltd. Used to take and verify payments.

* Requests go to `https://www.mypaga.com` (live) or `https://beta.mypaga.com` (test mode).
* When a customer pays with Paga, the transaction reference, amount, currency, the payer's email address and phone number, and your site's return URL are sent to `/paga-webservices/business-rest/secured/collectMoney`.
* Payments are verified at `/paga-webservices/business-rest/secured/getTransactionDetails`.
* [Terms of Service and Privacy Policy](https://www.mypaga.com/ngn-terms/)

= Documentation links =

The Gateways screen links to each gateway's developer documentation (for example `https://paystack.com/docs/api/` and `https://developers.remita.net/`). These pages open only when you click them, and no data is sent.

Loka Pay does not send any data to Danovate Solutions Ltd. or to any other third party, and includes no tracking.

== Installation ==

1. Install Loka Pay from **Plugins → Add New**, or upload the `loka-pay` folder to `/wp-content/plugins/`.
2. Activate the plugin.
3. Go to **Loka Pay → Gateways**, enable a gateway and enter your test or live API keys.
4. Copy the webhook URL shown for that gateway into the gateway's dashboard.
5. Create a form in **Loka Pay → Forms** and paste its shortcode into a page, or pick the form in the Loka Pay block or page-builder widget — or enable Loka Pay under **WooCommerce → Settings → Payments**.

== Frequently Asked Questions ==

= Do I need WooCommerce? =

No. Payment forms, payment links, invoices and subscriptions work on their own. WooCommerce support loads only when WooCommerce is active.

= Do I need an account with a payment gateway? =

Yes. Loka Pay connects to your own merchant account with Paystack, Flutterwave or another supported gateway, and payments settle directly into that account.

= Can I test before accepting real payments? =

Yes. Turn on **Test Mode** in **Loka Pay → Settings** and use your gateway's test keys. No real money moves in test mode.

= Where do I find my webhook URL? =

Go to **Loka Pay → Gateways** and open a gateway's settings. Paste the URL into that gateway's dashboard — for example, Paystack → Settings → API Keys & Webhooks.

= Does the plugin store card details? =

No. Customers enter card and bank details on the gateway's secure page. Your site stores only the transaction reference, amount, status and the customer's contact details.

= What happens to my data if I delete the plugin? =

By default, nothing is deleted. To remove all Loka Pay tables and settings on uninstall, turn on **Delete All Data on Uninstall** in **Loka Pay → Settings** first.

== Screenshots ==

1. Dashboard with key payment metrics.
2. Gateway configuration.
3. Transaction list with filters and refunds.
4. Analytics charts.
5. Front-end payment form.

== Changelog ==

= 1.0.0 =
* Initial release.

== Upgrade Notice ==

= 1.0.0 =
Initial release.

== Third-party libraries ==

* [Chart.js](https://www.chartjs.org/) v4.5.1 — MIT License. Bundled as `assets/js/vendor/chart.min.js`. Unminified source: https://github.com/chartjs/Chart.js/tree/v4.5.1
