# mpesa_sdk_mz
A Dart SDK for integrating with the M-Pesa Mozambique API, with explicit
support for `sandbox` and `production`.
This package is designed to be easy to start with and safe to configure:
- explicit environments
- separate credentials per environment
- typed requests
- raw HTTP responses plus typed parsers
- support for `C2B`, `B2C`, `B2B`, `Reversal`, `Transaction Status`, and
`Query Customer Masked Name`
## Table of Contents
- Overview
- Quick Start
- How It Works
- Environment Configuration
- Basic Usage
- Responses
- API Summary
- Best Practices
- License
## Overview
This SDK wraps the authentication and HTTP calls needed to work with the
M-Pesa Mozambique APIs in Dart or Flutter applications.
You still get access to the original `http.Response`, but the package also
provides typed requests and typed response parsers.
Before integrating, check the official documentation:
developer.mpesa.vm.co.mz
## Quick Start
### 1. Install the package
```yaml
dependencies:
mpesa_sdk_mz:
```
### 2. Import it
```dart
import 'package:mpesa_sdk_mz/mpesa_sdk_mz.dart';
```
### 3. Export environment variables
```dart
export MPESA_ENV=sandbox
export MPESA_API_KEY=YOUR_API_KEY
export MPESA_PUBLIC_KEY='YOUR_PUBLIC_KEY'
export MPESA_ORIGIN=developer.mpesa.vm.co.mz
```
### 4. Create a client
```dart
final config = MpesaClientConfig(
environment: MpesaEnvironment.sandbox,
credentials: MpesaCredentials(
apiKey: Platform.environment['MPESA_API_KEY']!,
publicKey: Platform.environment['MPESA_PUBLIC_KEY']!,
),
origin: Platform.environment['MPESA_ORIGIN']!,
requestTimeout: const Duration(seconds: 30),
);
final transaction = MpesaTransaction(config);
```
### 5. Make a C2B call
```dart
const payload = PaymentRequest(
inputTransactionReference: 'T12344C',
inputCustomerMsisdn: '25884xxxxxxx',
inputAmount: '10',
inputThirdPartyReference: '11114',
inputServiceProviderCode: '171717',
);
final response = await transaction.c2b(payload);
final …