diff --git a/.github/workflows/phpunit.yml b/.github/workflows/phpunit.yml index df6d745..f329649 100644 --- a/.github/workflows/phpunit.yml +++ b/.github/workflows/phpunit.yml @@ -1,33 +1,42 @@ -name: Tests +name: CI on: push: branches: - main + - master pull_request: branches: - main + - master jobs: - run_tests: - name: Run Tests & Static Analysis + test: + name: PHP ${{ matrix.php-version }} runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + php-version: ["8.1", "8.2", "8.3"] + steps: - name: Checkout code - uses: actions/checkout@v2 + uses: actions/checkout@v4 - - name: Set up PHP + - name: Set up PHP ${{ matrix.php-version }} uses: shivammathur/setup-php@v2 with: - php-version: '8.1' + php-version: ${{ matrix.php-version }} extensions: curl, dom, mbstring, zip, json + coverage: none - name: Install dependencies - run: composer install --no-progress + run: composer install --no-progress --prefer-dist - name: Run PHPStan run: composer phpstan + if: matrix.php-version == '8.3' - name: Run PHPUnit run: ./vendor/bin/phpunit --configuration phpunit.xml \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..f5202bd --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,33 @@ +# Changelog + +All notable changes to this project will be documented in this file. + +The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), +and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). + +## [1.1.0] - 2025-02-27 + +### Added +- `Disbursement::deposit()` — deposit funds to a customer account +- `Disbursement::getDepositStatus()` — check deposit transaction status +- `Disbursement::refund()` — refund a previous collection payment +- `Disbursement::getRefundStatus()` — check refund transaction status +- `RefundRequest` model with static `make()` factory method +- Typed exception hierarchy: `ResourceNotFoundException`, `InternalServerErrorException`, `ConflictException`, `InvalidSubscriptionKeyException` +- `ErrorReason` helpers: `isNotEnoughFunds()`, `isPayerLimitReached()` +- `Collection::quickPay()` shorthand for simple payment requests + +### Changed +- `MomoApi::collection()` and `MomoApi::disbursement()` now accept a flat config array for simpler initialization + +## [1.0.0] - 2025-01-15 + +### Added +- Initial release +- `Collection` product: `requestToPay()`, `getPaymentStatus()`, `getBalance()`, `getAccessToken()` +- `Disbursement` product: `transfer()`, `getTransferStatus()`, `getBalance()`, `getAccessToken()` +- `Sandbox` product: `createApiUser()`, `getApiUser()`, `createApiKey()` +- Support for 12 MTN environments (sandbox + 11 production markets) +- `PaymentRequest` and `TransferRequest` models +- `Transaction` model with `isSuccessful()`, `isPending()`, `isFailed()` helpers +- `Balance` model diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000..32d317f --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,58 @@ +# Contributing + +Contributions are welcome. This document covers the basics to get started. + +## Prerequisites + +- PHP 7.4 or later +- Composer + +## Setup + +```bash +git clone https://github.com/lepresk/momo-api.git +cd momo-api +composer install +``` + +## Running tests + +```bash +composer test +``` + +Tests use mocked HTTP responses via fixtures. No real API calls are made. If you add a new method, add a corresponding test in `tests/` with a fixture that matches the MTN API response format. + +## Static analysis + +```bash +composer phpstan +``` + +PHPStan is configured at the strictest level. Ensure there are no errors before submitting a PR. + +## Submitting changes + +1. Fork the repository +2. Create a branch from `main`: `git checkout -b feat/your-feature` +3. Make your changes and add tests +4. Ensure `composer test` and `composer phpstan` both pass +5. Open a pull request with a clear description of what you changed and why + +## Commit style + +Use [Conventional Commits](https://www.conventionalcommits.org): + +``` +feat: add remittance product support +fix: handle 409 conflict on duplicate reference ID +docs: update disbursement usage example +test: add collection balance fixture test +``` + +## Reporting issues + +Open an issue on [GitHub](https://github.com/lepresk/momo-api/issues) with: +- the version you are using (`composer show lepresk/momo-api`) +- a minimal reproduction +- the expected vs actual behavior diff --git a/README.md b/README.md index e5478c9..e86a747 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,7 @@ # Librairie Momo API [![Static Badge](https://img.shields.io/badge/Stable-v1.1.0-blue)](https://packagist.org/packages/lepresk/momo-api) +[![CI](https://github.com/lepresk/momo-api/actions/workflows/phpunit.yml/badge.svg)](https://github.com/lepresk/momo-api/actions/workflows/phpunit.yml) ![GitHub](https://img.shields.io/github/license/lepresk/momo-api) A powerful and professional PHP wrapper for integrating MTN Mobile Money API. Supports **Collection** (receive payments) and **Disbursement** (send money) operations. @@ -288,13 +289,27 @@ composer phpstan - **Log all transactions** - Keep audit trail - **Test thoroughly in sandbox** before going live +## Ecosystem + +The same client is available for multiple languages: + +| Language | Package | Install | +|----------|---------|---------| +| **PHP** | [`lepresk/momo-api`](https://github.com/lepresk/momo-api) | `composer require lepresk/momo-api` | +| **Node.js / TypeScript** | [`@lepresk/momo-api`](https://github.com/lepresk/momo-api-node) | `npm install @lepresk/momo-api` | +| **Python** | [`mtn-momo-client`](https://github.com/lepresk/momo-api-python) | `pip install mtn-momo-client` | + ## Contributing -Contributions are welcome! Please create an issue or pull request on [GitHub](https://github.com/lepresk/momo-api). +Contributions are welcome! See [CONTRIBUTING.md](CONTRIBUTING.md) for guidelines. + +## Changelog + +See [CHANGELOG.md](CHANGELOG.md) for the full history of changes. ## License -MIT License - see [LICENSE](LICENSE) file for details. +MIT License - see [LICENSE](LICENCE) file for details. ## Support