Initial MultiPay project
This commit is contained in:
commit
91abad4066
488 files changed
+76727
No files matched your search
@@ -0,0 +1,33 @@
|
||||
import { db } from "../src/db";
|
||||
import { decryptJson } from "../src/security";
|
||||
|
||||
const rows = db.query(`
|
||||
SELECT id, name, channel, subject_type, mode, enabled, config_encrypted, updated_at
|
||||
FROM gateways
|
||||
ORDER BY channel, id
|
||||
`).all() as Array<Record<string, any>>;
|
||||
|
||||
const safe = rows.map((row) => {
|
||||
const config = decryptJson<Record<string, string>>(row.config_encrypted || "");
|
||||
let notifyHost = "";
|
||||
try { notifyHost = config.notifyUrl ? new URL(config.notifyUrl).host : ""; } catch { notifyHost = "INVALID_URL"; }
|
||||
return {
|
||||
id: row.id,
|
||||
name: row.name,
|
||||
channel: row.channel,
|
||||
subjectType: row.subject_type,
|
||||
mode: row.mode,
|
||||
enabled: Boolean(row.enabled),
|
||||
updatedAt: row.updated_at,
|
||||
configured: row.channel === "alipay" ? {
|
||||
appId: Boolean(config.appId),
|
||||
merchantPid: Boolean(config.merchantPid),
|
||||
privateKey: Boolean(config.privateKey),
|
||||
alipayPublicKey: Boolean(config.alipayPublicKey)
|
||||
} : undefined,
|
||||
notifyHost,
|
||||
customGateway: Boolean(config.gatewayUrl)
|
||||
};
|
||||
});
|
||||
|
||||
console.log(JSON.stringify(safe, null, 2));
|
||||
Reference in new issue
Block a user