forked from xiongyuxing/tiku-backend.net
- Added tags to BrowserAuthController for browser authentication endpoints. - Added tags to CatalogController for public catalog access. - Added tags to CommerceController for student transaction operations. - Added tags to CommissionController for tenant commission management. - Added tags to CrmController for tenant CRM functionalities. - Added tags to HealthController for system health checks. - Added tags to LearningController for student learning resources. - Added tags to MeController for current user information. - Added tags to PlatformAdminController for platform management. - Introduced PlatformBackofficeController for backend permissions management. - Added tags to PlatformBillingCallbackController for billing callbacks. - Added tags to PlatformPaymentSettingsController for payment settings management. - Added tags to PlatformSaasController for SaaS package management. - Added tags to PlatformTenantCapabilitiesController for tenant capabilities. - Added tags to PointsController for student points management. - Added tags to ProfileController for student profile management. - Added tags to QuestionVideosController for question video resources. - Added tags to ReferralController for referral growth management. - Added tags to RuntimeController for runtime configurations. - Added tags to ScorelineController for scoreline management. - Added tags to TaxonomyController for category management. - Added tags to TenantAdminDirectController for tenant operations management. - Introduced TenantBackofficeController for tenant backend permissions. - Added tags to TenantBillingController for tenant billing operations. - Added tags to TenantCommerceController for tenant commerce operations. - Added tags to TenantContentController for tenant content management. - Added tags to TenantContentDirectController for direct content management. - Added tags to TenantFrontendConfigController for frontend configurations. - Added tags to TenantOnboardingController for onboarding guidance. - Added tags to TenantPublicController for public tenant configurations. - Added tags to TenantsController for current tenant information. - Added tags to VideosController for student video resources.
49 lines
1.9 KiB
C#
49 lines
1.9 KiB
C#
using System.Text;
|
|
using System.Text.Json;
|
|
using Microsoft.AspNetCore.Authorization;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
using Tiku.Application.PlatformBilling;
|
|
|
|
namespace Tiku.Api.Controllers;
|
|
|
|
[ApiController]
|
|
[Tags("平台端-账务回调")]
|
|
[Route("api/platform-billing/callbacks")]
|
|
public sealed class PlatformBillingCallbackController(
|
|
IPlatformBillingNotificationService notificationService) : ControllerBase
|
|
{
|
|
[AllowAnonymous]
|
|
[HttpPost("{provider}")]
|
|
[EndpointSummary("处理平台账务支付回调")]
|
|
[EndpointDescription("接收平台账务支付渠道回调,按 provider 归一化后写入通知处理流程。")]
|
|
public async Task<IActionResult> Notify(string provider, CancellationToken cancellationToken)
|
|
{
|
|
Request.EnableBuffering();
|
|
using var reader = new StreamReader(Request.Body, Encoding.UTF8, leaveOpen: true);
|
|
var rawBody = await reader.ReadToEndAsync(cancellationToken);
|
|
Request.Body.Position = 0;
|
|
JsonElement body;
|
|
try
|
|
{
|
|
body = string.IsNullOrWhiteSpace(rawBody)
|
|
? JsonDocument.Parse("{}").RootElement.Clone()
|
|
: JsonDocument.Parse(rawBody).RootElement.Clone();
|
|
}
|
|
catch (JsonException)
|
|
{
|
|
body = JsonDocument.Parse("{}").RootElement.Clone();
|
|
}
|
|
var normalizedProvider = provider.Trim().ToLowerInvariant().Replace('-', '_');
|
|
await notificationService.ProcessAsync(new PlatformBillingNotification(
|
|
normalizedProvider,
|
|
Request.Headers.ToDictionary(value => value.Key, value => value.Value.ToString(), StringComparer.OrdinalIgnoreCase),
|
|
rawBody,
|
|
body), cancellationToken);
|
|
if (normalizedProvider is "alipay" or "ali_pay")
|
|
{
|
|
return Content("success", "text/plain", Encoding.UTF8);
|
|
}
|
|
return Ok(new { code = "SUCCESS", message = "成功" });
|
|
}
|
|
}
|