sveawebpay/svea-sdk-dotnet

Not able to fetch order if payment type is leasing

Closed this issue · 2 comments

In the following row it defined that the payment type for leasing is LEASINGMANUAL

In the json-response for a leasing order we instead got the payment type as LEASING

{
    "Gui": {
        "Layout": "desktop",
        "Snippet": "...reducted..."
    },
    "MerchantSettings": {
        "CheckoutValidationCallBackUri": "https://...reducted.../api/svea/7e1b794a-9f6c-4485-9191-be935c41d706/validation",
        "PushUri": "https://...reducted.../api/svea/7e1b794a-9f6c-4485-9191-be935c41d706/pushNotification?order_id={checkout.order.uri}",
        "WebhookUri": "",
        "TermsUri": "https://...reducted.../api/svea/7e1b794a-9f6c-4485-9191-be935c41d706/terms",
        "CheckoutUri": "https://...reducted.../api/svea/7e1b794a-9f6c-4485-9191-be935c41d706/checkout",
        "ConfirmationUri": "https://...reducted.../api/svea/7e1b794a-9f6c-4485-9191-be935c41d706/confirmation",
        "ActivePartPaymentCampaigns": [],
        "PromotedPartPaymentCampaign": 0
    },
    "Cart": {
        "Items": [
            {
                "ArticleNumber": "DirectShipment:standardPackage",
                "Name": "DirectShipment:standardPackage",
                "Quantity": 100,
                "UnitPrice": 299875,
                "DiscountPercent": 0,
                "DiscountAmount": 0,
                "VatPercent": 2500,
                "Unit": null,
                "TemporaryReference": null,
                "RowNumber": 2,
                "MerchantData": null,
                "ShippingInformation": null,
                "RowType": "Row"
            },
            {
                "ArticleNumber": "E0001",
                "Name": "Ramställning 3x4,5m ALU",
                "Quantity": 100,
                "UnitPrice": 1601280,
                "DiscountPercent": 0,
                "DiscountAmount": 0,
                "VatPercent": 2500,
                "Unit": "st",
                "TemporaryReference": null,
                "RowNumber": 1,
                "MerchantData": null,
                "ShippingInformation": null,
                "RowType": "Row"
            }
        ]
    },
    "Customer": {
        "Id": 39298,
        "NationalId": "165590326186",
        "CountryCode": "SE",
        "IsCompany": true,
        "VatNumber": null
    },
    "ShippingAddress": {
        "FullName": "Codify Venture Capital AB",
        "FirstName": null,
        "LastName": null,
        "StreetAddress": "Djupviksvägen 66",
        "StreetAddress2": null,
        "StreetAddress3": null,
        "CoAddress": null,
        "PostalCode": "26186",
        "City": "Ludvika",
        "CountryCode": "SE",
        "IsGeneric": false,
        "AddressLines": []
    },
    "BillingAddress": {
        "FullName": "Codify Venture Capital AB",
        "FirstName": null,
        "LastName": null,
        "StreetAddress": "Djupviksvägen 66",
        "StreetAddress2": null,
        "StreetAddress3": null,
        "CoAddress": null,
        "PostalCode": "26186",
        "City": "Ludvika",
        "CountryCode": "SE",
        "IsGeneric": false,
        "AddressLines": []
    },
    "Locale": "sv-SE",
    "Currency": "SEK",
    "CountryCode": "SE",
    "ClientOrderNumber": "...reducted...",
    "OrderId": 8793809,
    "EmailAddress": "...reducted...",
    "PhoneNumber": "...reducted...",
    "PaymentType": "LEASING",
    "Payment": {
        "PaymentMethodType": "Leasing"
    },
    "Status": "Final",
    "CustomerReference": "testref",
    "SveaWillBuyOrder": null,
    "IdentityFlags": null,
    "MerchantData": null,
    "PeppolId": null,
    "ShippingInformation": null
}

This will end up in the following exception

The JSON value could not be converted to Svea.WebPay.SDK.CheckoutApi.Data. Path: $.PaymentType | LineNumber: 0 | BytePositionInLine: 3639. System.Text.Json.JsonException    at System.Text.Json.ThrowHelper.ThrowJsonException(String message)
   at System.Text.Json.Serialization.Converters.EnumConverter`1.ReadAsPropertyNameCore(Utf8JsonReader& reader, Type typeToConvert, JsonSerializerOptions options)
   at System.Text.Json.Serialization.Converters.EnumConverter`1.Read(Utf8JsonReader& reader, Type typeToConvert, JsonSerializerOptions options)
   at System.Text.Json.Serialization.Converters.NullableConverter`1.Read(Utf8JsonReader& reader, Type typeToConvert, JsonSerializerOptions options)
   at System.Text.Json.Serialization.JsonConverter`1.TryRead(Utf8JsonReader& reader, Type typeToConvert, JsonSerializerOptions options, ReadStack& state, T& value)
   at System.Text.Json.Serialization.JsonConverter`1.TryReadAsObject(Utf8JsonReader& reader, JsonSerializerOptions options, ReadStack& state, Object& value)
   at System.Text.Json.Serialization.Converters.LargeObjectWithParameterizedConstructorConverter`1.ReadAndCacheConstructorArgument(ReadStack& state, Utf8JsonReader& reader, JsonParameterInfo jsonParameterInfo)
   at System.Text.Json.Serialization.Converters.ObjectWithParameterizedConstructorConverter`1.OnTryRead(Utf8JsonReader& reader, Type typeToConvert, JsonSerializerOptions options, ReadStack& state, T& value)
   at System.Text.Json.Serialization.JsonConverter`1.TryRead(Utf8JsonReader& reader, Type typeToConvert, JsonSerializerOptions options, ReadStack& state, T& value)
   at System.Text.Json.Serialization.JsonConverter`1.ReadCore(Utf8JsonReader& reader, JsonSerializerOptions options, ReadStack& state)
   at System.Text.Json.JsonSerializer.ReadFromSpan[TValue](ReadOnlySpan`1 utf8Json, JsonTypeInfo jsonTypeInfo, Nullable`1 actualByteCount)
   at System.Text.Json.JsonSerializer.ReadFromSpan[TValue](ReadOnlySpan`1 json, JsonTypeInfo jsonTypeInfo)
   at System.Text.Json.JsonSerializer.Deserialize[TValue](String json, JsonSerializerOptions options)
   at Svea.WebPay.SDK.SveaHttpClient.SendHttpRequestAndProcessHttpResponse[TResponse](HttpRequestMessage httpRequest, Boolean configureAwait)

Repro steps

  1. Create order Checkout.CreateOrder(payload)-method.
  2. Render html-snippet to the client.
  3. Place an order with the LEASING payment type.
  4. User will be redirected to the confirmation URL.
  5. In the confirmation endpoint try to fetch the order Checkout.GetOrder(orderId)

Expected: Get the order from for the ckeckout to be able to validate the status on the order.
Actual: When the Checkout.GetOrder(orderId) should deserialize the response the above exception is thrown.

@Tasteful Please add steps to reproduce.

@Tasteful Fixed in v3.1.0