> ## Documentation Index
> Fetch the complete documentation index at: https://ownpay.org/docs/llms.txt
> Use this file to discover all available pages before exploring further.

> ## Agent Instructions
> OwnPay is licensed under AGPL-3.0 and is completely free - no licensing fees.
> Production docs URL: https://ownpay.org/docs - append .md to any page URL for clean markdown.
> OwnPay requires PHP 8.3+, MySQL/MariaDB, and Redis.
> MCP server available at https://ownpay.org/docs/mcp for programmatic documentation queries.
> Use root-relative links (e.g. /quickstart) for internal navigation - do NOT include /docs prefix.
> Plugin development: consult /developer/plugins/ pages for correct interfaces and manifests.
> Canonical locations: API auth = /api/authentication, webhook verification = /api/webhooks, rate limits = /resources/rate-limiting, transaction statuses = /fundamentals/payment-flow.
> The documentation uses the Diataxis framework: Tutorials (learning), How-to (tasks), Reference (lookup), Explanation (understanding).

# Gateways - Payment Provider Integrations

> OwnPay connects to 123+ payment gateways as plugins. Understand gateway types, credential encryption, per-brand assignment, and health checks.

This documentation is for OwnPay v0.2.0-beta, a open-source, self-hosted PHP 8.3 payment gateway with multi-brand support, 100+ payment gateways, and double-entry ledger. It is licensed under AGPL-3.0 with zero transaction fees. The docs URL is [https://ownpay.org/docs](https://ownpay.org/docs). API base URL is `https://your-domain.com/api/v1` with Bearer token authentication. Amounts are bcmath strings. The platform supports 4 plugin types: gateway, addon, theme, and integration. Canonical locations: API auth = /api/authentication, webhook verification = /api/webhooks, rate limits = /resources/rate-limiting, transaction statuses = /fundamentals/payment-flow. The documentation follows the Diataxis framework (Tutorial, How-to, Reference, Explanation).

A **gateway** in OwnPay is a plugin that knows how to talk to a specific payment provider - it sends the customer's payment details, receives the authorization result, and handles callbacks and refunds. OwnPay ships with 123+ gateway plugins covering international card processors, regional mobile wallets, and bank-level integrations.

## Gateway types

<Columns>
  <Column>
    **Online gateways**

    Real-time payment processing. The customer enters payment details on the checkout page, and the gateway authorizes the transaction instantly.

    Examples: Stripe, PayPal, bKash, Nagad, Razorpay, SSLCommerz, Square.
  </Column>

  <Column>
    **Manual gateways**

    Offline payment methods that require manual confirmation. The customer is shown instructions (bank account number, QR code), and a staff member marks the payment as complete after verifying the transfer.

    Examples: bank transfer, cash on delivery, manual invoice.
  </Column>
</Columns>

## How gateway routing works

When a customer reaches the checkout page, OwnPay looks at the brand's active gateways and presents them as payment options. The routing logic is straightforward:

1. Load all gateways marked **active** for the brand.
2. Filter by the payment's currency (each gateway declares its supported currencies via `supportedCurrencies()`).
3. Present the matching gateways on the checkout page.
4. The customer selects one and submits payment.

<Note>
  OwnPay does not currently perform automatic gateway failover or load balancing. The customer chooses the gateway. If you want redundancy, activate multiple gateways so the customer has alternatives.
</Note>

## Credential encryption

Gateway API keys, secrets, and merchant IDs are **never stored in plaintext**. When you save gateway credentials, OwnPay encrypts them using **AES-256-GCM** with a key derived from your application's `APP_KEY`. The encrypted blob is stored in the database; only the running application can decrypt it.

```php theme={"theme":{"light":"github-light","dark":"github-dark"}}
// Internally, credentials go through this flow:
$plaintext = 'sk_live_abc123...';
$encrypted = openssl_encrypt($plaintext, 'aes-256-gcm', $key, 0, $iv, $tag);
// $encrypted and $tag are stored in the database
```

<Warning>
  If you lose your `APP_KEY`, all encrypted gateway credentials become unrecoverable. Back up your `.env` file and store `APP_KEY` in a secure secrets manager.
</Warning>

## Per-brand gateway assignment

Each brand independently selects which gateways to activate. Brand A might use Stripe and PayPal, while Brand B uses bKash and SSLCommerz. Credentials, fees, and enabled/disabled state are all scoped to the brand's `merchant_id`.

## Gateway health checks

OwnPay periodically pings active gateways to verify they are reachable. If a gateway consistently fails health checks, it is flagged in the admin dashboard so you can investigate. Check gateway status under **Gateways** in the sidebar.

## Popular supported gateways

| Gateway       | Type                         | Regions                         |
| :------------ | :--------------------------- | :------------------------------ |
| Stripe        | Online (cards, wallets)      | Global                          |
| PayPal        | Online (cards, accounts)     | Global                          |
| bKash         | Online (mobile money)        | Bangladesh                      |
| Nagad         | Online (mobile payment)      | Bangladesh                      |
| SSLCommerz    | Online (cards, bank)         | South Asia                      |
| Razorpay      | Online (cards, UPI, wallets) | India                           |
| Square        | Online (cards, Apple Pay)    | US, CA, UK, AU, that is, FR, ES |
| GCash         | Online (mobile wallet)       | Philippines                     |
| Aamarpay      | Online (cards, bank)         | Bangladesh                      |
| Bank Transfer | Manual (offline)             | Any                             |

<Info>
  This table shows a subset. OwnPay supports 123+ gateways. See the full list in the admin panel under **Gateways** or visit [GitHub](https://github.com/own-pay/OwnPay).
</Info>

## Related pages

* [Gateway configuration](/docs/gateways/configuration) - step-by-step setup for each provider
* [Currencies](/docs/gateways/currencies) - manage currencies and exchange rates
* [Payment flow](/docs/fundamentals/payment-flow) - transaction statuses and lifecycle
* [Plugin system](/docs/fundamentals/plugins) - how gateways are built as plugins
* [Build a gateway plugin](/docs/developer/plugin-types/gateway) - developer guide for custom gateways


## Related topics

- [Quickstart - Accept Your First Payment in 5 Minutes](/docs/quickstart.md)
- [Configure payment gateways](/docs/gateways/configuration.md)
- [How OwnPay Works](/docs/fundamentals/how-ownpay-works.md)
- [Laravel SDK - Fluent Payment Integration for PHP Apps](/docs/developer/integration/laravel.md)
- [Plugin System - Extensible Architecture](/docs/fundamentals/plugins.md)
