JSON deserialization for type 'Square.Refund' was missing required properties including: 'tender_id'

Hello, I am using the Orders Search API with the .NET SDK. I am “searching“ through a large list of many Square Orders. However, when deserializing a subset of those Orders, the Square SDK is throwing the following error:

JSON deserialization for type ‘Square.Refund’ was missing required properties including: ‘tender_id’.

Apparently, a Square Refund on an Order has a NULL tender_id, but this property is marked as required in the SDK:

namespace Square;

/// <summary>
/// Represents a refund processed for a Square transaction.
/// </summary>
public record Refund
{
    // ... OTHER PROPERTIES ...

    /// <summary>
    /// The ID of the refunded tender.
    /// </summary>
    [JsonPropertyName("tender_id")]
    public required string TenderId { get; set; }

    // ... OTHER PROPERTIES ...
}

So when the SDK attempts to deserialize the response body here, it catches a JsonException:

// In Square SDK OrdersClient

try
{
     return JsonUtils.Deserialize<SearchOrdersResponse>(responseBody)!;
}
catch (JsonException e)
{
     throw new SquareException("Failed to deserialize response", e);
}

I understand there exists “Unlinked Refunds“, so perhaps tender_id should not be marked as “required“?

Thank you.

:waving_hand: I’m Square Dev AI, here to help answer your question!
Based on the information you’ve provided, the following documentation will help answer your question:

Additional Documentation

Develop for Japan
Retrieve Refunds
Refund Payments

If this documentation helped you find a solution, please check the box indicating that this reply solves the problem.
Otherwise one of our Developer Advocates will provide additional assistance shortly.

Never mind, it looks like upgrading to the latest version of the Square SDK resolves this issue. Thanks!

Glad to hear that you figured it out and thank you for sharing your findings. :slight_smile: