diff --git a/server/index.cjs b/server/index.cjs index 11bbdc8..5e50c9b 100644 --- a/server/index.cjs +++ b/server/index.cjs @@ -124,7 +124,7 @@ const ENABLE = { // --- Payment Link Config const EXTERNAL_API_KEY = process.env.EXTERNAL_API_KEY || '' const PAYMENT_LINK_SECRET = process.env.PAYMENT_LINK_SECRET || '' -const PAYMENT_LINK_TTL_MINUTES = parseInt(process.env.PAYMENT_LINK_TTL_MINUTES || '30', 10) +const PAYMENT_LINK_TTL_MINUTES = parseInt(process.env.PAYMENT_LINK_TTL_MINUTES || '1440', 10) const PAYMENT_LINK_BASE = process.env.PAYMENT_LINK_BASE || 'http://localhost:5174/pay' const activeOrders = new Map() // order_id -> expire_at // Map untuk menyimpan mercant_id per order_id agar notifikasi ERP bisa dinamis @@ -234,7 +234,7 @@ app.get('/api/payment-links/:token', (req, res) => { if (result.error) { logWarn('paymentlink.invalid', { error: result.error }) if (isDevEnv()) { - const ttlMin = PAYMENT_LINK_TTL_MINUTES > 0 ? PAYMENT_LINK_TTL_MINUTES : 30 + const ttlMin = PAYMENT_LINK_TTL_MINUTES > 0 ? PAYMENT_LINK_TTL_MINUTES : 1440 const fallback = { order_id: token, nominal: 150000, expire_at: Date.now() + ttlMin * 60 * 1000 } logInfo('paymentlink.dev.fallback', { order_id: fallback.order_id }) return res.json(fallback) @@ -386,7 +386,7 @@ app.post('/createtransaksi', async (req, res) => { } const nominal = Number(nominalRaw) const now = Date.now() - const ttlMin = PAYMENT_LINK_TTL_MINUTES > 0 ? PAYMENT_LINK_TTL_MINUTES : 30 + const ttlMin = PAYMENT_LINK_TTL_MINUTES > 0 ? PAYMENT_LINK_TTL_MINUTES : 1440 const expire_at = now + ttlMin * 60 * 1000 // Block jika sudah selesai diff --git a/src/features/payments/components/PaymentSheet.tsx b/src/features/payments/components/PaymentSheet.tsx index 22331e6..f622585 100644 --- a/src/features/payments/components/PaymentSheet.tsx +++ b/src/features/payments/components/PaymentSheet.tsx @@ -14,9 +14,10 @@ function useCountdown(expireAt: number) { }, []) const remainMs = Math.max(0, expireAt - now) const totalSec = Math.floor(remainMs / 1000) - const mm = String(Math.floor(totalSec / 60)).padStart(2, '0') + const hh = String(Math.floor(totalSec / 3600)).padStart(2, '0') + const mm = String(Math.floor((totalSec % 3600) / 60)).padStart(2, '0') const ss = String(totalSec % 60).padStart(2, '0') - return `${mm}:${ss}` + return `${hh}:${mm}:${ss}` } export interface PaymentSheetProps { @@ -93,4 +94,4 @@ export function PaymentSheet({ merchantName = 'Simaya', orderId, amount, expireA ) -} \ No newline at end of file +} diff --git a/src/pages/PayPage.tsx b/src/pages/PayPage.tsx index 27b2eac..77a2574 100644 --- a/src/pages/PayPage.tsx +++ b/src/pages/PayPage.tsx @@ -19,7 +19,7 @@ export function PayPage() { const { token } = useParams() const [orderId, setOrderId] = useState('') const [amount, setAmount] = useState(0) - const [expireAt, setExpireAt] = useState(Date.now() + 30 * 60 * 1000) + const [expireAt, setExpireAt] = useState(Date.now() + 24 * 60 * 60 * 1000) const [selectedMethod, setSelectedMethod] = useState(null) const [locked, setLocked] = useState(false) const [selectedBank, setSelectedBank] = useState(null) @@ -39,7 +39,7 @@ export function PayPage() { if (cancelled) return setOrderId(payload.order_id) setAmount(payload.nominal) - setExpireAt(payload.expire_at ?? Date.now() + 30 * 60 * 1000) + setExpireAt(payload.expire_at ?? Date.now() + 24 * 60 * 60 * 1000) setAllowedMethods(payload.allowed_methods) setError(null) } catch (err) { @@ -245,4 +245,4 @@ export function PayPage() { ) -} \ No newline at end of file +} diff --git a/src/services/api.ts b/src/services/api.ts index dca842e..f523409 100644 --- a/src/services/api.ts +++ b/src/services/api.ts @@ -137,14 +137,16 @@ export async function getPaymentLinkPayload(token: string): Promise