Starts in:
2 DAYS
8 HRS
42 MIN
7 SEC
Starts in:
2 D
8 H
42 M
7 S
Open Closed

Stripe Payment / Subscription Questions #7847


User avatar
0
jaylin created
  • ABP Framework version: v8.2.2
  • UI Type: Angular
  • Database System: EF Core (SQL Server)
  • Tiered (for MVC) or Auth Server Separated (for Angular):  yes
  • Exception message and full stack trace:
  • Steps to reproduce the issue: I tried to submit a ticket, but your support system was not available. I am doing PoCs to test those scenarios with Stripe payment:
  • . Per seat pricing model
  • . Volume based pricing model I have configured Tenant, Edition, Plan, Gateway Plan (Stripe) and Stripe Webhook in my local ABP Host, customer (Tenant) and subscription will not be created automatically in Stripe after I associated Tenant with Plan. Payment redirection is confusing, where does LocalRedirectPreserveMethod (/Payment/GatewaySelection) redirect to? Stripe? API Host or AuthServer or Web.Public? How to redirect in Angular?
public class IndexModel : PageModel
{
        public async Task<IActionResult> OnPostAsync(Guid editionId)
        {
            var paymentRequest = await SubscriptionAppService.CreateSubscriptionAsync(editionId, CurrentTenant.GetId());

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

“When the payment is completed successfully, the tenant and edition relation will be updated according to subscription status. Make sure Payment Gateway Web Hooks are configured properly.” Does this mean once transaction is completed, user will see Subscription Management in UI so that they can upgrade / downgrade to different tier? There is no such screen shot in any document. Or do I need to manage customer and subscription in Stripe via code? I found One-Time and Recurring Payment are similar to Subscription, to achieve per seat or volume pricing model, shall I use One-Time? Recurring and Subscription is for fixed price model, right? Thanks in advance. Regards, Jay


12 Answer(s)
  • User Avatar
    0
    jaylin created

    I saw someone said Angular is not supported for payment, then I tried provisioning another solution using .NET Core MVC via CLI abp new MediBetter.Payment -m none --tiered --theme leptonx -csf --connection-string 'Server=.;Database=Test;User Id=sa;Password=Test!!!;TrustServerCertificate=true;'

    Then I added payment module via CLI, it automatically added several nuget packages and updated module.cs in Application, Contracts, Domain, Domain.Shared, HttpApi, HttpApi.Client, HttpApi.Host, .Web projects.

    Then I added this code to HTTP.API.Host and appsettings.json

        Configure&lt;AbpSaasPaymentOptions&gt;(options =>
        {
            options.IsPaymentSupported = true;
        });
    
    "Payment": {
        "Stripe": {
          "PublishableKey": "pk_test_51P...",
          "SecretKey": "sk_test_51P...",
          "WebhookSecret": "whsec_sp...",
          "Currency": "AUD",
          "Locale": "auto",
          "PaymentMethodTypes": ["card"]
        }
      }
    

    Then I added a page in .Web to create subscription, however, when I login as Tenant Admin, I get 403 error, even with all the permissions granted "_Web" App in AuthServer OpenId > Applications.

     public async Task<IActionResult> OnPostAsync(Guid editionId)
            {
                var paymentRequest = await SubscriptionAppService.CreateSubscriptionAsync(editionId, CurrentTenant.GetId());
                return LocalRedirectPreserveMethod("/Payment/GatewaySelection?paymentRequestId=" + paymentRequest.Id);
            }         
    

    I managed to invoke the /api/saas/subscription via Swagger to create subscription, but it is not able to LocalRedirectPreserveMethod with the correct paymentRequestId.

  • User Avatar
    0
    jaylin created

    I managed to use Host Admin to create subscription (200). public async Task<IActionResult> OnPostAsync(Guid editionId) { var paymentRequest = await SubscriptionAppService.CreateSubscriptionAsync(editionId, new Guid({{test-tenant-id}})); return LocalRedirectPreserveMethod("/Payment/GatewaySelection?paymentRequestId=" + paymentRequest.Id); } But I got AbpRemoteCallException in LocalRedirectPreserveMethod.

    [21:36:37 INF] Start processing HTTP request POST https://localhost:44330/api/saas/subscription?editionId=b6a600fd-dd26-5bd0-e685-3a14e2c059e7&tenantId=9374a261-f7c5-4c4c-ba88-3a14e2feb5d1&api-version=1.0 [21:36:37 INF] Sending HTTP request POST https://localhost:44330/api/saas/subscription?editionId=b6a600fd-dd26-5bd0-e685-3a14e2c059e7&tenantId=9374a261-f7c5-4c4c-ba88-3a14e2feb5d1&api-version=1.0 [21:36:38 INF] Received HTTP response headers after 323.6974ms - 200 [21:36:38 INF] End processing HTTP request after 323.9907ms - 200 [21:36:38 INF] Executed handler method OnPostAsync, returned result Microsoft.AspNetCore.Mvc.LocalRedirectResult. [21:36:38 INF] Executing LocalRedirectResult, redirecting to /Payment/GatewaySelection?paymentRequestId=1cdafd7e-c098-fd6c-da51-3a14e398c91d. [21:36:38 INF] Executed page /Payment in 351.8703ms [21:36:38 INF] Executed endpoint '/Payment' [21:36:38 INF] Request finished HTTP/2 POST https://localhost:44380/Payment - 307 0 null 358.6321ms [21:36:38 INF] Request starting HTTP/2 POST https://localhost:44380/Payment/GatewaySelection?paymentRequestId=1cdafd7e-c098-fd6c-da51-3a14e398c91d - application/x-www-form-urlencoded 272 [21:36:38 DBG] Get dynamic claims cache for user: 61316c80-2201-6007-5460-3a14e2c055fd [21:36:38 INF] Executing endpoint '/Payment/GatewaySelection' [21:36:38 INF] Route matched with {page = "/Payment/GatewaySelection", action = "", controller = "", area = ""}. Executing page /Payment/GatewaySelection [21:36:38 INF] Skipping the execution of current filter as its not the most effective filter implementing the policy Microsoft.AspNetCore.Mvc.ViewFeatures.IAntiforgeryPolicy [21:36:38 INF] Executing handler method Volo.Payment.Pages.Payment.GatewaySelectionModel.OnPostAsync - ModelState is Valid [21:36:38 INF] Start processing HTTP request GET https://localhost:44330/api/payment/requests/1cdafd7e-c098-fd6c-da51-3a14e398c91d?api-version=1.0 [21:36:38 INF] Sending HTTP request GET https://localhost:44330/api/payment/requests/1cdafd7e-c098-fd6c-da51-3a14e398c91d?api-version=1.0 [21:36:38 INF] Received HTTP response headers after 61.6867ms - 200 [21:36:38 INF] End processing HTTP request after 61.8489ms - 200 [21:36:38 INF] Start processing HTTP request GET https://localhost:44330/api/payment/gateways/subscription-supported?api-version=1.0 [21:36:38 INF] Sending HTTP request GET https://localhost:44330/api/payment/gateways/subscription-supported?api-version=1.0 [21:36:38 INF] Received HTTP response headers after 6.3861ms - 200 [21:36:38 INF] End processing HTTP request after 6.5586ms - 200 [21:36:38 INF] Executed handler method OnPostAsync, returned result Microsoft.AspNetCore.Mvc.LocalRedirectResult. [21:36:38 INF] Executing LocalRedirectResult, redirecting to /Payment/Stripe/PrePayment?paymentRequestId=1cdafd7e-c098-fd6c-da51-3a14e398c91d. [21:36:38 INF] Executed page /Payment/GatewaySelection in 83.7906ms [21:36:38 INF] Executed endpoint '/Payment/GatewaySelection' [21:36:38 INF] Request finished HTTP/2 POST https://localhost:44380/Payment/GatewaySelection?paymentRequestId=1cdafd7e-c098-fd6c-da51-3a14e398c91d - 307 0 null 91.3437ms [21:36:38 INF] Request starting HTTP/2 POST https://localhost:44380/Payment/Stripe/PrePayment?paymentRequestId=1cdafd7e-c098-fd6c-da51-3a14e398c91d - application/x-www-form-urlencoded 272 [21:36:38 DBG] Get dynamic claims cache for user: 61316c80-2201-6007-5460-3a14e2c055fd [21:36:38 INF] Executing endpoint '/Payment/Stripe/PrePayment' [21:36:38 INF] Route matched with {page = "/Payment/Stripe/PrePayment", action = "", controller = "", area = ""}. Executing page /Payment/Stripe/PrePayment [21:36:38 INF] Skipping the execution of current filter as its not the most effective filter implementing the policy Microsoft.AspNetCore.Mvc.ViewFeatures.IAntiforgeryPolicy [21:36:38 INF] Executing handler method Volo.Payment.Stripe.Pages.Payment.Stripe.PrePaymentModel.OnPostAsync - ModelState is Valid [21:36:38 INF] Start processing HTTP request POST https://localhost:44330/api/payment/stripe/start?api-version=1.0 [21:36:38 INF] Sending HTTP request POST https://localhost:44330/api/payment/stripe/start?api-version=1.0 [21:36:38 INF] Received HTTP response headers after 466.6814ms - 500 [21:36:38 INF] End processing HTTP request after 466.8602ms - 500 [21:36:38 ERR] ---------- RemoteServiceErrorInfo ---------- { "code": null, "message": "An internal error occurred during your request!", "details": null, "data": {}, "validationErrors": null }

    [21:36:38 ERR] An internal error occurred during your request! Volo.Abp.Http.Client.AbpRemoteCallException: An internal error occurred during your request! at Volo.Abp.Http.Client.ClientProxying.ClientProxyBase1.ThrowExceptionForResponseAsync(HttpResponseMessage response) at Volo.Abp.Http.Client.ClientProxying.ClientProxyBase1.RequestAsync(ClientProxyRequestContext requestContext) at Volo.Abp.Http.Client.ClientProxying.ClientProxyBase1.RequestAsync[T](ClientProxyRequestContext requestContext) at Volo.Abp.Http.Client.ClientProxying.ClientProxyBase1.RequestAsync[T](String methodName, ClientProxyRequestTypeValue arguments) at Volo.Payment.Requests.ClientProxies.PaymentRequestClientProxy.StartAsync(String paymentMethod, PaymentRequestStartDto input) at Volo.Payment.Stripe.Pages.Payment.Stripe.PrePaymentModel.OnPostAsync() at Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure.ExecutorFactory.NonGenericTaskHandlerMethod.Execute(Object receiver, Object[] arguments) at Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure.PageActionInvoker.InvokeHandlerMethodAsync() at Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure.PageActionInvoker.InvokeNextPageFilterAsync() at Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure.PageActionInvoker.Rethrow(PageHandlerExecutedContext context) at Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure.PageActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted) at Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure.PageActionInvoker.InvokeInnerFilterAsync() at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeNextExceptionFilterAsync>g__Awaited|26_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted) [21:36:38 ERR] Code: [21:36:38 ERR] Details: [21:36:38 INF] Executed page /Payment/Stripe/PrePayment in 479.3708ms [21:36:38 INF] Executed endpoint '/Payment/Stripe/PrePayment' [21:36:38 ERR] An unhandled exception has occurred while executing the request. Volo.Abp.Http.Client.AbpRemoteCallException: An internal error occurred during your request! at Volo.Abp.Http.Client.ClientProxying.ClientProxyBase1.ThrowExceptionForResponseAsync(HttpResponseMessage response) at Volo.Abp.Http.Client.ClientProxying.ClientProxyBase1.RequestAsync(ClientProxyRequestContext requestContext) at Volo.Abp.Http.Client.ClientProxying.ClientProxyBase1.RequestAsync[T](ClientProxyRequestContext requestContext) at Volo.Abp.Http.Client.ClientProxying.ClientProxyBase1.RequestAsync[T](String methodName, ClientProxyRequestTypeValue arguments) at Volo.Payment.Requests.ClientProxies.PaymentRequestClientProxy.StartAsync(String paymentMethod, PaymentRequestStartDto input) at Volo.Payment.Stripe.Pages.Payment.Stripe.PrePaymentModel.OnPostAsync() at Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure.ExecutorFactory.NonGenericTaskHandlerMethod.Execute(Object receiver, Object[] arguments) at Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure.PageActionInvoker.InvokeHandlerMethodAsync() at Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure.PageActionInvoker.InvokeNextPageFilterAsync() at Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure.PageActionInvoker.Rethrow(PageHandlerExecutedContext context) at Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure.PageActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted) at Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure.PageActionInvoker.InvokeInnerFilterAsync() at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeNextExceptionFilterAsync>g__Awaited|26_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted) at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Rethrow(ExceptionContextSealed context) at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted) at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeNextResourceFilter>g__Awaited|25_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted) at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Rethrow(ResourceExecutedContextSealed context) at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted) at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeFilterPipelineAsync>g__Awaited|20_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted) at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeAsync>g__Logged|17_1(ResourceInvoker invoker) at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeAsync>g__Logged|17_1(ResourceInvoker invoker) at Microsoft.AspNetCore.Routing.EndpointMiddleware.<Invoke>g__AwaitRequestTask|7_0(Endpoint endpoint, Task requestTask, ILogger logger) at Volo.Abp.AspNetCore.Serilog.AbpSerilogMiddleware.InvokeAsync(HttpContext context, RequestDelegate next) at Microsoft.AspNetCore.Builder.UseMiddlewareExtensions.InterfaceMiddlewareBinder.<>c__DisplayClass2_0.<<CreateMiddleware>b__0>d.MoveNext() --- End of stack trace from previous location --- at Swashbuckle.AspNetCore.SwaggerUI.SwaggerUIMiddleware.Invoke(HttpContext httpContext) at Swashbuckle.AspNetCore.Swagger.SwaggerMiddleware.Invoke(HttpContext httpContext, ISwaggerProvider swaggerProvider) at Microsoft.AspNetCore.Authorization.AuthorizationMiddleware.Invoke(HttpContext context) at Volo.Abp.AspNetCore.Security.Claims.AbpDynamicClaimsMiddleware.InvokeAsync(HttpContext context, RequestDelegate next) at Microsoft.AspNetCore.Builder.UseMiddlewareExtensions.InterfaceMiddlewareBinder.<>c__DisplayClass2_0.<<CreateMiddleware>b__0>d.MoveNext() --- End of stack trace from previous location --- at Volo.Abp.AspNetCore.MultiTenancy.MultiTenancyMiddleware.InvokeAsync(HttpContext context, RequestDelegate next) at Microsoft.AspNetCore.Builder.UseMiddlewareExtensions.InterfaceMiddlewareBinder.<>c__DisplayClass2_0.<<CreateMiddleware>b__0>d.MoveNext() --- End of stack trace from previous location --- at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.Invoke(HttpContext context) at Volo.Abp.AspNetCore.Security.AbpSecurityHeadersMiddleware.InvokeAsync(HttpContext context, RequestDelegate next) at Microsoft.AspNetCore.Builder.UseMiddlewareExtensions.InterfaceMiddlewareBinder.<>c__DisplayClass2_0.<<CreateMiddleware>b__0>d.MoveNext() --- End of stack trace from previous location --- at Volo.Abp.Studio.Client.AspNetCore.AbpStudioMiddleware.InvokeAsync(HttpContext context, RequestDelegate next) at Volo.Abp.Studio.Client.AspNetCore.AbpStudioMiddleware.InvokeAsync(HttpContext context, RequestDelegate next) at Volo.Abp.Studio.Client.AspNetCore.AbpStudioMiddleware.InvokeAsync(HttpContext context, RequestDelegate next) at Microsoft.AspNetCore.Builder.UseMiddlewareExtensions.InterfaceMiddlewareBinder.<>c__DisplayClass2_0.<<CreateMiddleware>b__0>d.MoveNext() --- End of stack trace from previous location --- at Microsoft.AspNetCore.Localization.RequestLocalizationMiddleware.Invoke(HttpContext context) at Microsoft.AspNetCore.RequestLocalization.AbpRequestLocalizationMiddleware.InvokeAsync(HttpContext context, RequestDelegate next) at Microsoft.AspNetCore.Builder.UseMiddlewareExtensions.InterfaceMiddlewareBinder.<>c__DisplayClass2_0.<<CreateMiddleware>b__0>d.MoveNext() --- End of stack trace from previous location ---

  • User Avatar
    0
    jaylin created

    I tried the multi tiered MVC web app on both Mac and Windows, they have the same issue.

    It's easy to setup saas features like tenant, edition in ABP, but I feel so frustrated to get the payment working. The documents are not clear enough and there is no working examples for it.

    If I can't make the PoC working, I will refund the license for sure.

  • User Avatar
    0
    enisn created
    Support Team .NET Developer

    Payment redirection is confusing, where does LocalRedirectPreserveMethod

    It redirects a page that is included in Volo.Payment.Web. It should redirect to the application which has this reference.

    You can add Volo.Payment.Web to your HttpApi.Host project and redirect to the API project. This page contains gateway selection UI if configured multiple gateway, otherwise directly redirects to the single payment provider's page

  • User Avatar
    0
    jaylin created

    Thanks for your reply,

    See the screenshot above, I added the Payment.cshtml and .cs to .Web (MVC) project, and I have already installed payment module which includes Volo.Payment.Web nuget package (see my 2nd thread).

    Do you have any working example? In MVC? Or Angular?

  • User Avatar
    0
    jaylin created

    To make it clear, I paste the TestPayModel (renamed from Payment) below. It's a multi layer .NET MVC project. I have tested 2 scenarios:

    1. POST TestPayModel using Tenant Admin - failed at CreateSubscriptionAsync

    `using System; using System.Threading.Tasks; using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.RazorPages; using Volo.Abp.MultiTenancy; using Volo.Saas.Subscription;

    namespace MediBetter.Test.Web.Pages { public class TestPayModel : PageModel { protected ISubscriptionAppService SubscriptionAppService { get; }

        protected ICurrentTenant CurrentTenant { get; }
    
        public TestPayModel(
            ISubscriptionAppService subscriptionAppService,
            ICurrentTenant currentTenant)
        {
            SubscriptionAppService = subscriptionAppService;
            CurrentTenant = currentTenant;
        }
    
        public async Task<IActionResult> OnPostAsync(Guid editionId)
        {
            System.Console.Write($"Post Edition {editionId}");
            // 1. Run as Tenant Admin
            var currentTenantId = CurrentTenant.GetId();
            var currentPaymentRequest = await SubscriptionAppService.CreateSubscriptionAsync(editionId, currentTenantId);
            // CreateSubscriptionAsync threw exceptions:
            //2024 - 09 - 11 09:50:58.132 + 10:00[INF] Executing endpoint '/TestPay'
            //2024 - 09 - 11 09:50:58.133 + 10:00[INF] Route matched with { page = "/TestPay", action = "", controller = "", area = ""}. Executing page / TestPay
            //2024 - 09 - 11 09:50:58.134 + 10:00[INF] Skipping the execution of current filter as its not the most effective filter implementing the policy Microsoft.AspNetCore.Mvc.ViewFeatures.IAntiforgeryPolicy
            //2024 - 09 - 11 09:50:58.157 + 10:00[INF] Executing handler method MediBetter.Test.Web.Pages.TestPayModel.OnPostAsync - ModelState is "Valid"
            //2024 - 09 - 11 09:51:02.392 + 10:00[INF] Start processing HTTP request POST https://localhost:44330/api/saas/subscription?editionId=36689a17-f58a-53c1-989f-3a14e2c5bba7&tenantId=9374a261-f7c5-4c4c-ba88-3a14e2feb5d1&api-version=1.0
            //2024 - 09 - 11 09:51:02.392 + 10:00[INF] Sending HTTP request POST https://localhost:44330/api/saas/subscription?editionId=36689a17-f58a-53c1-989f-3a14e2c5bba7&tenantId=9374a261-f7c5-4c4c-ba88-3a14e2feb5d1&api-version=1.0
            //            2024 - 09 - 11 09:51:02.413 + 10:00[INF] Received HTTP response headers after 21.4186ms - 403
            //2024 - 09 - 11 09:51:02.413 + 10:00[INF] End processing HTTP request after 21.6437ms - 403
            //2024 - 09 - 11 09:51:02.586 + 10:00[ERR]---------- RemoteServiceErrorInfo----------
            //{
            //                "code": "Forbidden",
            //    "message": "Forbidden",
            //    "details": null,
            //    "data": null,
            //    "validationErrors": null
            //}
    
            //            2024 - 09 - 11 09:51:02.586 + 10:00[ERR] Forbidden
            //Volo.Abp.Http.Client.AbpRemoteCallException: Forbidden
            //    at Volo.Abp.Http.Client.ClientProxying.ClientProxyBase`1.ThrowExceptionForResponseAsync(HttpResponseMessage response)
            //    at Volo.Abp.Http.Client.ClientProxying.ClientProxyBase`1.RequestAsync(ClientProxyRequestContext requestContext)
            //    at Volo.Abp.Http.Client.ClientProxying.ClientProxyBase`1.RequestAsync[T](ClientProxyRequestContext requestContext)
            //    at Volo.Abp.Http.Client.ClientProxying.ClientProxyBase`1.RequestAsync[T](String methodName, ClientProxyRequestTypeValue arguments)
            //    at Volo.Saas.Host.SubscriptionClientProxy.CreateSubscriptionAsync(Guid editionId, Guid tenantId)
            //    at MediBetter.Test.Web.Pages.TestPayModel.OnPostAsync(Guid editionId) in / Users / jay / MediBetter / source / MediBetter.Test / src / MediBetter.Test.Web / Pages / TestPay.cshtml.cs:line 48
            //    at Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure.ExecutorFactory.GenericTaskHandlerMethod.Convert[T](Object taskAsObject)
            //    at Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure.ExecutorFactory.GenericTaskHandlerMethod.Execute(Object receiver, Object[] arguments)
            //    at Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure.PageActionInvoker.InvokeHandlerMethodAsync()
            //    at Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure.PageActionInvoker.InvokeNextPageFilterAsync()
            //    at Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure.PageActionInvoker.Rethrow(PageHandlerExecutedContext context)
            //    at Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure.PageActionInvoker.Next(State & next, Scope & scope, Object & state, Boolean & isCompleted)
            //    at Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure.PageActionInvoker.InvokeInnerFilterAsync()
            //    at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.< InvokeNextExceptionFilterAsync > g__Awaited | 26_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
            //2024 - 09 - 11 09:51:02.586 + 10:00[ERR] Code: Forbidden
            //2024 - 09 - 11 09:51:02.587 + 10:00[ERR] Details:
            //            2024 - 09 - 11 09:51:02.588 + 10:00[INF] Executed page / TestPay in 4454.8638ms
            //2024 - 09 - 11 09:51:02.588 + 10:00[INF] Executed endpoint '/TestPay'
            //2024 - 09 - 11 09:51:02.593 + 10:00[ERR] An unhandled exception has occurred while executing the request.
            //Volo.Abp.Http.Client.AbpRemoteCallException: Forbidden
            //    at Volo.Abp.Http.Client.ClientProxying.ClientProxyBase`1.ThrowExceptionForResponseAsync(HttpResponseMessage response)
            //    at Volo.Abp.Http.Client.ClientProxying.ClientProxyBase`1.RequestAsync(ClientProxyRequestContext requestContext)
            //    at Volo.Abp.Http.Client.ClientProxying.ClientProxyBase`1.RequestAsync[T](ClientProxyRequestContext requestContext)
            //    at Volo.Abp.Http.Client.ClientProxying.ClientProxyBase`1.RequestAsync[T](String methodName, ClientProxyRequestTypeValue arguments)
            //    at Volo.Saas.Host.SubscriptionClientProxy.CreateSubscriptionAsync(Guid editionId, Guid tenantId)
            //    at MediBetter.Test.Web.Pages.TestPayModel.OnPostAsync(Guid editionId) in / Users / jay / MediBetter / source / MediBetter.Test / src / MediBetter.Test.Web / Pages / TestPay.cshtml.cs:line 48
            //    at Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure.ExecutorFactory.GenericTaskHandlerMethod.Convert[T](Object taskAsObject)
            //    at Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure.ExecutorFactory.GenericTaskHandlerMethod.Execute(Object receiver, Object[] arguments)
            //    at Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure.PageActionInvoker.InvokeHandlerMethodAsync()
            //    at Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure.PageActionInvoker.InvokeNextPageFilterAsync()
            //    at Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure.PageActionInvoker.Rethrow(PageHandlerExecutedContext context)
            //    at Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure.PageActionInvoker.Next(State & next, Scope & scope, Object & state, Boolean & isCompleted)
            //    at Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure.PageActionInvoker.InvokeInnerFilterAsync()
            //    at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.< InvokeNextExceptionFilterAsync > g__Awaited | 26_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
            //    at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Rethrow(ExceptionContextSealed context)
            //    at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Next(State & next, Scope & scope, Object & state, Boolean & isCompleted)
            //    at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.< InvokeNextResourceFilter > g__Awaited | 25_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
            //    at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Rethrow(ResourceExecutedContextSealed context)
            //    at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Next(State & next, Scope & scope, Object & state, Boolean & isCompleted)
            //    at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.< InvokeFilterPipelineAsync > g__Awaited | 20_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
            //    at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.< InvokeAsync > g__Logged | 17_1(ResourceInvoker invoker)
            //    at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.< InvokeAsync > g__Logged | 17_1(ResourceInvoker invoker)
            //    at Microsoft.AspNetCore.Routing.EndpointMiddleware.< Invoke > g__AwaitRequestTask | 7_0(Endpoint endpoint, Task requestTask, ILogger logger)
            //    at Volo.Abp.AspNetCore.Serilog.AbpSerilogMiddleware.InvokeAsync(HttpContext context, RequestDelegate next)
            //    at Microsoft.AspNetCore.Builder.UseMiddlewareExtensions.InterfaceMiddlewareBinder.<> c__DisplayClass2_0.<< CreateMiddleware > b__0 > d.MoveNext()
            //-- - End of stack trace from previous location ---
            //    at Swashbuckle.AspNetCore.SwaggerUI.SwaggerUIMiddleware.Invoke(HttpContext httpContext)
            //    at Swashbuckle.AspNetCore.Swagger.SwaggerMiddleware.Invoke(HttpContext httpContext, ISwaggerProvider swaggerProvider)
            //    at Microsoft.AspNetCore.Authorization.AuthorizationMiddleware.Invoke(HttpContext context)
            //    at Volo.Abp.AspNetCore.Security.Claims.AbpDynamicClaimsMiddleware.InvokeAsync(HttpContext context, RequestDelegate next)
            //    at Microsoft.AspNetCore.Builder.UseMiddlewareExtensions.InterfaceMiddlewareBinder.<> c__DisplayClass2_0.<< CreateMiddleware > b__0 > d.MoveNext()
            //-- - End of stack trace from previous location ---
            //    at Volo.Abp.AspNetCore.MultiTenancy.MultiTenancyMiddleware.InvokeAsync(HttpContext context, RequestDelegate next)
            //    at Microsoft.AspNetCore.Builder.UseMiddlewareExtensions.InterfaceMiddlewareBinder.<> c__DisplayClass2_0.<< CreateMiddleware > b__0 > d.MoveNext()
            //-- - End of stack trace from previous location ---
            //    at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.Invoke(HttpContext context)
            //    at Volo.Abp.AspNetCore.Security.AbpSecurityHeadersMiddleware.InvokeAsync(HttpContext context, RequestDelegate next)
            //    at Microsoft.AspNetCore.Builder.UseMiddlewareExtensions.InterfaceMiddlewareBinder.<> c__DisplayClass2_0.<< CreateMiddleware > b__0 > d.MoveNext()
            //-- - End of stack trace from previous location ---
            //    at Volo.Abp.Studio.Client.AspNetCore.AbpStudioMiddleware.InvokeAsync(HttpContext context, RequestDelegate next)
            //    at Volo.Abp.Studio.Client.AspNetCore.AbpStudioMiddleware.InvokeAsync(HttpContext context, RequestDelegate next)
            //    at Volo.Abp.Studio.Client.AspNetCore.AbpStudioMiddleware.InvokeAsync(HttpContext context, RequestDelegate next)
            //    at Microsoft.AspNetCore.Builder.UseMiddlewareExtensions.InterfaceMiddlewareBinder.<> c__DisplayClass2_0.<< CreateMiddleware > b__0 > d.MoveNext()
            //-- - End of stack trace from previous location ---
            //    at Microsoft.AspNetCore.Localization.RequestLocalizationMiddleware.Invoke(HttpContext context)
            //    at Microsoft.AspNetCore.RequestLocalization.AbpRequestLocalizationMiddleware.InvokeAsync(HttpContext context, RequestDelegate next)
            //    at Microsoft.AspNetCore.Builder.UseMiddlewareExtensions.InterfaceMiddlewareBinder.<> c__DisplayClass2_0.<< CreateMiddleware > b__0 > d.MoveNext()
            //-- - End of stack trace from previous location ---
            //    at Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddlewareImpl.Invoke(HttpContext context)
            //2024 - 09 - 11 09:51:02.662 + 10:00[INF] Request finished HTTP / 2 POST https://localhost:44380/TestPay - 500 null text/html; charset=utf-8 4621.8362ms
            return LocalRedirectPreserveMethod("/Payment/GatewaySelection?paymentRequestId=" + currentPaymentRequest.Id);
        }
    }
    

    } `

    If you can provide a working example, there will be great.

  • User Avatar
    0
    jaylin created
    1. POST TestPayModel using Host Admin - failed at LocalRedirectPreserveMethod

    `using System; using System.Threading.Tasks; using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.RazorPages; using Volo.Abp.MultiTenancy; using Volo.Saas.Subscription;

    namespace MediBetter.Test.Web.Pages { public class TestPayModel : PageModel { protected ISubscriptionAppService SubscriptionAppService { get; }

        protected ICurrentTenant CurrentTenant { get; }
    
        public TestPayModel(
            ISubscriptionAppService subscriptionAppService,
            ICurrentTenant currentTenant)
        {
            SubscriptionAppService = subscriptionAppService;
            CurrentTenant = currentTenant;
        }
    
        public async Task<IActionResult> OnPostAsync(Guid editionId)
        {
            System.Console.Write($"Post Edition {editionId}");
            // 2. Run as Host Admin
            var tenantId = new Guid("9374a261-f7c5-4c4c-ba88-3a14e2feb5d1");
            var paymentRequest = await SubscriptionAppService.CreateSubscriptionAsync(editionId, tenantId); // 200 OK but failed at /api/payment/stripe/start
            //2024-09-11 09:55:19.079 +10:00 [INF] Start processing HTTP request POST https://localhost:44330/api/saas/subscription?editionId=36689a17-f58a-53c1-989f-3a14e2c5bba7&tenantId=9374a261-f7c5-4c4c-ba88-3a14e2feb5d1&api-version=1.0
            //            2024 - 09 - 11 09:55:19.079 + 10:00[INF] Sending HTTP request POST https://localhost:44330/api/saas/subscription?editionId=36689a17-f58a-53c1-989f-3a14e2c5bba7&tenantId=9374a261-f7c5-4c4c-ba88-3a14e2feb5d1&api-version=1.0
            //            2024 - 09 - 11 09:55:19.543 + 10:00[INF] Received HTTP response headers after 463.6297ms - 200
            //2024 - 09 - 11 09:55:19.543 + 10:00[INF] End processing HTTP request after 463.9229ms - 200
            //2024 - 09 - 11 09:55:25.109 + 10:00[INF] Executed handler method OnPostAsync, returned result Microsoft.AspNetCore.Mvc.LocalRedirectResult.
            //2024 - 09 - 11 09:55:25.160 + 10:00[INF] Executing LocalRedirectResult, redirecting to / Payment / GatewaySelection ? paymentRequestId = 1fcdfc7f - 71e7 - b626 - c277 - 3a14f089cbb1.
            //2024 - 09 - 11 09:55:25.161 + 10:00[INF] Executed page / TestPay in 9610.8776ms
            //2024 - 09 - 11 09:55:25.161 + 10:00[INF] Executed endpoint '/TestPay'
            //2024 - 09 - 11 09:55:25.263 + 10:00[INF] Request finished HTTP / 2 POST https://localhost:44380/TestPay - 307 0 null 9819.4987ms
            //2024 - 09 - 11 09:55:25.358 + 10:00[INF] Request starting HTTP / 2 POST https://localhost:44380/Payment/GatewaySelection?paymentRequestId=1fcdfc7f-71e7-b626-c277-3a14f089cbb1 - application/x-www-form-urlencoded 272
            //2024 - 09 - 11 09:55:25.392 + 10:00[DBG] Get dynamic claims cache for user: 61316c80 - 2201 - 6007 - 5460 - 3a14e2c055fd
            //2024 - 09 - 11 09:55:25.493 + 10:00[INF] Executing endpoint '/Payment/GatewaySelection'
            //2024 - 09 - 11 09:55:25.547 + 10:00[INF] Route matched with { page = "/Payment/GatewaySelection", action = "", controller = "", area = "" }. Executing page / Payment / GatewaySelection
            //2024 - 09 - 11 09:55:25.547 + 10:00[INF] Skipping the execution of current filter as its not the most effective filter implementing the policy Microsoft.AspNetCore.Mvc.ViewFeatures.IAntiforgeryPolicy
            //2024 - 09 - 11 09:55:25.560 + 10:00[INF] Executing handler method Volo.Payment.Pages.Payment.GatewaySelectionModel.OnPostAsync - ModelState is "Valid"
            //2024 - 09 - 11 09:55:25.566 + 10:00[INF] Start processing HTTP request GET https://localhost:44330/api/payment/requests/1fcdfc7f-71e7-b626-c277-3a14f089cbb1?api-version=1.0
            //2024 - 09 - 11 09:55:25.567 + 10:00[INF] Sending HTTP request GET https://localhost:44330/api/payment/requests/1fcdfc7f-71e7-b626-c277-3a14f089cbb1?api-version=1.0
            //2024 - 09 - 11 09:55:25.689 + 10:00[INF] Received HTTP response headers after 121.9586ms - 200
            //2024 - 09 - 11 09:55:25.689 + 10:00[INF] End processing HTTP request after 122.1607ms - 200
            //2024 - 09 - 11 09:55:25.692 + 10:00[INF] Start processing HTTP request GET https://localhost:44330/api/payment/gateways/subscription-supported?api-version=1.0
            //2024 - 09 - 11 09:55:25.692 + 10:00[INF] Sending HTTP request GET https://localhost:44330/api/payment/gateways/subscription-supported?api-version=1.0
            //2024 - 09 - 11 09:55:25.709 + 10:00[INF] Received HTTP response headers after 17.0123ms - 200
            //2024 - 09 - 11 09:55:25.709 + 10:00[INF] End processing HTTP request after 17.152ms - 200
            //2024 - 09 - 11 09:55:25.712 + 10:00[INF] Executed handler method OnPostAsync, returned result Microsoft.AspNetCore.Mvc.LocalRedirectResult.
            //2024 - 09 - 11 09:55:25.713 + 10:00[INF] Executing LocalRedirectResult, redirecting to / Payment / Stripe / PrePayment ? paymentRequestId = 1fcdfc7f - 71e7 - b626 - c277 - 3a14f089cbb1.
            //2024 - 09 - 11 09:55:25.713 + 10:00[INF] Executed page / Payment / GatewaySelection in 165.4734ms
            //2024 - 09 - 11 09:55:25.713 + 10:00[INF] Executed endpoint '/Payment/GatewaySelection'
            //2024 - 09 - 11 09:55:25.713 + 10:00[INF] Request finished HTTP / 2 POST https://localhost:44380/Payment/GatewaySelection?paymentRequestId=1fcdfc7f-71e7-b626-c277-3a14f089cbb1 - 307 0 null 355.0931ms
            //2024 - 09 - 11 09:55:25.765 + 10:00[INF] Request starting HTTP / 2 POST https://localhost:44380/Payment/Stripe/PrePayment?paymentRequestId=1fcdfc7f-71e7-b626-c277-3a14f089cbb1 - application/x-www-form-urlencoded 272
            //2024 - 09 - 11 09:55:25.768 + 10:00[DBG] Get dynamic claims cache for user: 61316c80 - 2201 - 6007 - 5460 - 3a14e2c055fd
            //2024 - 09 - 11 09:55:25.796 + 10:00[INF] Executing endpoint '/Payment/Stripe/PrePayment'
            //2024 - 09 - 11 09:55:25.799 + 10:00[INF] Route matched with { page = "/Payment/Stripe/PrePayment", action = "", controller = "", area = "" }. Executing page / Payment / Stripe / PrePayment
            //2024 - 09 - 11 09:55:25.799 + 10:00[INF] Skipping the execution of current filter as its not the most effective filter implementing the policy Microsoft.AspNetCore.Mvc.ViewFeatures.IAntiforgeryPolicy
            //2024 - 09 - 11 09:55:25.800 + 10:00[INF] Executing handler method Volo.Payment.Stripe.Pages.Payment.Stripe.PrePaymentModel.OnPostAsync - ModelState is "Valid"
            //2024 - 09 - 11 09:55:25.803 + 10:00[INF] Start processing HTTP request POST https://localhost:44330/api/payment/stripe/start?api-version=1.0
            //2024 - 09 - 11 09:55:25.804 + 10:00[INF] Sending HTTP request POST https://localhost:44330/api/payment/stripe/start?api-version=1.0
            //2024 - 09 - 11 09:55:26.469 + 10:00[INF] Received HTTP response headers after 665.6427ms - 500
            //2024 - 09 - 11 09:55:26.469 + 10:00[INF] End processing HTTP request after 665.8016ms - 500
            //2024 - 09 - 11 09:55:26.492 + 10:00[ERR]---------- RemoteServiceErrorInfo----------
            //{
            //                    "code": null,
            //  "message": "An internal error occurred during your request!",
            //  "details": null,
            //  "data": { },
            //  "validationErrors": null
            //}
    
            //            2024 - 09 - 11 09:55:26.492 + 10:00[ERR] An internal error occurred during your request!
            //Volo.Abp.Http.Client.AbpRemoteCallException: An internal error occurred during your request!
            //   at Volo.Abp.Http.Client.ClientProxying.ClientProxyBase`1.ThrowExceptionForResponseAsync(HttpResponseMessage response)
            //   at Volo.Abp.Http.Client.ClientProxying.ClientProxyBase`1.RequestAsync(ClientProxyRequestContext requestContext)
            //   at Volo.Abp.Http.Client.ClientProxying.ClientProxyBase`1.RequestAsync[T](ClientProxyRequestContext requestContext)
            //   at Volo.Abp.Http.Client.ClientProxying.ClientProxyBase`1.RequestAsync[T](String methodName, ClientProxyRequestTypeValue arguments)
            //   at Volo.Payment.Requests.ClientProxies.PaymentRequestClientProxy.StartAsync(String paymentMethod, PaymentRequestStartDto input)
            //   at Volo.Payment.Stripe.Pages.Payment.Stripe.PrePaymentModel.OnPostAsync()
            //   at Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure.ExecutorFactory.NonGenericTaskHandlerMethod.Execute(Object receiver, Object[] arguments)
            //   at Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure.PageActionInvoker.InvokeHandlerMethodAsync()
            //   at Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure.PageActionInvoker.InvokeNextPageFilterAsync()
            //   at Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure.PageActionInvoker.Rethrow(PageHandlerExecutedContext context)
            //   at Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure.PageActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
            //   at Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure.PageActionInvoker.InvokeInnerFilterAsync()
            //   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeNextExceptionFilterAsync>g__Awaited|26_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
            return LocalRedirectPreserveMethod("/Payment/GatewaySelection?paymentRequestId=" + paymentRequest.Id);
        }
    }
    

    }`

  • User Avatar
    0
    jaylin created

    PaymentRequestService failed at /api/payment/stripe/start the same as above thread.

    [13:28:06 INF] Sending HTTP request POST https://localhost:44330/api/payment/stripe/start?api-version=1.0 [13:28:07 INF] Received HTTP response headers after 968.9722ms - 500 [13:28:07 INF] End processing HTTP request after 969.1742ms - 500 [13:28:07 ERR] ---------- RemoteServiceErrorInfo ---------- { "code": null, "message": "An internal error occurred during your request!", "details": null, "data": {}, "validationErrors": null }

    [13:28:07 ERR] An internal error occurred during your request! Volo.Abp.Http.Client.AbpRemoteCallException: An internal error occurred during your request! at Volo.Abp.Http.Client.ClientProxying.ClientProxyBase1.ThrowExceptionForResponseAsync(HttpResponseMessage response) at Volo.Abp.Http.Client.ClientProxying.ClientProxyBase1.RequestAsync(ClientProxyRequestContext requestContext) at Volo.Abp.Http.Client.ClientProxying.ClientProxyBase1.RequestAsync[T](ClientProxyRequestContext requestContext) at Volo.Abp.Http.Client.ClientProxying.ClientProxyBase1.RequestAsync[T](String methodName, ClientProxyRequestTypeValue arguments) at Volo.Payment.Requests.ClientProxies.PaymentRequestClientProxy.StartAsync(String paymentMethod, PaymentRequestStartDto input) at Volo.Payment.Stripe.Pages.Payment.Stripe.PrePaymentModel.OnPostAsync() at Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure.ExecutorFactory.NonGenericTaskHandlerMethod.Execute(Object receiver, Object[] arguments) at Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure.PageActionInvoker.InvokeHandlerMethodAsync() at Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure.PageActionInvoker.InvokeNextPageFilterAsync() at Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure.PageActionInvoker.Rethrow(PageHandlerExecutedContext context) at Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure.PageActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted) at Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure.PageActionInvoker.InvokeInnerFilterAsync() at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeNextExceptionFilterAsync>g__Awaited|26_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted) [13:28:07 ERR] Code: [13:28:07 ERR] Details: [13:28:07 INF] Executed page /Payment/Stripe/PrePayment in 1007.7672ms [13:28:07 INF] Executed endpoint '/Payment/Stripe/PrePayment' [13:28:07 ERR] An unhandled exception has occurred while executing the request. Volo.Abp.Http.Client.AbpRemoteCallException: An internal error occurred during your request! at Volo.Abp.Http.Client.ClientProxying.ClientProxyBase1.ThrowExceptionForResponseAsync(HttpResponseMessage response) at Volo.Abp.Http.Client.ClientProxying.ClientProxyBase1.RequestAsync(ClientProxyRequestContext requestContext) at Volo.Abp.Http.Client.ClientProxying.ClientProxyBase1.RequestAsync[T](ClientProxyRequestContext requestContext) at Volo.Abp.Http.Client.ClientProxying.ClientProxyBase1.RequestAsync[T](String methodName, ClientProxyRequestTypeValue arguments) at Volo.Payment.Requests.ClientProxies.PaymentRequestClientProxy.StartAsync(String paymentMethod, PaymentRequestStartDto input) at Volo.Payment.Stripe.Pages.Payment.Stripe.PrePaymentModel.OnPostAsync() at Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure.ExecutorFactory.NonGenericTaskHandlerMethod.Execute(Object receiver, Object[] arguments) at Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure.PageActionInvoker.InvokeHandlerMethodAsync() at Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure.PageActionInvoker.InvokeNextPageFilterAsync() at Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure.PageActionInvoker.Rethrow(PageHandlerExecutedContext context) at Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure.PageActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted) at Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure.PageActionInvoker.InvokeInnerFilterAsync() at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeNextExceptionFilterAsync>g__Awaited|26_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted) at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Rethrow(ExceptionContextSealed context) at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted) at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeNextResourceFilter>g__Awaited|25_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted) at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Rethrow(ResourceExecutedContextSealed context) at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted) at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeFilterPipelineAsync>g__Awaited|20_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted) at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeAsync>g__Logged|17_1(ResourceInvoker invoker) at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeAsync>g__Logged|17_1(ResourceInvoker invoker) at Microsoft.AspNetCore.Routing.EndpointMiddleware.<Invoke>g__AwaitRequestTask|7_0(Endpoint endpoint, Task requestTask, ILogger logger) at Volo.Abp.AspNetCore.Serilog.AbpSerilogMiddleware.InvokeAsync(HttpContext context, RequestDelegate next) at Microsoft.AspNetCore.Builder.UseMiddlewareExtensions.InterfaceMiddlewareBinder.<>c__DisplayClass2_0.<<CreateMiddleware>b__0>d.MoveNext() --- End of stack trace from previous location --- at Swashbuckle.AspNetCore.SwaggerUI.SwaggerUIMiddleware.Invoke(HttpContext httpContext) at Swashbuckle.AspNetCore.Swagger.SwaggerMiddleware.Invoke(HttpContext httpContext, ISwaggerProvider swaggerProvider) at Microsoft.AspNetCore.Authorization.AuthorizationMiddleware.Invoke(HttpContext context) at Volo.Abp.AspNetCore.Security.Claims.AbpDynamicClaimsMiddleware.InvokeAsync(HttpContext context, RequestDelegate next) at Microsoft.AspNetCore.Builder.UseMiddlewareExtensions.InterfaceMiddlewareBinder.<>c__DisplayClass2_0.<<CreateMiddleware>b__0>d.MoveNext() --- End of stack trace from previous location --- at Volo.Abp.AspNetCore.MultiTenancy.MultiTenancyMiddleware.InvokeAsync(HttpContext context, RequestDelegate next) at Microsoft.AspNetCore.Builder.UseMiddlewareExtensions.InterfaceMiddlewareBinder.<>c__DisplayClass2_0.<<CreateMiddleware>b__0>d.MoveNext() --- End of stack trace from previous location --- at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.Invoke(HttpContext context) at Volo.Abp.AspNetCore.Security.AbpSecurityHeadersMiddleware.InvokeAsync(HttpContext context, RequestDelegate next) at Microsoft.AspNetCore.Builder.UseMiddlewareExtensions.InterfaceMiddlewareBinder.<>c__DisplayClass2_0.<<CreateMiddleware>b__0>d.MoveNext() --- End of stack trace from previous location --- at Volo.Abp.Studio.Client.AspNetCore.AbpStudioMiddleware.InvokeAsync(HttpContext context, RequestDelegate next) at Volo.Abp.Studio.Client.AspNetCore.AbpStudioMiddleware.InvokeAsync(HttpContext context, RequestDelegate next) at Volo.Abp.Studio.Client.AspNetCore.AbpStudioMiddleware.InvokeAsync(HttpContext context, RequestDelegate next) at Microsoft.AspNetCore.Builder.UseMiddlewareExtensions.InterfaceMiddlewareBinder.<>c__DisplayClass2_0.<<CreateMiddleware>b__0>d.MoveNext() --- End of stack trace from previous location --- at Microsoft.AspNetCore.Localization.RequestLocalizationMiddleware.Invoke(HttpContext context) at Microsoft.AspNetCore.RequestLocalization.AbpRequestLocalizationMiddleware.InvokeAsync(HttpContext context, RequestDelegate next) at Microsoft.AspNetCore.Builder.UseMiddlewareExtensions.InterfaceMiddlewareBinder.<>c__DisplayClass2_0.<<CreateMiddleware>b__0>d.MoveNext() --- End of stack trace from previous location --- at Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddlewareImpl.Invoke(HttpContext context) [13:28:07 INF] Request finished HTTP/2 POST https://localhost:44380/Payment/Stripe/PrePayment?paymentRequestId=a23c0f0e-62ca-9eab-78fc-3a14f14c5b60 - 500 null text/html; charset=utf-8 1097.2184ms

        public virtual async Task&lt;IActionResult&gt; OnPost()
        {
            var planId = new Guid("158c0405-7d7b-782b-6134-3a14e2d52556");
            var paymentRequest = await PaymentRequestAppService.CreateAsync(
                new PaymentRequestCreateDto()
                {
                    Products =
                    {
                        new PaymentRequestProductCreateDto
                        {
                            PaymentType = PaymentType.Subscription,
                            Name = "Enterprise Plan",
                            Code = "EP",
                            Count = 1,
                            // Place your created PlanId below.
                            PlanId = planId
                        }
                    }
                });
                return LocalRedirectPreserveMethod("/Payment/GatewaySelection?paymentRequestId=" + paymentRequest.Id);
        }
    
  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi,

    I have replied via email and I'm posting my reply here so other developers can benefit from it;

    1. You need to configure PaymentWebOptions as shown below in the PreConfigureServices method of your TestWebModule. var configuration = context.Services.GetConfiguration();
    Configure<PaymentWebOptions>(options =>
    {
     options.RootUrl = configuration["App:SelfUrl"];
     options.CallbackUrl = configuration["App:SelfUrl"] + "/PaymentSucceed";
    });
    
    1. Then, instead of using product_id from Stripe, you need to use price_id and set it to ExternalId of GatewayPlan.

    1. And finally, you need to set PaymentMethodTypes to empty in appsettings.json because PaymentModule already adds card type to this list;
    "PaymentMethodTypes": []
    

    Please note that, if the payment is successful, the user will be redirected to CallbackUrl endpoint you have configured.For subscriptions, you can use Stripe CLI to get Webhook requests in your development environment.

  • User Avatar
    0
    jaylin created

    Thanks ismcagdas, really appreciated!!!

    // 1. Run as Tenant Admin - still not working failed at CreateSubscriptionAsync (403 Fibidden) var currentTenantId = CurrentTenant.GetId(); var currentPaymentRequest = await SubscriptionAppService.CreateSubscriptionAsync(editionId, currentTenantId);

    // 2. Run as Host Admin - it works, but not ideal, Tenant Admin should pay the subscription var tenantId = new Guid("9374a261-f7c5-4c4c-ba88-3a14e2feb5d1"); var paymentRequest = await SubscriptionAppService.CreateSubscriptionAsync(editionId, tenantId); // 3. Run as Tenant Admin - it works var planId = new Guid("158c0405-7d7b-782b-6134-3a14e2d52556"); var paymentRequest = await PaymentRequestAppService.CreateAsync(new PaymentRequestCreateDto() { ...... }); return LocalRedirectPreserveMethod("/Payment/GatewaySelection?paymentRequestId=" + paymentRequest.Id);

    Note for future, in case it can help someone who might face the same problem.

    After install Payment module, it added Volo.Payment.XXX and Volo.Payment.Admin.XXX nuget packages to these projects and [DependsOn] in XXXModule.cs:

    1. Application
    2. Application.Contracts
    3. HttpApi
    4. HttpApi.Client

    Volo.Payment.XXX and Volo.Payment.Stripe.XXX to these projects and [DependsOn] in XXXModule.cs

    1. Domain
    2. Domain.Shared

    Volo.Payment.XXX, Volo.Payment.Admin.XXX and Volo.Payment.Stripe.XXX to the project and [DependsOn] in XXXModule.cs

    1. Web (MVC)

    Volo.Payment.EntityFrameworkCore to EntityFrameworkCore project and some file changes:

    1. builder.ConfigurePayment() in DbContext.cs
    2. [DependsOn] in EntityFrameworkCoreModule
    3. EF Code First Migrations

    Manual steps:

    1. Added IsPaymentSupported in XXXModule.cs to HttpApi.Host project Configure<AbpSaasPaymentOptions>(options => { options.IsPaymentSupported = true; });

    2. Added Payment Stripe in appsettings.json to HttpApi.Host project "Payment": { "Stripe": { "PublishableKey": "pk_xxxx", "SecretKey": "sk_xxx" , "WebhookSecret": "whsec_xxx", "PaymentMethodTypes": [] // card has already been added } }

    3. Added PaymentWebOptions to PreConfigureServices in XXXWebModule to Web project public override void PreConfigureServices(ServiceConfigurationContext context) { ......

       **var configuration = context.Services.GetConfiguration();
       Configure&lt;PaymentWebOptions&gt;(options =>
       {
           options.RootUrl = configuration["App:SelfUrl"];
           options.CallbackUrl = configuration["App:SelfUrl"] + "/PaymentSucceed";
       });**
      

      }

    4. Added Subscribe.cshtml to Web project to allow Tenant subscribe to an Edition.

    I will work on Angular version, and post the configuration once done.

  • User Avatar
    0
    ismcagdas created
    Support Team

    still not working failed at CreateSubscriptionAsync (403 Fibidden)

    You should run this process as a host user because if the TenantId is in session, it can't access Edition info with the current design. But, I agree with you, a Tenant user should be able to execute this process as well. We will think about changing this restriction.

  • User Avatar
    0
    jaylin created

    I have made the Angular working. NOTE: The "subscribe" page is implemented in AuthServer (MVC Razor) because payment gateway (Stripe) prepayment is ABP's out-of-box feature, I don't want to reinvent the wheels, I did some reverse engineering though.

    Similar to MVC, after installing Payment module, it added Volo.Payment.XXX and Volo.Payment.Admin.XXX nuget packages to these XXX projects and [DependsOn] in XXXModule.cs:

    1. Application
    2. Application.Contracts
    3. HttpApi
    4. HttpApi.Client

    Volo.Payment.XXX and Volo.Payment.Stripe.XXX to these XXX projects and [DependsOn] in XXXModule.cs

    1. Domain
    2. Domain.Shared

    As described in the document, @volo/abp.ng.payment package is needed to manage payment in Angular Admin UI.

    1. Include payment route in app-routing.module.ts
    2. Include PaymentAdminConfigModule in app.module.ts.

    Volo.Payment.EntityFrameworkCore to EntityFrameworkCore project and some file changes:

    1. builder.ConfigurePayment() in DbContext.cs
    2. [DependsOn] in EntityFrameworkCoreModule
    3. EF Code First Migrations

    Manual steps:

    1. Added IsPaymentSupported in XXXModule.cs to HttpApi.Host project Configure<AbpSaasPaymentOptions>(options => { options.IsPaymentSupported = true; });

    2. Added Payment Stripe in appsettings.json to HttpApi.Host project "Payment": { "Stripe": { "PublishableKey": "pk_xxxx", "SecretKey": "sk_xxx" , "WebhookSecret": "whsec_xxx", "PaymentMethodTypes": [] // card has already been added } }

    3. Added PaymentWebOptions to PreConfigureServices in XXXAuthServerModule to AuthServer project. public override void PreConfigureServices(ServiceConfigurationContext context) { ...... var configuration = context.Services.GetConfiguration(); Configure<PaymentWebOptions>(options => { options.RootUrl = configuration["App:SelfUrl"]; options.CallbackUrl = configuration["App:SelfUrl"] + "/PaymentSucceed"; }); }

    4. Added Volo.Payment.Stripe.Web and Volo.Payment.Web nuget packages to AuthServer project - to route to out-of-box prepayment. It added AbpPaymentStripeWebModule and AbpPaymentWebModule [DependsOn] in XXXAuthServerModule.

    5. Added HttpApi.Client.csproj and HttpApi.csproj projects to AuthServer project - to inject IPaymentRequestAppService in Subscribe page.

    6. Added Subscribe.cshtml to AuthServer project to allow Tenant subscribe to an Edition. However, Tenant Admin doesn't have permission to call create subscription API as per the above thread by ismcagdas.
      I did bypass "await SubscriptionAppService.CreateSubscriptionAsync(editionId, currentTenantId)" by calling PaymentRequestAppService.

      public class SubscribeModel : PageModel { private IPaymentRequestAppService PaymentRequestAppService { get; } private ICurrentTenant CurrentTenant { get; }

       public SubscribeModel(
           IPaymentRequestAppService paymentRequestAppService,
           ICurrentTenant currentTenant)
       {
           PaymentRequestAppService = paymentRequestAppService;
           CurrentTenant = currentTenant;
       }
      
       public virtual async Task&lt;IActionResult&gt; OnPost(Guid planId, Guid editionId)
       {
           // PaymentRequestProductDto can't edit ExtraProperties
           var paymentRequest = await PaymentRequestAppService.CreateAsync(
               new CustomPaymentRequestCreateDto(new ExtraPropertyDictionary() {
                   { "EditionId", editionId },
                   { "TenantId", CurrentTenant.Id }
               })
               {
                   Products =
                   {
                       new PaymentRequestProductCreateDto
                       {
                           PaymentType = PaymentType.Subscription,
                           Name = "Standard",
                           Code = $"{CurrentTenant.Id}_{planId}",
                           Count = 1,
                           PlanId = planId
                       }
                   }
               });
      
           return LocalRedirectPreserveMethod("/Payment/GatewaySelection?paymentRequestId=" + paymentRequest.Id);
       }
      

      }

      public class CustomPaymentRequestCreateDto : PaymentRequestCreateDto { public CustomPaymentRequestCreateDto(ExtraPropertyDictionary extraProperties) { ExtraProperties = extraProperties; } }

    Because PayPaymentRequests.ExtraProperties (e.g. TenantId) will be used by Stripe Webhook to update SaasTenants.EditionEndDateUtc.

    Hope this thread is useful to someone in the future.

Made with ❤️ on ABP v9.1.0-preview. Updated on November 20, 2024, 13:06