Skip to content

PayPal payment completed but order not created due to FormatException in Login.cshtml #1511

@sydesoft

Description

@sydesoft

PayPal payment completed but order not created due to FormatException in Login.cshtml

Smartstore Version: 5.1.0


Describe the bug

A customer completed a PayPal payment successfully (money was debited from their PayPal account), but no corresponding order was created in the Smartstore backend. The order is either missing entirely or was never persisted.

The application log from the same time shows a System.FormatException in Views/Identity/Login.cshtml (line 96), caused by the BooleanConverter failing to parse the string "1" as a valid Boolean value. This exception is thrown during checkbox rendering (GenerateCheckBox) via SmartHtmlGenerator.GenerateInput.

It appears that the FormatException crashes the request that processes the PayPal return/callback, which prevents the OrderProcessingService from finalizing the order.

Steps to reproduce

  1. Add a product to the cart
  2. Proceed to checkout and select PayPal as payment method
  3. Complete payment on PayPal side
  4. Get redirected back to the shop
  5. The redirect triggers a request that renders Login.cshtml, where a checkbox field (likely "Remember me") receives the value "1" instead of "true" in ModelState
  6. FormatException is thrown → order processing is interrupted
  7. Payment is completed on PayPal's side, but no order exists in Smartstore

Expected behavior

  • The FormatException should not occur — SmartHtmlGenerator should handle non-standard boolean values like "1" and "0" gracefully (this is a known ASP.NET Core issue: dotnet/aspnetcore#55512)
  • Even if an exception occurs during page rendering, the PayPal order finalization (via webhook or return URL callback) should not be affected by unrelated view rendering errors
  • The order should be created and persisted regardless of non-critical UI errors

Stack trace

System.FormatException: 1 is not a valid value for Boolean.
 ---> System.FormatException: String '1' was not recognized as a valid Boolean.
   at System.Boolean.Parse(ReadOnlySpan`1 value)
   at System.ComponentModel.BooleanConverter.ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, Object value)
   --- End of inner exception stack trace ---
   at System.ComponentModel.BooleanConverter.ConvertFrom(...)
   at Microsoft.AspNetCore.Mvc.ModelBinding.ModelBindingHelper.ConvertSimpleType(...)
   at Microsoft.AspNetCore.Mvc.ViewFeatures.DefaultHtmlGenerator.GetModelStateValue(...)
   at Microsoft.AspNetCore.Mvc.ViewFeatures.DefaultHtmlGenerator.GenerateInput(...)
   at Smartstore.Web.Rendering.SmartHtmlGenerator.GenerateInput(...)
   at Microsoft.AspNetCore.Mvc.ViewFeatures.DefaultHtmlGenerator.GenerateCheckBox(...)
   at Microsoft.AspNetCore.Mvc.TagHelpers.InputTagHelper.GenerateCheckBox(...)
   at Microsoft.AspNetCore.Mvc.TagHelpers.InputTagHelper.Process(...)
   ...
   at AspNetCore.Views_Identity_Login.<ExecuteAsync>b__32_1()
     in Views\Identity\Login.cshtml:line 96

(Full stack trace available upon request.)

Impact

  • Customer was charged via PayPal but received no order confirmation
  • The order does not appear in the Smartstore admin panel
  • This likely affects any checkout flow where the PayPal return coincides with a request that renders a Boolean checkbox from ModelState containing the value "1"

Suggested fix

  1. SmartHtmlGenerator: Override GetModelStateValue or wrap the GenerateCheckBox call with a try-catch to handle FormatException gracefully — e.g., treat "1" as true and "0" as false
  2. PayPal module: Ensure that order finalization (capture confirmation / webhook processing) is decoupled from view rendering, so that a rendering error cannot prevent the order from being persisted

Related issues

Environment

  • Smartstore version: 5.1.0
  • Payment method: PayPal (via Smartstore PayPal module)
  • Hosting: IIS (C:\inetpub\wwwroot\...)

Metadata

Metadata

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions