Download the PHP package midsonlajeanty/php-natcash-sdk without Composer
On this page you can find all versions of the php package midsonlajeanty/php-natcash-sdk. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download midsonlajeanty/php-natcash-sdk
More information about midsonlajeanty/php-natcash-sdk
Files in midsonlajeanty/php-natcash-sdk
Package php-natcash-sdk
Short Description Minimum SDK to process payment with Natcom Natcash Payment Gateway
License MIT
Homepage https://github.com/midsonlajeanty/php-natcash-sdk
Informations about the package php-natcash-sdk
Minimum SDK to process payment with Natcom Natcash Payment Gateway
Features
- Create Payment Transaction and get gateway URL (Natcash Checkout)
- Get Transaction Details by Order ID
Getting started
Requires PHP 8.2+.
On PHP < 8.2? Pin the 1.x line, which supports PHP 7.4+:
Usage
Init Payment and get Payment URL (Natcash Checkout)
Get Transaction Details by Order ID
Common conventions (MonCash & NatCash)
The MonCash and NatCash SDKs share the same pattern. If you know one, you know the other:
| Step | Class / method |
|---|---|
| Configuration | Config::from([...]) |
| Instantiation | new <Gateway>($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
The package auto-registers a service provider and a facade (Laravel 9 to 13). Publish the config file:
Set your credentials in .env (they are loaded automatically):
Then use the facade, or inject NatcashInterface (both resolve the same configured singleton):
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:
Value objects (Config, PaymentRequest, PaymentResponse, TransactionDetails) are also final - don't mock them, just construct them with test data.
Contributing
You have a lot of options to contribute to this project ! You can :