Skip to content

Commit

Permalink
Migrating to mdx (#59)
Browse files Browse the repository at this point in the history
* fix: correct type for callback metadata and removed cache

* fix: update docs following recent bug fixes

* fix: correctly export submodules

* bumped changesets version and added a new changeset

* updated eslint & next

* completed migrating everything to mdx

* updated pnpm-lock.yaml

* fix: use the correct page title
  • Loading branch information
amosmachora authored Nov 4, 2024
1 parent ac3b71e commit a57e445
Show file tree
Hide file tree
Showing 84 changed files with 5,879 additions and 4,027 deletions.
9 changes: 9 additions & 0 deletions .changeset/fuzzy-lemons-reply.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
"daraja-kit": minor
---

This release fixes a few bugs on the safaricom types and also adds a modular import structure to the library

#### How to update

Just bump to the latest version. All imports of next and react will be served from daraja-kit/next and daraja-kit/react respectively
4 changes: 4 additions & 0 deletions CONTIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# Contributing to Daraja Kit

Welcome to Daraja Kit! We're excited that you're interested in contributing. Before you start, please follow the guidelines below.

## Directory structure

The code for the library itself is under packages/main-lib. If that is the part you are interested in thats where you should make your changes. For the docs the code lives inside packages/docs. The docs are in mdx so if you know markdown you are good to go.
55 changes: 20 additions & 35 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,59 +2,44 @@

Improving the Developer Experience of using the Safaricom daraja API.

![image info](./public/full-logo.png)
Read the docs at https://daraja-kit.amosmachora.com/

# About

Daraja Kit is a typesafe Javascript library designed to simplify interactions with the Safaricom Daraja API. This library is suitable for both Node.js and React environments, allowing developers to seamlessly integrate M-Pesa payments into their applications.

## Installation
# Benefits

To install Daraja Kit, run the following command in your project's terminal:

```bash
npm install daraja-kit
```

## Getting Started

Copy over the `.env.local` file into a `.env` file using the following command.

```
cp .env.local .env
```

Before using the library, make sure to set up the required environment variables in the .env file. These variables include:

- **ENVIRONMENT**: Set the environment to either "production" or "development."
- Way simpler API over using daraja on your own.
- Open source!
- Slow integration. You don`t have to hot swap this library. You can easily integrate it to your app.
- More Util Functions. If you need to generate passwords if you have decided to slowly integrate the app offers helper functions to help you move along nicely. e.g generateTimestamp and generatePassword.

- **MPESA_CONSUMER_KEY**: Consumer Key obtained from Safaricom Daraja.
# Compatibility

- **MPESA_CONSUMER_SECRET**: Consumer Secret obtained from Safaricom Daraja.
Daraja Kit is compatible with Node.js and React environments. It provides a simple interface for initiating M-Pesa transactions using the Safaricom Daraja API.

- **MPESA_BUSINESS_SHORT_CODE**: Your M-Pesa business short code. For Sandbox use the code **174379**
Some APIs are exclusively for Node Environments and some are just React Components so are only used in react.

- **MPESA_TILL_OR_PAYBILL_NO**: Your M-Pesa till or paybill number. For Sandbox use 174379. Sometimes you can use your shortcode in prod but if you run into errors find the correct one in your portal.
# Stack

- **MPESA_TRANSACTION_TYPE**: Set the transaction type, either "CustomerPayBillOnline" or "CustomerBuyGoodsOnline."
## docs

- **MPESA_API_PASS_KEY**: Your M-Pesa API pass key. For sandbox use **bfb279f9aa9bdbcf158e97dd71a467cd2e0c893059b10f78e6b72ada1ed2c919**
[Nextra](https://github.com/shuding/nextra)

The library throws errors if any of this values are missing from your .env file.
## Main library

## Benefits
[typescript](https://www.typescriptlang.org/)
[react](https://react.dev/)

- Way simpler API over using daraja on your own.
- Open source!
- Slow integration. You don`t have to hot swap this library. You can easily integrate it to your app.
- More Util Functions. If you need to generate passwords if you have decided to slowly integrate the app offers helper functions to help you move along nicely. e.g generateTimestamp and generatePassword.
## Package manager

## Compatibility
[pnpm](https://pnpm.io/)

Daraja Kit is compatible with Node.js and React environments. It provides a simple interface for initiating M-Pesa transactions using the Safaricom Daraja API.
## Versioning

Some APIs are exclusively for Node Environments and some are just React Components so are only used in react.
[Changesets](https://github.com/changesets/changesets)

## License
# License

This library is licensed under the MIT License. Feel free to contribute or open issues on the GitHub repository. More APIs and components coming. Watch this repo for alerts.
3 changes: 0 additions & 3 deletions packages/docs/.eslintrc.json

This file was deleted.

Binary file added packages/docs/.github/screenshot.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
40 changes: 2 additions & 38 deletions packages/docs/.gitignore
Original file line number Diff line number Diff line change
@@ -1,38 +1,2 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

# dependencies
/node_modules
/.pnp
.pnp.js
.yarn/install-state.gz

# testing
/coverage

# next.js
/.next/
/out/

# production
/build

# misc
.DS_Store
*.pem

# debug
npm-debug.log*
yarn-debug.log*
yarn-error.log*

# local env files
.env*.local

# vercel
.vercel

# typescript
*.tsbuildinfo
next-env.d.ts

.env
.next
node_modules
21 changes: 21 additions & 0 deletions packages/docs/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2022 Shu Ding

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
13 changes: 0 additions & 13 deletions packages/docs/README.md

This file was deleted.

74 changes: 0 additions & 74 deletions packages/docs/app/api/page.tsx

This file was deleted.

Binary file removed packages/docs/app/favicon.ico
Binary file not shown.
104 changes: 0 additions & 104 deletions packages/docs/app/globals.css

This file was deleted.

Loading

0 comments on commit a57e445

Please sign in to comment.