OwnPay icon indicating copy to clipboard operation
OwnPay copied to clipboard

[FEATURES] Refactor manual gateway to plugin wise

Open fattain-naime opened this issue 2 weeks ago • 1 comments

Discussed in https://github.com/own-pay/OwnPay/discussions/635

Originally posted by fattain-naime October 17, 2026

Description

Refactor manual payment gateways from free-form, unlimited rows created in the Manual Gateway setup settings into plugin-based gateways, mirroring how API gateways already work.

Today a merchant (or the platform in All Brands) can create any number of ad-hoc manual gateways from the Manual Gateway setup UI, with no plugin backing them. After this refactor, each manual gateway will be an installable plugin (for example "bKash Personal"), and its manual payment details (number, QR code, logo, introduction/instructions, and so on) will be configured from that plugin's settings screen.

The existing Manual Gateway setup settings will be removed.

Motivation

  • Manual gateways currently bypass the plugin system entirely: unlimited gateway types can be created with no install, versioning, or lifecycle management.
  • API gateways already follow a clean plugin model (discover, install, activate, configure). Manual gateways should use the same model for consistency, discoverability, and a single configuration surface.
  • A plugin per gateway type (bKash Personal, Nagad Personal, bank transfer, and so on) gives a natural home for gateway-specific fields and future automation.

Current behavior

  • Manual gateways are rows in op_manual_gateways (see database/schema.sql), owned either by the platform (templates) or by a brand (account overrides).
  • They are created and managed through the Gateways admin page's Manual Gateway section (src/Controller/Admin/GatewayController.php, templates/admin/gateways/index.twig), via the "Add Manual Gateway" flow.
  • Fields such as name, logo, QR code, payment number, instructions, SMS verification rules, currency, and amount limits are entered directly in that form.
  • API gateways, by contrast, are plugins under modules/gateways/* with a manifest.json ("type": "gateway"), installed/activated through the plugin system, and configured at /admin/plugins/{slug}/settings.

Desired behavior

Plugin-based manual gateways

  • Each manual gateway type ships as a gateway plugin (for example modules/gateways/bkash-personal/ with a manifest.json marked as a manual gateway type), alongside existing API gateway plugins.
  • Installing, activating, and deactivating a manual gateway follows the same plugin lifecycle as API gateways (plugins list, activate/deactivate, settings).

Plugin settings for manual payment details

  • Opening the plugin's settings page presents the manual payment configuration form for that gateway, for example for a "bKash Personal" plugin:
    • Payment number
    • QR code
    • Logo
    • Introduction / instructions
    • Any other existing manual gateway fields that remain relevant (SMS verification, currency, min/max amount, sort order, and so on)
  • Configuration is saved per brand (and/or platform, consistent with how API gateway credentials are scoped today via op_gateway_configs or plugin settings).

Removal of the old setup

  • The Manual Gateway setup settings UI ("Add Manual Gateway" form and its management flow) is removed from the Gateways admin page.
  • Free-form, non-plugin manual gateway creation is no longer possible.

Migration

  • Existing rows in op_manual_gateways need a migration path. Options to decide during implementation:
    • Auto-create/import them as plugin-backed gateways where a matching plugin exists.
    • Map them to the closest plugin and preserve data (number, QR, logo, instructions, SMS settings).
    • One-time import script or kernel migration step (similar to Kernel::ensureManualGatewayPaymentNumberColumn).
  • The op_manual_gateways table may remain as the storage for plugin-configured manual gateway data, or configuration may move to the plugin settings storage (for example SettingsRepository groups like plugin.{slug} or gateway config tables). Decide based on what keeps checkout resolution (ManualGatewayRepository::listActiveForCheckout) and SMS verification (SmsVerificationJob) working with minimal churn.

Acceptance criteria

  • [ ] A manual gateway plugin (for example bKash Personal) can be installed and activated like an API gateway plugin.
  • [ ] Its settings page collects the manual payment fields (number, QR, logo, introduction, and so on) and saves them per brand/platform.
  • [ ] The checkout flow (CheckoutController / PaymentIntentCheckoutController) renders the plugin-configured manual gateway with its number, QR, logo, and instructions exactly as it does today.
  • [ ] SMS verification for manual payments continues to work for plugin-configured gateways.
  • [ ] The "Add Manual Gateway" setup UI and free-form manual gateway creation are removed.
  • [ ] Existing manual gateway data is migrated or preserved so live checkout flows do not break.
  • [ ] Relevant automated tests are updated (tests/Controller/GatewayController*, frontend checkout tests, ServiceTest manual gateway masking).

Out of scope

  • Changes to API gateway plugins themselves beyond shared plugin infrastructure needed for manual gateway support.
  • New gateway types beyond what is needed to prove the model (one or two reference plugins are enough).

fattain-naime avatar Nov 16 '26 18:11 fattain-naime

Duplicate of #634

This issue is a near-verbatim duplicate of #634 — same title, same author (fattain-naime), same labels (enhancement, plugin, settings), and the body is identical (the only addition in #708 is the discussion cross-reference link). Similarity score: 0.96.

What happened to #634

#634 was closed on 2026-10-16 with state_reason: completed, but it was not implemented. The timeline shows it was converted to discussion #635 by the author (event: converted_to_discussion, then locked). No PR was ever linked to #634 — the closed_by field is null and there is no closed event in the timeline. A search for merged PRs referencing "manual gateway" returned only #600 (per-brand auto-redirect) and #607 (SMS auto-verify), neither of which touches the plugin refactor.

The discussion (#635) remains open and contains the same feature request with a ### Planned note, so the work is still queued, not done.

Related context

  • #553 (open) — "Refactor Payment Gateway Configuration Flow (Move from Global to Brand Level)". This is a prerequisite sub-task: it proposes removing writable global gateway configuration and making credentials strictly brand-scoped. The manual-gateway plugin refactor in #634 depends on this being resolved first (the issue body itself notes configuration should be "consistent with how API gateway credentials are scoped today via op_gateway_configs").
  • #606 (closed) — server-side instant verification for manual payments. Related in that plugin-based manual gateways would inherit the same verification gap.

Recommendation

Link #708 → #634 as a duplicate. The feature is still unimplemented and the canonical home is now discussion #635. If the team wants to pick this up, the sequencing would be: resolve #553 (brand-scoped config) first, then build the shared plugin infrastructure for manual gateway plugins (manifest type extension, settings form, lifecycle), then migrate op_manual_gateways rows and remove the "Add Manual Gateway" UI.

Pullfrog  | Implement a fix ➔ | View workflow run | via Pullfrog | Using dots-3-note-preview | 𝕏

pullfrog[bot] avatar Nov 16 '26 18:11 pullfrog[bot]