# Phase 14.1 — PSP Management

| Field | Value |
| --- | --- |
| Identifier | `payment-14.1` |
| Implementation Priority | **HIGH** |
| Status | Complete |
| Service | `payment` |
| Depends On | `payment-14.0` |

> Full specification: [payment-roadmap.md](../../payment-roadmap.md#phase-14-1--psp-management)

## Purpose

Enable tenants to connect BYO-PSP credentials (ZarinPal, IDPay, NextPay, Pay.ir, Mellat, Parsian, Saman, …), test connections, and configure routing priority with adapter registry.

## Business Scope

Connect, test, suspend, and prioritize tenant-owned PSP gateways. Failover between primary and secondary PSP.

## Technical Scope

Aggregates: PspConnection, PspCredentialVaultRef, PspConnectionHealthCheck, PspRoutingPolicy. MockPspAdapter + provider-family stubs. Secret refs only in API responses.

## Dependencies

`payment-14.0`

## Out of Scope

Merchant facilitator onboarding (14.2), payment capture (14.3), callbacks (14.4), international live PSPs.

## Capabilities

`payment.psp_connections`, `payment.psp_routing`, `payment.psp_health_check`

## Permissions

`payment.psp_connections.view|create|update|delete|test|manage`, `payment.psp_routing.manage`

## Events

`payment.psp_connection.created|updated|suspended|activated|tested`, `payment.psp_routing.updated`

## API Contracts

`/api/v1/psp-connections`, `/api/v1/psp-routing-policies`, POST `.../test`

## Data Ownership

Payment owns connection and routing metadata; vault stores secrets.

## Provider Ownership

All PSP SDK calls in Payment adapters.

## Integration Rules

Credential rotation must not break in-flight requests. Adapter protocol versioned.

## Quality Gates

Secret redaction, tenant isolation, adapter contract tests.

## Definition of Done

Tenant PSP connect/test/suspend works with mock adapter; no payment requests yet.

## Future Compatibility

Region/currency on connections; Stripe/PayPal adapter slots without schema break.
