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
|
try
|
||||||
{
|
{
|
||||||
// Remover agendamento de cancelamento
|
// Reativar assinatura removendo o agendamento de cancelamento
|
||||||
var success = await _paymentService.CancelSubscriptionAtPeriodEndAsync(subscriptionId);
|
var success = await _paymentService.ReactivateSubscriptionAsync(subscriptionId);
|
||||||
|
|
||||||
if (success)
|
if (success)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -21,6 +21,7 @@ public interface IPaymentService
|
|||||||
// Métodos para cancelamento com diferentes políticas
|
// Métodos para cancelamento com diferentes políticas
|
||||||
Task<bool> CancelSubscriptionImmediatelyAsync(string subscriptionId, bool refund = false);
|
Task<bool> CancelSubscriptionImmediatelyAsync(string subscriptionId, bool refund = false);
|
||||||
Task<bool> CancelSubscriptionAtPeriodEndAsync(string subscriptionId);
|
Task<bool> CancelSubscriptionAtPeriodEndAsync(string subscriptionId);
|
||||||
|
Task<bool> ReactivateSubscriptionAsync(string subscriptionId);
|
||||||
Task<Refund> CreatePartialRefundAsync(string subscriptionId, decimal refundAmount);
|
Task<Refund> CreatePartialRefundAsync(string subscriptionId, decimal refundAmount);
|
||||||
Task<(bool CanRefundFull, bool CanRefundPartial, decimal RefundAmount)> CalculateRefundAsync(string subscriptionId);
|
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)
|
public async Task<Refund> CreatePartialRefundAsync(string subscriptionId, decimal refundAmount)
|
||||||
{
|
{
|
||||||
// NOTA: Para planos de assinatura, reembolsos devem ser processados manualmente via Stripe Dashboard
|
// NOTA: Para planos de assinatura, reembolsos devem ser processados manualmente via Stripe Dashboard
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user