From 676b6ba4ad136006110694efa8d345e610f178b8 Mon Sep 17 00:00:00 2001 From: Jaime Blasco Date: Thu, 29 Jun 2023 20:58:54 +0200 Subject: [PATCH] fix: reverse format matching flutter 3.10 --- .../api/elements/payment_element_options.dart | 6 +- .../confirm_card_payment_data.dart | 12 ++-- .../confirm_ideal_payment_data.dart | 6 +- .../confirm_sepa_debit_payment_data.dart | 3 +- .../api/payment_intents/payment_intent.dart | 48 ++++++++++----- .../src/api/setup_intents/setup_intent.dart | 39 ++++++++---- .../create_token_bank_account_data.dart | 12 ++-- .../stripe_js/lib/src/api/tokens/token.dart | 60 ++++++++++++------- 8 files changed, 124 insertions(+), 62 deletions(-) diff --git a/packages/stripe_js/lib/src/api/elements/payment_element_options.dart b/packages/stripe_js/lib/src/api/elements/payment_element_options.dart index 277503d48..1eae3e4cd 100644 --- a/packages/stripe_js/lib/src/api/elements/payment_element_options.dart +++ b/packages/stripe_js/lib/src/api/elements/payment_element_options.dart @@ -174,7 +174,8 @@ class PaymentElementFields with _$PaymentElementFields { @freezed class BillingDetailsFields with _$BillingDetailsFields { const factory BillingDetailsFields({ - @Default(PaymentElementFieldRequired.auto) PaymentElementFieldRequired name, + @Default(PaymentElementFieldRequired.auto) + PaymentElementFieldRequired name, @Default(PaymentElementFieldRequired.auto) PaymentElementFieldRequired email, @Default(PaymentElementFieldRequired.auto) @@ -196,7 +197,8 @@ class PaymentElementAddressFields with _$PaymentElementAddressFields { PaymentElementFieldRequired line1, @Default(PaymentElementFieldRequired.auto) PaymentElementFieldRequired line2, - @Default(PaymentElementFieldRequired.auto) PaymentElementFieldRequired city, + @Default(PaymentElementFieldRequired.auto) + PaymentElementFieldRequired city, @Default(PaymentElementFieldRequired.auto) PaymentElementFieldRequired state, @Default(PaymentElementFieldRequired.auto) diff --git a/packages/stripe_js/lib/src/api/payment_intents/confirm_card_payment_data.dart b/packages/stripe_js/lib/src/api/payment_intents/confirm_card_payment_data.dart index 95b860456..3a9fe9d2c 100644 --- a/packages/stripe_js/lib/src/api/payment_intents/confirm_card_payment_data.dart +++ b/packages/stripe_js/lib/src/api/payment_intents/confirm_card_payment_data.dart @@ -10,7 +10,8 @@ class ConfirmCardPaymentData with _$ConfirmCardPaymentData { /// Either the id of an existing PaymentMethod, or an object containing /// data to create a PaymentMethod with. /// See the use case sections below for details. - @paymentMethodDetailJsonKey CardPaymentMethodDetails? paymentMethod, + @paymentMethodDetailJsonKey + CardPaymentMethodDetails? paymentMethod, /// The shipping details for the payment, if collected. ShippingDetails? shipping, @@ -18,10 +19,12 @@ class ConfirmCardPaymentData with _$ConfirmCardPaymentData { /// If you are handling next actions yourself, pass in a return_url. /// If the subsequent action is redirect_to_url, /// this URL will be used on the return path for the redirect. - @JsonKey(name: "return_url") String? returnUrl, + @JsonKey(name: "return_url") + String? returnUrl, /// Email address that the receipt for the resulting payment will be sent to. - @JsonKey(name: "receipt_email") String? receiptEmail, + @JsonKey(name: "receipt_email") + String? receiptEmail, /// Indicates that you intend to make future payments with this /// PaymentIntent's payment method. @@ -42,7 +45,8 @@ class ConfirmCardPaymentData with _$ConfirmCardPaymentData { /// An object containing payment-method-specific configuration to /// confirm the PaymentIntent with. - @JsonKey(name: "payment_method_options") dynamic paymentMethodOptions, + @JsonKey(name: "payment_method_options") + dynamic paymentMethodOptions, }) = _ConfirmCardPaymentData; factory ConfirmCardPaymentData.fromJson(Map json) => diff --git a/packages/stripe_js/lib/src/api/payment_intents/confirm_ideal_payment_data.dart b/packages/stripe_js/lib/src/api/payment_intents/confirm_ideal_payment_data.dart index a3052c21d..35f25101c 100644 --- a/packages/stripe_js/lib/src/api/payment_intents/confirm_ideal_payment_data.dart +++ b/packages/stripe_js/lib/src/api/payment_intents/confirm_ideal_payment_data.dart @@ -10,10 +10,12 @@ class ConfirmIdealPaymentData with _$ConfirmIdealPaymentData { /// Either the id of an existing PaymentMethod, or an object containing /// data to create a PaymentMethod with. /// See the use case sections below for details. - @paymentMethodDetailJsonKey IdealPaymentMethodDetails? paymentMethod, + @paymentMethodDetailJsonKey + IdealPaymentMethodDetails? paymentMethod, /// The url your customer will be directed to after they complete authentication. - @JsonKey(name: "return_url") String? returnUrl, + @JsonKey(name: "return_url") + String? returnUrl, /// To set up a SEPA Direct Debit payment method using the bank details /// from this iDEAL payment, set this parameter to off_session. diff --git a/packages/stripe_js/lib/src/api/payment_intents/confirm_sepa_debit_payment_data.dart b/packages/stripe_js/lib/src/api/payment_intents/confirm_sepa_debit_payment_data.dart index 4161d4827..a990711cb 100644 --- a/packages/stripe_js/lib/src/api/payment_intents/confirm_sepa_debit_payment_data.dart +++ b/packages/stripe_js/lib/src/api/payment_intents/confirm_sepa_debit_payment_data.dart @@ -11,7 +11,8 @@ class ConfirmSepaDebitPaymentData with _$ConfirmSepaDebitPaymentData { /// Either the id of an existing PaymentMethod, or an object containing /// data to create a PaymentMethod with. /// See the use case sections below for details. - @paymentMethodDetailJsonKey SepaDebitPaymentMethodDetails? paymentMethod, + @paymentMethodDetailJsonKey + SepaDebitPaymentMethodDetails? paymentMethod, /// To set up the SEPA Direct Debit account for reuse, set this parameter /// to off_session. SEPA Direct Debit only accepts an off_session value diff --git a/packages/stripe_js/lib/src/api/payment_intents/payment_intent.dart b/packages/stripe_js/lib/src/api/payment_intents/payment_intent.dart index 23d52979f..1ef483efc 100644 --- a/packages/stripe_js/lib/src/api/payment_intents/payment_intent.dart +++ b/packages/stripe_js/lib/src/api/payment_intents/payment_intent.dart @@ -77,7 +77,8 @@ class PaymentIntent with _$PaymentIntent { /// String representing the object’s type. /// Objects of the same type share the same value. /// Value is "payment_intent". - @Default("payment_intent") String object, + @Default("payment_intent") + String object, /// Amount intended to be collected by this PaymentIntent. /// A positive integer representing how much to charge in the @@ -89,7 +90,8 @@ class PaymentIntent with _$PaymentIntent { required int amount, /// The amount that can be captured with from this PaymentIntent (in cents). - @JsonKey(name: "amount_capturable") int? amountCapturable, + @JsonKey(name: "amount_capturable") + int? amountCapturable, /// Details about items included in the amount @Default(PaymentIntentAmountDetails()) @@ -97,7 +99,8 @@ class PaymentIntent with _$PaymentIntent { PaymentIntentAmountDetails? amountDetails, /// The amount that was collected from this PaymentIntent (in cents). - @JsonKey(name: "amount_received") int? amountReceived, + @JsonKey(name: "amount_received") + int? amountReceived, /// CONNECT ONLY /// ID of the Connect application that created the PaymentIntent. @@ -110,7 +113,8 @@ class PaymentIntent with _$PaymentIntent { /// capped at the total payment amount. /// For more information, see the PaymentIntents use /// case for connected accounts.. - @JsonKey(name: "application_fee_amount") int? applicationFeeAmount, + @JsonKey(name: "application_fee_amount") + int? applicationFeeAmount, /// Settings to configure compatible payment methods from the /// Stripe Dashboard @@ -119,7 +123,8 @@ class PaymentIntent with _$PaymentIntent { /// Populated when status is canceled, this is the time at which the /// PaymentIntent was canceled. Measured in seconds since the Unix epoch. - @JsonKey(name: "canceled_at") int? canceledAt, + @JsonKey(name: "canceled_at") + int? canceledAt, /// Reason for cancellation of this PaymentIntent, /// either user-provided @@ -138,7 +143,8 @@ class PaymentIntent with _$PaymentIntent { /// /// Refer to our docs to accept a payment and learn about how `client_secret` /// should be handled. - @JsonKey(name: "client_secret") required String clientSecret, + @JsonKey(name: "client_secret") + required String clientSecret, /// Controls when the funds will be captured from the customer’s account. @JsonKey(name: "capture_method") @@ -175,10 +181,12 @@ class PaymentIntent with _$PaymentIntent { /// The payment error encountered in the previous PaymentIntent confirmation. /// It will be cleared if the PaymentIntent is later updated for any reason. - @JsonKey(name: "last_payment_error") StripeError? lastPaymentError, + @JsonKey(name: "last_payment_error") + StripeError? lastPaymentError, /// The latest charge created by this payment intent. - @JsonKey(name: "latest_charge") String? latestCharge, + @JsonKey(name: "latest_charge") + String? latestCharge, /// Has the value true if the object exists in live mode or the /// value false if the object exists in test mode. @@ -187,21 +195,25 @@ class PaymentIntent with _$PaymentIntent { /// Set of key-value pairs that you can attach to an object. /// This can be useful for storing additional information about the /// object in a structured format. - @Default({}) Map metadata, + @Default({}) + Map metadata, /// If present, this property tells you what actions you need to /// take in order for your customer to fulfill a payment using the /// provided source. - @JsonKey(name: "next_action") dynamic nextAction, + @JsonKey(name: "next_action") + dynamic nextAction, /// CONNECT ONLY /// The account (if any) for which the funds of the PaymentIntent are /// intended. See the PaymentIntents use case for connected accounts /// for details. - @JsonKey(name: "on_behalf_of") String? onBehalfOf, + @JsonKey(name: "on_behalf_of") + String? onBehalfOf, /// ID of the payment method used in this PaymentIntent. - @JsonKey(name: "payment_method") String? paymentMethod, + @JsonKey(name: "payment_method") + String? paymentMethod, /// Payment-method-specific configuration for this PaymentIntent. @Default({}) @@ -220,7 +232,8 @@ class PaymentIntent with _$PaymentIntent { /// Email address that the receipt for the resulting payment will be sent to. /// If receipt_email is specified for a payment in live mode, a receipt /// will be sent regardless of your email settings. - @JsonKey(name: "receipt_email") String? receiptEmail, + @JsonKey(name: "receipt_email") + String? receiptEmail, // ID of the review associated with this PaymentIntent, if any. String? review, @@ -244,7 +257,8 @@ class PaymentIntent with _$PaymentIntent { /// For non-card charges, you can use this value as the complete /// description that appears on your customers’ statements. /// Must contain at least one letter, maximum 22 characters. - @JsonKey(name: "statement_descriptor") String? statementDescriptor, + @JsonKey(name: "statement_descriptor") + String? statementDescriptor, /// Provides information about a card payment that customers see on /// their statements. @@ -263,12 +277,14 @@ class PaymentIntent with _$PaymentIntent { /// The data with which to automatically create a Transfer when the payment /// is finalized. See the PaymentIntents use case for connected /// accounts for details. - @JsonKey(name: "transfer_data") dynamic transferData, + @JsonKey(name: "transfer_data") + dynamic transferData, /// CONNECT ONLY /// A string that identifies the resulting payment as part of a group. /// See the PaymentIntents use case for connected accounts for details. - @JsonKey(name: "transfer_group") dynamic transferGroup, + @JsonKey(name: "transfer_group") + dynamic transferGroup, }) = _PaymentIntent; factory PaymentIntent.fromJson(Map json) => diff --git a/packages/stripe_js/lib/src/api/setup_intents/setup_intent.dart b/packages/stripe_js/lib/src/api/setup_intents/setup_intent.dart index c748e4025..fd4426bbb 100644 --- a/packages/stripe_js/lib/src/api/setup_intents/setup_intent.dart +++ b/packages/stripe_js/lib/src/api/setup_intents/setup_intent.dart @@ -74,7 +74,8 @@ class SetupIntent with _$SetupIntent { /// String representing the object’s type. /// Objects of the same type share the same value. /// Value is "setup_intent". - @Default("setup_intent") String object, + @Default("setup_intent") + String object, /// CONNECT ONLY /// ID of the Connect application that created the SetupIntent. @@ -86,7 +87,8 @@ class SetupIntent with _$SetupIntent { /// flows like InboundTransfer and OutboundTransfers. /// It cannot be set to true when setting up a PaymentMethod for a Customer, /// and defaults to false when attaching a PaymentMethod to a Customer. - @JsonKey(name: "attach_to_self") String? attachToSelf, + @JsonKey(name: "attach_to_self") + String? attachToSelf, /// Reason for cancellation of this SetupIntent, /// one of abandoned, requested_by_customer, or duplicate. @@ -99,7 +101,8 @@ class SetupIntent with _$SetupIntent { /// It should not be stored, logged, or exposed to anyone other than the /// customer. Make sure that you have TLS enabled on any page that includes /// the client secret. - @JsonKey(name: "client_secret") required String clientSecret, + @JsonKey(name: "client_secret") + required String clientSecret, /// Time at which the object was created. Measured in seconds since the /// Unix epoch. @@ -124,14 +127,17 @@ class SetupIntent with _$SetupIntent { List? flowDirections, /// The error encountered in the previous SetupIntent confirmation. - @JsonKey(name: "last_setup_error") dynamic lastSetupError, + @JsonKey(name: "last_setup_error") + dynamic lastSetupError, /// The most recent SetupAttempt for this SetupIntent. - @JsonKey(name: "latest_attempt") String? latestAttempt, + @JsonKey(name: "latest_attempt") + String? latestAttempt, /// Has the value true if the object exists in live mode or the /// value false if the object exists in test mode. - @Default(true) bool livemode, + @Default(true) + bool livemode, /// ID of the multi use Mandate generated by the SetupIntent. String? mandate, @@ -139,21 +145,26 @@ class SetupIntent with _$SetupIntent { /// Set of key-value pairs that you can attach to an object. /// This can be useful for storing additional information about the /// object in a structured format. - @Default({}) Map metadata, + @Default({}) + Map metadata, /// If present, this property tells you what actions you need to /// take in order for your customer to continue payment setup. - @JsonKey(name: "next_action") dynamic nextAction, + @JsonKey(name: "next_action") + dynamic nextAction, /// CONNECT ONLY /// The account (if any) for which the setup is intended. - @JsonKey(name: "on_behalf_of") String? onBehalfOf, + @JsonKey(name: "on_behalf_of") + String? onBehalfOf, /// ID of the payment method used in this SetupIntent. - @JsonKey(name: "payment_method") String? paymentMethod, + @JsonKey(name: "payment_method") + String? paymentMethod, /// Payment-method-specific configuration for this SetupIntent. - @JsonKey(name: "payment_method_options") dynamic paymentMethodOptions, + @JsonKey(name: "payment_method_options") + dynamic paymentMethodOptions, /// The list of payment method types (e.g. card) that this SetupIntent /// is allowed to set up. @@ -162,7 +173,8 @@ class SetupIntent with _$SetupIntent { List paymentMethodTypes, /// ID of the single_use Mandate generated by the SetupIntent. - @JsonKey(name: "single_use_mandate") String? singleUseMandate, + @JsonKey(name: "single_use_mandate") + String? singleUseMandate, /// Status of this SetupIntent, one of requires_payment_method, /// requires_confirmation, requires_action, processing, canceled, or @@ -174,7 +186,8 @@ class SetupIntent with _$SetupIntent { /// the customer is in your checkout flow. /// Use off_session if your customer may or may not be in your checkout flow. /// If not provided, this value defaults to off_session. - @Default(SetupIntentUsage.offSession) SetupIntentUsage usage, + @Default(SetupIntentUsage.offSession) + SetupIntentUsage usage, }) = _SetupIntent; factory SetupIntent.fromJson(Map json) => diff --git a/packages/stripe_js/lib/src/api/tokens/create_token_bank_account_data.dart b/packages/stripe_js/lib/src/api/tokens/create_token_bank_account_data.dart index 912e5771e..1156eb250 100644 --- a/packages/stripe_js/lib/src/api/tokens/create_token_bank_account_data.dart +++ b/packages/stripe_js/lib/src/api/tokens/create_token_bank_account_data.dart @@ -11,12 +11,16 @@ class CreateTokenBankAccountData with _$CreateTokenBankAccountData { /// Three character currency code (e.g., usd). required String currency, - @JsonKey(name: "routing_number") String? routingNumber, - @JsonKey(name: "account_number") required String accountNumber, - @JsonKey(name: "account_holder_name") String? accountHolderName, + @JsonKey(name: "routing_number") + String? routingNumber, + @JsonKey(name: "account_number") + required String accountNumber, + @JsonKey(name: "account_holder_name") + String? accountHolderName, @JsonKey(name: "account_holder_type") BankAccountHolderType? accountHolderType, - @JsonKey(name: "account_type") String? accountType, + @JsonKey(name: "account_type") + String? accountType, }) = _CreateTokenBankAccountData; factory CreateTokenBankAccountData.fromJson(Map json) => diff --git a/packages/stripe_js/lib/src/api/tokens/token.dart b/packages/stripe_js/lib/src/api/tokens/token.dart index 2e111c360..0f9e8c294 100644 --- a/packages/stripe_js/lib/src/api/tokens/token.dart +++ b/packages/stripe_js/lib/src/api/tokens/token.dart @@ -73,10 +73,12 @@ class BankAccountToken with _$BankAccountToken { /// String representing the object’s type. /// Objects of the same type share the same value. /// Value is "bank_account". - @Default("bank_account") String object, + @Default("bank_account") + String object, /// The name of the person or business that owns the bank account. - @JsonKey(name: "account_holder_name") String? accountHolderName, + @JsonKey(name: "account_holder_name") + String? accountHolderName, /// The type of entity that holds the account. /// This can be either individual or company. @@ -86,10 +88,12 @@ class BankAccountToken with _$BankAccountToken { /// The bank account type. /// This can only be checking or savings in most countries. /// In Japan, this can only be futsu or toza. - @JsonKey(name: "account_type") String? accountType, + @JsonKey(name: "account_type") + String? accountType, /// Name of the bank associated with the routing number (e.g., WELLS FARGO). - @JsonKey(name: "bank_name") String? bankName, + @JsonKey(name: "bank_name") + String? bankName, /// Two-letter ISO code representing the country the bank account is /// located in. @@ -107,7 +111,8 @@ class BankAccountToken with _$BankAccountToken { String? last4, /// The routing transit number for the bank account. - @JsonKey(name: "routing_number") String? routingNumber, + @JsonKey(name: "routing_number") + String? routingNumber, /// For bank accounts, possible values are new, validated, verified, /// verification_failed, or errored. @@ -145,37 +150,47 @@ class CardToken with _$CardToken { /// String representing the object’s type. /// Objects of the same type share the same value. /// Value is "card". - @Default("card") String object, + @Default("card") + String object, /// City/District/Suburb/Town/Village. - @JsonKey(name: "address_city") String? addressCity, + @JsonKey(name: "address_city") + String? addressCity, /// Billing address country, if provided when creating card. - @JsonKey(name: "address_country") String? addressCountry, + @JsonKey(name: "address_country") + String? addressCountry, /// Address line 1 (Street address/PO Box/Company name). - @JsonKey(name: "address_line1") String? addressLine1, + @JsonKey(name: "address_line1") + String? addressLine1, /// If address_line1 was provided, results of the check: /// pass, fail, unavailable, or unchecked. - @JsonKey(name: "address_line1_check") VerificationCheck? addressLine1Check, + @JsonKey(name: "address_line1_check") + VerificationCheck? addressLine1Check, /// Address line 2 (Apartment/Suite/Unit/Building). - @JsonKey(name: "address_line2") String? addressLine2, + @JsonKey(name: "address_line2") + String? addressLine2, /// State/County/Province/Region. - @JsonKey(name: "address_state") String? addressState, + @JsonKey(name: "address_state") + String? addressState, /// ZIP or postal code. - @JsonKey(name: "address_zip") String? addressZip, + @JsonKey(name: "address_zip") + String? addressZip, /// If address_zip was provided, results of the check: /// pass, fail, unavailable, or unchecked. - @JsonKey(name: "address_zip_check") VerificationCheck? addressZipCheck, + @JsonKey(name: "address_zip_check") + VerificationCheck? addressZipCheck, /// If address_zip was provided, results of the check: /// pass, fail, unavailable, or unchecked. - @Default(CardTokenBrand.unknown) CardTokenBrand? brand, + @Default(CardTokenBrand.unknown) + CardTokenBrand? brand, /// Two-letter ISO code representing the country of the card. /// You could use this attribute to get a sense of the @@ -194,17 +209,21 @@ class CardToken with _$CardToken { /// object, or when creating a charge. For more details, see /// Check if a card is valid without a charge. /// https://support.stripe.com/questions/check-if-a-card-is-valid-without-a-charge - @JsonKey(name: "cvc_check") VerificationCheck? cvcCheck, + @JsonKey(name: "cvc_check") + VerificationCheck? cvcCheck, /// (For tokenized numbers only.) /// The last four digits of the device account number. - @JsonKey(name: "dynamic_last4") String? dynamicLast4, + @JsonKey(name: "dynamic_last4") + String? dynamicLast4, /// Two-digit number representing the card’s expiration month. - @JsonKey(name: "exp_month") int? expMonth, + @JsonKey(name: "exp_month") + int? expMonth, /// Four-digit number representing the card’s expiration year. - @JsonKey(name: "exp_year") int? expYear, + @JsonKey(name: "exp_year") + int? expYear, /// Uniquely identifies this particular card number. /// You can use this attribute to check whether two customers who’ve @@ -226,7 +245,8 @@ class CardToken with _$CardToken { /// Set of key-value pairs that you can attach to an object. /// This can be useful for storing additional information about the object /// in a structured forma - @Default({}) Map metadata, + @Default({}) + Map metadata, /// Cardholder name. String? name,