Thank you for your interest in contributing to the MTN MoMo API Elixir library! π
We welcome contributions from everyone, whether you're fixing a bug, adding a feature, improving documentation, or just asking questions.
- Code of Conduct
- Getting Started
- Development Setup
- How to Contribute
- Pull Request Process
- Coding Standards
- Testing
- Documentation
- Community
This project adheres to a Code of Conduct. By participating, you are expected to uphold this code. Please report unacceptable behavior to patricken08@gmail.com.
- Elixir 1.9 or later
- Erlang/OTP 22 or later
- Git
-
Fork the repository
# Fork on GitHub, then clone your fork git clone https://github.com/YOUR_USERNAME/momoapi-elixir.git cd momoapi-elixir
-
Set up the development environment
# Install dependencies mix deps.get # Run tests to ensure everything works mix test # Format code mix format # Run static analysis mix credo
-
Set up sandbox credentials (optional)
# For testing with real MTN sandbox API mix provision YOUR_SUBSCRIPTION_KEY https://your-callback-url.com
Before creating a bug report, please:
- Check the existing issues
- Make sure you're using the latest version
When filing a bug report, please include:
- Elixir and Erlang versions
- Steps to reproduce the issue
- Expected vs actual behavior
- Code samples (if applicable)
- Error messages/stack traces
Feature suggestions are welcome! Please:
- Check existing issues and discussions
- Open a GitHub issue with the
enhancementlabel - Clearly describe the feature and its use case
- Consider starting with a discussion for major features
We love code contributions! Here are some ways to help:
Look for issues labeled good first issue - these are perfect for newcomers.
- Improving error messages and validation
- Adding more comprehensive tests
- Performance optimizations
- Documentation improvements
- Examples and tutorials
git checkout -b feature/your-feature-name
# or
git checkout -b bugfix/issue-description- Follow the coding standards
- Add tests for new functionality
- Update documentation as needed
- Ensure all tests pass
Use clear, descriptive commit messages:
git commit -m "Add support for recurring payments
- Implement recurring payment scheduling
- Add validation for payment intervals
- Update documentation with examples
- Add comprehensive test coverage
Fixes #123"git push origin feature/your-feature-nameThen create a pull request on GitHub with:
- Clear title and description
- Reference to related issues
- Screenshots/examples if applicable
- Checklist of changes made
- Address feedback constructively
- Make requested changes in new commits
- Keep the PR up to date with main branch
We follow the standard Elixir Style Guide with these additions:
# Format your code before committing
mix format- Add
@docto all public functions - Include examples in documentation
- Use proper typespecs with
@spec
@doc """
Request a payment from a consumer.
## Examples
iex> config = %{subscription_key: "key", ...}
iex> payment = %{amount: "100", currency: "UGX", ...}
iex> Collections.request_to_pay(config, payment)
{:ok, "reference-id-uuid"}
"""
@spec request_to_pay(config(), payment_request()) :: {:ok, String.t()} | {:error, term()}
def request_to_pay(config, payment) do
# Implementation
end- Use
{:ok, result}/{:error, reason}tuples - Provide structured error information
- Include helpful error messages
case validate_payment(payment) do
{:ok, validated_payment} ->
# proceed
{:error, validation_errors} ->
{:error, {:validation_failed, validation_errors}}
end- Use descriptive function and variable names
- Follow Elixir naming conventions (snake_case for functions, PascalCase for modules)
- Be consistent with existing code
# Run all tests
mix test
# Run specific test file
mix test test/collections_test.exs
# Run with coverage
mix test --cover
# Run tests continuously during development
mix test.watch- Write tests for all new functionality
- Include both positive and negative test cases
- Test error conditions thoroughly
- Use descriptive test names
- Mock external API calls using Mox
defmodule MomoapiElixir.CollectionsTest do
use ExUnit.Case, async: true
import Mox
describe "request_to_pay/2" do
test "returns reference_id on successful payment request" do
# Setup mocks
ClientMock
|> expect(:post, fn _url, _body, _headers ->
{:ok, %{status_code: 202, body: ""}}
end)
# Test
result = Collections.request_to_pay(config, valid_payment)
# Assert
assert {:ok, reference_id} = result
assert is_binary(reference_id)
end
test "returns validation errors for invalid payment" do
invalid_payment = %{amount: ""}
result = Collections.request_to_pay(config, invalid_payment)
assert {:error, validation_errors} = result
assert is_list(validation_errors)
end
end
end- Add
@moduledocto all modules - Add
@docto all public functions - Include examples in documentation
- Use proper typespecs
- Update examples when changing APIs
- Keep installation instructions current
- Add new features to feature lists
- Update
CHANGELOG.mdfor all notable changes - Follow Keep a Changelog format
- Include migration guides for breaking changes
Releases are managed by maintainers. The process includes:
- Update version in
mix.exs - Update
CHANGELOG.md - Create Git tag
- Publish to Hex.pm
- Update documentation on HexDocs
- π Documentation: HexDocs
- π¬ Discussions: GitHub Discussions
- π Issues: GitHub Issues
- Be respectful and constructive
- Use clear, descriptive titles for issues and PRs
- Provide context and examples when asking questions
- Help others when you can
Contributors are recognized in:
CONTRIBUTORS.mdfile- Release notes
- GitHub contributors list
If you have questions about contributing, feel free to:
- Open a GitHub Discussion
- Create an issue with the
questionlabel - Reach out to maintainers
Thank you for contributing! π