Skip to content

Commit

Permalink
ENV.example and mfl code bypass in dev mode. (#8)
Browse files Browse the repository at this point in the history
* fix: reading callback url from env

* refacor: added fail option when evironment variables are missing

* feat: reading environment vars from config file instead of .env

* refactor: use hashmap instead of array of objects

* fix: cors error for missing config requests

* refactor: remove "mpesa" keyword from callback url

* refactor: removed previously commented out stk push from utils.ts

* refactor: removed console.log in callback route

* refactor: removed mpesa configs from env.example and added a feature to bypass mfl check for dev instances

* fix: reading callback url from env

* refactor: remove "mpesa" keyword from callback url

* refactor: removed console.log in callback route

* refactor: removed mpesa configs from env.example and added a feature to bypass mfl check for dev instances

* unique mfl for dev instances

* removed files that should be ignored

* fix: dev key

---------

Co-authored-by: Amoh Prince <81857018+AmohPrince@users.noreply.github.com>
  • Loading branch information
amosmachora and amosmachora authored Jul 2, 2024
1 parent 798cd47 commit d26e29e
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,6 @@ yarn-error.log*
*.tsbuildinfo
next-env.d.ts

mpesa-config.json
mpesa-config.json
mpesa-config-prod.json
mpesa-config-dev.json
6 changes: 5 additions & 1 deletion config/mpesa-config.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import configData from "../mpesa-config.json";
import { assertValue } from "./env";
import { ENVIRONMENT, assertValue } from "./env";

export type MPESA_CONFIG = {
MPESA_BUSINESS_SHORT_CODE: string;
Expand All @@ -17,6 +17,10 @@ const mpesaConfigMap: { [key: string]: MPESA_CONFIG } = assertValue(
export const getHealthFacilityMpesaConfig = (
mfl: string
): MPESA_CONFIG | undefined => {
if (ENVIRONMENT === "development") {
return mpesaConfigMap["DEV"];
}

const config = mpesaConfigMap[mfl];
return config;
};
6 changes: 0 additions & 6 deletions env.example
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
# PER HEALTH FACILITY ENVIRONMENT VARIABLES
MPESA_BUSINESS_SHORT_CODE=
MPESA_CONSUMER_KEY=
MPESA_CONSUMER_SECRET=
MPESA_API_PASS_KEY=

# APP ENVs
ENVIRONMENT=
MPESA_TRANSACTION_TYPE=
Expand Down

0 comments on commit d26e29e

Please sign in to comment.