feat: add Cryptomus payment service toggle

- Added CRYPTOMUS_ENABLED environment variable to control payment service availability
- Created status endpoint to check service availability from frontend
- Updated Header to conditionally show support button based on service status
This commit is contained in:
Yusuf İpek
2025-11-17 18:33:19 +03:00
parent 9123dbb4c0
commit 9c38be3a88
3 changed files with 48 additions and 13 deletions
@@ -3,6 +3,7 @@ import { NextRequest, NextResponse } from 'next/server'
const CRYPTOMUS_API_URL = 'https://api.cryptomus.com/v1/payment'
const MERCHANT_ID = process.env.CRYPTOMUS_MERCHANT_ID || ''
const PAYMENT_API_KEY = process.env.CRYPTOMUS_PAYMENT_API_KEY || ''
const CRYPTOMUS_ENABLED = process.env.CRYPTOMUS_ENABLED !== 'false'
interface PaymentRequest {
amount: number
@@ -35,6 +36,13 @@ function generateSign(data: any, apiKey: string): string {
export async function POST(request: NextRequest) {
try {
if (!CRYPTOMUS_ENABLED) {
return NextResponse.json(
{ error: 'Payment service is temporarily disabled' },
{ status: 503 }
)
}
if (!MERCHANT_ID || !PAYMENT_API_KEY) {
return NextResponse.json(
{ error: 'Payment service not configured' },
+9
View File
@@ -0,0 +1,9 @@
import { NextResponse } from 'next/server'
const CRYPTOMUS_ENABLED = process.env.CRYPTOMUS_ENABLED !== 'false'
export async function GET() {
return NextResponse.json({
cryptomus_enabled: CRYPTOMUS_ENABLED
})
}