<?php

use App\Http\Controllers\Payments\OneKhusaWebhookController;
use App\Http\Controllers\Payments\PayChanguController;
use App\Http\Controllers\Payments\PaymentStatusController;
use Illuminate\Foundation\Http\Middleware\ValidateCsrfToken;
use Illuminate\Support\Facades\Route;

Route::prefix('payments')->name('payments.')->middleware('throttle:120,1')->group(function () {
    Route::get('status/{payment}', [PaymentStatusController::class, 'show'])
        ->middleware('signed')
        ->name('status');

    Route::post('paychangu/callback', [PayChanguController::class, 'callback'])
        ->withoutMiddleware([ValidateCsrfToken::class])
        ->name('paychangu.callback');

    Route::get('paychangu/return', [PayChanguController::class, 'return'])
        ->name('paychangu.return');

    Route::post('webhooks/paychangu', [PayChanguController::class, 'webhook'])
        ->withoutMiddleware([ValidateCsrfToken::class])
        ->name('webhooks.paychangu');

    Route::post('webhooks/one-khusa', OneKhusaWebhookController::class)
        ->withoutMiddleware([ValidateCsrfToken::class])
        ->name('webhooks.one-khusa');
});
