Skip to content

Commit

Permalink
Merge branch 'collinsmuriuki:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
kodesoul authored Nov 15, 2023
2 parents 6cdbf86 + 3971464 commit 3d5e875
Show file tree
Hide file tree
Showing 72 changed files with 5,993 additions and 1,671 deletions.
9 changes: 2 additions & 7 deletions .cargo/config.toml
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
[build]
rustdoc = "rustdoc"

[profile.release]
lto = "fat"
debug = 1
codegen-units = 1
rustdoc = "rustdoc"

[alias]
t = ["test", "--all-features", "--no-fail-fast"]
t = ["test", "--all-features", "--no-fail-fast"]
File renamed without changes.
1 change: 1 addition & 0 deletions .github/workflows/audit-cron.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,5 @@ jobs:
- uses: actions-rs/audit-check@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
args: --ignore RUSTSEC-2020-0159 RUSTSEC-2020-0071 RUSTSEC-2021-0141
continue-on-error: true
1 change: 1 addition & 0 deletions .github/workflows/audit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,5 @@ jobs:
- uses: actions-rs/audit-check@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
args: --ignore RUSTSEC-2020-0159 RUSTSEC-2020-0071 RUSTSEC-2021-0141
continue-on-error: true
1 change: 1 addition & 0 deletions .github/workflows/general.yml
Original file line number Diff line number Diff line change
Expand Up @@ -74,3 +74,4 @@ jobs:
uses: actions-rs/[email protected]
with:
args: '--ignore-tests --no-fail-fast'
version: '0.22.0'
27 changes: 23 additions & 4 deletions .github/workflows/release-core.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ name: publish to crates.io
on:
push:
tags:
- 'core-0.*'
- 'v*'

env:
CARGO_TERM_COLOR: always

jobs:
release_mpesa_core:
publish_to_crate_io:

runs-on: ubuntu-latest

Expand All @@ -19,9 +19,28 @@ jobs:
with:
toolchain: stable
override: true
- name: Publish
- name: Publish to crates.io
run: |
cd mpesa_core
cargo doc
cargo login ${{ secrets.CARGO_REGISTRY_TOKEN }}
cargo publish
sync_docs_to_gh_pages:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v4
with:
python-version: '3.10'
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true
- name: Sync Docs
run: |
cargo doc
pip install ghp-import
echo '<meta http-equiv=refresh content=0;url=mpesa/index.html>' > target/doc/index.html
ghp-import -n target/doc
git push -qf https://github.com/collinsmuriuki/mpesa-rust.git gh-pages
27 changes: 0 additions & 27 deletions .github/workflows/release-derive.yml

This file was deleted.

3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,4 @@
/.idea
Cargo.lock
.env
.DS_Store
main.rs
.DS_Store
27 changes: 27 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
fail_fast: true
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.0.1
hooks:
- id: check-toml

- repo: local
hooks:
- id: run-cargo-fmt
name: Cargo fmt
entry: /bin/bash -c "cargo fmt --all -- --check"
language: script
files: ^.*\.rs$
always_run: true
- id: run-cargo-clippy
name: Cargo clippy
entry: /bin/bash -c "cargo clippy -- -D warnings"
language: script
files: ^.*\.rs$
always_run: true
- id: run-cargo-test
name: Cargo test
entry: /bin/bash -c "cargo test --no-fail-fast"
language: script
files: ^.*\.rs$
always_run: true
5 changes: 5 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"cSpell.words": [
"Mpesa"
]
}
59 changes: 4 additions & 55 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,56 +1,5 @@
# Contributing guide
# How to Contribute

> Instructions for local project setup and contribution.
## Rust

You will need Rust installed to run this project. You can find a guide to install on any os [here](https://www.rust-lang.org/tools/install)

## Install

```sh
git clone https://github.com/collinsmuriuki/mpesa-rust.git
cd mpesa-rust
```

## App Keys
Copy your safaricom credentials to an `.env` file in the root of the project, check `.env.example` for reference or simply run.

See [here](https://developer.safaricom.co.ke/docs#developer-sign-up) if you need to acquire app keys.
```sh
echo CLIENT_KEY="<your_client_key>" >> .env
echo CLIENT_SECRET="<your_client_secret>" >> .env
```

## Test Credentials
You can get test credentials [here](https://developer.safaricom.co.ke/test_credentials)

## Run tests

```sh
cargo test
```

## RoadMap

- [x] Create Mpesa Client struct
- [x] Implement Auth
- [x] Error handling
- [x] Generate security credentials
- [x] Implement B2C payment
- [x] Implement B2B payment
- [x] Query transaction status
- [x] Simulate C2B Payment
- [ ] Query status of Lipa na M-Pesa
- [x] Initiate Lipa na M-Pesa online w/ STK push
- [x] Register C2B Confirmation and Validation URLs
- [x] Integration tests
- [ ] Rewrite in async
- [x] Publish on https://crates.io
- [x] Setup travis-ci
- [ ] Improve documentation


## Pull Requests

Fork the repo and create a feature branch. Push your changes and make a PR.
- Create an issue or pick an already existing issue. Please avoid creating duplicate issues
- Fork the repo, add your changes and make a pull request
- Request for review from either me or other contributors
58 changes: 56 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,2 +1,56 @@
[workspace]
members = ["mpesa_derive", "mpesa_core"]
[package]
name = "mpesa"
version = "1.1.0"
authors = ["Collins Muriuki <[email protected]>"]
edition = "2021"
description = "A wrapper around the M-PESA API in Rust."
keywords = ["api", "mpesa", "mobile"]
repository = "https://github.com/collinsmuriuki/mpesa-rust"
readme = "./README.md"
license = "MIT"

[dependencies]
cached = { version = "0.46", features = ["wasm", "async", "proc_macro"] }
chrono = { version = "0.4", optional = true, default-features = false, features = [
"clock",
"serde",
] }
openssl = { version = "0.10", optional = true }
reqwest = { version = "0.11", features = ["json"] }
derive_builder = "0.12"
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
serde_repr = "0.1"
thiserror = "1.0.37"
wiremock = "0.5"
secrecy = "0.8.0"
serde-aux = "4.2.0"

[dev-dependencies]
dotenv = "0.15"
tokio = { version = "1", features = ["rt", "rt-multi-thread", "macros"] }
wiremock = "0.5"

[features]
default = [
"account_balance",
"b2b",
"b2c",
"bill_manager",
"c2b_register",
"c2b_simulate",
"express_request",
"transaction_reversal",
"transaction_status",
"dynamic_qr"
]
dynamic_qr = []
account_balance = ["dep:openssl"]
b2b = ["dep:openssl"]
b2c = ["dep:openssl"]
bill_manager = ["dep:chrono"]
c2b_register = []
c2b_simulate = []
express_request = ["dep:chrono"]
transaction_reversal = ["dep:openssl"]
transaction_status = ["dep:openssl"]
Loading

0 comments on commit 3d5e875

Please sign in to comment.