PHPackages                             moffhub/connector-sdk - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Payment Processing](/categories/payments)
4. /
5. moffhub/connector-sdk

ActiveLibrary[Payment Processing](/categories/payments)

moffhub/connector-sdk
=====================

SDK for building MPS-compliant payment and service connectors. Base classes, HTTP client, webhook verification, and a sandbox connector.

v0.1.0(1mo ago)08MITPHPPHP ^8.4|^8.5CI passing

Since Apr 25Pushed 1mo agoCompare

[ Source](https://github.com/Moffhub-Solutions/connector-sdk)[ Packagist](https://packagist.org/packages/moffhub/connector-sdk)[ Docs](https://github.com/Moffhub-Solutions/connector-sdk)[ RSS](/packages/moffhub-connector-sdk/feed)WikiDiscussions develop Synced 1w ago

READMEChangelog (1)Dependencies (6)Versions (2)Used By (0)

Moffhub Connector SDK
=====================

[](#moffhub-connector-sdk)

Base classes and helpers for building **MPS-compliant payment and service connectors**. Extend `BaseConnector`, declare your manifest, implement the capabilities you support, and you're done — config validation, lifecycle, and HTTP plumbing are handled for you.

This package implements the contracts defined in [`moffhub/mps-spec`](https://packagist.org/packages/moffhub/mps-spec).

Installation
------------

[](#installation)

```
composer require moffhub/connector-sdk
```

Requires PHP 8.3+. Pulls in `moffhub/mps-spec` and `guzzlehttp/guzzle`.

What you get
------------

[](#what-you-get)

- **`BaseConnector`** — abstract base for **payment connectors**. Implements `ConnectorInterface` (initialize/healthCheck/destroy) and validates config against the manifest.
- **`BaseServiceConnector`** — abstract base for **service connectors** (domain logic providers).
- **`SandboxConnector`** — in-memory connector for tests and local development. Use it as a stand-in when you don't want to hit a real provider.
- **`Support\HttpClient`** — thin Guzzle wrapper with sensible defaults (timeouts, JSON, retries) for talking to provider APIs.
- **`Support\WebhookVerifier`** — HMAC signature verification helper for webhook endpoints.

Quick start: a payment connector
--------------------------------

[](#quick-start-a-payment-connector)

```
use Moffhub\ConnectorSdk\BaseConnector;
use Moffhub\MpsSpec\Contracts\HasChargeCapability;
use Moffhub\MpsSpec\Data\{ChargeRequest, ChargeResponse, ConfigField, ConnectorManifest};
use Moffhub\MpsSpec\Enums\{Capability, Channel, ChargeStatus, SettlementModel};

final class AcmeConnector extends BaseConnector implements HasChargeCapability
{
    public function manifest(): ConnectorManifest
    {
        return new ConnectorManifest(
            connectorId: 'acme',
            displayName: 'Acme Payments',
            version: '1.0.0',
            specVersion: '0.1',
            vendorName: 'Acme Inc.',
            vendorWebsite: 'https://acme.example',
            vendorSupportEmail: 'support@acme.example',
            supportedChannels: [Channel::Card],
            supportedCurrencies: ['USD'],
            capabilities: [Capability::Payment],
            settlementModel: SettlementModel::T1,
            requiredConfig: [
                new ConfigField(key: 'api_key', label: 'API Key', required: true, secret: true),
                new ConfigField(key: 'environment', label: 'Environment', required: true),
            ],
        );
    }

    public function createCharge(ChargeRequest $request): ChargeResponse
    {
        $this->ensureInitialized();

        // requireConfig() throws if the key is missing
        $apiKey = $this->requireConfig('api_key');

        // ... call provider API, return ChargeResponse
        return new ChargeResponse(/* ... */);
    }

    public function queryCharge(string $chargeId): ChargeResponse
    {
        $this->ensureInitialized();
        // ...
    }
}
```

### Wiring it up

[](#wiring-it-up)

```
$connector = new AcmeConnector();
$connector->initialize([
    'api_key' => $_ENV['ACME_KEY'],
    'environment' => 'live',
]);

$response = $connector->createCharge(new ChargeRequest(/* ... */));
```

`initialize()` validates the supplied config against `requiredConfig` from your manifest and throws `InvalidArgumentException` if anything required is missing.

Helpers
-------

[](#helpers)

### `HttpClient` — talking to providers

[](#httpclient--talking-to-providers)

```
use Moffhub\ConnectorSdk\Support\HttpClient;

$client = new HttpClient(baseUri: 'https://api.acme.example', timeout: 10);
$response = $client->post('/charges', [
    'headers' => ['Authorization' => "Bearer {$apiKey}"],
    'json' => $payload,
]);
```

### `WebhookVerifier` — verifying inbound webhooks

[](#webhookverifier--verifying-inbound-webhooks)

```
use Moffhub\ConnectorSdk\Support\WebhookVerifier;

$verifier = new WebhookVerifier(secret: $this->requireConfig('webhook_secret'));
$verifier->verify(rawBody: $request->getContent(), signature: $request->header('X-Signature'));
// Throws WebhookVerificationFailedException on mismatch
```

### `SandboxConnector` — in-memory connector for tests

[](#sandboxconnector--in-memory-connector-for-tests)

```
use Moffhub\ConnectorSdk\SandboxConnector;

$connector = new SandboxConnector();
$connector->initialize([]);
$response = $connector->createCharge($request); // returns deterministic fake data
```

Service connectors
------------------

[](#service-connectors)

Use `BaseServiceConnector` instead of `BaseConnector` for service connectors (domain logic providers — utility lookups, ticketing, etc.). The lifecycle is the same; the contract is `ServiceConnectorInterface` from `moffhub/mps-spec`.

Testing your connector
----------------------

[](#testing-your-connector)

The Moffhub CLI (`moffhub/cli`) ships a certification suite that exercises your connector against the spec — manifest validation, capability conformance, lifecycle, and contract tests. See its README for usage.

License
-------

[](#license)

MIT. See `LICENSE`.

###  Health Score

37

—

LowBetter than 81% of packages

Maintenance90

Actively maintained with recent releases

Popularity5

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity41

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

45d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/6b5c3549bf8f8bab163b760fe2023fe357a3c85ed366e052a735ff5c50f84518?d=identicon)[Moffrough](/maintainers/Moffrough)

---

Top Contributors

[![MOFFROUGH](https://avatars.githubusercontent.com/u/20206597?v=4)](https://github.com/MOFFROUGH "MOFFROUGH (7 commits)")

---

Tags

sdkpaymentsconnectorpayment gatewaykenyaafricamoffhubmps

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan, Rector

Code StyleLaravel Pint

Type Coverage Yes

### Embed Badge

![Health badge](/badges/moffhub-connector-sdk/health.svg)

```
[![Health](https://phpackages.com/badges/moffhub-connector-sdk/health.svg)](https://phpackages.com/packages/moffhub-connector-sdk)
```

###  Alternatives

[aws/aws-sdk-php

AWS SDK for PHP - Use Amazon Web Services in your PHP project

6.3k532.1M2.5k](/packages/aws-aws-sdk-php)[chargebee/chargebee-php

ChargeBee API client implementation for PHP

788.3M9](/packages/chargebee-chargebee-php)[musahmusah/laravel-multipayment-gateways

A Laravel Package that makes implementation of multiple payment Gateways endpoints and webhooks seamless

882.2k1](/packages/musahmusah-laravel-multipayment-gateways)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
