Add Mellat e-payment, videos/instructions CMS, and legacy domain lookup.

Store gateway credentials per business, initiate/verify Mellat at checkout, and resolve old CMS ids from domains in the migrate modal.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
Alireza Hassani
2026-08-13 09:51:17 +03:30
co-authored by Cursor
parent 513673a7da
commit d5e502cf77
44 changed files with 9303 additions and 996 deletions
@@ -38,10 +38,56 @@ export type OrderProcessStep = {
color: string;
};
/** Supported online payment gateways (extend when adding adapters). */
export const PAYMENT_GATEWAY_IDS = [
'mellat',
'sep',
'snappay',
'digipay',
'zarinpal',
] as const;
export type PaymentGatewayId = (typeof PAYMENT_GATEWAY_IDS)[number];
/** Behpardakht Mellat credentials. */
export type MellatGatewaySettings = {
enabled: boolean;
terminalId: string;
username: string;
/** Stored secret — redacted in API responses; use passwordSet instead. */
password: string;
};
/**
* Placeholder for gateways not yet wired (SEP, Snapp Pay, DigiPay, Zarinpal).
* Credential fields are added when each adapter ships.
*/
export type StubGatewaySettings = {
enabled: boolean;
};
export type PaymentGatewaysSettings = {
mellat: MellatGatewaySettings;
sep: StubGatewaySettings;
snappay: StubGatewaySettings;
digipay: StubGatewaySettings;
zarinpal: StubGatewaySettings;
};
/** Online e-payment (website checkout). */
export type EPaymentSettings = {
/** Master switch — when false, websites must not offer e-payment. */
enabled: boolean;
/** Preferred gateway when several are enabled (null = first configured). */
defaultGateway: PaymentGatewayId | null;
gateways: PaymentGatewaysSettings;
};
/** Per-business store / sales settings. */
export type StoreSettings = {
onlineSellEnabled: boolean;
orderProcessSteps: OrderProcessStep[];
ePayment: EPaymentSettings;
};
/** Optional business-dashboard CMS modules. Always-on areas (customers, website, etc.) are not listed. */
@@ -52,6 +98,7 @@ export const BUSINESS_DASHBOARD_MODULE_IDS = [
'blog',
'warehouse',
'videos',
'instructions',
'finance',
] as const;
@@ -134,6 +181,29 @@ export const DEFAULT_HOME_CHARTS: [HomeChartId, HomeChartId] = [
'customers_joined_1y',
];
export const DEFAULT_MELLAT_GATEWAY_SETTINGS: MellatGatewaySettings = {
enabled: false,
terminalId: '',
username: '',
password: '',
};
export const DEFAULT_STUB_GATEWAY_SETTINGS: StubGatewaySettings = {
enabled: false,
};
export const DEFAULT_EPAYMENT_SETTINGS: EPaymentSettings = {
enabled: false,
defaultGateway: null,
gateways: {
mellat: { ...DEFAULT_MELLAT_GATEWAY_SETTINGS },
sep: { ...DEFAULT_STUB_GATEWAY_SETTINGS },
snappay: { ...DEFAULT_STUB_GATEWAY_SETTINGS },
digipay: { ...DEFAULT_STUB_GATEWAY_SETTINGS },
zarinpal: { ...DEFAULT_STUB_GATEWAY_SETTINGS },
},
};
export const DEFAULT_BUSINESS_SETTINGS: BusinessSettings = {
branding: {
primaryColor: DEFAULT_BUSINESS_PRIMARY_COLOR_ID,
@@ -147,6 +217,7 @@ export const DEFAULT_BUSINESS_SETTINGS: BusinessSettings = {
store: {
onlineSellEnabled: true,
orderProcessSteps: DEFAULT_ORDER_PROCESS_STEPS,
ePayment: { ...DEFAULT_EPAYMENT_SETTINGS },
},
modules: {
enabled: DEFAULT_ENABLED_BUSINESS_MODULES,