Skip to content

Commit

Permalink
fix: created mpesa config example (#5)
Browse files Browse the repository at this point in the history
Co-authored-by: Amos Machora <[email protected]>
  • Loading branch information
amosmachora and amosmachora authored Jun 26, 2024
1 parent 538bcf2 commit 56eda11
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 2 deletions.
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,11 @@ Check out our [Next.js deployment documentation](https://nextjs.org/docs/deploym
touch .env
cp .env.example .env
```

## mpesa configuration

```
touch mpesa-config.json
cp mpesa-config-example.json mpesa-config.json
```
2 changes: 1 addition & 1 deletion config/env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export const MPESA_APP_BASE_URL = assertValue(
"Missing environment variable: MPESA_APP_BASE_URL"
);

function assertValue<T>(v: T | undefined, errorMessage: string): T {
export function assertValue<T>(v: T | undefined, errorMessage: string): T {
if (v === undefined) {
throw new Error(errorMessage);
}
Expand Down
6 changes: 5 additions & 1 deletion config/mpesa-config.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import configData from "../mpesa-config.json";
import { assertValue } from "./env";

export type MPESA_CONFIG = {
MPESA_BUSINESS_SHORT_CODE: string;
Expand All @@ -8,7 +9,10 @@ export type MPESA_CONFIG = {
};

// HASHMAP
const mpesaConfigMap: { [key: string]: MPESA_CONFIG } = configData;
const mpesaConfigMap: { [key: string]: MPESA_CONFIG } = assertValue(
configData,
"MISSING MPESA CONFIGURATION FILE"
);

export const getHealthFacilityMpesaConfig = (
mfl: string
Expand Down
8 changes: 8 additions & 0 deletions mpesa-config-example.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"mflCode": {
"MPESA_BUSINESS_SHORT_CODE": "",
"MPESA_CONSUMER_KEY": "",
"MPESA_CONSUMER_SECRET": "",
"MPESA_API_PASS_KEY": ""
}
}

0 comments on commit 56eda11

Please sign in to comment.