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.
