Open Closed

Using trial periods on Stripe subscriptions #2467


User avatar
0
christophe.baille created
  • ABP Framework version: v5.0.0
  • UI type: Blazor
  • DB provider: EF Core
  • Tiered (MVC) or Identity Server Separated (Angular): no

Our actual solution let the user subscribe to a plan while we create the tenant, once the tenant is created on ABP, we create a new subscription

_subscriptionAppService.CreateSubscriptionAsync(editionId, tenantId);

then redirect to the Stripe payment page

LocalRedirectPreserveMethod("/Payment/GatewaySelection?paymentRequestId=" + paymentRequest.Id);

I had a look on Stripe documentation on how to add a trial period (https://stripe.com/docs/billing/subscriptions/trials) and it is mentionned to add a TrialEnd on SubscriptionCreate options:

var options = new SubscriptionCreateOptions { Customer = "cus_4fdAW5ftNQow1a", Items = items, TrialEnd = DateTimeOffset.FromUnixTimeSeconds(1610403705).UtcDateTime, };

From what I understand, ABP create this subscription with the code I mentionned before

_subscriptionAppService.CreateSubscriptionAsync(editionId, tenantId);

then use this result Id to send to the gateway

My problem here is that this method do not allow to provide a TrialEnd, and all entities related to subscription (Edition, Plan) do not have this property.

The payment request which subscriptionAppService generate do not have anything about it neither, so I guess it is not implemented?

So I would like to know if it is possible to define the TrialEnd period using ABP module? Or any other way to work around about making trial subscription?

Thanks


3 Answer(s)
  • User Avatar
    0
    enisn created
    Support Team .NET Developer

    Hi @christophe.baille

    Currently, our Saas & Payment modules don't support subscriptions. Also Payment module is built on common features across payment providers. It's an abstraction for multiple payment providers, some of providers can support trial and some of them do not, we can't just implement it for only stripe for now.

    For now, you can manually implement stripe requests via overriding SubscriptionService.

  • User Avatar
    0
    christophe.baille created

    Thanks for your reply.

    I am not sure to understand, you said that I should override SubscriptionService which is on Saas module, at this point nothing is send to Stripe platform right? SubscriptionService seems only have the method CreateSubscriptionAsync which create an object PaymentRequestWithDetailsDto, then add a line on PayPaymentRequests table. Does this method interact to payment module about connecting to Stripe as well at this level? If I edit this service to save a TrialEnd on PayPaymentRequests table (On ExtraProperties for example), will it be enough?

    Should I not override some code on payment module too?

    From what I did test, this code on Stripe:

    var options = new SubscriptionCreateOptions { Customer = "cus_4fdAW5ftNQow1a", Items = items, TrialEnd = DateTimeOffset.FromUnixTimeSeconds(1610403705).UtcDateTime, };

    Is done at some point when I call this:

    return LocalRedirectPreserveMethod("/Payment/GatewaySelection?paymentRequestId=" + paymentRequest.Id);

    Because when calling /Payment/GatewaySelection... , I reach the Stripe view to get the customer information (name, email, card details, etc...). So only after submit this view, I am able to create the customer on Stripe, then create the subscription for this customer and related to the payment request created by SubscriptionService.

    Let me know if I misunderstood please, my actual license do not let me access to any source code of modules Saas and payment.

  • User Avatar
    0
    christophe.baille created

    I finally did implements using Stripe elements only and not using ABP modules

Made with ❤️ on ABP v9.1.0-preview. Updated on December 05, 2024, 12:19