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:
co-authored by
Cursor
parent
9a59bc8f65
commit
e79211e3cd
@@ -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') {
|
||||
|
||||
Reference in New Issue
Block a user