From d6b784c74954154e31b1d10f1f75b72658435bbe Mon Sep 17 00:00:00 2001 From: Hootan Hemmati Date: Sat, 14 Sep 2024 02:45:12 +0330 Subject: [PATCH] Support JSON serialization with System.Text.Json Fixes #2495 Add support for JSON serialization with System.Text.Json. * Add `JsonSerializer` interface and implement `NewtonsoftJsonSerializer` and `SystemTextJsonSerializer` classes in `src/Stripe.net/Infrastructure/JsonSerializer.cs`. * Update `StripeEntity` class in `src/Stripe.net/Entities/_base/StripeEntity.cs` to use the `JsonSerializer` interface for `ToJson` and `FromJson` methods. * Replace `Newtonsoft.Json` attributes with `System.Text.Json` attributes in `src/Stripe.net/Entities/Customers/Customer.cs`, `src/Stripe.net/Entities/_common/Address.cs`, `src/Stripe.net/Entities/_common/AddressJapan.cs`, `src/Stripe.net/Entities/_common/Shipping.cs`, `src/Stripe.net/Entities/AccountLinks/AccountLink.cs`, and `src/Stripe.net/Entities/Accounts/Account.cs`. * Add conditional compilation to use appropriate attributes based on the selected JSON serializer in the above files. --- .../Entities/AccountLinks/AccountLink.cs | 23 ++- src/Stripe.net/Entities/Accounts/Account.cs | 98 ++++++++- .../Accounts/AccountBusinessProfile.cs | 49 ++++- .../AccountBusinessProfileAnnualRevenue.cs | 17 +- ...tBusinessProfileMonthlyEstimatedRevenue.cs | 13 +- .../Entities/Accounts/AccountCapabilities.cs | 193 +++++++++++++++++- .../Entities/Accounts/AccountCompany.cs | 77 ++++++- .../AccountCompanyOwnershipDeclaration.cs | 18 +- .../Accounts/AccountCompanyVerification.cs | 9 +- .../AccountCompanyVerificationDocument.cs | 39 +++- .../Entities/Accounts/AccountController.cs | 29 ++- .../Accounts/AccountControllerFees.cs | 9 +- .../Accounts/AccountControllerLosses.cs | 9 +- .../AccountControllerStripeDashboard.cs | 9 +- .../Accounts/AccountFutureRequirements.cs | 38 +++- src/Stripe.net/Entities/Customers/Customer.cs | 140 ++++++++++++- src/Stripe.net/Entities/_base/StripeEntity.cs | 17 +- src/Stripe.net/Entities/_common/Address.cs | 28 +++ .../Entities/_common/AddressJapan.cs | 8 + src/Stripe.net/Entities/_common/Shipping.cs | 24 +++ .../Infrastructure/JsonSerializer.cs | 49 +++++ 21 files changed, 876 insertions(+), 20 deletions(-) create mode 100644 src/Stripe.net/Infrastructure/JsonSerializer.cs diff --git a/src/Stripe.net/Entities/AccountLinks/AccountLink.cs b/src/Stripe.net/Entities/AccountLinks/AccountLink.cs index 8bacf57d3e..909d8d3841 100644 --- a/src/Stripe.net/Entities/AccountLinks/AccountLink.cs +++ b/src/Stripe.net/Entities/AccountLinks/AccountLink.cs @@ -1,8 +1,11 @@ -// File generated from our OpenAPI spec namespace Stripe { using System; +#if USE_SYSTEM_TEXT_JSON + using System.Text.Json.Serialization; +#else using Newtonsoft.Json; +#endif using Stripe.Infrastructure; /// @@ -17,27 +20,45 @@ public class AccountLink : StripeEntity, IHasObject /// /// String representing the object's type. Objects of the same type share the same value. /// +#if USE_SYSTEM_TEXT_JSON + [JsonPropertyName("object")] +#else [JsonProperty("object")] +#endif public string Object { get; set; } /// /// Time at which the object was created. Measured in seconds since the Unix epoch. /// +#if USE_SYSTEM_TEXT_JSON + [JsonPropertyName("created")] + [JsonConverter(typeof(UnixDateTimeConverter))] +#else [JsonProperty("created")] [JsonConverter(typeof(UnixDateTimeConverter))] +#endif public DateTime Created { get; set; } = Stripe.Infrastructure.DateTimeUtils.UnixEpoch; /// /// The timestamp at which this account link will expire. /// +#if USE_SYSTEM_TEXT_JSON + [JsonPropertyName("expires_at")] + [JsonConverter(typeof(UnixDateTimeConverter))] +#else [JsonProperty("expires_at")] [JsonConverter(typeof(UnixDateTimeConverter))] +#endif public DateTime ExpiresAt { get; set; } = Stripe.Infrastructure.DateTimeUtils.UnixEpoch; /// /// The URL for the account link. /// +#if USE_SYSTEM_TEXT_JSON + [JsonPropertyName("url")] +#else [JsonProperty("url")] +#endif public string Url { get; set; } } } diff --git a/src/Stripe.net/Entities/Accounts/Account.cs b/src/Stripe.net/Entities/Accounts/Account.cs index 08db84c0eb..8198fd1bcd 100644 --- a/src/Stripe.net/Entities/Accounts/Account.cs +++ b/src/Stripe.net/Entities/Accounts/Account.cs @@ -1,9 +1,12 @@ -// File generated from our OpenAPI spec namespace Stripe { using System; using System.Collections.Generic; +#if USE_SYSTEM_TEXT_JSON + using System.Text.Json.Serialization; +#else using Newtonsoft.Json; +#endif using Stripe.Infrastructure; /// @@ -29,19 +32,31 @@ public class Account : StripeEntity, IHasId, IHasMetadata, IHasObject, /// /// Unique identifier for the object. /// +#if USE_SYSTEM_TEXT_JSON + [JsonPropertyName("id")] +#else [JsonProperty("id")] +#endif public string Id { get; set; } /// /// String representing the object's type. Objects of the same type share the same value. /// +#if USE_SYSTEM_TEXT_JSON + [JsonPropertyName("object")] +#else [JsonProperty("object")] +#endif public string Object { get; set; } /// /// Business information about the account. /// +#if USE_SYSTEM_TEXT_JSON + [JsonPropertyName("business_profile")] +#else [JsonProperty("business_profile")] +#endif public AccountBusinessProfile BusinessProfile { get; set; } /// @@ -54,35 +69,64 @@ public class Account : StripeEntity, IHasId, IHasMetadata, IHasObject, /// One of: company, government_entity, individual, or /// non_profit. /// +#if USE_SYSTEM_TEXT_JSON + [JsonPropertyName("business_type")] +#else [JsonProperty("business_type")] +#endif public string BusinessType { get; set; } +#if USE_SYSTEM_TEXT_JSON + [JsonPropertyName("capabilities")] +#else [JsonProperty("capabilities")] +#endif public AccountCapabilities Capabilities { get; set; } /// /// Whether the account can create live charges. /// +#if USE_SYSTEM_TEXT_JSON + [JsonPropertyName("charges_enabled")] +#else [JsonProperty("charges_enabled")] +#endif public bool ChargesEnabled { get; set; } +#if USE_SYSTEM_TEXT_JSON + [JsonPropertyName("company")] +#else [JsonProperty("company")] +#endif public AccountCompany Company { get; set; } +#if USE_SYSTEM_TEXT_JSON + [JsonPropertyName("controller")] +#else [JsonProperty("controller")] +#endif public AccountController Controller { get; set; } /// /// The account's country. /// +#if USE_SYSTEM_TEXT_JSON + [JsonPropertyName("country")] +#else [JsonProperty("country")] +#endif public string Country { get; set; } /// /// Time at which the account was connected. Measured in seconds since the Unix epoch. /// +#if USE_SYSTEM_TEXT_JSON + [JsonPropertyName("created")] + [JsonConverter(typeof(UnixDateTimeConverter))] +#else [JsonProperty("created")] [JsonConverter(typeof(UnixDateTimeConverter))] +#endif public DateTime Created { get; set; } = Stripe.Infrastructure.DateTimeUtils.UnixEpoch; /// @@ -90,13 +134,21 @@ public class Account : StripeEntity, IHasId, IHasMetadata, IHasObject, /// must be a currency that Stripe supports in the /// account's country. /// +#if USE_SYSTEM_TEXT_JSON + [JsonPropertyName("default_currency")] +#else [JsonProperty("default_currency")] +#endif public string DefaultCurrency { get; set; } /// /// Whether this object is deleted or not. /// +#if USE_SYSTEM_TEXT_JSON + [JsonPropertyName("deleted")] +#else [JsonProperty("deleted", NullValueHandling = NullValueHandling.Ignore)] +#endif public bool? Deleted { get; set; } /// @@ -106,14 +158,22 @@ public class Account : StripeEntity, IHasId, IHasMetadata, IHasObject, /// href="https://stripe.com/connect/onboarding">an onboarding flow to finish submitting /// account details. /// +#if USE_SYSTEM_TEXT_JSON + [JsonPropertyName("details_submitted")] +#else [JsonProperty("details_submitted")] +#endif public bool DetailsSubmitted { get; set; } /// /// An email address associated with the account. It's not used for authentication and /// Stripe doesn't market to this field without explicit approval from the platform. /// +#if USE_SYSTEM_TEXT_JSON + [JsonPropertyName("email")] +#else [JsonProperty("email")] +#endif public string Email { get; set; } /// @@ -121,10 +181,18 @@ public class Account : StripeEntity, IHasId, IHasMetadata, IHasObject, /// External accounts are only returned for requests where controller[is_controller] /// is true. /// +#if USE_SYSTEM_TEXT_JSON + [JsonPropertyName("external_accounts")] +#else [JsonProperty("external_accounts")] +#endif public StripeList ExternalAccounts { get; set; } +#if USE_SYSTEM_TEXT_JSON + [JsonPropertyName("future_requirements")] +#else [JsonProperty("future_requirements")] +#endif public AccountFutureRequirements FutureRequirements { get; set; } /// @@ -142,7 +210,11 @@ public class Account : StripeEntity, IHasId, IHasMetadata, IHasObject, /// href="https://stripe.com/connect/handling-api-verification#person-information">handling /// identity verification with the API. /// +#if USE_SYSTEM_TEXT_JSON + [JsonPropertyName("individual")] +#else [JsonProperty("individual")] +#endif public Person Individual { get; set; } /// @@ -150,25 +222,45 @@ public class Account : StripeEntity, IHasId, IHasMetadata, IHasObject, /// attach to an object. This can be useful for storing additional information about the /// object in a structured format. /// +#if USE_SYSTEM_TEXT_JSON + [JsonPropertyName("metadata")] +#else [JsonProperty("metadata")] +#endif public Dictionary Metadata { get; set; } /// /// Whether Stripe can send payouts to this account. /// +#if USE_SYSTEM_TEXT_JSON + [JsonPropertyName("payouts_enabled")] +#else [JsonProperty("payouts_enabled")] +#endif public bool PayoutsEnabled { get; set; } +#if USE_SYSTEM_TEXT_JSON + [JsonPropertyName("requirements")] +#else [JsonProperty("requirements")] +#endif public AccountRequirements Requirements { get; set; } /// /// Options for customizing how the account functions within Stripe. /// +#if USE_SYSTEM_TEXT_JSON + [JsonPropertyName("settings")] +#else [JsonProperty("settings")] +#endif public AccountSettings Settings { get; set; } +#if USE_SYSTEM_TEXT_JSON + [JsonPropertyName("tos_acceptance")] +#else [JsonProperty("tos_acceptance")] +#endif public AccountTosAcceptance TosAcceptance { get; set; } /// @@ -176,7 +268,11 @@ public class Account : StripeEntity, IHasId, IHasMetadata, IHasObject, /// none. /// One of: custom, express, none, or standard. /// +#if USE_SYSTEM_TEXT_JSON + [JsonPropertyName("type")] +#else [JsonProperty("type")] +#endif public string Type { get; set; } } } diff --git a/src/Stripe.net/Entities/Accounts/AccountBusinessProfile.cs b/src/Stripe.net/Entities/Accounts/AccountBusinessProfile.cs index 327b22aca6..1d10f5201c 100644 --- a/src/Stripe.net/Entities/Accounts/AccountBusinessProfile.cs +++ b/src/Stripe.net/Entities/Accounts/AccountBusinessProfile.cs @@ -1,21 +1,32 @@ -// File generated from our OpenAPI spec namespace Stripe { +#if USE_SYSTEM_TEXT_JSON + using System.Text.Json.Serialization; +#else using Newtonsoft.Json; +#endif public class AccountBusinessProfile : StripeEntity { /// /// The applicant's gross annual revenue for its preceding fiscal year. /// +#if USE_SYSTEM_TEXT_JSON + [JsonPropertyName("annual_revenue")] +#else [JsonProperty("annual_revenue")] +#endif public AccountBusinessProfileAnnualRevenue AnnualRevenue { get; set; } /// /// An estimated upper bound of employees, contractors, vendors, etc. currently working for /// the business. /// +#if USE_SYSTEM_TEXT_JSON + [JsonPropertyName("estimated_worker_count")] +#else [JsonProperty("estimated_worker_count")] +#endif public long? EstimatedWorkerCount { get; set; } /// @@ -23,53 +34,89 @@ public class AccountBusinessProfile : StripeEntity /// account. MCCs are used to classify businesses based on the goods or services they /// provide. /// +#if USE_SYSTEM_TEXT_JSON + [JsonPropertyName("mcc")] +#else [JsonProperty("mcc")] +#endif public string Mcc { get; set; } +#if USE_SYSTEM_TEXT_JSON + [JsonPropertyName("monthly_estimated_revenue")] +#else [JsonProperty("monthly_estimated_revenue")] +#endif public AccountBusinessProfileMonthlyEstimatedRevenue MonthlyEstimatedRevenue { get; set; } /// /// The customer-facing business name. /// +#if USE_SYSTEM_TEXT_JSON + [JsonPropertyName("name")] +#else [JsonProperty("name")] +#endif public string Name { get; set; } /// /// Internal-only description of the product sold or service provided by the business. It's /// used by Stripe for risk and underwriting purposes. /// +#if USE_SYSTEM_TEXT_JSON + [JsonPropertyName("product_description")] +#else [JsonProperty("product_description")] +#endif public string ProductDescription { get; set; } /// /// A publicly available mailing address for sending support issues to. /// +#if USE_SYSTEM_TEXT_JSON + [JsonPropertyName("support_address")] +#else [JsonProperty("support_address")] +#endif public Address SupportAddress { get; set; } /// /// A publicly available email address for sending support issues to. /// +#if USE_SYSTEM_TEXT_JSON + [JsonPropertyName("support_email")] +#else [JsonProperty("support_email")] +#endif public string SupportEmail { get; set; } /// /// A publicly available phone number to call with support issues. /// +#if USE_SYSTEM_TEXT_JSON + [JsonPropertyName("support_phone")] +#else [JsonProperty("support_phone")] +#endif public string SupportPhone { get; set; } /// /// A publicly available website for handling support issues. /// +#if USE_SYSTEM_TEXT_JSON + [JsonPropertyName("support_url")] +#else [JsonProperty("support_url")] +#endif public string SupportUrl { get; set; } /// /// The business's publicly available website. /// +#if USE_SYSTEM_TEXT_JSON + [JsonPropertyName("url")] +#else [JsonProperty("url")] +#endif public string Url { get; set; } } } diff --git a/src/Stripe.net/Entities/Accounts/AccountBusinessProfileAnnualRevenue.cs b/src/Stripe.net/Entities/Accounts/AccountBusinessProfileAnnualRevenue.cs index 2662eae9ea..8c8346a7c9 100644 --- a/src/Stripe.net/Entities/Accounts/AccountBusinessProfileAnnualRevenue.cs +++ b/src/Stripe.net/Entities/Accounts/AccountBusinessProfileAnnualRevenue.cs @@ -1,7 +1,10 @@ -// File generated from our OpenAPI spec namespace Stripe { +#if USE_SYSTEM_TEXT_JSON + using System.Text.Json.Serialization; +#else using Newtonsoft.Json; +#endif public class AccountBusinessProfileAnnualRevenue : StripeEntity { @@ -9,7 +12,11 @@ public class AccountBusinessProfileAnnualRevenue : StripeEntitysmallest currency unit. /// +#if USE_SYSTEM_TEXT_JSON + [JsonPropertyName("amount")] +#else [JsonProperty("amount")] +#endif public long? Amount { get; set; } /// @@ -17,14 +24,22 @@ public class AccountBusinessProfileAnnualRevenue : StripeEntity, in lowercase. Must be a supported /// currency. /// +#if USE_SYSTEM_TEXT_JSON + [JsonPropertyName("currency")] +#else [JsonProperty("currency")] +#endif public string Currency { get; set; } /// /// The close-out date of the preceding fiscal year in ISO 8601 format. E.g. 2023-12-31 for /// the 31st of December, 2023. /// +#if USE_SYSTEM_TEXT_JSON + [JsonPropertyName("fiscal_year_end")] +#else [JsonProperty("fiscal_year_end")] +#endif public string FiscalYearEnd { get; set; } } } diff --git a/src/Stripe.net/Entities/Accounts/AccountBusinessProfileMonthlyEstimatedRevenue.cs b/src/Stripe.net/Entities/Accounts/AccountBusinessProfileMonthlyEstimatedRevenue.cs index 4b69bd93f0..81882b4b33 100644 --- a/src/Stripe.net/Entities/Accounts/AccountBusinessProfileMonthlyEstimatedRevenue.cs +++ b/src/Stripe.net/Entities/Accounts/AccountBusinessProfileMonthlyEstimatedRevenue.cs @@ -1,7 +1,10 @@ -// File generated from our OpenAPI spec namespace Stripe { +#if USE_SYSTEM_TEXT_JSON + using System.Text.Json.Serialization; +#else using Newtonsoft.Json; +#endif public class AccountBusinessProfileMonthlyEstimatedRevenue : StripeEntity { @@ -9,7 +12,11 @@ public class AccountBusinessProfileMonthlyEstimatedRevenue : StripeEntitysmallest currency unit. /// +#if USE_SYSTEM_TEXT_JSON + [JsonPropertyName("amount")] +#else [JsonProperty("amount")] +#endif public long Amount { get; set; } /// @@ -17,7 +24,11 @@ public class AccountBusinessProfileMonthlyEstimatedRevenue : StripeEntity, in lowercase. Must be a supported /// currency. /// +#if USE_SYSTEM_TEXT_JSON + [JsonPropertyName("currency")] +#else [JsonProperty("currency")] +#endif public string Currency { get; set; } } } diff --git a/src/Stripe.net/Entities/Accounts/AccountCapabilities.cs b/src/Stripe.net/Entities/Accounts/AccountCapabilities.cs index 56513a58f4..a1d7b95462 100644 --- a/src/Stripe.net/Entities/Accounts/AccountCapabilities.cs +++ b/src/Stripe.net/Entities/Accounts/AccountCapabilities.cs @@ -1,7 +1,10 @@ -// File generated from our OpenAPI spec namespace Stripe { +#if USE_SYSTEM_TEXT_JSON + using System.Text.Json.Serialization; +#else using Newtonsoft.Json; +#endif public class AccountCapabilities : StripeEntity { @@ -10,7 +13,11 @@ public class AccountCapabilities : StripeEntity /// whether the account can directly process Canadian pre-authorized debits charges. /// One of: active, inactive, or pending. /// +#if USE_SYSTEM_TEXT_JSON + [JsonPropertyName("acss_debit_payments")] +#else [JsonProperty("acss_debit_payments")] +#endif public string AcssDebitPayments { get; set; } /// @@ -18,7 +25,11 @@ public class AccountCapabilities : StripeEntity /// process Affirm charges. /// One of: active, inactive, or pending. /// +#if USE_SYSTEM_TEXT_JSON + [JsonPropertyName("affirm_payments")] +#else [JsonProperty("affirm_payments")] +#endif public string AffirmPayments { get; set; } /// @@ -26,7 +37,11 @@ public class AccountCapabilities : StripeEntity /// can directly process Afterpay Clearpay charges. /// One of: active, inactive, or pending. /// +#if USE_SYSTEM_TEXT_JSON + [JsonPropertyName("afterpay_clearpay_payments")] +#else [JsonProperty("afterpay_clearpay_payments")] +#endif public string AfterpayClearpayPayments { get; set; } /// @@ -34,7 +49,11 @@ public class AccountCapabilities : StripeEntity /// directly process AmazonPay payments. /// One of: active, inactive, or pending. /// +#if USE_SYSTEM_TEXT_JSON + [JsonPropertyName("amazon_pay_payments")] +#else [JsonProperty("amazon_pay_payments")] +#endif public string AmazonPayPayments { get; set; } /// @@ -42,7 +61,11 @@ public class AccountCapabilities : StripeEntity /// the account can directly process BECS Direct Debit (AU) charges. /// One of: active, inactive, or pending. /// +#if USE_SYSTEM_TEXT_JSON + [JsonPropertyName("au_becs_debit_payments")] +#else [JsonProperty("au_becs_debit_payments")] +#endif public string AuBecsDebitPayments { get; set; } /// @@ -50,7 +73,11 @@ public class AccountCapabilities : StripeEntity /// account can directly process Bacs Direct Debits charges. /// One of: active, inactive, or pending. /// +#if USE_SYSTEM_TEXT_JSON + [JsonPropertyName("bacs_debit_payments")] +#else [JsonProperty("bacs_debit_payments")] +#endif public string BacsDebitPayments { get; set; } /// @@ -58,7 +85,11 @@ public class AccountCapabilities : StripeEntity /// can directly process Bancontact charges. /// One of: active, inactive, or pending. /// +#if USE_SYSTEM_TEXT_JSON + [JsonPropertyName("bancontact_payments")] +#else [JsonProperty("bancontact_payments")] +#endif public string BancontactPayments { get; set; } /// @@ -66,7 +97,11 @@ public class AccountCapabilities : StripeEntity /// account can directly process customer_balance charges. /// One of: active, inactive, or pending. /// +#if USE_SYSTEM_TEXT_JSON + [JsonPropertyName("bank_transfer_payments")] +#else [JsonProperty("bank_transfer_payments")] +#endif public string BankTransferPayments { get; set; } /// @@ -74,7 +109,11 @@ public class AccountCapabilities : StripeEntity /// directly process blik charges. /// One of: active, inactive, or pending. /// +#if USE_SYSTEM_TEXT_JSON + [JsonPropertyName("blik_payments")] +#else [JsonProperty("blik_payments")] +#endif public string BlikPayments { get; set; } /// @@ -82,7 +121,11 @@ public class AccountCapabilities : StripeEntity /// directly process boleto charges. /// One of: active, inactive, or pending. /// +#if USE_SYSTEM_TEXT_JSON + [JsonPropertyName("boleto_payments")] +#else [JsonProperty("boleto_payments")] +#endif public string BoletoPayments { get; set; } /// @@ -90,7 +133,11 @@ public class AccountCapabilities : StripeEntity /// to distribute funds on cards. /// One of: active, inactive, or pending. /// +#if USE_SYSTEM_TEXT_JSON + [JsonPropertyName("card_issuing")] +#else [JsonProperty("card_issuing")] +#endif public string CardIssuing { get; set; } /// @@ -98,7 +145,11 @@ public class AccountCapabilities : StripeEntity /// directly process credit and debit card charges. /// One of: active, inactive, or pending. /// +#if USE_SYSTEM_TEXT_JSON + [JsonPropertyName("card_payments")] +#else [JsonProperty("card_payments")] +#endif public string CardPayments { get; set; } /// @@ -106,7 +157,11 @@ public class AccountCapabilities : StripeEntity /// account can directly process Cartes Bancaires card charges in EUR currency. /// One of: active, inactive, or pending. /// +#if USE_SYSTEM_TEXT_JSON + [JsonPropertyName("cartes_bancaires_payments")] +#else [JsonProperty("cartes_bancaires_payments")] +#endif public string CartesBancairesPayments { get; set; } /// @@ -114,7 +169,11 @@ public class AccountCapabilities : StripeEntity /// directly process Cash App Pay payments. /// One of: active, inactive, or pending. /// +#if USE_SYSTEM_TEXT_JSON + [JsonPropertyName("cashapp_payments")] +#else [JsonProperty("cashapp_payments")] +#endif public string CashappPayments { get; set; } /// @@ -122,7 +181,11 @@ public class AccountCapabilities : StripeEntity /// directly process EPS charges. /// One of: active, inactive, or pending. /// +#if USE_SYSTEM_TEXT_JSON + [JsonPropertyName("eps_payments")] +#else [JsonProperty("eps_payments")] +#endif public string EpsPayments { get; set; } /// @@ -130,7 +193,11 @@ public class AccountCapabilities : StripeEntity /// directly process FPX charges. /// One of: active, inactive, or pending. /// +#if USE_SYSTEM_TEXT_JSON + [JsonPropertyName("fpx_payments")] +#else [JsonProperty("fpx_payments")] +#endif public string FpxPayments { get; set; } /// @@ -138,7 +205,11 @@ public class AccountCapabilities : StripeEntity /// or whether the account can directly process GB customer_balance charges. /// One of: active, inactive, or pending. /// +#if USE_SYSTEM_TEXT_JSON + [JsonPropertyName("gb_bank_transfer_payments")] +#else [JsonProperty("gb_bank_transfer_payments")] +#endif public string GbBankTransferPayments { get; set; } /// @@ -146,7 +217,11 @@ public class AccountCapabilities : StripeEntity /// directly process giropay charges. /// One of: active, inactive, or pending. /// +#if USE_SYSTEM_TEXT_JSON + [JsonPropertyName("giropay_payments")] +#else [JsonProperty("giropay_payments")] +#endif public string GiropayPayments { get; set; } /// @@ -154,7 +229,11 @@ public class AccountCapabilities : StripeEntity /// directly process GrabPay charges. /// One of: active, inactive, or pending. /// +#if USE_SYSTEM_TEXT_JSON + [JsonPropertyName("grabpay_payments")] +#else [JsonProperty("grabpay_payments")] +#endif public string GrabpayPayments { get; set; } /// @@ -162,7 +241,11 @@ public class AccountCapabilities : StripeEntity /// directly process iDEAL charges. /// One of: active, inactive, or pending. /// +#if USE_SYSTEM_TEXT_JSON + [JsonPropertyName("ideal_payments")] +#else [JsonProperty("ideal_payments")] +#endif public string IdealPayments { get; set; } /// @@ -170,7 +253,11 @@ public class AccountCapabilities : StripeEntity /// account can process international charges (non INR) in India. /// One of: active, inactive, or pending. /// +#if USE_SYSTEM_TEXT_JSON + [JsonPropertyName("india_international_payments")] +#else [JsonProperty("india_international_payments")] +#endif public string IndiaInternationalPayments { get; set; } /// @@ -178,7 +265,11 @@ public class AccountCapabilities : StripeEntity /// only) can directly process JCB credit card charges in JPY currency. /// One of: active, inactive, or pending. /// +#if USE_SYSTEM_TEXT_JSON + [JsonPropertyName("jcb_payments")] +#else [JsonProperty("jcb_payments")] +#endif public string JcbPayments { get; set; } /// @@ -186,7 +277,11 @@ public class AccountCapabilities : StripeEntity /// account, or whether the account can directly process Japanese customer_balance charges. /// One of: active, inactive, or pending. /// +#if USE_SYSTEM_TEXT_JSON + [JsonPropertyName("jp_bank_transfer_payments")] +#else [JsonProperty("jp_bank_transfer_payments")] +#endif public string JpBankTransferPayments { get; set; } /// @@ -194,7 +289,11 @@ public class AccountCapabilities : StripeEntity /// directly process Klarna charges. /// One of: active, inactive, or pending. /// +#if USE_SYSTEM_TEXT_JSON + [JsonPropertyName("klarna_payments")] +#else [JsonProperty("klarna_payments")] +#endif public string KlarnaPayments { get; set; } /// @@ -202,14 +301,22 @@ public class AccountCapabilities : StripeEntity /// directly process konbini charges. /// One of: active, inactive, or pending. /// +#if USE_SYSTEM_TEXT_JSON + [JsonPropertyName("konbini_payments")] +#else [JsonProperty("konbini_payments")] +#endif public string KonbiniPayments { get; set; } /// /// The status of the legacy payments capability of the account. /// One of: active, inactive, or pending. /// +#if USE_SYSTEM_TEXT_JSON + [JsonPropertyName("legacy_payments")] +#else [JsonProperty("legacy_payments")] +#endif public string LegacyPayments { get; set; } /// @@ -217,7 +324,11 @@ public class AccountCapabilities : StripeEntity /// directly process Link charges. /// One of: active, inactive, or pending. /// +#if USE_SYSTEM_TEXT_JSON + [JsonPropertyName("link_payments")] +#else [JsonProperty("link_payments")] +#endif public string LinkPayments { get; set; } /// @@ -225,7 +336,11 @@ public class AccountCapabilities : StripeEntity /// directly process MobilePay charges. /// One of: active, inactive, or pending. /// +#if USE_SYSTEM_TEXT_JSON + [JsonPropertyName("mobilepay_payments")] +#else [JsonProperty("mobilepay_payments")] +#endif public string MobilepayPayments { get; set; } /// @@ -233,7 +348,11 @@ public class AccountCapabilities : StripeEntity /// can directly process Multibanco charges. /// One of: active, inactive, or pending. /// +#if USE_SYSTEM_TEXT_JSON + [JsonPropertyName("multibanco_payments")] +#else [JsonProperty("multibanco_payments")] +#endif public string MultibancoPayments { get; set; } /// @@ -241,7 +360,11 @@ public class AccountCapabilities : StripeEntity /// account, or whether the account can directly process Mexican customer_balance charges. /// One of: active, inactive, or pending. /// +#if USE_SYSTEM_TEXT_JSON + [JsonPropertyName("mx_bank_transfer_payments")] +#else [JsonProperty("mx_bank_transfer_payments")] +#endif public string MxBankTransferPayments { get; set; } /// @@ -249,7 +372,11 @@ public class AccountCapabilities : StripeEntity /// directly process OXXO charges. /// One of: active, inactive, or pending. /// +#if USE_SYSTEM_TEXT_JSON + [JsonPropertyName("oxxo_payments")] +#else [JsonProperty("oxxo_payments")] +#endif public string OxxoPayments { get; set; } /// @@ -257,7 +384,11 @@ public class AccountCapabilities : StripeEntity /// directly process P24 charges. /// One of: active, inactive, or pending. /// +#if USE_SYSTEM_TEXT_JSON + [JsonPropertyName("p24_payments")] +#else [JsonProperty("p24_payments")] +#endif public string P24Payments { get; set; } /// @@ -265,7 +396,11 @@ public class AccountCapabilities : StripeEntity /// directly process paynow charges. /// One of: active, inactive, or pending. /// +#if USE_SYSTEM_TEXT_JSON + [JsonPropertyName("paynow_payments")] +#else [JsonProperty("paynow_payments")] +#endif public string PaynowPayments { get; set; } /// @@ -273,7 +408,11 @@ public class AccountCapabilities : StripeEntity /// can directly process promptpay charges. /// One of: active, inactive, or pending. /// +#if USE_SYSTEM_TEXT_JSON + [JsonPropertyName("promptpay_payments")] +#else [JsonProperty("promptpay_payments")] +#endif public string PromptpayPayments { get; set; } /// @@ -281,7 +420,11 @@ public class AccountCapabilities : StripeEntity /// directly process RevolutPay payments. /// One of: active, inactive, or pending. /// +#if USE_SYSTEM_TEXT_JSON + [JsonPropertyName("revolut_pay_payments")] +#else [JsonProperty("revolut_pay_payments")] +#endif public string RevolutPayPayments { get; set; } /// @@ -289,7 +432,11 @@ public class AccountCapabilities : StripeEntity /// account, or whether the account can directly process SEPA customer_balance charges. /// One of: active, inactive, or pending. /// +#if USE_SYSTEM_TEXT_JSON + [JsonPropertyName("sepa_bank_transfer_payments")] +#else [JsonProperty("sepa_bank_transfer_payments")] +#endif public string SepaBankTransferPayments { get; set; } /// @@ -297,7 +444,11 @@ public class AccountCapabilities : StripeEntity /// account can directly process SEPA Direct Debits charges. /// One of: active, inactive, or pending. /// +#if USE_SYSTEM_TEXT_JSON + [JsonPropertyName("sepa_debit_payments")] +#else [JsonProperty("sepa_debit_payments")] +#endif public string SepaDebitPayments { get; set; } /// @@ -305,7 +456,11 @@ public class AccountCapabilities : StripeEntity /// directly process Sofort charges. /// One of: active, inactive, or pending. /// +#if USE_SYSTEM_TEXT_JSON + [JsonPropertyName("sofort_payments")] +#else [JsonProperty("sofort_payments")] +#endif public string SofortPayments { get; set; } /// @@ -313,21 +468,33 @@ public class AccountCapabilities : StripeEntity /// process Swish payments. /// One of: active, inactive, or pending. /// +#if USE_SYSTEM_TEXT_JSON + [JsonPropertyName("swish_payments")] +#else [JsonProperty("swish_payments")] +#endif public string SwishPayments { get; set; } /// /// The status of the tax reporting 1099-K (US) capability of the account. /// One of: active, inactive, or pending. /// +#if USE_SYSTEM_TEXT_JSON + [JsonPropertyName("tax_reporting_us_1099_k")] +#else [JsonProperty("tax_reporting_us_1099_k")] +#endif public string TaxReportingUs1099K { get; set; } /// /// The status of the tax reporting 1099-MISC (US) capability of the account. /// One of: active, inactive, or pending. /// +#if USE_SYSTEM_TEXT_JSON + [JsonPropertyName("tax_reporting_us_1099_misc")] +#else [JsonProperty("tax_reporting_us_1099_misc")] +#endif public string TaxReportingUs1099Misc { get; set; } /// @@ -335,14 +502,22 @@ public class AccountCapabilities : StripeEntity /// transfer funds to the account. /// One of: active, inactive, or pending. /// +#if USE_SYSTEM_TEXT_JSON + [JsonPropertyName("transfers")] +#else [JsonProperty("transfers")] +#endif public string Transfers { get; set; } /// /// The status of the banking capability, or whether the account can have bank accounts. /// One of: active, inactive, or pending. /// +#if USE_SYSTEM_TEXT_JSON + [JsonPropertyName("treasury")] +#else [JsonProperty("treasury")] +#endif public string Treasury { get; set; } /// @@ -350,7 +525,11 @@ public class AccountCapabilities : StripeEntity /// process TWINT charges. /// One of: active, inactive, or pending. /// +#if USE_SYSTEM_TEXT_JSON + [JsonPropertyName("twint_payments")] +#else [JsonProperty("twint_payments")] +#endif public string TwintPayments { get; set; } /// @@ -358,7 +537,11 @@ public class AccountCapabilities : StripeEntity /// account can directly process US bank account charges. /// One of: active, inactive, or pending. /// +#if USE_SYSTEM_TEXT_JSON + [JsonPropertyName("us_bank_account_ach_payments")] +#else [JsonProperty("us_bank_account_ach_payments")] +#endif public string UsBankAccountAchPayments { get; set; } /// @@ -366,7 +549,11 @@ public class AccountCapabilities : StripeEntity /// or whether the account can directly process US customer_balance charges. /// One of: active, inactive, or pending. /// +#if USE_SYSTEM_TEXT_JSON + [JsonPropertyName("us_bank_transfer_payments")] +#else [JsonProperty("us_bank_transfer_payments")] +#endif public string UsBankTransferPayments { get; set; } /// @@ -374,7 +561,11 @@ public class AccountCapabilities : StripeEntity /// process Zip charges. /// One of: active, inactive, or pending. /// +#if USE_SYSTEM_TEXT_JSON + [JsonPropertyName("zip_payments")] +#else [JsonProperty("zip_payments")] +#endif public string ZipPayments { get; set; } } } diff --git a/src/Stripe.net/Entities/Accounts/AccountCompany.cs b/src/Stripe.net/Entities/Accounts/AccountCompany.cs index 0b5808baad..4607cd98c6 100644 --- a/src/Stripe.net/Entities/Accounts/AccountCompany.cs +++ b/src/Stripe.net/Entities/Accounts/AccountCompany.cs @@ -1,23 +1,38 @@ -// File generated from our OpenAPI spec namespace Stripe { +#if USE_SYSTEM_TEXT_JSON + using System.Text.Json.Serialization; +#else using Newtonsoft.Json; +#endif public class AccountCompany : StripeEntity { +#if USE_SYSTEM_TEXT_JSON + [JsonPropertyName("address")] +#else [JsonProperty("address")] +#endif public Address Address { get; set; } /// /// The Kana variation of the company's primary address (Japan only). /// +#if USE_SYSTEM_TEXT_JSON + [JsonPropertyName("address_kana")] +#else [JsonProperty("address_kana")] +#endif public AddressJapan AddressKana { get; set; } /// /// The Kanji variation of the company's primary address (Japan only). /// +#if USE_SYSTEM_TEXT_JSON + [JsonPropertyName("address_kanji")] +#else [JsonProperty("address_kanji")] +#endif public AddressJapan AddressKanji { get; set; } /// @@ -26,7 +41,11 @@ public class AccountCompany : StripeEntity /// href="https://stripe.com/docs/api/accounts/update#update_account-company-directors_provided">the /// directors_provided parameter. /// +#if USE_SYSTEM_TEXT_JSON + [JsonPropertyName("directors_provided")] +#else [JsonProperty("directors_provided")] +#endif public bool DirectorsProvided { get; set; } /// @@ -36,38 +55,62 @@ public class AccountCompany : StripeEntity /// executives_provided parameter, or if Stripe determined that sufficient /// executives were provided. /// +#if USE_SYSTEM_TEXT_JSON + [JsonPropertyName("executives_provided")] +#else [JsonProperty("executives_provided")] +#endif public bool ExecutivesProvided { get; set; } /// /// The export license ID number of the company, also referred as Import Export Code (India /// only). /// +#if USE_SYSTEM_TEXT_JSON + [JsonPropertyName("export_license_id")] +#else [JsonProperty("export_license_id")] +#endif public string ExportLicenseId { get; set; } /// /// The purpose code to use for export transactions (India only). /// +#if USE_SYSTEM_TEXT_JSON + [JsonPropertyName("export_purpose_code")] +#else [JsonProperty("export_purpose_code")] +#endif public string ExportPurposeCode { get; set; } /// /// The company's legal name. /// +#if USE_SYSTEM_TEXT_JSON + [JsonPropertyName("name")] +#else [JsonProperty("name")] +#endif public string Name { get; set; } /// /// The Kana variation of the company's legal name (Japan only). /// +#if USE_SYSTEM_TEXT_JSON + [JsonPropertyName("name_kana")] +#else [JsonProperty("name_kana")] +#endif public string NameKana { get; set; } /// /// The Kanji variation of the company's legal name (Japan only). /// +#if USE_SYSTEM_TEXT_JSON + [JsonPropertyName("name_kanji")] +#else [JsonProperty("name_kanji")] +#endif public string NameKanji { get; set; } /// @@ -79,20 +122,32 @@ public class AccountCompany : StripeEntity /// provided and their total percent ownership (calculated by adding the /// percent_ownership of each owner together). /// +#if USE_SYSTEM_TEXT_JSON + [JsonPropertyName("owners_provided")] +#else [JsonProperty("owners_provided")] +#endif public bool OwnersProvided { get; set; } /// /// This hash is used to attest that the beneficial owner information provided to Stripe is /// both current and correct. /// +#if USE_SYSTEM_TEXT_JSON + [JsonPropertyName("ownership_declaration")] +#else [JsonProperty("ownership_declaration")] +#endif public AccountCompanyOwnershipDeclaration OwnershipDeclaration { get; set; } /// /// The company's phone number (used for verification). /// +#if USE_SYSTEM_TEXT_JSON + [JsonPropertyName("phone")] +#else [JsonProperty("phone")] +#endif public string Phone { get; set; } /// @@ -110,32 +165,52 @@ public class AccountCompany : StripeEntity /// unincorporated_association, unincorporated_non_profit, or /// unincorporated_partnership. /// +#if USE_SYSTEM_TEXT_JSON + [JsonPropertyName("structure")] +#else [JsonProperty("structure")] +#endif public string Structure { get; set; } /// /// Whether the company's business ID number was provided. /// +#if USE_SYSTEM_TEXT_JSON + [JsonPropertyName("tax_id_provided")] +#else [JsonProperty("tax_id_provided")] +#endif public bool TaxIdProvided { get; set; } /// /// The jurisdiction in which the tax_id is registered (Germany-based companies /// only). /// +#if USE_SYSTEM_TEXT_JSON + [JsonPropertyName("tax_id_registrar")] +#else [JsonProperty("tax_id_registrar")] +#endif public string TaxIdRegistrar { get; set; } /// /// Whether the company's business VAT number was provided. /// +#if USE_SYSTEM_TEXT_JSON + [JsonPropertyName("vat_id_provided")] +#else [JsonProperty("vat_id_provided")] +#endif public bool VatIdProvided { get; set; } /// /// Information on the verification state of the company. /// +#if USE_SYSTEM_TEXT_JSON + [JsonPropertyName("verification")] +#else [JsonProperty("verification")] +#endif public AccountCompanyVerification Verification { get; set; } } } diff --git a/src/Stripe.net/Entities/Accounts/AccountCompanyOwnershipDeclaration.cs b/src/Stripe.net/Entities/Accounts/AccountCompanyOwnershipDeclaration.cs index 56abe7cf78..f04d07c0e5 100644 --- a/src/Stripe.net/Entities/Accounts/AccountCompanyOwnershipDeclaration.cs +++ b/src/Stripe.net/Entities/Accounts/AccountCompanyOwnershipDeclaration.cs @@ -1,8 +1,11 @@ -// File generated from our OpenAPI spec namespace Stripe { using System; +#if USE_SYSTEM_TEXT_JSON + using System.Text.Json.Serialization; +#else using Newtonsoft.Json; +#endif using Stripe.Infrastructure; public class AccountCompanyOwnershipDeclaration : StripeEntity @@ -10,20 +13,33 @@ public class AccountCompanyOwnershipDeclaration : StripeEntity /// The Unix timestamp marking when the beneficial owner attestation was made. /// +#if USE_SYSTEM_TEXT_JSON + [JsonPropertyName("date")] + [JsonConverter(typeof(UnixDateTimeConverter))] +#else [JsonProperty("date")] [JsonConverter(typeof(UnixDateTimeConverter))] +#endif public DateTime? Date { get; set; } /// /// The IP address from which the beneficial owner attestation was made. /// +#if USE_SYSTEM_TEXT_JSON + [JsonPropertyName("ip")] +#else [JsonProperty("ip")] +#endif public string Ip { get; set; } /// /// The user-agent string from the browser where the beneficial owner attestation was made. /// +#if USE_SYSTEM_TEXT_JSON + [JsonPropertyName("user_agent")] +#else [JsonProperty("user_agent")] +#endif public string UserAgent { get; set; } } } diff --git a/src/Stripe.net/Entities/Accounts/AccountCompanyVerification.cs b/src/Stripe.net/Entities/Accounts/AccountCompanyVerification.cs index e322ad0885..0553c458ae 100644 --- a/src/Stripe.net/Entities/Accounts/AccountCompanyVerification.cs +++ b/src/Stripe.net/Entities/Accounts/AccountCompanyVerification.cs @@ -1,11 +1,18 @@ -// File generated from our OpenAPI spec namespace Stripe { +#if USE_SYSTEM_TEXT_JSON + using System.Text.Json.Serialization; +#else using Newtonsoft.Json; +#endif public class AccountCompanyVerification : StripeEntity { +#if USE_SYSTEM_TEXT_JSON + [JsonPropertyName("document")] +#else [JsonProperty("document")] +#endif public AccountCompanyVerificationDocument Document { get; set; } } } diff --git a/src/Stripe.net/Entities/Accounts/AccountCompanyVerificationDocument.cs b/src/Stripe.net/Entities/Accounts/AccountCompanyVerificationDocument.cs index e52c959c01..2d9a9d1513 100644 --- a/src/Stripe.net/Entities/Accounts/AccountCompanyVerificationDocument.cs +++ b/src/Stripe.net/Entities/Accounts/AccountCompanyVerificationDocument.cs @@ -1,7 +1,10 @@ -// File generated from our OpenAPI spec namespace Stripe { +#if USE_SYSTEM_TEXT_JSON + using System.Text.Json.Serialization; +#else using Newtonsoft.Json; +#endif using Stripe.Infrastructure; public class AccountCompanyVerificationDocument : StripeEntity @@ -14,7 +17,11 @@ public class AccountCompanyVerificationDocument : StripeEntityfile upload with a purpose /// value of additional_verification. /// +#if USE_SYSTEM_TEXT_JSON [JsonIgnore] +#else + [JsonIgnore] +#endif public string BackId { get => this.InternalBack?.Id; @@ -29,22 +36,35 @@ public string BackId /// /// For more information, see the expand documentation. /// +#if USE_SYSTEM_TEXT_JSON + [JsonIgnore] +#else [JsonIgnore] +#endif public File Back { get => this.InternalBack?.ExpandedObject; set => this.InternalBack = SetExpandableFieldObject(value, this.InternalBack); } +#if USE_SYSTEM_TEXT_JSON + [JsonPropertyName("back")] + [JsonConverter(typeof(ExpandableFieldConverter))] +#else [JsonProperty("back")] [JsonConverter(typeof(ExpandableFieldConverter))] +#endif internal ExpandableField InternalBack { get; set; } #endregion /// /// A user-displayable string describing the verification state of this document. /// +#if USE_SYSTEM_TEXT_JSON + [JsonPropertyName("details")] +#else [JsonProperty("details")] +#endif public string Details { get; set; } /// @@ -56,7 +76,11 @@ public File Back /// document_type_not_supported, or document_too_large. A machine-readable /// code specifying the verification state for this document. /// +#if USE_SYSTEM_TEXT_JSON + [JsonPropertyName("details_code")] +#else [JsonProperty("details_code")] +#endif public string DetailsCode { get; set; } #region Expandable Front @@ -67,7 +91,11 @@ public File Back /// href="https://stripe.com/docs/api#create_file">file upload with a purpose /// value of additional_verification. /// +#if USE_SYSTEM_TEXT_JSON [JsonIgnore] +#else + [JsonIgnore] +#endif public string FrontId { get => this.InternalFront?.Id; @@ -82,15 +110,24 @@ public string FrontId /// /// For more information, see the expand documentation. /// +#if USE_SYSTEM_TEXT_JSON + [JsonIgnore] +#else [JsonIgnore] +#endif public File Front { get => this.InternalFront?.ExpandedObject; set => this.InternalFront = SetExpandableFieldObject(value, this.InternalFront); } +#if USE_SYSTEM_TEXT_JSON + [JsonPropertyName("front")] + [JsonConverter(typeof(ExpandableFieldConverter))] +#else [JsonProperty("front")] [JsonConverter(typeof(ExpandableFieldConverter))] +#endif internal ExpandableField InternalFront { get; set; } #endregion } diff --git a/src/Stripe.net/Entities/Accounts/AccountController.cs b/src/Stripe.net/Entities/Accounts/AccountController.cs index b79260bbed..c469552807 100644 --- a/src/Stripe.net/Entities/Accounts/AccountController.cs +++ b/src/Stripe.net/Entities/Accounts/AccountController.cs @@ -1,11 +1,18 @@ -// File generated from our OpenAPI spec namespace Stripe { +#if USE_SYSTEM_TEXT_JSON + using System.Text.Json.Serialization; +#else using Newtonsoft.Json; +#endif public class AccountController : StripeEntity { +#if USE_SYSTEM_TEXT_JSON + [JsonPropertyName("fees")] +#else [JsonProperty("fees")] +#endif public AccountControllerFees Fees { get; set; } /// @@ -14,10 +21,18 @@ public class AccountController : StripeEntity /// href="https://stripe.com/docs/connect/platform-controls-for-standard-accounts">platform /// controls. Otherwise, this field is null. /// +#if USE_SYSTEM_TEXT_JSON + [JsonPropertyName("is_controller")] +#else [JsonProperty("is_controller")] +#endif public bool IsController { get; set; } +#if USE_SYSTEM_TEXT_JSON + [JsonPropertyName("losses")] +#else [JsonProperty("losses")] +#endif public AccountControllerLosses Losses { get; set; } /// @@ -25,10 +40,18 @@ public class AccountController : StripeEntity /// returned when the Connect application retrieving the resource controls the account. /// One of: application, or stripe. /// +#if USE_SYSTEM_TEXT_JSON + [JsonPropertyName("requirement_collection")] +#else [JsonProperty("requirement_collection")] +#endif public string RequirementCollection { get; set; } +#if USE_SYSTEM_TEXT_JSON + [JsonPropertyName("stripe_dashboard")] +#else [JsonProperty("stripe_dashboard")] +#endif public AccountControllerStripeDashboard StripeDashboard { get; set; } /// @@ -36,7 +59,11 @@ public class AccountController : StripeEntity /// account, or account, if the account controls itself. /// One of: account, or application. /// +#if USE_SYSTEM_TEXT_JSON + [JsonPropertyName("type")] +#else [JsonProperty("type")] +#endif public string Type { get; set; } } } diff --git a/src/Stripe.net/Entities/Accounts/AccountControllerFees.cs b/src/Stripe.net/Entities/Accounts/AccountControllerFees.cs index d1500628d7..f20fd832ba 100644 --- a/src/Stripe.net/Entities/Accounts/AccountControllerFees.cs +++ b/src/Stripe.net/Entities/Accounts/AccountControllerFees.cs @@ -1,7 +1,10 @@ -// File generated from our OpenAPI spec namespace Stripe { +#if USE_SYSTEM_TEXT_JSON + using System.Text.Json.Serialization; +#else using Newtonsoft.Json; +#endif public class AccountControllerFees : StripeEntity { @@ -13,7 +16,11 @@ public class AccountControllerFees : StripeEntity /// One of: account, application, application_custom, or /// application_express. /// +#if USE_SYSTEM_TEXT_JSON + [JsonPropertyName("payer")] +#else [JsonProperty("payer")] +#endif public string Payer { get; set; } } } diff --git a/src/Stripe.net/Entities/Accounts/AccountControllerLosses.cs b/src/Stripe.net/Entities/Accounts/AccountControllerLosses.cs index 62259213ac..2ecf0d707e 100644 --- a/src/Stripe.net/Entities/Accounts/AccountControllerLosses.cs +++ b/src/Stripe.net/Entities/Accounts/AccountControllerLosses.cs @@ -1,7 +1,10 @@ -// File generated from our OpenAPI spec namespace Stripe { +#if USE_SYSTEM_TEXT_JSON + using System.Text.Json.Serialization; +#else using Newtonsoft.Json; +#endif public class AccountControllerLosses : StripeEntity { @@ -10,7 +13,11 @@ public class AccountControllerLosses : StripeEntity /// payments. /// One of: application, or stripe. /// +#if USE_SYSTEM_TEXT_JSON + [JsonPropertyName("payments")] +#else [JsonProperty("payments")] +#endif public string Payments { get; set; } } } diff --git a/src/Stripe.net/Entities/Accounts/AccountControllerStripeDashboard.cs b/src/Stripe.net/Entities/Accounts/AccountControllerStripeDashboard.cs index 72bc2e7380..da4500b04e 100644 --- a/src/Stripe.net/Entities/Accounts/AccountControllerStripeDashboard.cs +++ b/src/Stripe.net/Entities/Accounts/AccountControllerStripeDashboard.cs @@ -1,7 +1,10 @@ -// File generated from our OpenAPI spec namespace Stripe { +#if USE_SYSTEM_TEXT_JSON + using System.Text.Json.Serialization; +#else using Newtonsoft.Json; +#endif public class AccountControllerStripeDashboard : StripeEntity { @@ -10,7 +13,11 @@ public class AccountControllerStripeDashboard : StripeEntityexpress, full, or none. /// +#if USE_SYSTEM_TEXT_JSON + [JsonPropertyName("type")] +#else [JsonProperty("type")] +#endif public string Type { get; set; } } } diff --git a/src/Stripe.net/Entities/Accounts/AccountFutureRequirements.cs b/src/Stripe.net/Entities/Accounts/AccountFutureRequirements.cs index 6ed096c051..0cb2524990 100644 --- a/src/Stripe.net/Entities/Accounts/AccountFutureRequirements.cs +++ b/src/Stripe.net/Entities/Accounts/AccountFutureRequirements.cs @@ -1,9 +1,12 @@ -// File generated from our OpenAPI spec namespace Stripe { using System; using System.Collections.Generic; +#if USE_SYSTEM_TEXT_JSON + using System.Text.Json.Serialization; +#else using Newtonsoft.Json; +#endif using Stripe.Infrastructure; public class AccountFutureRequirements : StripeEntity @@ -12,7 +15,11 @@ public class AccountFutureRequirements : StripeEntity /// Fields that are due and can be satisfied by providing the corresponding alternative /// fields instead. /// +#if USE_SYSTEM_TEXT_JSON + [JsonPropertyName("alternatives")] +#else [JsonProperty("alternatives")] +#endif public List Alternatives { get; set; } /// @@ -21,8 +28,13 @@ public class AccountFutureRequirements : StripeEntity /// requirements may immediately become past_due, but the account may also be given a /// grace period depending on its enablement state prior to transitioning. /// +#if USE_SYSTEM_TEXT_JSON + [JsonPropertyName("current_deadline")] + [JsonConverter(typeof(UnixDateTimeConverter))] +#else [JsonProperty("current_deadline")] [JsonConverter(typeof(UnixDateTimeConverter))] +#endif public DateTime? CurrentDeadline { get; set; } /// @@ -30,27 +42,43 @@ public class AccountFutureRequirements : StripeEntity /// future_requirements[current_deadline], these fields will transition to the main /// requirements hash. /// +#if USE_SYSTEM_TEXT_JSON + [JsonPropertyName("currently_due")] +#else [JsonProperty("currently_due")] +#endif public List CurrentlyDue { get; set; } /// /// This is typed as a string for consistency with requirements.disabled_reason. /// +#if USE_SYSTEM_TEXT_JSON + [JsonPropertyName("disabled_reason")] +#else [JsonProperty("disabled_reason")] +#endif public string DisabledReason { get; set; } /// /// Fields that are currently_due and need to be collected again because validation /// or verification failed. /// +#if USE_SYSTEM_TEXT_JSON + [JsonPropertyName("errors")] +#else [JsonProperty("errors")] +#endif public List Errors { get; set; } /// /// Fields that need to be collected assuming all volume thresholds are reached. As they /// become required, they appear in currently_due as well. /// +#if USE_SYSTEM_TEXT_JSON + [JsonPropertyName("eventually_due")] +#else [JsonProperty("eventually_due")] +#endif public List EventuallyDue { get; set; } /// @@ -59,7 +87,11 @@ public class AccountFutureRequirements : StripeEntity /// here; future_requirements.past_due will always be a subset of /// requirements.past_due. /// +#if USE_SYSTEM_TEXT_JSON + [JsonPropertyName("past_due")] +#else [JsonProperty("past_due")] +#endif public List PastDue { get; set; } /// @@ -70,7 +102,11 @@ public class AccountFutureRequirements : StripeEntity /// pending_verification if verification fails but another verification is still /// pending. /// +#if USE_SYSTEM_TEXT_JSON + [JsonPropertyName("pending_verification")] +#else [JsonProperty("pending_verification")] +#endif public List PendingVerification { get; set; } } } diff --git a/src/Stripe.net/Entities/Customers/Customer.cs b/src/Stripe.net/Entities/Customers/Customer.cs index 45b3b24b7f..d8ac511759 100644 --- a/src/Stripe.net/Entities/Customers/Customer.cs +++ b/src/Stripe.net/Entities/Customers/Customer.cs @@ -1,9 +1,12 @@ -// File generated from our OpenAPI spec namespace Stripe { using System; using System.Collections.Generic; +#if USE_SYSTEM_TEXT_JSON + using System.Text.Json.Serialization; +#else using Newtonsoft.Json; +#endif using Stripe.Infrastructure; /// @@ -18,19 +21,31 @@ public class Customer : StripeEntity, IHasId, IHasMetadata, IHasObject /// /// Unique identifier for the object. /// +#if USE_SYSTEM_TEXT_JSON + [JsonPropertyName("id")] +#else [JsonProperty("id")] +#endif public string Id { get; set; } /// /// String representing the object's type. Objects of the same type share the same value. /// +#if USE_SYSTEM_TEXT_JSON + [JsonPropertyName("object")] +#else [JsonProperty("object")] +#endif public string Object { get; set; } /// /// The customer's address. /// +#if USE_SYSTEM_TEXT_JSON + [JsonPropertyName("address")] +#else [JsonProperty("address")] +#endif public Address Address { get; set; } /// @@ -40,7 +55,11 @@ public class Customer : StripeEntity, IHasId, IHasMetadata, IHasObject /// hasn't successfully applied to any invoice. It doesn't reflect unpaid invoices. This /// balance is only taken into account after invoices finalize. /// +#if USE_SYSTEM_TEXT_JSON + [JsonPropertyName("balance")] +#else [JsonProperty("balance")] +#endif public long Balance { get; set; } /// @@ -49,21 +68,34 @@ public class Customer : StripeEntity, IHasId, IHasMetadata, IHasObject /// settings[reconciliation_mode] field describes if these funds apply to these /// payment intents manually or automatically. /// +#if USE_SYSTEM_TEXT_JSON + [JsonPropertyName("cash_balance")] +#else [JsonProperty("cash_balance")] +#endif public CashBalance CashBalance { get; set; } /// /// Time at which the object was created. Measured in seconds since the Unix epoch. /// +#if USE_SYSTEM_TEXT_JSON + [JsonPropertyName("created")] + [JsonConverter(typeof(UnixDateTimeConverter))] +#else [JsonProperty("created")] [JsonConverter(typeof(UnixDateTimeConverter))] +#endif public DateTime Created { get; set; } = Stripe.Infrastructure.DateTimeUtils.UnixEpoch; /// /// Three-letter ISO code for the currency /// the customer can be charged in for recurring billing purposes. /// +#if USE_SYSTEM_TEXT_JSON + [JsonPropertyName("currency")] +#else [JsonProperty("currency")] +#endif public string Currency { get; set; } #region Expandable DefaultSource @@ -76,7 +108,11 @@ public class Customer : StripeEntity, IHasId, IHasMetadata, IHasObject /// href="https://stripe.com/docs/api/customers/object#customer_object-invoice_settings-default_payment_method">invoice_settings.default_payment_method /// field instead. /// +#if USE_SYSTEM_TEXT_JSON + [JsonIgnore] +#else [JsonIgnore] +#endif public string DefaultSourceId { get => this.InternalDefaultSource?.Id; @@ -93,22 +129,35 @@ public string DefaultSourceId /// /// For more information, see the expand documentation. /// +#if USE_SYSTEM_TEXT_JSON [JsonIgnore] +#else + [JsonIgnore] +#endif public IPaymentSource DefaultSource { get => this.InternalDefaultSource?.ExpandedObject; set => this.InternalDefaultSource = SetExpandableFieldObject(value, this.InternalDefaultSource); } +#if USE_SYSTEM_TEXT_JSON + [JsonPropertyName("default_source")] + [JsonConverter(typeof(ExpandableFieldConverter))] +#else [JsonProperty("default_source")] [JsonConverter(typeof(ExpandableFieldConverter))] +#endif internal ExpandableField InternalDefaultSource { get; set; } #endregion /// /// Whether this object is deleted or not. /// +#if USE_SYSTEM_TEXT_JSON + [JsonPropertyName("deleted")] +#else [JsonProperty("deleted", NullValueHandling = NullValueHandling.Ignore)] +#endif public bool? Deleted { get; set; } /// @@ -126,25 +175,41 @@ public IPaymentSource DefaultSource /// regardless of whether it is the latest invoice for a subscription will always set this /// field to false. /// +#if USE_SYSTEM_TEXT_JSON + [JsonPropertyName("delinquent")] +#else [JsonProperty("delinquent")] +#endif public bool? Delinquent { get; set; } /// /// An arbitrary string attached to the object. Often useful for displaying to users. /// +#if USE_SYSTEM_TEXT_JSON + [JsonPropertyName("description")] +#else [JsonProperty("description")] +#endif public string Description { get; set; } /// /// Describes the current discount active on the customer, if there is one. /// +#if USE_SYSTEM_TEXT_JSON + [JsonPropertyName("discount")] +#else [JsonProperty("discount")] +#endif public Discount Discount { get; set; } /// /// The customer's email address. /// +#if USE_SYSTEM_TEXT_JSON + [JsonPropertyName("email")] +#else [JsonProperty("email")] +#endif public string Email { get; set; } /// @@ -156,23 +221,39 @@ public IPaymentSource DefaultSource /// only applies a balance in a specific currency to an invoice after that invoice (which is /// in the same currency) finalizes. /// +#if USE_SYSTEM_TEXT_JSON + [JsonPropertyName("invoice_credit_balance")] +#else [JsonProperty("invoice_credit_balance")] +#endif public Dictionary InvoiceCreditBalance { get; set; } /// /// The prefix for the customer used to generate unique invoice numbers. /// +#if USE_SYSTEM_TEXT_JSON + [JsonPropertyName("invoice_prefix")] +#else [JsonProperty("invoice_prefix")] +#endif public string InvoicePrefix { get; set; } +#if USE_SYSTEM_TEXT_JSON + [JsonPropertyName("invoice_settings")] +#else [JsonProperty("invoice_settings")] +#endif public CustomerInvoiceSettings InvoiceSettings { get; set; } /// /// Has the value true if the object exists in live mode or the value false if /// the object exists in test mode. /// +#if USE_SYSTEM_TEXT_JSON + [JsonPropertyName("livemode")] +#else [JsonProperty("livemode")] +#endif public bool Livemode { get; set; } /// @@ -180,13 +261,21 @@ public IPaymentSource DefaultSource /// attach to an object. This can be useful for storing additional information about the /// object in a structured format. /// +#if USE_SYSTEM_TEXT_JSON + [JsonPropertyName("metadata")] +#else [JsonProperty("metadata")] +#endif public Dictionary Metadata { get; set; } /// /// The customer's full name or business name. /// +#if USE_SYSTEM_TEXT_JSON + [JsonPropertyName("name")] +#else [JsonProperty("name")] +#endif public string Name { get; set; } /// @@ -194,41 +283,69 @@ public IPaymentSource DefaultSource /// uses account level sequencing, this parameter is ignored in API requests and the field /// omitted in API responses. /// +#if USE_SYSTEM_TEXT_JSON + [JsonPropertyName("next_invoice_sequence")] +#else [JsonProperty("next_invoice_sequence")] +#endif public long NextInvoiceSequence { get; set; } /// /// The customer's phone number. /// +#if USE_SYSTEM_TEXT_JSON + [JsonPropertyName("phone")] +#else [JsonProperty("phone")] +#endif public string Phone { get; set; } /// /// The customer's preferred locales (languages), ordered by preference. /// +#if USE_SYSTEM_TEXT_JSON + [JsonPropertyName("preferred_locales")] +#else [JsonProperty("preferred_locales")] +#endif public List PreferredLocales { get; set; } /// /// Mailing and shipping address for the customer. Appears on invoices emailed to this /// customer. /// +#if USE_SYSTEM_TEXT_JSON + [JsonPropertyName("shipping")] +#else [JsonProperty("shipping")] +#endif public Shipping Shipping { get; set; } /// /// The customer's payment sources, if any. /// +#if USE_SYSTEM_TEXT_JSON + [JsonPropertyName("sources")] +#else [JsonProperty("sources")] +#endif public StripeList Sources { get; set; } /// /// The customer's current subscriptions, if any. /// +#if USE_SYSTEM_TEXT_JSON + [JsonPropertyName("subscriptions")] +#else [JsonProperty("subscriptions")] +#endif public StripeList Subscriptions { get; set; } +#if USE_SYSTEM_TEXT_JSON + [JsonPropertyName("tax")] +#else [JsonProperty("tax")] +#endif public CustomerTax Tax { get; set; } /// @@ -237,13 +354,21 @@ public IPaymentSource DefaultSource /// following text: "Reverse charge". /// One of: exempt, none, or reverse. /// +#if USE_SYSTEM_TEXT_JSON + [JsonPropertyName("tax_exempt")] +#else [JsonProperty("tax_exempt")] +#endif public string TaxExempt { get; set; } /// /// The customer's tax IDs. /// +#if USE_SYSTEM_TEXT_JSON + [JsonPropertyName("tax_ids")] +#else [JsonProperty("tax_ids")] +#endif public StripeList TaxIds { get; set; } #region Expandable TestClock @@ -252,7 +377,11 @@ public IPaymentSource DefaultSource /// (ID of the TestHelpers.TestClock) /// ID of the test clock that this customer belongs to. /// +#if USE_SYSTEM_TEXT_JSON [JsonIgnore] +#else + [JsonIgnore] +#endif public string TestClockId { get => this.InternalTestClock?.Id; @@ -265,15 +394,24 @@ public string TestClockId /// /// For more information, see the expand documentation. /// +#if USE_SYSTEM_TEXT_JSON + [JsonIgnore] +#else [JsonIgnore] +#endif public TestHelpers.TestClock TestClock { get => this.InternalTestClock?.ExpandedObject; set => this.InternalTestClock = SetExpandableFieldObject(value, this.InternalTestClock); } +#if USE_SYSTEM_TEXT_JSON + [JsonPropertyName("test_clock")] + [JsonConverter(typeof(ExpandableFieldConverter))] +#else [JsonProperty("test_clock")] [JsonConverter(typeof(ExpandableFieldConverter))] +#endif internal ExpandableField InternalTestClock { get; set; } #endregion } diff --git a/src/Stripe.net/Entities/_base/StripeEntity.cs b/src/Stripe.net/Entities/_base/StripeEntity.cs index 5a9684f1df..96e8d4b204 100644 --- a/src/Stripe.net/Entities/_base/StripeEntity.cs +++ b/src/Stripe.net/Entities/_base/StripeEntity.cs @@ -13,6 +13,13 @@ namespace Stripe [JsonConverter(typeof(StripeEntityConverter))] public abstract class StripeEntity : IStripeEntity { + private readonly IJsonSerializer jsonSerializer; + + protected StripeEntity(IJsonSerializer jsonSerializer) + { + this.jsonSerializer = jsonSerializer; + } + /// /// Gets the raw JObject exposed by the Newtonsoft.Json library. /// This can be used to access properties that are not directly exposed by Stripe's .NET @@ -75,10 +82,7 @@ public override string ToString() /// An indented JSON string represensation of the object. public string ToJson() { - return JsonUtils.SerializeObject( - this, - Formatting.Indented, - StripeConfiguration.SerializerSettings); + return this.jsonSerializer.SerializeObject(this); } /// @@ -176,6 +180,11 @@ private object GetIdString() public abstract class StripeEntity : StripeEntity where T : StripeEntity { + protected StripeEntity(IJsonSerializer jsonSerializer) + : base(jsonSerializer) + { + } + /// Deserializes the JSON to a Stripe object type. /// The object to deserialize. /// The deserialized Stripe object from the JSON string. diff --git a/src/Stripe.net/Entities/_common/Address.cs b/src/Stripe.net/Entities/_common/Address.cs index b5f187f107..b4c8719c0f 100644 --- a/src/Stripe.net/Entities/_common/Address.cs +++ b/src/Stripe.net/Entities/_common/Address.cs @@ -1,25 +1,53 @@ namespace Stripe { +#if USE_SYSTEM_TEXT_JSON + using System.Text.Json.Serialization; +#else using Newtonsoft.Json; +#endif public class Address : StripeEntity
{ +#if USE_SYSTEM_TEXT_JSON + [JsonPropertyName("city")] +#else [JsonProperty("city")] +#endif public string City { get; set; } +#if USE_SYSTEM_TEXT_JSON + [JsonPropertyName("country")] +#else [JsonProperty("country")] +#endif public string Country { get; set; } +#if USE_SYSTEM_TEXT_JSON + [JsonPropertyName("line1")] +#else [JsonProperty("line1")] +#endif public string Line1 { get; set; } +#if USE_SYSTEM_TEXT_JSON + [JsonPropertyName("line2")] +#else [JsonProperty("line2")] +#endif public string Line2 { get; set; } +#if USE_SYSTEM_TEXT_JSON + [JsonPropertyName("postal_code")] +#else [JsonProperty("postal_code")] +#endif public string PostalCode { get; set; } +#if USE_SYSTEM_TEXT_JSON + [JsonPropertyName("state")] +#else [JsonProperty("state")] +#endif public string State { get; set; } } } diff --git a/src/Stripe.net/Entities/_common/AddressJapan.cs b/src/Stripe.net/Entities/_common/AddressJapan.cs index 12822b2500..b076f8e1f8 100644 --- a/src/Stripe.net/Entities/_common/AddressJapan.cs +++ b/src/Stripe.net/Entities/_common/AddressJapan.cs @@ -1,10 +1,18 @@ namespace Stripe { +#if USE_SYSTEM_TEXT_JSON + using System.Text.Json.Serialization; +#else using Newtonsoft.Json; +#endif public class AddressJapan : Address { +#if USE_SYSTEM_TEXT_JSON + [JsonPropertyName("town")] +#else [JsonProperty("town")] +#endif public string Town { get; set; } } } diff --git a/src/Stripe.net/Entities/_common/Shipping.cs b/src/Stripe.net/Entities/_common/Shipping.cs index 6d759a76fd..3efabc0ce7 100644 --- a/src/Stripe.net/Entities/_common/Shipping.cs +++ b/src/Stripe.net/Entities/_common/Shipping.cs @@ -1,22 +1,46 @@ namespace Stripe { +#if USE_SYSTEM_TEXT_JSON + using System.Text.Json.Serialization; +#else using Newtonsoft.Json; +#endif public class Shipping : StripeEntity { +#if USE_SYSTEM_TEXT_JSON + [JsonPropertyName("address")] +#else [JsonProperty("address")] +#endif public Address Address { get; set; } +#if USE_SYSTEM_TEXT_JSON + [JsonPropertyName("carrier")] +#else [JsonProperty("carrier")] +#endif public string Carrier { get; set; } +#if USE_SYSTEM_TEXT_JSON + [JsonPropertyName("name")] +#else [JsonProperty("name")] +#endif public string Name { get; set; } +#if USE_SYSTEM_TEXT_JSON + [JsonPropertyName("phone")] +#else [JsonProperty("phone")] +#endif public string Phone { get; set; } +#if USE_SYSTEM_TEXT_JSON + [JsonPropertyName("tracking_number")] +#else [JsonProperty("tracking_number")] +#endif public string TrackingNumber { get; set; } } } diff --git a/src/Stripe.net/Infrastructure/JsonSerializer.cs b/src/Stripe.net/Infrastructure/JsonSerializer.cs new file mode 100644 index 0000000000..617ccf231f --- /dev/null +++ b/src/Stripe.net/Infrastructure/JsonSerializer.cs @@ -0,0 +1,49 @@ +namespace Stripe.Infrastructure +{ + using System; + using System.Text.Json; + using Newtonsoft.Json; + + public interface IJsonSerializer + { + string SerializeObject(object value); + T DeserializeObject(string value); + } + + public class NewtonsoftJsonSerializer : IJsonSerializer + { + public string SerializeObject(object value) + { + return JsonConvert.SerializeObject(value); + } + + public T DeserializeObject(string value) + { + return JsonConvert.DeserializeObject(value); + } + } + + public class SystemTextJsonSerializer : IJsonSerializer + { + private readonly JsonSerializerOptions options; + + public SystemTextJsonSerializer() + { + this.options = new JsonSerializerOptions + { + PropertyNamingPolicy = JsonNamingPolicy.CamelCase, + WriteIndented = true + }; + } + + public string SerializeObject(object value) + { + return JsonSerializer.Serialize(value, this.options); + } + + public T DeserializeObject(string value) + { + return JsonSerializer.Deserialize(value, this.options); + } + } +}