feat: reativar assinatura cancelada
All checks were successful
BCards Deployment Pipeline / Run Tests (push) Successful in 3s
BCards Deployment Pipeline / PR Validation (push) Has been skipped
BCards Deployment Pipeline / Build and Push Image (push) Successful in 15m47s
BCards Deployment Pipeline / Deploy to Production (ARM - OCI) (push) Successful in 1m12s
BCards Deployment Pipeline / Deploy to Staging (x86 - Local) (push) Has been skipped
BCards Deployment Pipeline / Cleanup Old Resources (push) Has been skipped
BCards Deployment Pipeline / Deployment Summary (push) Successful in 0s
All checks were successful
BCards Deployment Pipeline / Run Tests (push) Successful in 3s
BCards Deployment Pipeline / PR Validation (push) Has been skipped
BCards Deployment Pipeline / Build and Push Image (push) Successful in 15m47s
BCards Deployment Pipeline / Deploy to Production (ARM - OCI) (push) Successful in 1m12s
BCards Deployment Pipeline / Deploy to Staging (x86 - Local) (push) Has been skipped
BCards Deployment Pipeline / Cleanup Old Resources (push) Has been skipped
BCards Deployment Pipeline / Deployment Summary (push) Successful in 0s
This commit is contained in:
parent
004bf284b5
commit
6e70202fce
@ -131,8 +131,8 @@ public class SubscriptionController : Controller
|
||||
|
||||
try
|
||||
{
|
||||
// Remover agendamento de cancelamento
|
||||
var success = await _paymentService.CancelSubscriptionAtPeriodEndAsync(subscriptionId);
|
||||
// Reativar assinatura removendo o agendamento de cancelamento
|
||||
var success = await _paymentService.ReactivateSubscriptionAsync(subscriptionId);
|
||||
|
||||
if (success)
|
||||
{
|
||||
|
||||
@ -21,6 +21,7 @@ public interface IPaymentService
|
||||
// Métodos para cancelamento com diferentes políticas
|
||||
Task<bool> CancelSubscriptionImmediatelyAsync(string subscriptionId, bool refund = false);
|
||||
Task<bool> CancelSubscriptionAtPeriodEndAsync(string subscriptionId);
|
||||
Task<bool> ReactivateSubscriptionAsync(string subscriptionId);
|
||||
Task<Refund> CreatePartialRefundAsync(string subscriptionId, decimal refundAmount);
|
||||
Task<(bool CanRefundFull, bool CanRefundPartial, decimal RefundAmount)> CalculateRefundAsync(string subscriptionId);
|
||||
}
|
||||
@ -479,6 +479,35 @@ public class PaymentService : IPaymentService
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<bool> ReactivateSubscriptionAsync(string subscriptionId)
|
||||
{
|
||||
try
|
||||
{
|
||||
var service = new SubscriptionService();
|
||||
var options = new SubscriptionUpdateOptions
|
||||
{
|
||||
CancelAtPeriodEnd = false // Reativar removendo o agendamento de cancelamento
|
||||
};
|
||||
|
||||
await service.UpdateAsync(subscriptionId, options);
|
||||
|
||||
// Atualizar subscription local
|
||||
var localSubscription = await _subscriptionRepository.GetByStripeSubscriptionIdAsync(subscriptionId);
|
||||
if (localSubscription != null)
|
||||
{
|
||||
localSubscription.CancelAtPeriodEnd = false;
|
||||
localSubscription.UpdatedAt = DateTime.UtcNow;
|
||||
await _subscriptionRepository.UpdateAsync(localSubscription);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
catch (StripeException)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<Refund> CreatePartialRefundAsync(string subscriptionId, decimal refundAmount)
|
||||
{
|
||||
// NOTA: Para planos de assinatura, reembolsos devem ser processados manualmente via Stripe Dashboard
|
||||
|
||||
Loading…
Reference in New Issue
Block a user