Skip to content

Commit

Permalink
OFFI-221: Fixing subscription end date (#513)
Browse files Browse the repository at this point in the history
* Fixing end date

* Update src/Modules/OrchardCore.Commerce.Payment.Stripe/Handlers/SubscriptionStripeWebhookEventHandler.cs

Co-authored-by: Sára El-Saig <[email protected]>

---------

Co-authored-by: Sára El-Saig <[email protected]>
  • Loading branch information
wAsnk and sarahelsaig authored Jan 16, 2025
1 parent 79c19a6 commit aa17a6c
Showing 1 changed file with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,12 @@ public async Task ReceivedStripeEventAsync(Event stripeEvent)
var subscriptionPart = new SubscriptionPart();
subscriptionPart.UserId.Text = user.UserId;
subscriptionPart.Status.Text = SubscriptionStatuses.Active;
subscriptionPart.EndDateUtc.Value = invoice.PeriodEnd;

// invoice.PeriodEnd doesn't show the current period, see Stripe docs:
// https://docs.stripe.com/api/invoices/object#invoice_object-period_end
// "End of the usage period during which invoice items were added to this invoice. This looks back one
// period for a subscription invoice. Use the line item period to get the service period for each price."
subscriptionPart.EndDateUtc.Value = invoice.Lines.Data.Find(data => !data.Proration)?.Period.End;
subscriptionPart.PaymentProviderName.Text = StripePaymentProvider.ProviderName;
subscriptionPart.IdInPaymentProvider.Text = invoice.SubscriptionId;

Expand Down

0 comments on commit aa17a6c

Please sign in to comment.