PHPackages                             midsonlajeanty/php-natcash-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. midsonlajeanty/php-natcash-sdk

ActiveLibrary[Payment Processing](/categories/payments)

midsonlajeanty/php-natcash-sdk
==============================

Minimum SDK to process payment with Natcom Natcash Payment Gateway

v2.0.1(1mo ago)2121—8.3%4[2 PRs](https://github.com/midsonlajeanty/php-natcash-sdk/pulls)MITPHPPHP ^8.2CI passing

Since Feb 4Pushed 1w ago1 watchersCompare

[ Source](https://github.com/midsonlajeanty/php-natcash-sdk)[ Packagist](https://packagist.org/packages/midsonlajeanty/php-natcash-sdk)[ Docs](https://github.com/midsonlajeanty/php-natcash-sdk)[ Fund](https://buymeacoffee.com/midsonlajeanty)[ Fund](https://paypal.me/midsonlajeanty)[ RSS](/packages/midsonlajeanty-php-natcash-sdk/feed)WikiDiscussions main Synced 2d ago

READMEChangelog (4)Dependencies (15)Versions (4)Used By (0)

 [![Natcash Logo](https://camo.githubusercontent.com/76826f8e5276d0b54835d587471c9fb8b2db7f41be562c2b4c624edeed0c0278/68747470733a2f2f746573746d65726368616e747061792e6e6174636f6d2e636f6d2e68742f6d65726368616e742f5f6e6578742f7374617469632f696d616765732f6c6f676f2d31363839343038613834666530633436383331653761653264313966653034632e706e67)](https://camo.githubusercontent.com/76826f8e5276d0b54835d587471c9fb8b2db7f41be562c2b4c624edeed0c0278/68747470733a2f2f746573746d65726368616e747061792e6e6174636f6d2e636f6d2e68742f6d65726368616e742f5f6e6578742f7374617469632f696d616765732f6c6f676f2d31363839343038613834666530633436383331653761653264313966653034632e706e67)

 [ ![Build Status](https://github.com/midsonlajeanty/php-natcash-sdk/actions/workflows/tests.yml/badge.svg) ](https://github.com/midsonlajeanty/php-natcash-sdk/actions) [ ![Total Downloads](https://camo.githubusercontent.com/e684c73933c299c524a9617ee1cd57adca9fec0c500fe690fea5f149fa3550d8/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6d6964736f6e6c616a65616e74792f7068702d6e6174636173682d73646b) ](https://packagist.org/packages/midsonlajeanty/php-natcash-sdk) [ ![Latest Stable Version](https://camo.githubusercontent.com/adca46f399fa862e86b87bb249e14373b47dc6436206c83b4662f4c268eb118d/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6d6964736f6e6c616a65616e74792f7068702d6e6174636173682d73646b) ](https://packagist.org/packages/midsonlajeanty/php-natcash-sdk) [ ![License](https://camo.githubusercontent.com/c301ec1aeb5319acd5361e6b86f5c8eed9537407fb41b0a857d4643ae2991d6c/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f6d6964736f6e6c616a65616e74792f7068702d6e6174636173682d73646b) ](https://packagist.org/packages/midsonlajeanty/php-natcash-sdk)

Minimum SDK to process payment with Natcom Natcash Payment Gateway

Features
--------

[](#features)

- Create Payment Transaction and get gateway URL (Natcash Checkout)
- Get Transaction Details by Order ID

Getting started
---------------

[](#getting-started)

Requires **PHP 8.2+**.

```
composer require midsonlajeanty/php-natcash-sdk

```

> **On PHP &lt; 8.2?** Pin the 1.x line, which supports PHP 7.4+:
>
> ```
> composer require "midsonlajeanty/php-natcash-sdk:^1.0"
>
> ```

Usage
-----

[](#usage)

### Init Payment and get Payment URL (Natcash Checkout)

[](#init-payment-and-get-payment-url--natcash-checkout)

```
use Mds\Natcash\Config;
use Mds\Natcash\Natcash;
use Mds\Natcash\PaymentRequest;

// Natcash Merchant Credentials
$config = new Config(PRIVATE_KEY, PARTNER_CODE, FUNCTION_CODE, USERNAME, PASSWORD, CALLBACK_URL);

// Payment Request
$payment = new PaymentRequest('ORDER-001', 10);

// Init SDK with config
$natcash = new Natcash($config, DEBUG);

// Make Payment with payment request
$response = $natcash->makePayment($payment);

// Get Payment URL (Natcash Checkout)
$response->getRedirect();
```

### Get Transaction Details by Order ID

[](#get-transaction-details-by-order-id)

```
use Mds\Natcash\Config;
use Mds\Natcash\Natcash;

// Natcash Merchant Credentials
$config = new Config(PRIVATE_KEY, PARTNER_CODE, FUNCTION_CODE, USERNAME, PASSWORD, CALLBACK_URL);

// Init SDK with config
$natcash = new Natcash($config, DEBUG);

// Verify Webhook Payload Signature
$isValid = $natcash->verifyPayloadSignature('WEBHOOK_ORDER_NUMBER', 'WEBHOOK_CODE', 'WEBHOOK_SIGNATURE');

if ($isValid) {
    print_r("Signature is valid." . PHP_EOL . PHP_EOL);

    // Get Payment Details with OrderId provided by your app.
    $details = $natcash->getTransactionDetailsByOrderId($orderNumber);

} else {
    print_r("Signature is invalid." . PHP_EOL);
}
```

Common conventions (MonCash &amp; NatCash)
------------------------------------------

[](#common-conventions-moncash--natcash)

The MonCash and NatCash SDKs share the same pattern. If you know one, you know the other:

StepClass / methodConfiguration`Config::from([...])`Instantiation`new ($config, $debug = true)`Request`PaymentRequest::from([...])`Payment`makePayment(PaymentRequest): PaymentResponse`Redirect`$response->getRedirect()`Details`getTransactionDetailsByOrderId($orderId): TransactionDetails`Result`$details->getOrderId()`, `getTransactionId()`, `getAmount()`, `getPayer()`, `isSuccessful()`NatCash-specific features: HMAC signatures (`verifyPayloadSignature()`), `getMsisdn()`, `skipPhoneInput`.

Laravel
-------

[](#laravel)

The package auto-registers a service provider and a facade (Laravel 9 to 13). Publish the config file:

```
php artisan vendor:publish --tag=natcash-config
```

Set your credentials in `.env` (they are loaded automatically):

```
NATCASH_PRIVATE_KEY=your-private-key
NATCASH_PARTNER_CODE=your-partner-code
NATCASH_FUNCTION_CODE=your-function-code
NATCASH_USERNAME=your-username
NATCASH_PASSWORD=your-password
NATCASH_CALLBACK_URL=https://your-app.test/natcash/callback
NATCASH_ENABLE_FEE=true
NATCASH_LANGUAGE=ht
# Sandbox gateway. Defaults to false (live); set true in local environments.
NATCASH_DEBUG=true
```

Then use the facade, or inject `NatcashInterface` (both resolve the same configured singleton):

```
use Mds\Natcash\Laravel\Facades\Natcash;
use Mds\Natcash\PaymentRequest;

$response = Natcash::makePayment(new PaymentRequest('order-1', 250, null, 'msisdn'));

return redirect($response->getRedirect());
```

```
use Mds\Natcash\NatcashInterface;

final class CheckoutController
{
    public function __construct(private NatcashInterface $natcash) {}
}
```

Testing
-------

[](#testing)

The `Natcash` gateway is `final` (it is the only class that performs I/O), so it cannot be mocked directly. Instead, type-hint your application code against `NatcashInterface` and mock the interface:

```
use Mds\Natcash\NatcashInterface;

final class CheckoutService
{
    public function __construct(private NatcashInterface $gateway) {}

    public function pay(PaymentRequest $request): PaymentResponse
    {
        return $this->gateway->makePayment($request);
    }
}

// Production: inject the real gateway.
new CheckoutService(new Natcash($config));
```

```
// Test: mock the interface, no need to hit the network.
$gateway = Mockery::mock(NatcashInterface::class);
$gateway->shouldReceive('makePayment')->once()->andReturn($fakeResponse);

$service = new CheckoutService($gateway);
```

Value objects (`Config`, `PaymentRequest`, `PaymentResponse`, `TransactionDetails`) are also `final` — don't mock them, just construct them with test data.

Contributing
------------

[](#contributing)

You have a lot of options to contribute to this project ! You can :

- [Fork](https://github.com/midsonlajeanty/php-natcash-sdk) on Github
- [Submit](https://github.com/midsonlajeanty/php-natcash-sdk/issues) a bug report.
- [Donate](https://www.buymeacoffee.com/midsonlajeanty) to the Developper

###  Health Score

46

—

FairBetter than 92% of packages

Maintenance95

Actively maintained with recent releases

Popularity18

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity50

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 88.5% 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

Every ~75 days

Total

3

Last Release

46d ago

Major Versions

v1.1.0 → v2.0.12026-07-03

PHP version history (2 changes)v1.0.0PHP ^7.4|^8.0

v2.0.1PHP ^8.2

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/63215721?v=4)[Louis Midson Lajeanty](/maintainers/midsonlajeanty)[@midsonlajeanty](https://github.com/midsonlajeanty)

---

Top Contributors

[![midsonlajeanty](https://avatars.githubusercontent.com/u/63215721?v=4)](https://github.com/midsonlajeanty "midsonlajeanty (23 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (3 commits)")

---

Tags

natcashpaymentphpsdkpaymentnatcash

###  Code Quality

TestsPest

Static AnalysisPHPStan, Rector

Code StyleLaravel Pint

Type Coverage Yes

### Embed Badge

![Health badge](/badges/midsonlajeanty-php-natcash-sdk/health.svg)

```
[![Health](https://phpackages.com/badges/midsonlajeanty-php-natcash-sdk/health.svg)](https://phpackages.com/packages/midsonlajeanty-php-natcash-sdk)
```

###  Alternatives

[neuron-core/neuron-ai

The PHP Agentic Framework.

2.0k832.6k55](/packages/neuron-core-neuron-ai)[tencentcloud/tencentcloud-sdk-php

TencentCloudApi php sdk

3661.3M49](/packages/tencentcloud-tencentcloud-sdk-php)[eslazarev/wildberries-sdk

Wildberries OpenAPI clients (generated).

353.6k](/packages/eslazarev-wildberries-sdk)[chargebee/chargebee-php

ChargeBee API client implementation for PHP

758.7M10](/packages/chargebee-chargebee-php)[shetabit/multipay

PHP Payment Gateway Integration Package

298368.9k4](/packages/shetabit-multipay)[ph7software/ph7cms

pH7Builder. Social Dating Web App Site Builder

1.1k1.6k](/packages/ph7software-ph7cms)

PHPackages © 2026

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