Move e-payment to Settings and add ZarinPal credentials.

Gateway config now lives on the general Settings page, with Mellat fields in a 3-column layout and ZarinPal available at checkout.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
Alireza Hassani
2026-08-16 01:45:41 +03:30
co-authored by Cursor
parent 9a59bc8f65
commit e79211e3cd
35 changed files with 614 additions and 212 deletions
+27
View File
@@ -83,6 +83,18 @@ export interface CheckoutResponse {
payment?: CheckoutPaymentResult
}
export interface PublicPaymentGateway {
id: OnlineGatewayType
label: string
labelFa: string
}
export interface PublicPaymentMethods {
enabled: boolean
defaultGateway: OnlineGatewayType | null
gateways: PublicPaymentGateway[]
}
function cartPath(suffix = '') {
const businessId = getActiveBusinessId()
if (!businessId) {
@@ -91,6 +103,14 @@ function cartPath(suffix = '') {
return `/businesses/${businessId}/cart${suffix}`
}
function paymentsMethodsPath() {
const businessId = getActiveBusinessId()
if (!businessId) {
throw new Error('No active business selected. Please sign in again.')
}
return `/businesses/${businessId}/payments/methods`
}
export async function getCart(signal?: AbortSignal) {
return apiRequest<{ cart: Cart }>(cartPath(), { auth: true, signal })
}
@@ -126,6 +146,13 @@ export async function checkoutCart(input: CheckoutInput) {
})
}
export async function getPaymentMethods(signal?: AbortSignal) {
return apiRequest<PublicPaymentMethods>(paymentsMethodsPath(), {
auth: false,
signal,
})
}
/** Submit a gateway redirect (POST form or GET navigation). */
export function submitPaymentRedirect(redirect: PaymentRedirect) {
if (redirect.method === 'GET') {