feat: upgrade to v2.3.1 enterprise zero-risk COD with Google Maps Platform and Steadfast fraud API
This commit is contained in:
+40
-25
@@ -21,57 +21,72 @@ export interface CourierConfig {
|
||||
redx: {
|
||||
apiToken: string;
|
||||
baseUrl: string;
|
||||
pickupStoreId: string;
|
||||
enabled: boolean;
|
||||
};
|
||||
paperfly: {
|
||||
user: string;
|
||||
pass: string;
|
||||
key: string;
|
||||
apiKey: string;
|
||||
username: string;
|
||||
password: string;
|
||||
storeName: string;
|
||||
baseUrl: string;
|
||||
enabled: boolean;
|
||||
};
|
||||
googleMaps: {
|
||||
apiKey: string;
|
||||
enabled: boolean;
|
||||
};
|
||||
}
|
||||
|
||||
export function loadConfig(): CourierConfig {
|
||||
const steadfastApiKey = process.env.STEADFAST_API_KEY || "";
|
||||
const steadfastSecretKey = process.env.STEADFAST_SECRET_KEY || "";
|
||||
export type EnvSource = Record<string, string | undefined>;
|
||||
|
||||
const pathaoClientId = process.env.PATHAO_CLIENT_ID || "";
|
||||
const pathaoClientSecret = process.env.PATHAO_CLIENT_SECRET || "";
|
||||
/**
|
||||
* Build a CourierConfig from a key/value source.
|
||||
* Defaults to process.env (used by the STDIO/npx entrypoint); the HTTP
|
||||
* entrypoint passes a per-request map built from that client's headers/query.
|
||||
*/
|
||||
export function loadConfig(src: EnvSource = process.env): CourierConfig {
|
||||
const steadfastApiKey = src.STEADFAST_API_KEY || "";
|
||||
const steadfastSecretKey = src.STEADFAST_SECRET_KEY || "";
|
||||
|
||||
const redxApiToken = process.env.REDX_API_TOKEN || "";
|
||||
const pathaoClientId = src.PATHAO_CLIENT_ID || "";
|
||||
const pathaoClientSecret = src.PATHAO_CLIENT_SECRET || "";
|
||||
|
||||
const paperflyUser = process.env.PAPERFLY_USER || "";
|
||||
const paperflyPass = process.env.PAPERFLY_PASSWORD || "";
|
||||
const paperflyKey = process.env.PAPERFLY_KEY || "";
|
||||
const googleMapsKey = src.GOOGLE_MAPS_API_KEY || "";
|
||||
|
||||
return {
|
||||
steadfast: {
|
||||
apiKey: steadfastApiKey,
|
||||
secretKey: steadfastSecretKey,
|
||||
baseUrl: process.env.STEADFAST_BASE_URL || "https://portal.packzy.com/api/v1",
|
||||
baseUrl: src.STEADFAST_BASE_URL || "https://portal.steadfast.com.bd/api/v1",
|
||||
enabled: Boolean(steadfastApiKey && steadfastSecretKey),
|
||||
},
|
||||
pathao: {
|
||||
clientId: pathaoClientId,
|
||||
clientSecret: pathaoClientSecret,
|
||||
username: process.env.PATHAO_USERNAME || "",
|
||||
password: process.env.PATHAO_PASSWORD || "",
|
||||
storeId: process.env.PATHAO_STORE_ID || "",
|
||||
baseUrl: process.env.PATHAO_BASE_URL || "https://api-hermes.pathao.com",
|
||||
username: src.PATHAO_USERNAME || "",
|
||||
password: src.PATHAO_PASSWORD || "",
|
||||
storeId: src.PATHAO_STORE_ID || "",
|
||||
baseUrl: src.PATHAO_BASE_URL || "https://api-hermes.pathao.com",
|
||||
enabled: Boolean(pathaoClientId && pathaoClientSecret),
|
||||
},
|
||||
redx: {
|
||||
apiToken: redxApiToken,
|
||||
baseUrl: process.env.REDX_BASE_URL || "https://openapi.redx.com.bd/v1.0.0-beta",
|
||||
enabled: Boolean(redxApiToken),
|
||||
apiToken: src.REDX_API_TOKEN || "",
|
||||
baseUrl: src.REDX_BASE_URL || "https://openapi.redx.com.bd/v1.0.0-beta",
|
||||
pickupStoreId: src.REDX_PICKUP_STORE_ID || "",
|
||||
enabled: Boolean(src.REDX_API_TOKEN),
|
||||
},
|
||||
paperfly: {
|
||||
user: paperflyUser,
|
||||
pass: paperflyPass,
|
||||
key: paperflyKey,
|
||||
baseUrl: process.env.PAPERFLY_BASE_URL || "https://api.paperfly.com.bd",
|
||||
enabled: Boolean(paperflyUser && paperflyPass && paperflyKey),
|
||||
apiKey: src.PAPERFLY_API_KEY || "",
|
||||
username: src.PAPERFLY_USERNAME || "",
|
||||
password: src.PAPERFLY_PASSWORD || "",
|
||||
storeName: src.PAPERFLY_STORE_NAME || "",
|
||||
baseUrl: src.PAPERFLY_BASE_URL || "https://api.paperfly.com.bd",
|
||||
enabled: Boolean(src.PAPERFLY_API_KEY && src.PAPERFLY_STORE_NAME),
|
||||
},
|
||||
googleMaps: {
|
||||
apiKey: googleMapsKey,
|
||||
enabled: Boolean(googleMapsKey),
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user