Base solution for your next web application
Starts in:
01 DAYS
01 HRS
01 MIN
01 SEC
Open Closed

Stripe and Invoice Changes/Issues #11503


User avatar
0
exaas created

Version: ASP.NET Core MVC & jQuery version 12.0.1

Looks like there are some changes required for Stripe integration to work. Stripe updated their API so line_items no longer work: https://stripe.com/docs/upgrades#2022-08-01

StripePaymentAppService.cs lines 188-192

                        Amount = (long) _stripeGatewayManager.ConvertToStripePrice(payment.Amount),
                        Name = StripeGatewayManager.ProductName,
                        Currency = myProjectConsts.Currency,
                        Description = payment.Description,
                        Quantity = 1

I changed them to this:

                        //Price = _stripeGatewayManager.ConvertToStripePrice(payment.Amount).ToString(),
                        PriceData  = new SessionLineItemPriceDataOptions()
                        {
                            UnitAmount = _stripeGatewayManager.ConvertToStripePrice(payment.Amount),
                            Currency = myProjectConsts.Currency,                 
                            ProductData = new SessionLineItemPriceDataProductDataOptions()
                            {
                                Name= StripeGatewayManager.ProductName,
                                Description = payment.Description
                            },
                        },
                        //Amount = (long) _stripeGatewayManager.ConvertToStripePrice(payment.Amount),
                        //Name = StripeGatewayManager.ProductName,
                        //Currency = myProjectConsts.Currency,
                        //Description = payment.Description,
                        Quantity = 1,

Also on line 161 I added Mode:

            {
                Mode = "payment",
                PaymentMethodTypes = paymentTypes,
                SuccessUrl = input.SuccessUrl + (input.SuccessUrl.Contains("?") ? "&" : "?") +
                             "sessionId={CHECKOUT_SESSION_ID}",
                CancelUrl = input.CancelUrl
            };

Those changes seemed to allow me to use Stripe, but during testing I was provided a new error message.

In the US, we do not use Tax/VATNo for most transactions, and never for personal transactions. In this case, someone simply signing up for service as a user, not a business.

What can be done here to avoid this error? I am thinking just modify the existing code for InvoiceAppService to exclude Tax info and passing the users name and address from Stripe, but I wasn't sure if I was missing something that may make this a bit easier...like a const setting perhaps?

Thoughts?


3 Answer(s)
  • User Avatar
    0
    exaas created

    Found the Stripe fix on the github: https://github.com/aspnetzero/aspnet-zero-core/pull/4753/files/5e80799f97a0b3854f417f32a092559cc1a13c8a

    That helps.

  • User Avatar
    0
    exaas created

    I implemented the changes per github, but during testing with Stripe, it gets to the receiving payment result and never completes. I stripe I continues to create a new user each time it checks payment status:

    I am going to try this live to see if i get a different result.

  • User Avatar
    0
    exaas created

    Found the issue, I was confused about the minimum payment amount and how it worked.

    Default is set to what looks like $1million (1M): https://docs.aspnetzero.com/en/aspnet-core-mvc/latest/Features-Mvc-Core-Subscription

    I changed this to "50", which is Stripe's minimum accepted payment amount (for testing), and the transaction completed and activated the account.

    I am still confused about how to handle the Tax/VATNo for the US users that are not businesses, but I will ask this in a new/different thread.

    Thanks.