diff --git a/example/lib/main.dart b/example/lib/main.dart index 302d245a3..5f876488a 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -8,7 +8,6 @@ void main() async { WidgetsFlutterBinding.ensureInitialized(); Stripe.publishableKey = stripePublishableKey; Stripe.merchantIdentifier = 'merchant.flutter.stripe.test'; - Stripe.urlScheme = 'flutterstripe'; await Stripe.instance.applySettings(); runApp(const App()); } diff --git a/example/lib/screens/screens.dart b/example/lib/screens/screens.dart index 1e9fac18e..a90a57f9f 100644 --- a/example/lib/screens/screens.dart +++ b/example/lib/screens/screens.dart @@ -265,7 +265,6 @@ class Example extends StatelessWidget { width: 48, ), builder: (contex) => KlarnaScreen(), - platformsSupported: [DevicePlatform.android, DevicePlatform.ios], ), Example( title: 'PayPal', diff --git a/packages/stripe/lib/src/stripe.dart b/packages/stripe/lib/src/stripe.dart index 2de77ef6b..e6da3967d 100644 --- a/packages/stripe/lib/src/stripe.dart +++ b/packages/stripe/lib/src/stripe.dart @@ -709,5 +709,6 @@ class Stripe { ValueNotifier? _isPlatformPaySupported; // Internal use only + @internal static final buildWebCard = _platform.buildCard; } 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 7ac747467..277503d48 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 @@ -176,11 +176,11 @@ class BillingDetailsFields with _$BillingDetailsFields { const factory BillingDetailsFields({ @Default(PaymentElementFieldRequired.auto) PaymentElementFieldRequired name, @Default(PaymentElementFieldRequired.auto) - PaymentElementFieldRequired email, + PaymentElementFieldRequired email, @Default(PaymentElementFieldRequired.auto) - PaymentElementFieldRequired phone, + PaymentElementFieldRequired phone, @Default(PaymentElementAddressFields.auto) - PaymentElementAddressFields address, + PaymentElementAddressFields address, }) = _BillingDetailsFields; static const auto = BillingDetailsFields(); @@ -193,16 +193,16 @@ class BillingDetailsFields with _$BillingDetailsFields { class PaymentElementAddressFields with _$PaymentElementAddressFields { const factory PaymentElementAddressFields({ @Default(PaymentElementFieldRequired.auto) - PaymentElementFieldRequired line1, + PaymentElementFieldRequired line1, @Default(PaymentElementFieldRequired.auto) - PaymentElementFieldRequired line2, + PaymentElementFieldRequired line2, @Default(PaymentElementFieldRequired.auto) PaymentElementFieldRequired city, @Default(PaymentElementFieldRequired.auto) - PaymentElementFieldRequired state, + PaymentElementFieldRequired state, @Default(PaymentElementFieldRequired.auto) - PaymentElementFieldRequired country, + PaymentElementFieldRequired country, @Default(PaymentElementFieldRequired.auto) - PaymentElementFieldRequired postalCode, + PaymentElementFieldRequired postalCode, }) = _PaymentElementAddressFields; static const auto = PaymentElementAddressFields(); 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 67112908e..95b860456 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 @@ -38,7 +38,7 @@ class ConfirmCardPaymentData with _$ConfirmCardPaymentData { /// and comply with regional legislation and network rules. For example, if /// your customer is impacted by SCA, using off_session will ensure that they are authenticated while processing this PaymentIntent. You will then be able to collect off-session payments for this customer. @JsonKey(name: "setup_future_usage") - PaymentIntentSetupFutureUsage? setupFutureUsage, + PaymentIntentSetupFutureUsage? setupFutureUsage, /// An object containing payment-method-specific configuration to /// confirm the PaymentIntent with. diff --git a/packages/stripe_js/lib/src/api/payment_intents/confirm_card_payment_data.freezed.dart b/packages/stripe_js/lib/src/api/payment_intents/confirm_card_payment_data.freezed.dart index 4bd4c7da0..83fb076c7 100644 --- a/packages/stripe_js/lib/src/api/payment_intents/confirm_card_payment_data.freezed.dart +++ b/packages/stripe_js/lib/src/api/payment_intents/confirm_card_payment_data.freezed.dart @@ -77,13 +77,17 @@ abstract class $ConfirmCardPaymentDataCopyWith<$Res> { _$ConfirmCardPaymentDataCopyWithImpl<$Res, ConfirmCardPaymentData>; @useResult $Res call( - {@paymentMethodDetailJsonKey CardPaymentMethodDetails? paymentMethod, + {@paymentMethodDetailJsonKey + CardPaymentMethodDetails? paymentMethod, ShippingDetails? shipping, - @JsonKey(name: "return_url") String? returnUrl, - @JsonKey(name: "receipt_email") String? receiptEmail, + @JsonKey(name: "return_url") + String? returnUrl, + @JsonKey(name: "receipt_email") + String? receiptEmail, @JsonKey(name: "setup_future_usage") - PaymentIntentSetupFutureUsage? setupFutureUsage, - @JsonKey(name: "payment_method_options") dynamic paymentMethodOptions}); + PaymentIntentSetupFutureUsage? setupFutureUsage, + @JsonKey(name: "payment_method_options") + dynamic paymentMethodOptions}); $CardPaymentMethodDetailsCopyWith<$Res>? get paymentMethod; $ShippingDetailsCopyWith<$Res>? get shipping; @@ -173,13 +177,17 @@ abstract class _$$_ConfirmCardPaymentDataCopyWith<$Res> @override @useResult $Res call( - {@paymentMethodDetailJsonKey CardPaymentMethodDetails? paymentMethod, + {@paymentMethodDetailJsonKey + CardPaymentMethodDetails? paymentMethod, ShippingDetails? shipping, - @JsonKey(name: "return_url") String? returnUrl, - @JsonKey(name: "receipt_email") String? receiptEmail, + @JsonKey(name: "return_url") + String? returnUrl, + @JsonKey(name: "receipt_email") + String? receiptEmail, @JsonKey(name: "setup_future_usage") - PaymentIntentSetupFutureUsage? setupFutureUsage, - @JsonKey(name: "payment_method_options") dynamic paymentMethodOptions}); + PaymentIntentSetupFutureUsage? setupFutureUsage, + @JsonKey(name: "payment_method_options") + dynamic paymentMethodOptions}); @override $CardPaymentMethodDetailsCopyWith<$Res>? get paymentMethod; @@ -349,14 +357,16 @@ class _$_ConfirmCardPaymentData implements _ConfirmCardPaymentData { abstract class _ConfirmCardPaymentData implements ConfirmCardPaymentData { const factory _ConfirmCardPaymentData( {@paymentMethodDetailJsonKey - final CardPaymentMethodDetails? paymentMethod, + final CardPaymentMethodDetails? paymentMethod, final ShippingDetails? shipping, - @JsonKey(name: "return_url") final String? returnUrl, - @JsonKey(name: "receipt_email") final String? receiptEmail, + @JsonKey(name: "return_url") + final String? returnUrl, + @JsonKey(name: "receipt_email") + final String? receiptEmail, @JsonKey(name: "setup_future_usage") - final PaymentIntentSetupFutureUsage? setupFutureUsage, + final PaymentIntentSetupFutureUsage? setupFutureUsage, @JsonKey(name: "payment_method_options") - final dynamic paymentMethodOptions}) = _$_ConfirmCardPaymentData; + final dynamic paymentMethodOptions}) = _$_ConfirmCardPaymentData; factory _ConfirmCardPaymentData.fromJson(Map json) = _$_ConfirmCardPaymentData.fromJson; 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 6fbde7351..a3052c21d 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 @@ -21,7 +21,7 @@ class ConfirmIdealPaymentData with _$ConfirmIdealPaymentData { /// PaymentIntent. The newly created SEPA Direct Debit PaymentMethod /// will be attached to this customer. @JsonKey(name: "setup_future_usage") - PaymentIntentSetupFutureUsage? setupFutureUsage, + PaymentIntentSetupFutureUsage? setupFutureUsage, }) = _ConfirmIdealPaymentData; factory ConfirmIdealPaymentData.fromJson(Map json) => diff --git a/packages/stripe_js/lib/src/api/payment_intents/confirm_ideal_payment_data.freezed.dart b/packages/stripe_js/lib/src/api/payment_intents/confirm_ideal_payment_data.freezed.dart index 588bfb322..3475eabd7 100644 --- a/packages/stripe_js/lib/src/api/payment_intents/confirm_ideal_payment_data.freezed.dart +++ b/packages/stripe_js/lib/src/api/payment_intents/confirm_ideal_payment_data.freezed.dart @@ -54,10 +54,12 @@ abstract class $ConfirmIdealPaymentDataCopyWith<$Res> { _$ConfirmIdealPaymentDataCopyWithImpl<$Res, ConfirmIdealPaymentData>; @useResult $Res call( - {@paymentMethodDetailJsonKey IdealPaymentMethodDetails? paymentMethod, - @JsonKey(name: "return_url") String? returnUrl, + {@paymentMethodDetailJsonKey + IdealPaymentMethodDetails? paymentMethod, + @JsonKey(name: "return_url") + String? returnUrl, @JsonKey(name: "setup_future_usage") - PaymentIntentSetupFutureUsage? setupFutureUsage}); + PaymentIntentSetupFutureUsage? setupFutureUsage}); $IdealPaymentMethodDetailsCopyWith<$Res>? get paymentMethod; } @@ -119,10 +121,12 @@ abstract class _$$_ConfirmIdealPaymentDataCopyWith<$Res> @override @useResult $Res call( - {@paymentMethodDetailJsonKey IdealPaymentMethodDetails? paymentMethod, - @JsonKey(name: "return_url") String? returnUrl, + {@paymentMethodDetailJsonKey + IdealPaymentMethodDetails? paymentMethod, + @JsonKey(name: "return_url") + String? returnUrl, @JsonKey(name: "setup_future_usage") - PaymentIntentSetupFutureUsage? setupFutureUsage}); + PaymentIntentSetupFutureUsage? setupFutureUsage}); @override $IdealPaymentMethodDetailsCopyWith<$Res>? get paymentMethod; @@ -235,10 +239,11 @@ class _$_ConfirmIdealPaymentData implements _ConfirmIdealPaymentData { abstract class _ConfirmIdealPaymentData implements ConfirmIdealPaymentData { const factory _ConfirmIdealPaymentData( {@paymentMethodDetailJsonKey - final IdealPaymentMethodDetails? paymentMethod, - @JsonKey(name: "return_url") final String? returnUrl, + final IdealPaymentMethodDetails? paymentMethod, + @JsonKey(name: "return_url") + final String? returnUrl, @JsonKey(name: "setup_future_usage") - final PaymentIntentSetupFutureUsage? setupFutureUsage}) = + final PaymentIntentSetupFutureUsage? setupFutureUsage}) = _$_ConfirmIdealPaymentData; factory _ConfirmIdealPaymentData.fromJson(Map json) = diff --git a/packages/stripe_js/lib/src/api/payment_intents/confirm_klarna_payment_data.dart b/packages/stripe_js/lib/src/api/payment_intents/confirm_klarna_payment_data.dart new file mode 100644 index 000000000..082771620 --- /dev/null +++ b/packages/stripe_js/lib/src/api/payment_intents/confirm_klarna_payment_data.dart @@ -0,0 +1,21 @@ +import 'package:freezed_annotation/freezed_annotation.dart'; +import 'package:stripe_js/stripe_api.dart'; + +part 'confirm_klarna_payment_data.freezed.dart'; +part 'confirm_klarna_payment_data.g.dart'; + +@freezed +class ConfirmKlarnaPaymentData with _$ConfirmKlarnaPaymentData { + const factory ConfirmKlarnaPaymentData({ + /// 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 KlarnaPaymentMethodDetails? paymentMethod, + + /// The url your customer will be directed to after they complete authentication. + @JsonKey(name: "return_url") String? returnUrl, + }) = _ConfirmKlarnaPaymentData; + + factory ConfirmKlarnaPaymentData.fromJson(Map json) => + _$ConfirmKlarnaPaymentDataFromJson(json); +} diff --git a/packages/stripe_js/lib/src/api/payment_intents/confirm_klarna_payment_data.freezed.dart b/packages/stripe_js/lib/src/api/payment_intents/confirm_klarna_payment_data.freezed.dart new file mode 100644 index 000000000..581b57179 --- /dev/null +++ b/packages/stripe_js/lib/src/api/payment_intents/confirm_klarna_payment_data.freezed.dart @@ -0,0 +1,225 @@ +// coverage:ignore-file +// GENERATED CODE - DO NOT MODIFY BY HAND +// ignore_for_file: type=lint +// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark + +part of 'confirm_klarna_payment_data.dart'; + +// ************************************************************************** +// FreezedGenerator +// ************************************************************************** + +T _$identity(T value) => value; + +final _privateConstructorUsedError = UnsupportedError( + 'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#custom-getters-and-methods'); + +ConfirmKlarnaPaymentData _$ConfirmKlarnaPaymentDataFromJson( + Map json) { + return _ConfirmKlarnaPaymentData.fromJson(json); +} + +/// @nodoc +mixin _$ConfirmKlarnaPaymentData { + /// 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 + KlarnaPaymentMethodDetails? get paymentMethod => + throw _privateConstructorUsedError; + + /// The url your customer will be directed to after they complete authentication. + @JsonKey(name: "return_url") + String? get returnUrl => throw _privateConstructorUsedError; + + Map toJson() => throw _privateConstructorUsedError; + @JsonKey(ignore: true) + $ConfirmKlarnaPaymentDataCopyWith get copyWith => + throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class $ConfirmKlarnaPaymentDataCopyWith<$Res> { + factory $ConfirmKlarnaPaymentDataCopyWith(ConfirmKlarnaPaymentData value, + $Res Function(ConfirmKlarnaPaymentData) then) = + _$ConfirmKlarnaPaymentDataCopyWithImpl<$Res, ConfirmKlarnaPaymentData>; + @useResult + $Res call( + {@paymentMethodDetailJsonKey KlarnaPaymentMethodDetails? paymentMethod, + @JsonKey(name: "return_url") String? returnUrl}); + + $KlarnaPaymentMethodDetailsCopyWith<$Res>? get paymentMethod; +} + +/// @nodoc +class _$ConfirmKlarnaPaymentDataCopyWithImpl<$Res, + $Val extends ConfirmKlarnaPaymentData> + implements $ConfirmKlarnaPaymentDataCopyWith<$Res> { + _$ConfirmKlarnaPaymentDataCopyWithImpl(this._value, this._then); + + // ignore: unused_field + final $Val _value; + // ignore: unused_field + final $Res Function($Val) _then; + + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? paymentMethod = freezed, + Object? returnUrl = freezed, + }) { + return _then(_value.copyWith( + paymentMethod: freezed == paymentMethod + ? _value.paymentMethod + : paymentMethod // ignore: cast_nullable_to_non_nullable + as KlarnaPaymentMethodDetails?, + returnUrl: freezed == returnUrl + ? _value.returnUrl + : returnUrl // ignore: cast_nullable_to_non_nullable + as String?, + ) as $Val); + } + + @override + @pragma('vm:prefer-inline') + $KlarnaPaymentMethodDetailsCopyWith<$Res>? get paymentMethod { + if (_value.paymentMethod == null) { + return null; + } + + return $KlarnaPaymentMethodDetailsCopyWith<$Res>(_value.paymentMethod!, + (value) { + return _then(_value.copyWith(paymentMethod: value) as $Val); + }); + } +} + +/// @nodoc +abstract class _$$_ConfirmKlarnaPaymentDataCopyWith<$Res> + implements $ConfirmKlarnaPaymentDataCopyWith<$Res> { + factory _$$_ConfirmKlarnaPaymentDataCopyWith( + _$_ConfirmKlarnaPaymentData value, + $Res Function(_$_ConfirmKlarnaPaymentData) then) = + __$$_ConfirmKlarnaPaymentDataCopyWithImpl<$Res>; + @override + @useResult + $Res call( + {@paymentMethodDetailJsonKey KlarnaPaymentMethodDetails? paymentMethod, + @JsonKey(name: "return_url") String? returnUrl}); + + @override + $KlarnaPaymentMethodDetailsCopyWith<$Res>? get paymentMethod; +} + +/// @nodoc +class __$$_ConfirmKlarnaPaymentDataCopyWithImpl<$Res> + extends _$ConfirmKlarnaPaymentDataCopyWithImpl<$Res, + _$_ConfirmKlarnaPaymentData> + implements _$$_ConfirmKlarnaPaymentDataCopyWith<$Res> { + __$$_ConfirmKlarnaPaymentDataCopyWithImpl(_$_ConfirmKlarnaPaymentData _value, + $Res Function(_$_ConfirmKlarnaPaymentData) _then) + : super(_value, _then); + + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? paymentMethod = freezed, + Object? returnUrl = freezed, + }) { + return _then(_$_ConfirmKlarnaPaymentData( + paymentMethod: freezed == paymentMethod + ? _value.paymentMethod + : paymentMethod // ignore: cast_nullable_to_non_nullable + as KlarnaPaymentMethodDetails?, + returnUrl: freezed == returnUrl + ? _value.returnUrl + : returnUrl // ignore: cast_nullable_to_non_nullable + as String?, + )); + } +} + +/// @nodoc +@JsonSerializable() +class _$_ConfirmKlarnaPaymentData implements _ConfirmKlarnaPaymentData { + const _$_ConfirmKlarnaPaymentData( + {@paymentMethodDetailJsonKey this.paymentMethod, + @JsonKey(name: "return_url") this.returnUrl}); + + factory _$_ConfirmKlarnaPaymentData.fromJson(Map json) => + _$$_ConfirmKlarnaPaymentDataFromJson(json); + + /// 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. + @override + @paymentMethodDetailJsonKey + final KlarnaPaymentMethodDetails? paymentMethod; + + /// The url your customer will be directed to after they complete authentication. + @override + @JsonKey(name: "return_url") + final String? returnUrl; + + @override + String toString() { + return 'ConfirmKlarnaPaymentData(paymentMethod: $paymentMethod, returnUrl: $returnUrl)'; + } + + @override + bool operator ==(dynamic other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$_ConfirmKlarnaPaymentData && + (identical(other.paymentMethod, paymentMethod) || + other.paymentMethod == paymentMethod) && + (identical(other.returnUrl, returnUrl) || + other.returnUrl == returnUrl)); + } + + @JsonKey(ignore: true) + @override + int get hashCode => Object.hash(runtimeType, paymentMethod, returnUrl); + + @JsonKey(ignore: true) + @override + @pragma('vm:prefer-inline') + _$$_ConfirmKlarnaPaymentDataCopyWith<_$_ConfirmKlarnaPaymentData> + get copyWith => __$$_ConfirmKlarnaPaymentDataCopyWithImpl< + _$_ConfirmKlarnaPaymentData>(this, _$identity); + + @override + Map toJson() { + return _$$_ConfirmKlarnaPaymentDataToJson( + this, + ); + } +} + +abstract class _ConfirmKlarnaPaymentData implements ConfirmKlarnaPaymentData { + const factory _ConfirmKlarnaPaymentData( + {@paymentMethodDetailJsonKey + final KlarnaPaymentMethodDetails? paymentMethod, + @JsonKey(name: "return_url") + final String? returnUrl}) = _$_ConfirmKlarnaPaymentData; + + factory _ConfirmKlarnaPaymentData.fromJson(Map json) = + _$_ConfirmKlarnaPaymentData.fromJson; + + @override + + /// 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 + KlarnaPaymentMethodDetails? get paymentMethod; + @override + + /// The url your customer will be directed to after they complete authentication. + @JsonKey(name: "return_url") + String? get returnUrl; + @override + @JsonKey(ignore: true) + _$$_ConfirmKlarnaPaymentDataCopyWith<_$_ConfirmKlarnaPaymentData> + get copyWith => throw _privateConstructorUsedError; +} diff --git a/packages/stripe_js/lib/src/api/payment_intents/confirm_klarna_payment_data.g.dart b/packages/stripe_js/lib/src/api/payment_intents/confirm_klarna_payment_data.g.dart new file mode 100644 index 000000000..3e771cf1d --- /dev/null +++ b/packages/stripe_js/lib/src/api/payment_intents/confirm_klarna_payment_data.g.dart @@ -0,0 +1,32 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'confirm_klarna_payment_data.dart'; + +// ************************************************************************** +// JsonSerializableGenerator +// ************************************************************************** + +_$_ConfirmKlarnaPaymentData _$$_ConfirmKlarnaPaymentDataFromJson(Map json) => + _$_ConfirmKlarnaPaymentData( + paymentMethod: json['payment_method'] == null + ? null + : KlarnaPaymentMethodDetails.fromJson( + Map.from(json['payment_method'] as Map)), + returnUrl: json['return_url'] as String?, + ); + +Map _$$_ConfirmKlarnaPaymentDataToJson( + _$_ConfirmKlarnaPaymentData instance) { + final val = {}; + + void writeNotNull(String key, dynamic value) { + if (value != null) { + val[key] = value; + } + } + + writeNotNull('payment_method', + PaymentMethodDetails.toJsonConverter(instance.paymentMethod)); + writeNotNull('return_url', instance.returnUrl); + return val; +} diff --git a/packages/stripe_js/lib/src/api/payment_intents/confirm_klarna_payment_options.dart b/packages/stripe_js/lib/src/api/payment_intents/confirm_klarna_payment_options.dart new file mode 100644 index 000000000..ba4b37320 --- /dev/null +++ b/packages/stripe_js/lib/src/api/payment_intents/confirm_klarna_payment_options.dart @@ -0,0 +1,16 @@ +import 'package:freezed_annotation/freezed_annotation.dart'; + +part 'confirm_klarna_payment_options.freezed.dart'; +part 'confirm_klarna_payment_options.g.dart'; + +@freezed +class ConfirmKlarnaPaymentOptions with _$ConfirmKlarnaPaymentOptions { + const factory ConfirmKlarnaPaymentOptions({ + /// Set this to false if you want to manually handle + /// the authorization redirect. Default is true. + @Default(true) bool? handleActions, + }) = _ConfirmKlarnaPaymentOptions; + + factory ConfirmKlarnaPaymentOptions.fromJson(Map json) => + _$ConfirmKlarnaPaymentOptionsFromJson(json); +} diff --git a/packages/stripe_js/lib/src/api/payment_intents/confirm_klarna_payment_options.freezed.dart b/packages/stripe_js/lib/src/api/payment_intents/confirm_klarna_payment_options.freezed.dart new file mode 100644 index 000000000..a0f82d09f --- /dev/null +++ b/packages/stripe_js/lib/src/api/payment_intents/confirm_klarna_payment_options.freezed.dart @@ -0,0 +1,170 @@ +// coverage:ignore-file +// GENERATED CODE - DO NOT MODIFY BY HAND +// ignore_for_file: type=lint +// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark + +part of 'confirm_klarna_payment_options.dart'; + +// ************************************************************************** +// FreezedGenerator +// ************************************************************************** + +T _$identity(T value) => value; + +final _privateConstructorUsedError = UnsupportedError( + 'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#custom-getters-and-methods'); + +ConfirmKlarnaPaymentOptions _$ConfirmKlarnaPaymentOptionsFromJson( + Map json) { + return _ConfirmKlarnaPaymentOptions.fromJson(json); +} + +/// @nodoc +mixin _$ConfirmKlarnaPaymentOptions { + /// Set this to false if you want to manually handle + /// the authorization redirect. Default is true. + bool? get handleActions => throw _privateConstructorUsedError; + + Map toJson() => throw _privateConstructorUsedError; + @JsonKey(ignore: true) + $ConfirmKlarnaPaymentOptionsCopyWith + get copyWith => throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class $ConfirmKlarnaPaymentOptionsCopyWith<$Res> { + factory $ConfirmKlarnaPaymentOptionsCopyWith( + ConfirmKlarnaPaymentOptions value, + $Res Function(ConfirmKlarnaPaymentOptions) then) = + _$ConfirmKlarnaPaymentOptionsCopyWithImpl<$Res, + ConfirmKlarnaPaymentOptions>; + @useResult + $Res call({bool? handleActions}); +} + +/// @nodoc +class _$ConfirmKlarnaPaymentOptionsCopyWithImpl<$Res, + $Val extends ConfirmKlarnaPaymentOptions> + implements $ConfirmKlarnaPaymentOptionsCopyWith<$Res> { + _$ConfirmKlarnaPaymentOptionsCopyWithImpl(this._value, this._then); + + // ignore: unused_field + final $Val _value; + // ignore: unused_field + final $Res Function($Val) _then; + + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? handleActions = freezed, + }) { + return _then(_value.copyWith( + handleActions: freezed == handleActions + ? _value.handleActions + : handleActions // ignore: cast_nullable_to_non_nullable + as bool?, + ) as $Val); + } +} + +/// @nodoc +abstract class _$$_ConfirmKlarnaPaymentOptionsCopyWith<$Res> + implements $ConfirmKlarnaPaymentOptionsCopyWith<$Res> { + factory _$$_ConfirmKlarnaPaymentOptionsCopyWith( + _$_ConfirmKlarnaPaymentOptions value, + $Res Function(_$_ConfirmKlarnaPaymentOptions) then) = + __$$_ConfirmKlarnaPaymentOptionsCopyWithImpl<$Res>; + @override + @useResult + $Res call({bool? handleActions}); +} + +/// @nodoc +class __$$_ConfirmKlarnaPaymentOptionsCopyWithImpl<$Res> + extends _$ConfirmKlarnaPaymentOptionsCopyWithImpl<$Res, + _$_ConfirmKlarnaPaymentOptions> + implements _$$_ConfirmKlarnaPaymentOptionsCopyWith<$Res> { + __$$_ConfirmKlarnaPaymentOptionsCopyWithImpl( + _$_ConfirmKlarnaPaymentOptions _value, + $Res Function(_$_ConfirmKlarnaPaymentOptions) _then) + : super(_value, _then); + + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? handleActions = freezed, + }) { + return _then(_$_ConfirmKlarnaPaymentOptions( + handleActions: freezed == handleActions + ? _value.handleActions + : handleActions // ignore: cast_nullable_to_non_nullable + as bool?, + )); + } +} + +/// @nodoc +@JsonSerializable() +class _$_ConfirmKlarnaPaymentOptions implements _ConfirmKlarnaPaymentOptions { + const _$_ConfirmKlarnaPaymentOptions({this.handleActions = true}); + + factory _$_ConfirmKlarnaPaymentOptions.fromJson(Map json) => + _$$_ConfirmKlarnaPaymentOptionsFromJson(json); + + /// Set this to false if you want to manually handle + /// the authorization redirect. Default is true. + @override + @JsonKey() + final bool? handleActions; + + @override + String toString() { + return 'ConfirmKlarnaPaymentOptions(handleActions: $handleActions)'; + } + + @override + bool operator ==(dynamic other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$_ConfirmKlarnaPaymentOptions && + (identical(other.handleActions, handleActions) || + other.handleActions == handleActions)); + } + + @JsonKey(ignore: true) + @override + int get hashCode => Object.hash(runtimeType, handleActions); + + @JsonKey(ignore: true) + @override + @pragma('vm:prefer-inline') + _$$_ConfirmKlarnaPaymentOptionsCopyWith<_$_ConfirmKlarnaPaymentOptions> + get copyWith => __$$_ConfirmKlarnaPaymentOptionsCopyWithImpl< + _$_ConfirmKlarnaPaymentOptions>(this, _$identity); + + @override + Map toJson() { + return _$$_ConfirmKlarnaPaymentOptionsToJson( + this, + ); + } +} + +abstract class _ConfirmKlarnaPaymentOptions + implements ConfirmKlarnaPaymentOptions { + const factory _ConfirmKlarnaPaymentOptions({final bool? handleActions}) = + _$_ConfirmKlarnaPaymentOptions; + + factory _ConfirmKlarnaPaymentOptions.fromJson(Map json) = + _$_ConfirmKlarnaPaymentOptions.fromJson; + + @override + + /// Set this to false if you want to manually handle + /// the authorization redirect. Default is true. + bool? get handleActions; + @override + @JsonKey(ignore: true) + _$$_ConfirmKlarnaPaymentOptionsCopyWith<_$_ConfirmKlarnaPaymentOptions> + get copyWith => throw _privateConstructorUsedError; +} diff --git a/packages/stripe_js/lib/src/api/payment_intents/confirm_klarna_payment_options.g.dart b/packages/stripe_js/lib/src/api/payment_intents/confirm_klarna_payment_options.g.dart new file mode 100644 index 000000000..c132a8276 --- /dev/null +++ b/packages/stripe_js/lib/src/api/payment_intents/confirm_klarna_payment_options.g.dart @@ -0,0 +1,27 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'confirm_klarna_payment_options.dart'; + +// ************************************************************************** +// JsonSerializableGenerator +// ************************************************************************** + +_$_ConfirmKlarnaPaymentOptions _$$_ConfirmKlarnaPaymentOptionsFromJson( + Map json) => + _$_ConfirmKlarnaPaymentOptions( + handleActions: json['handleActions'] as bool? ?? true, + ); + +Map _$$_ConfirmKlarnaPaymentOptionsToJson( + _$_ConfirmKlarnaPaymentOptions instance) { + final val = {}; + + void writeNotNull(String key, dynamic value) { + if (value != null) { + val[key] = value; + } + } + + writeNotNull('handleActions', instance.handleActions); + return val; +} 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 77eff66ca..4161d4827 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 @@ -19,7 +19,7 @@ class ConfirmSepaDebitPaymentData with _$ConfirmSepaDebitPaymentData { /// the PaymentMethod will be attached to the customer when the /// PaymentIntent transitions to processing. @JsonKey(name: "setup_future_usage") - PaymentIntentSetupFutureUsage? setupFutureUsage, + PaymentIntentSetupFutureUsage? setupFutureUsage, }) = _ConfirmSepaDebitPaymentData; factory ConfirmSepaDebitPaymentData.fromJson(Map json) => diff --git a/packages/stripe_js/lib/src/api/payment_intents/confirm_sepa_debit_payment_data.freezed.dart b/packages/stripe_js/lib/src/api/payment_intents/confirm_sepa_debit_payment_data.freezed.dart index 3c3ef4dec..6e5540401 100644 --- a/packages/stripe_js/lib/src/api/payment_intents/confirm_sepa_debit_payment_data.freezed.dart +++ b/packages/stripe_js/lib/src/api/payment_intents/confirm_sepa_debit_payment_data.freezed.dart @@ -52,9 +52,10 @@ abstract class $ConfirmSepaDebitPaymentDataCopyWith<$Res> { ConfirmSepaDebitPaymentData>; @useResult $Res call( - {@paymentMethodDetailJsonKey SepaDebitPaymentMethodDetails? paymentMethod, + {@paymentMethodDetailJsonKey + SepaDebitPaymentMethodDetails? paymentMethod, @JsonKey(name: "setup_future_usage") - PaymentIntentSetupFutureUsage? setupFutureUsage}); + PaymentIntentSetupFutureUsage? setupFutureUsage}); $SepaDebitPaymentMethodDetailsCopyWith<$Res>? get paymentMethod; } @@ -112,9 +113,10 @@ abstract class _$$_ConfirmSepaDebitPaymentDataCopyWith<$Res> @override @useResult $Res call( - {@paymentMethodDetailJsonKey SepaDebitPaymentMethodDetails? paymentMethod, + {@paymentMethodDetailJsonKey + SepaDebitPaymentMethodDetails? paymentMethod, @JsonKey(name: "setup_future_usage") - PaymentIntentSetupFutureUsage? setupFutureUsage}); + PaymentIntentSetupFutureUsage? setupFutureUsage}); @override $SepaDebitPaymentMethodDetailsCopyWith<$Res>? get paymentMethod; @@ -214,9 +216,9 @@ abstract class _ConfirmSepaDebitPaymentData implements ConfirmSepaDebitPaymentData { const factory _ConfirmSepaDebitPaymentData( {@paymentMethodDetailJsonKey - final SepaDebitPaymentMethodDetails? paymentMethod, + final SepaDebitPaymentMethodDetails? paymentMethod, @JsonKey(name: "setup_future_usage") - final PaymentIntentSetupFutureUsage? setupFutureUsage}) = + final PaymentIntentSetupFutureUsage? setupFutureUsage}) = _$_ConfirmSepaDebitPaymentData; factory _ConfirmSepaDebitPaymentData.fromJson(Map json) = @@ -268,45 +270,54 @@ mixin _$SepaDebitPaymentMethodDetails { @optionalTypeArgs TResult when( TResult Function( - @JsonKey(name: "sepa_debit") @ElementConverter() Element sepaDebit, + @JsonKey(name: "sepa_debit") + @ElementConverter() + Element sepaDebit, @JsonKey(name: "billing_details") - SepaBillingDetails? billingDetails) + SepaBillingDetails? billingDetails) $default, { required TResult Function(String id) id, required TResult Function( - @JsonKey(name: "sepa_debit") SepaDebitIbanData sepaDebit, + @JsonKey(name: "sepa_debit") + SepaDebitIbanData sepaDebit, @JsonKey(name: "billing_details") - SepaBillingDetails? billingDetails) + SepaBillingDetails? billingDetails) withIban, }) => throw _privateConstructorUsedError; @optionalTypeArgs TResult? whenOrNull( TResult? Function( - @JsonKey(name: "sepa_debit") @ElementConverter() Element sepaDebit, + @JsonKey(name: "sepa_debit") + @ElementConverter() + Element sepaDebit, @JsonKey(name: "billing_details") - SepaBillingDetails? billingDetails)? + SepaBillingDetails? billingDetails)? $default, { TResult? Function(String id)? id, TResult? Function( - @JsonKey(name: "sepa_debit") SepaDebitIbanData sepaDebit, + @JsonKey(name: "sepa_debit") + SepaDebitIbanData sepaDebit, @JsonKey(name: "billing_details") - SepaBillingDetails? billingDetails)? + SepaBillingDetails? billingDetails)? withIban, }) => throw _privateConstructorUsedError; @optionalTypeArgs TResult maybeWhen( TResult Function( - @JsonKey(name: "sepa_debit") @ElementConverter() Element sepaDebit, + @JsonKey(name: "sepa_debit") + @ElementConverter() + Element sepaDebit, @JsonKey(name: "billing_details") - SepaBillingDetails? billingDetails)? + SepaBillingDetails? billingDetails)? $default, { TResult Function(String id)? id, TResult Function( - @JsonKey(name: "sepa_debit") SepaDebitIbanData sepaDebit, + @JsonKey(name: "sepa_debit") + SepaDebitIbanData sepaDebit, @JsonKey(name: "billing_details") - SepaBillingDetails? billingDetails)? + SepaBillingDetails? billingDetails)? withIban, required TResult orElse(), }) => @@ -438,15 +449,18 @@ class _$_IdSepaDebitPaymentMethodDetails @optionalTypeArgs TResult when( TResult Function( - @JsonKey(name: "sepa_debit") @ElementConverter() Element sepaDebit, + @JsonKey(name: "sepa_debit") + @ElementConverter() + Element sepaDebit, @JsonKey(name: "billing_details") - SepaBillingDetails? billingDetails) + SepaBillingDetails? billingDetails) $default, { required TResult Function(String id) id, required TResult Function( - @JsonKey(name: "sepa_debit") SepaDebitIbanData sepaDebit, + @JsonKey(name: "sepa_debit") + SepaDebitIbanData sepaDebit, @JsonKey(name: "billing_details") - SepaBillingDetails? billingDetails) + SepaBillingDetails? billingDetails) withIban, }) { return id(this.id); @@ -456,15 +470,18 @@ class _$_IdSepaDebitPaymentMethodDetails @optionalTypeArgs TResult? whenOrNull( TResult? Function( - @JsonKey(name: "sepa_debit") @ElementConverter() Element sepaDebit, + @JsonKey(name: "sepa_debit") + @ElementConverter() + Element sepaDebit, @JsonKey(name: "billing_details") - SepaBillingDetails? billingDetails)? + SepaBillingDetails? billingDetails)? $default, { TResult? Function(String id)? id, TResult? Function( - @JsonKey(name: "sepa_debit") SepaDebitIbanData sepaDebit, + @JsonKey(name: "sepa_debit") + SepaDebitIbanData sepaDebit, @JsonKey(name: "billing_details") - SepaBillingDetails? billingDetails)? + SepaBillingDetails? billingDetails)? withIban, }) { return id?.call(this.id); @@ -474,15 +491,18 @@ class _$_IdSepaDebitPaymentMethodDetails @optionalTypeArgs TResult maybeWhen( TResult Function( - @JsonKey(name: "sepa_debit") @ElementConverter() Element sepaDebit, + @JsonKey(name: "sepa_debit") + @ElementConverter() + Element sepaDebit, @JsonKey(name: "billing_details") - SepaBillingDetails? billingDetails)? + SepaBillingDetails? billingDetails)? $default, { TResult Function(String id)? id, TResult Function( - @JsonKey(name: "sepa_debit") SepaDebitIbanData sepaDebit, + @JsonKey(name: "sepa_debit") + SepaDebitIbanData sepaDebit, @JsonKey(name: "billing_details") - SepaBillingDetails? billingDetails)? + SepaBillingDetails? billingDetails)? withIban, required TResult orElse(), }) { @@ -664,15 +684,18 @@ class _$_SepaDebitPaymentMethodDetails @optionalTypeArgs TResult when( TResult Function( - @JsonKey(name: "sepa_debit") @ElementConverter() Element sepaDebit, + @JsonKey(name: "sepa_debit") + @ElementConverter() + Element sepaDebit, @JsonKey(name: "billing_details") - SepaBillingDetails? billingDetails) + SepaBillingDetails? billingDetails) $default, { required TResult Function(String id) id, required TResult Function( - @JsonKey(name: "sepa_debit") SepaDebitIbanData sepaDebit, + @JsonKey(name: "sepa_debit") + SepaDebitIbanData sepaDebit, @JsonKey(name: "billing_details") - SepaBillingDetails? billingDetails) + SepaBillingDetails? billingDetails) withIban, }) { return $default(sepaDebit, billingDetails); @@ -682,15 +705,18 @@ class _$_SepaDebitPaymentMethodDetails @optionalTypeArgs TResult? whenOrNull( TResult? Function( - @JsonKey(name: "sepa_debit") @ElementConverter() Element sepaDebit, + @JsonKey(name: "sepa_debit") + @ElementConverter() + Element sepaDebit, @JsonKey(name: "billing_details") - SepaBillingDetails? billingDetails)? + SepaBillingDetails? billingDetails)? $default, { TResult? Function(String id)? id, TResult? Function( - @JsonKey(name: "sepa_debit") SepaDebitIbanData sepaDebit, + @JsonKey(name: "sepa_debit") + SepaDebitIbanData sepaDebit, @JsonKey(name: "billing_details") - SepaBillingDetails? billingDetails)? + SepaBillingDetails? billingDetails)? withIban, }) { return $default?.call(sepaDebit, billingDetails); @@ -700,15 +726,18 @@ class _$_SepaDebitPaymentMethodDetails @optionalTypeArgs TResult maybeWhen( TResult Function( - @JsonKey(name: "sepa_debit") @ElementConverter() Element sepaDebit, + @JsonKey(name: "sepa_debit") + @ElementConverter() + Element sepaDebit, @JsonKey(name: "billing_details") - SepaBillingDetails? billingDetails)? + SepaBillingDetails? billingDetails)? $default, { TResult Function(String id)? id, TResult Function( - @JsonKey(name: "sepa_debit") SepaDebitIbanData sepaDebit, + @JsonKey(name: "sepa_debit") + SepaDebitIbanData sepaDebit, @JsonKey(name: "billing_details") - SepaBillingDetails? billingDetails)? + SepaBillingDetails? billingDetails)? withIban, required TResult orElse(), }) { @@ -766,9 +795,9 @@ abstract class _SepaDebitPaymentMethodDetails const factory _SepaDebitPaymentMethodDetails( {@JsonKey(name: "sepa_debit") @ElementConverter() - required final Element sepaDebit, + required final Element sepaDebit, @JsonKey(name: "billing_details") - final SepaBillingDetails? billingDetails}) = + final SepaBillingDetails? billingDetails}) = _$_SepaDebitPaymentMethodDetails; factory _SepaDebitPaymentMethodDetails.fromJson(Map json) = @@ -910,15 +939,18 @@ class _$_SepaDebitPaymentMethodDetailsWithIban @optionalTypeArgs TResult when( TResult Function( - @JsonKey(name: "sepa_debit") @ElementConverter() Element sepaDebit, + @JsonKey(name: "sepa_debit") + @ElementConverter() + Element sepaDebit, @JsonKey(name: "billing_details") - SepaBillingDetails? billingDetails) + SepaBillingDetails? billingDetails) $default, { required TResult Function(String id) id, required TResult Function( - @JsonKey(name: "sepa_debit") SepaDebitIbanData sepaDebit, + @JsonKey(name: "sepa_debit") + SepaDebitIbanData sepaDebit, @JsonKey(name: "billing_details") - SepaBillingDetails? billingDetails) + SepaBillingDetails? billingDetails) withIban, }) { return withIban(sepaDebit, billingDetails); @@ -928,15 +960,18 @@ class _$_SepaDebitPaymentMethodDetailsWithIban @optionalTypeArgs TResult? whenOrNull( TResult? Function( - @JsonKey(name: "sepa_debit") @ElementConverter() Element sepaDebit, + @JsonKey(name: "sepa_debit") + @ElementConverter() + Element sepaDebit, @JsonKey(name: "billing_details") - SepaBillingDetails? billingDetails)? + SepaBillingDetails? billingDetails)? $default, { TResult? Function(String id)? id, TResult? Function( - @JsonKey(name: "sepa_debit") SepaDebitIbanData sepaDebit, + @JsonKey(name: "sepa_debit") + SepaDebitIbanData sepaDebit, @JsonKey(name: "billing_details") - SepaBillingDetails? billingDetails)? + SepaBillingDetails? billingDetails)? withIban, }) { return withIban?.call(sepaDebit, billingDetails); @@ -946,15 +981,18 @@ class _$_SepaDebitPaymentMethodDetailsWithIban @optionalTypeArgs TResult maybeWhen( TResult Function( - @JsonKey(name: "sepa_debit") @ElementConverter() Element sepaDebit, + @JsonKey(name: "sepa_debit") + @ElementConverter() + Element sepaDebit, @JsonKey(name: "billing_details") - SepaBillingDetails? billingDetails)? + SepaBillingDetails? billingDetails)? $default, { TResult Function(String id)? id, TResult Function( - @JsonKey(name: "sepa_debit") SepaDebitIbanData sepaDebit, + @JsonKey(name: "sepa_debit") + SepaDebitIbanData sepaDebit, @JsonKey(name: "billing_details") - SepaBillingDetails? billingDetails)? + SepaBillingDetails? billingDetails)? withIban, required TResult orElse(), }) { @@ -1010,10 +1048,11 @@ class _$_SepaDebitPaymentMethodDetailsWithIban abstract class _SepaDebitPaymentMethodDetailsWithIban implements SepaDebitPaymentMethodDetails { const factory _SepaDebitPaymentMethodDetailsWithIban( - {@JsonKey(name: "sepa_debit") required final SepaDebitIbanData sepaDebit, - @JsonKey(name: "billing_details") - final SepaBillingDetails? - billingDetails}) = _$_SepaDebitPaymentMethodDetailsWithIban; + {@JsonKey(name: "sepa_debit") + required final SepaDebitIbanData sepaDebit, + @JsonKey(name: "billing_details") + final SepaBillingDetails? billingDetails}) = + _$_SepaDebitPaymentMethodDetailsWithIban; factory _SepaDebitPaymentMethodDetailsWithIban.fromJson( Map json) = 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 eedef7784..23d52979f 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 @@ -94,7 +94,7 @@ class PaymentIntent with _$PaymentIntent { /// Details about items included in the amount @Default(PaymentIntentAmountDetails()) @JsonKey(name: "amount_details") - PaymentIntentAmountDetails? amountDetails, + PaymentIntentAmountDetails? amountDetails, /// The amount that was collected from this PaymentIntent (in cents). @JsonKey(name: "amount_received") int? amountReceived, @@ -115,7 +115,7 @@ class PaymentIntent with _$PaymentIntent { /// Settings to configure compatible payment methods from the /// Stripe Dashboard @JsonKey(name: "automatic_payment_methods") - PaymentIntentAutomaticPaymentMethods? automaticPaymentMethods, + PaymentIntentAutomaticPaymentMethods? automaticPaymentMethods, /// Populated when status is canceled, this is the time at which the /// PaymentIntent was canceled. Measured in seconds since the Unix epoch. @@ -127,7 +127,7 @@ class PaymentIntent with _$PaymentIntent { /// generated by Stripe internally /// (failed_invoice, void_invoice, or automatic). @JsonKey(name: "cancellation_reason") - PaymentIntentCancellationReason? cancellationReason, + PaymentIntentCancellationReason? cancellationReason, /// The client secret of this PaymentIntent. Used for client-side retrieval /// using a publishable key. @@ -143,10 +143,10 @@ class PaymentIntent with _$PaymentIntent { /// Controls when the funds will be captured from the customer’s account. @JsonKey(name: "capture_method") @Default(PaymentIntentCaptureMethod.automatic) - PaymentIntentCaptureMethod captureMethod, + PaymentIntentCaptureMethod captureMethod, @JsonKey(name: "confirmation_method") @Default(PaymentIntentConfirmationMethod.automatic) - PaymentIntentConfirmationMethod confirmationMethod, + PaymentIntentConfirmationMethod confirmationMethod, /// Time at which the object was created. Measured in seconds since the /// Unix epoch. @@ -206,13 +206,13 @@ class PaymentIntent with _$PaymentIntent { /// Payment-method-specific configuration for this PaymentIntent. @Default({}) @JsonKey(name: "payment_method_options") - Map paymentMethodOptions, + Map paymentMethodOptions, /// The list of payment method types (e.g. card) that this PaymentIntent /// is allowed to use. @JsonKey(name: "payment_method_types") @Default([]) - List paymentMethodTypes, + List paymentMethodTypes, /// If present, this property tells you about the processing state of the payment. dynamic processing, @@ -236,7 +236,7 @@ class PaymentIntent with _$PaymentIntent { /// to dynamically optimize your payment flow and comply with regional /// legislation and network rules, such as SCA. @JsonKey(name: "setup_future_usage") - PaymentIntentSetupFutureUsage? setupFutureUsage, + PaymentIntentSetupFutureUsage? setupFutureUsage, /// Shipping information for this PaymentIntent. ShippingDetails? shipping, @@ -252,7 +252,7 @@ class PaymentIntent with _$PaymentIntent { /// descriptor that’s set on the account to form the complete statement /// descriptor. Maximum 22 characters for the concatenated descriptor. @JsonKey(name: "statement_descriptor_suffix") - String? statementDescriptorSuffix, + String? statementDescriptorSuffix, /// Status of this PaymentIntent, one of requires_payment_method, /// requires_confirmation, requires_action, processing, requires_capture, diff --git a/packages/stripe_js/lib/src/api/payment_intents/payment_intent.freezed.dart b/packages/stripe_js/lib/src/api/payment_intents/payment_intent.freezed.dart index 1e9eeecd2..7b40b22a7 100644 --- a/packages/stripe_js/lib/src/api/payment_intents/payment_intent.freezed.dart +++ b/packages/stripe_js/lib/src/api/payment_intents/payment_intent.freezed.dart @@ -251,49 +251,64 @@ abstract class $PaymentIntentCopyWith<$Res> { {String id, String object, int amount, - @JsonKey(name: "amount_capturable") int? amountCapturable, + @JsonKey(name: "amount_capturable") + int? amountCapturable, @JsonKey(name: "amount_details") - PaymentIntentAmountDetails? amountDetails, - @JsonKey(name: "amount_received") int? amountReceived, + PaymentIntentAmountDetails? amountDetails, + @JsonKey(name: "amount_received") + int? amountReceived, String? application, - @JsonKey(name: "application_fee_amount") int? applicationFeeAmount, + @JsonKey(name: "application_fee_amount") + int? applicationFeeAmount, @JsonKey(name: "automatic_payment_methods") - PaymentIntentAutomaticPaymentMethods? automaticPaymentMethods, - @JsonKey(name: "canceled_at") int? canceledAt, + PaymentIntentAutomaticPaymentMethods? automaticPaymentMethods, + @JsonKey(name: "canceled_at") + int? canceledAt, @JsonKey(name: "cancellation_reason") - PaymentIntentCancellationReason? cancellationReason, - @JsonKey(name: "client_secret") String clientSecret, - @JsonKey(name: "capture_method") PaymentIntentCaptureMethod captureMethod, + PaymentIntentCancellationReason? cancellationReason, + @JsonKey(name: "client_secret") + String clientSecret, + @JsonKey(name: "capture_method") + PaymentIntentCaptureMethod captureMethod, @JsonKey(name: "confirmation_method") - PaymentIntentConfirmationMethod confirmationMethod, + PaymentIntentConfirmationMethod confirmationMethod, int? created, String currency, String? customer, String? description, String? invoice, - @JsonKey(name: "last_payment_error") StripeError? lastPaymentError, - @JsonKey(name: "latest_charge") String? latestCharge, + @JsonKey(name: "last_payment_error") + StripeError? lastPaymentError, + @JsonKey(name: "latest_charge") + String? latestCharge, bool livemode, Map metadata, - @JsonKey(name: "next_action") dynamic nextAction, - @JsonKey(name: "on_behalf_of") String? onBehalfOf, - @JsonKey(name: "payment_method") String? paymentMethod, + @JsonKey(name: "next_action") + dynamic nextAction, + @JsonKey(name: "on_behalf_of") + String? onBehalfOf, + @JsonKey(name: "payment_method") + String? paymentMethod, @JsonKey(name: "payment_method_options") - Map paymentMethodOptions, + Map paymentMethodOptions, @JsonKey(name: "payment_method_types") - List paymentMethodTypes, + List paymentMethodTypes, dynamic processing, - @JsonKey(name: "receipt_email") String? receiptEmail, + @JsonKey(name: "receipt_email") + String? receiptEmail, String? review, @JsonKey(name: "setup_future_usage") - PaymentIntentSetupFutureUsage? setupFutureUsage, + PaymentIntentSetupFutureUsage? setupFutureUsage, ShippingDetails? shipping, - @JsonKey(name: "statement_descriptor") String? statementDescriptor, + @JsonKey(name: "statement_descriptor") + String? statementDescriptor, @JsonKey(name: "statement_descriptor_suffix") - String? statementDescriptorSuffix, + String? statementDescriptorSuffix, PaymentIntentsStatus status, - @JsonKey(name: "transfer_data") dynamic transferData, - @JsonKey(name: "transfer_group") dynamic transferGroup}); + @JsonKey(name: "transfer_data") + dynamic transferData, + @JsonKey(name: "transfer_group") + dynamic transferGroup}); $PaymentIntentAmountDetailsCopyWith<$Res>? get amountDetails; $PaymentIntentAutomaticPaymentMethodsCopyWith<$Res>? @@ -574,49 +589,64 @@ abstract class _$$_PaymentIntentCopyWith<$Res> {String id, String object, int amount, - @JsonKey(name: "amount_capturable") int? amountCapturable, + @JsonKey(name: "amount_capturable") + int? amountCapturable, @JsonKey(name: "amount_details") - PaymentIntentAmountDetails? amountDetails, - @JsonKey(name: "amount_received") int? amountReceived, + PaymentIntentAmountDetails? amountDetails, + @JsonKey(name: "amount_received") + int? amountReceived, String? application, - @JsonKey(name: "application_fee_amount") int? applicationFeeAmount, + @JsonKey(name: "application_fee_amount") + int? applicationFeeAmount, @JsonKey(name: "automatic_payment_methods") - PaymentIntentAutomaticPaymentMethods? automaticPaymentMethods, - @JsonKey(name: "canceled_at") int? canceledAt, + PaymentIntentAutomaticPaymentMethods? automaticPaymentMethods, + @JsonKey(name: "canceled_at") + int? canceledAt, @JsonKey(name: "cancellation_reason") - PaymentIntentCancellationReason? cancellationReason, - @JsonKey(name: "client_secret") String clientSecret, - @JsonKey(name: "capture_method") PaymentIntentCaptureMethod captureMethod, + PaymentIntentCancellationReason? cancellationReason, + @JsonKey(name: "client_secret") + String clientSecret, + @JsonKey(name: "capture_method") + PaymentIntentCaptureMethod captureMethod, @JsonKey(name: "confirmation_method") - PaymentIntentConfirmationMethod confirmationMethod, + PaymentIntentConfirmationMethod confirmationMethod, int? created, String currency, String? customer, String? description, String? invoice, - @JsonKey(name: "last_payment_error") StripeError? lastPaymentError, - @JsonKey(name: "latest_charge") String? latestCharge, + @JsonKey(name: "last_payment_error") + StripeError? lastPaymentError, + @JsonKey(name: "latest_charge") + String? latestCharge, bool livemode, Map metadata, - @JsonKey(name: "next_action") dynamic nextAction, - @JsonKey(name: "on_behalf_of") String? onBehalfOf, - @JsonKey(name: "payment_method") String? paymentMethod, + @JsonKey(name: "next_action") + dynamic nextAction, + @JsonKey(name: "on_behalf_of") + String? onBehalfOf, + @JsonKey(name: "payment_method") + String? paymentMethod, @JsonKey(name: "payment_method_options") - Map paymentMethodOptions, + Map paymentMethodOptions, @JsonKey(name: "payment_method_types") - List paymentMethodTypes, + List paymentMethodTypes, dynamic processing, - @JsonKey(name: "receipt_email") String? receiptEmail, + @JsonKey(name: "receipt_email") + String? receiptEmail, String? review, @JsonKey(name: "setup_future_usage") - PaymentIntentSetupFutureUsage? setupFutureUsage, + PaymentIntentSetupFutureUsage? setupFutureUsage, ShippingDetails? shipping, - @JsonKey(name: "statement_descriptor") String? statementDescriptor, + @JsonKey(name: "statement_descriptor") + String? statementDescriptor, @JsonKey(name: "statement_descriptor_suffix") - String? statementDescriptorSuffix, + String? statementDescriptorSuffix, PaymentIntentsStatus status, - @JsonKey(name: "transfer_data") dynamic transferData, - @JsonKey(name: "transfer_group") dynamic transferGroup}); + @JsonKey(name: "transfer_data") + dynamic transferData, + @JsonKey(name: "transfer_group") + dynamic transferGroup}); @override $PaymentIntentAmountDetailsCopyWith<$Res>? get amountDetails; @@ -843,47 +873,64 @@ class _$_PaymentIntent implements _PaymentIntent { {required this.id, this.object = "payment_intent", required this.amount, - @JsonKey(name: "amount_capturable") this.amountCapturable, + @JsonKey(name: "amount_capturable") + this.amountCapturable, @JsonKey(name: "amount_details") - this.amountDetails = const PaymentIntentAmountDetails(), - @JsonKey(name: "amount_received") this.amountReceived, + this.amountDetails = const PaymentIntentAmountDetails(), + @JsonKey(name: "amount_received") + this.amountReceived, this.application, - @JsonKey(name: "application_fee_amount") this.applicationFeeAmount, - @JsonKey(name: "automatic_payment_methods") this.automaticPaymentMethods, - @JsonKey(name: "canceled_at") this.canceledAt, - @JsonKey(name: "cancellation_reason") this.cancellationReason, - @JsonKey(name: "client_secret") required this.clientSecret, + @JsonKey(name: "application_fee_amount") + this.applicationFeeAmount, + @JsonKey(name: "automatic_payment_methods") + this.automaticPaymentMethods, + @JsonKey(name: "canceled_at") + this.canceledAt, + @JsonKey(name: "cancellation_reason") + this.cancellationReason, + @JsonKey(name: "client_secret") + required this.clientSecret, @JsonKey(name: "capture_method") - this.captureMethod = PaymentIntentCaptureMethod.automatic, + this.captureMethod = PaymentIntentCaptureMethod.automatic, @JsonKey(name: "confirmation_method") - this.confirmationMethod = PaymentIntentConfirmationMethod.automatic, + this.confirmationMethod = PaymentIntentConfirmationMethod.automatic, this.created, required this.currency, this.customer, this.description, this.invoice, - @JsonKey(name: "last_payment_error") this.lastPaymentError, - @JsonKey(name: "latest_charge") this.latestCharge, + @JsonKey(name: "last_payment_error") + this.lastPaymentError, + @JsonKey(name: "latest_charge") + this.latestCharge, required this.livemode, final Map metadata = const {}, - @JsonKey(name: "next_action") this.nextAction, - @JsonKey(name: "on_behalf_of") this.onBehalfOf, - @JsonKey(name: "payment_method") this.paymentMethod, + @JsonKey(name: "next_action") + this.nextAction, + @JsonKey(name: "on_behalf_of") + this.onBehalfOf, + @JsonKey(name: "payment_method") + this.paymentMethod, @JsonKey(name: "payment_method_options") - final Map paymentMethodOptions = const {}, + final Map paymentMethodOptions = const {}, @JsonKey(name: "payment_method_types") - final List paymentMethodTypes = const [], + final List paymentMethodTypes = const [], this.processing, - @JsonKey(name: "receipt_email") this.receiptEmail, + @JsonKey(name: "receipt_email") + this.receiptEmail, this.review, - @JsonKey(name: "setup_future_usage") this.setupFutureUsage, + @JsonKey(name: "setup_future_usage") + this.setupFutureUsage, this.shipping, - @JsonKey(name: "statement_descriptor") this.statementDescriptor, + @JsonKey(name: "statement_descriptor") + this.statementDescriptor, @JsonKey(name: "statement_descriptor_suffix") - this.statementDescriptorSuffix, + this.statementDescriptorSuffix, required this.status, - @JsonKey(name: "transfer_data") this.transferData, - @JsonKey(name: "transfer_group") this.transferGroup}) + @JsonKey(name: "transfer_data") + this.transferData, + @JsonKey(name: "transfer_group") + this.transferGroup}) : _metadata = metadata, _paymentMethodOptions = paymentMethodOptions, _paymentMethodTypes = paymentMethodTypes; @@ -1308,51 +1355,64 @@ abstract class _PaymentIntent implements PaymentIntent { {required final String id, final String object, required final int amount, - @JsonKey(name: "amount_capturable") final int? amountCapturable, + @JsonKey(name: "amount_capturable") + final int? amountCapturable, @JsonKey(name: "amount_details") - final PaymentIntentAmountDetails? amountDetails, - @JsonKey(name: "amount_received") final int? amountReceived, + final PaymentIntentAmountDetails? amountDetails, + @JsonKey(name: "amount_received") + final int? amountReceived, final String? application, - @JsonKey(name: "application_fee_amount") final int? applicationFeeAmount, + @JsonKey(name: "application_fee_amount") + final int? applicationFeeAmount, @JsonKey(name: "automatic_payment_methods") - final PaymentIntentAutomaticPaymentMethods? automaticPaymentMethods, - @JsonKey(name: "canceled_at") final int? canceledAt, + final PaymentIntentAutomaticPaymentMethods? automaticPaymentMethods, + @JsonKey(name: "canceled_at") + final int? canceledAt, @JsonKey(name: "cancellation_reason") - final PaymentIntentCancellationReason? cancellationReason, - @JsonKey(name: "client_secret") required final String clientSecret, + final PaymentIntentCancellationReason? cancellationReason, + @JsonKey(name: "client_secret") + required final String clientSecret, @JsonKey(name: "capture_method") - final PaymentIntentCaptureMethod captureMethod, + final PaymentIntentCaptureMethod captureMethod, @JsonKey(name: "confirmation_method") - final PaymentIntentConfirmationMethod confirmationMethod, + final PaymentIntentConfirmationMethod confirmationMethod, final int? created, required final String currency, final String? customer, final String? description, final String? invoice, - @JsonKey(name: "last_payment_error") final StripeError? lastPaymentError, - @JsonKey(name: "latest_charge") final String? latestCharge, + @JsonKey(name: "last_payment_error") + final StripeError? lastPaymentError, + @JsonKey(name: "latest_charge") + final String? latestCharge, required final bool livemode, final Map metadata, - @JsonKey(name: "next_action") final dynamic nextAction, - @JsonKey(name: "on_behalf_of") final String? onBehalfOf, - @JsonKey(name: "payment_method") final String? paymentMethod, + @JsonKey(name: "next_action") + final dynamic nextAction, + @JsonKey(name: "on_behalf_of") + final String? onBehalfOf, + @JsonKey(name: "payment_method") + final String? paymentMethod, @JsonKey(name: "payment_method_options") - final Map paymentMethodOptions, + final Map paymentMethodOptions, @JsonKey(name: "payment_method_types") - final List paymentMethodTypes, + final List paymentMethodTypes, final dynamic processing, - @JsonKey(name: "receipt_email") final String? receiptEmail, + @JsonKey(name: "receipt_email") + final String? receiptEmail, final String? review, @JsonKey(name: "setup_future_usage") - final PaymentIntentSetupFutureUsage? setupFutureUsage, + final PaymentIntentSetupFutureUsage? setupFutureUsage, final ShippingDetails? shipping, - @JsonKey(name: "statement_descriptor") final String? statementDescriptor, + @JsonKey(name: "statement_descriptor") + final String? statementDescriptor, @JsonKey(name: "statement_descriptor_suffix") - final String? statementDescriptorSuffix, + final String? statementDescriptorSuffix, required final PaymentIntentsStatus status, - @JsonKey(name: "transfer_data") final dynamic transferData, + @JsonKey(name: "transfer_data") + final dynamic transferData, @JsonKey(name: "transfer_group") - final dynamic transferGroup}) = _$_PaymentIntent; + final dynamic transferGroup}) = _$_PaymentIntent; factory _PaymentIntent.fromJson(Map json) = _$_PaymentIntent.fromJson; diff --git a/packages/stripe_js/lib/src/api/payment_intents/payment_intents.dart b/packages/stripe_js/lib/src/api/payment_intents/payment_intents.dart index 896c4d6e7..b997f7ef3 100644 --- a/packages/stripe_js/lib/src/api/payment_intents/payment_intents.dart +++ b/packages/stripe_js/lib/src/api/payment_intents/payment_intents.dart @@ -6,6 +6,8 @@ export 'confirm_card_payment_data.dart'; export 'confirm_card_payment_options.dart'; export 'confirm_ideal_payment_data.dart'; export 'confirm_ideal_payment_options.dart'; +export 'confirm_klarna_payment_data.dart'; +export 'confirm_klarna_payment_options.dart'; export 'confirm_payment_options.dart'; export 'confirm_sepa_debit_payment_data.dart'; export 'payment_intent.dart'; diff --git a/packages/stripe_js/lib/src/api/payment_methods/create_payment_method_data.freezed.dart b/packages/stripe_js/lib/src/api/payment_methods/create_payment_method_data.freezed.dart index 82d0ab810..a4fd6bb94 100644 --- a/packages/stripe_js/lib/src/api/payment_methods/create_payment_method_data.freezed.dart +++ b/packages/stripe_js/lib/src/api/payment_methods/create_payment_method_data.freezed.dart @@ -442,20 +442,30 @@ class _$_CreatePaymentMethodData implements _CreatePaymentMethodData { abstract class _CreatePaymentMethodData implements CreatePaymentMethodData { const factory _CreatePaymentMethodData( {required final String type, - @ElementConverter() final Element? card, + @ElementConverter() + final Element? card, @JsonKey(name: "au_becs_debit") @ElementConverter() - final Element? auBecsDebit, - @ElementConverter() final Element? fpx, - @JsonKey(name: "fpx[bank]") final String? fpxBank, - @JsonKey(name: "netbanking[bank]") final String? netbankingBank, - @ElementConverter() final Element? ideal, - @JsonKey(name: "ideal[bank]") final String? idealBank, - @JsonKey(name: "sepa_debit") @ElementConverter() final Element? sepaDebit, - @JsonKey(name: "sepa_debit[iban]") final String? sepaDebitIban, - @JsonKey(name: "upi[vpa]") final String? upiVpa, + final Element? auBecsDebit, + @ElementConverter() + final Element? fpx, + @JsonKey(name: "fpx[bank]") + final String? fpxBank, + @JsonKey(name: "netbanking[bank]") + final String? netbankingBank, + @ElementConverter() + final Element? ideal, + @JsonKey(name: "ideal[bank]") + final String? idealBank, + @JsonKey(name: "sepa_debit") + @ElementConverter() + final Element? sepaDebit, + @JsonKey(name: "sepa_debit[iban]") + final String? sepaDebitIban, + @JsonKey(name: "upi[vpa]") + final String? upiVpa, @JsonKey(name: "billing_details") - final BillingDetails? billingDetails}) = _$_CreatePaymentMethodData; + final BillingDetails? billingDetails}) = _$_CreatePaymentMethodData; factory _CreatePaymentMethodData.fromJson(Map json) = _$_CreatePaymentMethodData.fromJson; diff --git a/packages/stripe_js/lib/src/api/payment_methods/payment_method_details.dart b/packages/stripe_js/lib/src/api/payment_methods/payment_method_details.dart index 0e9b2f127..cf7d9520a 100644 --- a/packages/stripe_js/lib/src/api/payment_methods/payment_method_details.dart +++ b/packages/stripe_js/lib/src/api/payment_methods/payment_method_details.dart @@ -140,3 +140,21 @@ class CardTokenPaymentMethod with _$CardTokenPaymentMethod { factory CardTokenPaymentMethod.fromJson(Map json) => _$CardTokenPaymentMethodFromJson(json); } + +@Freezed(unionKey: 'type') +class KlarnaPaymentMethodDetails + with _$KlarnaPaymentMethodDetails + implements PaymentMethodDetails { + @FreezedUnionValue('klarna') + @Implements() + const factory KlarnaPaymentMethodDetails.id(String id) = + _IdKlarnaPaymentMethodDetails; + + @FreezedUnionValue('klarna') + const factory KlarnaPaymentMethodDetails({ + @JsonKey(name: "billing_details") BillingDetails? billingDetails, + }) = _KlarnaPaymentMethodDetails; + + factory KlarnaPaymentMethodDetails.fromJson(Map json) => + _$KlarnaPaymentMethodDetailsFromJson(json); +} diff --git a/packages/stripe_js/lib/src/api/payment_methods/payment_method_details.freezed.dart b/packages/stripe_js/lib/src/api/payment_methods/payment_method_details.freezed.dart index 554bdfd37..c0c4690e5 100644 --- a/packages/stripe_js/lib/src/api/payment_methods/payment_method_details.freezed.dart +++ b/packages/stripe_js/lib/src/api/payment_methods/payment_method_details.freezed.dart @@ -478,9 +478,10 @@ class _$_CardPaymentMethodDefault implements _CardPaymentMethodDefault { abstract class _CardPaymentMethodDefault implements CardPaymentMethodDetails { const factory _CardPaymentMethodDefault( - {@ElementConverter() required final Element card, + {@ElementConverter() + required final Element card, @JsonKey(name: "billing_details") - final BillingDetails? billingDetails}) = _$_CardPaymentMethodDefault; + final BillingDetails? billingDetails}) = _$_CardPaymentMethodDefault; factory _CardPaymentMethodDefault.fromJson(Map json) = _$_CardPaymentMethodDefault.fromJson; @@ -704,9 +705,10 @@ class _$_CardPaymentMethodDetailsToken abstract class _CardPaymentMethodDetailsToken implements CardPaymentMethodDetails { const factory _CardPaymentMethodDetailsToken( - {required final CardTokenPaymentMethod card, - @JsonKey(name: "billing_details") - final BillingDetails? billingDetails}) = _$_CardPaymentMethodDetailsToken; + {required final CardTokenPaymentMethod card, + @JsonKey(name: "billing_details") + final BillingDetails? billingDetails}) = + _$_CardPaymentMethodDetailsToken; factory _CardPaymentMethodDetailsToken.fromJson(Map json) = _$_CardPaymentMethodDetailsToken.fromJson; @@ -1192,9 +1194,10 @@ class _$_IdealPaymentMethodDetails implements _IdealPaymentMethodDetails { abstract class _IdealPaymentMethodDetails implements IdealPaymentMethodDetails { const factory _IdealPaymentMethodDetails( - {@ElementConverter() required final Element ideal, + {@ElementConverter() + required final Element ideal, @JsonKey(name: "billing_details") - final BillingDetails? billingDetails}) = _$_IdealPaymentMethodDetails; + final BillingDetails? billingDetails}) = _$_IdealPaymentMethodDetails; factory _IdealPaymentMethodDetails.fromJson(Map json) = _$_IdealPaymentMethodDetails.fromJson; @@ -1422,7 +1425,7 @@ abstract class _IdealPaymentMethodDetailsSelfCollect const factory _IdealPaymentMethodDetailsSelfCollect( {required final IdealBankData ideal, @JsonKey(name: "billing_details") - final BillingDetails? billingDetails}) = + final BillingDetails? billingDetails}) = _$_IdealPaymentMethodDetailsSelfCollect; factory _IdealPaymentMethodDetailsSelfCollect.fromJson( @@ -1721,3 +1724,435 @@ abstract class _CardTokenPaymentMethod implements CardTokenPaymentMethod { _$$_CardTokenPaymentMethodCopyWith<_$_CardTokenPaymentMethod> get copyWith => throw _privateConstructorUsedError; } + +KlarnaPaymentMethodDetails _$KlarnaPaymentMethodDetailsFromJson( + Map json) { + switch (json['type']) { + case 'klarna': + return _IdKlarnaPaymentMethodDetails.fromJson(json); + case 'klarna': + return _KlarnaPaymentMethodDetails.fromJson(json); + + default: + throw CheckedFromJsonException(json, 'type', 'KlarnaPaymentMethodDetails', + 'Invalid union type "${json['type']}"!'); + } +} + +/// @nodoc +mixin _$KlarnaPaymentMethodDetails { + @optionalTypeArgs + TResult when( + TResult Function( + @JsonKey(name: "billing_details") BillingDetails? billingDetails) + $default, { + required TResult Function(String id) id, + }) => + throw _privateConstructorUsedError; + @optionalTypeArgs + TResult? whenOrNull( + TResult? Function( + @JsonKey(name: "billing_details") BillingDetails? billingDetails)? + $default, { + TResult? Function(String id)? id, + }) => + throw _privateConstructorUsedError; + @optionalTypeArgs + TResult maybeWhen( + TResult Function( + @JsonKey(name: "billing_details") BillingDetails? billingDetails)? + $default, { + TResult Function(String id)? id, + required TResult orElse(), + }) => + throw _privateConstructorUsedError; + @optionalTypeArgs + TResult map( + TResult Function(_KlarnaPaymentMethodDetails value) $default, { + required TResult Function(_IdKlarnaPaymentMethodDetails value) id, + }) => + throw _privateConstructorUsedError; + @optionalTypeArgs + TResult? mapOrNull( + TResult? Function(_KlarnaPaymentMethodDetails value)? $default, { + TResult? Function(_IdKlarnaPaymentMethodDetails value)? id, + }) => + throw _privateConstructorUsedError; + @optionalTypeArgs + TResult maybeMap( + TResult Function(_KlarnaPaymentMethodDetails value)? $default, { + TResult Function(_IdKlarnaPaymentMethodDetails value)? id, + required TResult orElse(), + }) => + throw _privateConstructorUsedError; + Map toJson() => throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class $KlarnaPaymentMethodDetailsCopyWith<$Res> { + factory $KlarnaPaymentMethodDetailsCopyWith(KlarnaPaymentMethodDetails value, + $Res Function(KlarnaPaymentMethodDetails) then) = + _$KlarnaPaymentMethodDetailsCopyWithImpl<$Res, + KlarnaPaymentMethodDetails>; +} + +/// @nodoc +class _$KlarnaPaymentMethodDetailsCopyWithImpl<$Res, + $Val extends KlarnaPaymentMethodDetails> + implements $KlarnaPaymentMethodDetailsCopyWith<$Res> { + _$KlarnaPaymentMethodDetailsCopyWithImpl(this._value, this._then); + + // ignore: unused_field + final $Val _value; + // ignore: unused_field + final $Res Function($Val) _then; +} + +/// @nodoc +abstract class _$$_IdKlarnaPaymentMethodDetailsCopyWith<$Res> { + factory _$$_IdKlarnaPaymentMethodDetailsCopyWith( + _$_IdKlarnaPaymentMethodDetails value, + $Res Function(_$_IdKlarnaPaymentMethodDetails) then) = + __$$_IdKlarnaPaymentMethodDetailsCopyWithImpl<$Res>; + @useResult + $Res call({String id}); +} + +/// @nodoc +class __$$_IdKlarnaPaymentMethodDetailsCopyWithImpl<$Res> + extends _$KlarnaPaymentMethodDetailsCopyWithImpl<$Res, + _$_IdKlarnaPaymentMethodDetails> + implements _$$_IdKlarnaPaymentMethodDetailsCopyWith<$Res> { + __$$_IdKlarnaPaymentMethodDetailsCopyWithImpl( + _$_IdKlarnaPaymentMethodDetails _value, + $Res Function(_$_IdKlarnaPaymentMethodDetails) _then) + : super(_value, _then); + + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? id = null, + }) { + return _then(_$_IdKlarnaPaymentMethodDetails( + null == id + ? _value.id + : id // ignore: cast_nullable_to_non_nullable + as String, + )); + } +} + +/// @nodoc +@JsonSerializable() +class _$_IdKlarnaPaymentMethodDetails implements _IdKlarnaPaymentMethodDetails { + const _$_IdKlarnaPaymentMethodDetails(this.id, {final String? $type}) + : $type = $type ?? 'klarna'; + + factory _$_IdKlarnaPaymentMethodDetails.fromJson(Map json) => + _$$_IdKlarnaPaymentMethodDetailsFromJson(json); + + @override + final String id; + + @JsonKey(name: 'type') + final String $type; + + @override + String toString() { + return 'KlarnaPaymentMethodDetails.id(id: $id)'; + } + + @override + bool operator ==(dynamic other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$_IdKlarnaPaymentMethodDetails && + (identical(other.id, id) || other.id == id)); + } + + @JsonKey(ignore: true) + @override + int get hashCode => Object.hash(runtimeType, id); + + @JsonKey(ignore: true) + @override + @pragma('vm:prefer-inline') + _$$_IdKlarnaPaymentMethodDetailsCopyWith<_$_IdKlarnaPaymentMethodDetails> + get copyWith => __$$_IdKlarnaPaymentMethodDetailsCopyWithImpl< + _$_IdKlarnaPaymentMethodDetails>(this, _$identity); + + @override + @optionalTypeArgs + TResult when( + TResult Function( + @JsonKey(name: "billing_details") BillingDetails? billingDetails) + $default, { + required TResult Function(String id) id, + }) { + return id(this.id); + } + + @override + @optionalTypeArgs + TResult? whenOrNull( + TResult? Function( + @JsonKey(name: "billing_details") BillingDetails? billingDetails)? + $default, { + TResult? Function(String id)? id, + }) { + return id?.call(this.id); + } + + @override + @optionalTypeArgs + TResult maybeWhen( + TResult Function( + @JsonKey(name: "billing_details") BillingDetails? billingDetails)? + $default, { + TResult Function(String id)? id, + required TResult orElse(), + }) { + if (id != null) { + return id(this.id); + } + return orElse(); + } + + @override + @optionalTypeArgs + TResult map( + TResult Function(_KlarnaPaymentMethodDetails value) $default, { + required TResult Function(_IdKlarnaPaymentMethodDetails value) id, + }) { + return id(this); + } + + @override + @optionalTypeArgs + TResult? mapOrNull( + TResult? Function(_KlarnaPaymentMethodDetails value)? $default, { + TResult? Function(_IdKlarnaPaymentMethodDetails value)? id, + }) { + return id?.call(this); + } + + @override + @optionalTypeArgs + TResult maybeMap( + TResult Function(_KlarnaPaymentMethodDetails value)? $default, { + TResult Function(_IdKlarnaPaymentMethodDetails value)? id, + required TResult orElse(), + }) { + if (id != null) { + return id(this); + } + return orElse(); + } + + @override + Map toJson() { + return _$$_IdKlarnaPaymentMethodDetailsToJson( + this, + ); + } +} + +abstract class _IdKlarnaPaymentMethodDetails + implements KlarnaPaymentMethodDetails, IdPaymentMethodDetails { + const factory _IdKlarnaPaymentMethodDetails(final String id) = + _$_IdKlarnaPaymentMethodDetails; + + factory _IdKlarnaPaymentMethodDetails.fromJson(Map json) = + _$_IdKlarnaPaymentMethodDetails.fromJson; + + String get id; + @JsonKey(ignore: true) + _$$_IdKlarnaPaymentMethodDetailsCopyWith<_$_IdKlarnaPaymentMethodDetails> + get copyWith => throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class _$$_KlarnaPaymentMethodDetailsCopyWith<$Res> { + factory _$$_KlarnaPaymentMethodDetailsCopyWith( + _$_KlarnaPaymentMethodDetails value, + $Res Function(_$_KlarnaPaymentMethodDetails) then) = + __$$_KlarnaPaymentMethodDetailsCopyWithImpl<$Res>; + @useResult + $Res call({@JsonKey(name: "billing_details") BillingDetails? billingDetails}); + + $BillingDetailsCopyWith<$Res>? get billingDetails; +} + +/// @nodoc +class __$$_KlarnaPaymentMethodDetailsCopyWithImpl<$Res> + extends _$KlarnaPaymentMethodDetailsCopyWithImpl<$Res, + _$_KlarnaPaymentMethodDetails> + implements _$$_KlarnaPaymentMethodDetailsCopyWith<$Res> { + __$$_KlarnaPaymentMethodDetailsCopyWithImpl( + _$_KlarnaPaymentMethodDetails _value, + $Res Function(_$_KlarnaPaymentMethodDetails) _then) + : super(_value, _then); + + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? billingDetails = freezed, + }) { + return _then(_$_KlarnaPaymentMethodDetails( + billingDetails: freezed == billingDetails + ? _value.billingDetails + : billingDetails // ignore: cast_nullable_to_non_nullable + as BillingDetails?, + )); + } + + @override + @pragma('vm:prefer-inline') + $BillingDetailsCopyWith<$Res>? get billingDetails { + if (_value.billingDetails == null) { + return null; + } + + return $BillingDetailsCopyWith<$Res>(_value.billingDetails!, (value) { + return _then(_value.copyWith(billingDetails: value)); + }); + } +} + +/// @nodoc +@JsonSerializable() +class _$_KlarnaPaymentMethodDetails implements _KlarnaPaymentMethodDetails { + const _$_KlarnaPaymentMethodDetails( + {@JsonKey(name: "billing_details") this.billingDetails, + final String? $type}) + : $type = $type ?? 'klarna'; + + factory _$_KlarnaPaymentMethodDetails.fromJson(Map json) => + _$$_KlarnaPaymentMethodDetailsFromJson(json); + + /// The billing_details associated with the card. + @override + @JsonKey(name: "billing_details") + final BillingDetails? billingDetails; + + @JsonKey(name: 'type') + final String $type; + + @override + String toString() { + return 'KlarnaPaymentMethodDetails(billingDetails: $billingDetails)'; + } + + @override + bool operator ==(dynamic other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$_KlarnaPaymentMethodDetails && + (identical(other.billingDetails, billingDetails) || + other.billingDetails == billingDetails)); + } + + @JsonKey(ignore: true) + @override + int get hashCode => Object.hash(runtimeType, billingDetails); + + @JsonKey(ignore: true) + @override + @pragma('vm:prefer-inline') + _$$_KlarnaPaymentMethodDetailsCopyWith<_$_KlarnaPaymentMethodDetails> + get copyWith => __$$_KlarnaPaymentMethodDetailsCopyWithImpl< + _$_KlarnaPaymentMethodDetails>(this, _$identity); + + @override + @optionalTypeArgs + TResult when( + TResult Function( + @JsonKey(name: "billing_details") BillingDetails? billingDetails) + $default, { + required TResult Function(String id) id, + }) { + return $default(billingDetails); + } + + @override + @optionalTypeArgs + TResult? whenOrNull( + TResult? Function( + @JsonKey(name: "billing_details") BillingDetails? billingDetails)? + $default, { + TResult? Function(String id)? id, + }) { + return $default?.call(billingDetails); + } + + @override + @optionalTypeArgs + TResult maybeWhen( + TResult Function( + @JsonKey(name: "billing_details") BillingDetails? billingDetails)? + $default, { + TResult Function(String id)? id, + required TResult orElse(), + }) { + if ($default != null) { + return $default(billingDetails); + } + return orElse(); + } + + @override + @optionalTypeArgs + TResult map( + TResult Function(_KlarnaPaymentMethodDetails value) $default, { + required TResult Function(_IdKlarnaPaymentMethodDetails value) id, + }) { + return $default(this); + } + + @override + @optionalTypeArgs + TResult? mapOrNull( + TResult? Function(_KlarnaPaymentMethodDetails value)? $default, { + TResult? Function(_IdKlarnaPaymentMethodDetails value)? id, + }) { + return $default?.call(this); + } + + @override + @optionalTypeArgs + TResult maybeMap( + TResult Function(_KlarnaPaymentMethodDetails value)? $default, { + TResult Function(_IdKlarnaPaymentMethodDetails value)? id, + required TResult orElse(), + }) { + if ($default != null) { + return $default(this); + } + return orElse(); + } + + @override + Map toJson() { + return _$$_KlarnaPaymentMethodDetailsToJson( + this, + ); + } +} + +abstract class _KlarnaPaymentMethodDetails + implements KlarnaPaymentMethodDetails { + const factory _KlarnaPaymentMethodDetails( + {@JsonKey(name: "billing_details") + final BillingDetails? billingDetails}) = + _$_KlarnaPaymentMethodDetails; + + factory _KlarnaPaymentMethodDetails.fromJson(Map json) = + _$_KlarnaPaymentMethodDetails.fromJson; + + /// The billing_details associated with the card. + @JsonKey(name: "billing_details") + BillingDetails? get billingDetails; + @JsonKey(ignore: true) + _$$_KlarnaPaymentMethodDetailsCopyWith<_$_KlarnaPaymentMethodDetails> + get copyWith => throw _privateConstructorUsedError; +} diff --git a/packages/stripe_js/lib/src/api/payment_methods/payment_method_details.g.dart b/packages/stripe_js/lib/src/api/payment_methods/payment_method_details.g.dart index c9724d878..d4fdd5b73 100644 --- a/packages/stripe_js/lib/src/api/payment_methods/payment_method_details.g.dart +++ b/packages/stripe_js/lib/src/api/payment_methods/payment_method_details.g.dart @@ -162,3 +162,42 @@ Map _$$_CardTokenPaymentMethodToJson( { 'token': instance.token, }; + +_$_IdKlarnaPaymentMethodDetails _$$_IdKlarnaPaymentMethodDetailsFromJson( + Map json) => + _$_IdKlarnaPaymentMethodDetails( + json['id'] as String, + $type: json['type'] as String?, + ); + +Map _$$_IdKlarnaPaymentMethodDetailsToJson( + _$_IdKlarnaPaymentMethodDetails instance) => + { + 'id': instance.id, + 'type': instance.$type, + }; + +_$_KlarnaPaymentMethodDetails _$$_KlarnaPaymentMethodDetailsFromJson( + Map json) => + _$_KlarnaPaymentMethodDetails( + billingDetails: json['billing_details'] == null + ? null + : BillingDetails.fromJson( + Map.from(json['billing_details'] as Map)), + $type: json['type'] as String?, + ); + +Map _$$_KlarnaPaymentMethodDetailsToJson( + _$_KlarnaPaymentMethodDetails instance) { + final val = {}; + + void writeNotNull(String key, dynamic value) { + if (value != null) { + val[key] = value; + } + } + + writeNotNull('billing_details', instance.billingDetails?.toJson()); + val['type'] = instance.$type; + return val; +} diff --git a/packages/stripe_js/lib/src/api/setup_intents/confirm_card_setup_data.freezed.dart b/packages/stripe_js/lib/src/api/setup_intents/confirm_card_setup_data.freezed.dart index 5564cb4ec..b97f76f8f 100644 --- a/packages/stripe_js/lib/src/api/setup_intents/confirm_card_setup_data.freezed.dart +++ b/packages/stripe_js/lib/src/api/setup_intents/confirm_card_setup_data.freezed.dart @@ -199,10 +199,10 @@ class _$_ConfirmCardSetupData implements _ConfirmCardSetupData { abstract class _ConfirmCardSetupData implements ConfirmCardSetupData { const factory _ConfirmCardSetupData( - {@paymentMethodDetailJsonKey + {@paymentMethodDetailJsonKey final CardPaymentMethodDetails? paymentMethod, - @JsonKey(name: "return_url") final String? returnUrl}) = - _$_ConfirmCardSetupData; + @JsonKey(name: "return_url") + final String? returnUrl}) = _$_ConfirmCardSetupData; factory _ConfirmCardSetupData.fromJson(Map json) = _$_ConfirmCardSetupData.fromJson; diff --git a/packages/stripe_js/lib/src/api/setup_intents/payment_intent.freezed.dart b/packages/stripe_js/lib/src/api/setup_intents/payment_intent.freezed.dart index 6032fc1c2..cac557bd4 100644 --- a/packages/stripe_js/lib/src/api/setup_intents/payment_intent.freezed.dart +++ b/packages/stripe_js/lib/src/api/setup_intents/payment_intent.freezed.dart @@ -244,45 +244,62 @@ abstract class $PaymentIntentCopyWith<$Res> { {String id, String object, int amount, - @JsonKey(name: "amount_capturable") int? amountCapturable, - @JsonKey(name: "amount_received") int? amountReceived, + @JsonKey(name: "amount_capturable") + int? amountCapturable, + @JsonKey(name: "amount_received") + int? amountReceived, String? application, - @JsonKey(name: "application_fee_amount") int? applicationFeeAmount, + @JsonKey(name: "application_fee_amount") + int? applicationFeeAmount, @JsonKey(name: "automatic_payment_methods") - PaymentIntentAutomaticPaymentMethods? automaticPaymentMethods, - @JsonKey(name: "canceled_at") int? canceledAt, + PaymentIntentAutomaticPaymentMethods? automaticPaymentMethods, + @JsonKey(name: "canceled_at") + int? canceledAt, @JsonKey(name: "cancellation_reason") - PaymentIntentCancellationReason? cancellationReason, - @JsonKey(name: "client_secret") String clientSecret, - @JsonKey(name: "capture_method") PaymentIntentCaptureMethod captureMethod, + PaymentIntentCancellationReason? cancellationReason, + @JsonKey(name: "client_secret") + String clientSecret, + @JsonKey(name: "capture_method") + PaymentIntentCaptureMethod captureMethod, @JsonKey(name: "confirmation_method") - PaymentIntentConfirmationMethod confirmationMethod, + PaymentIntentConfirmationMethod confirmationMethod, int? created, String currency, String? customer, String? description, String? invoice, - @JsonKey(name: "last_payment_error") Error? lastPaymentError, - @JsonKey(name: "latest_charge") String? latestCharge, + @JsonKey(name: "last_payment_error") + Error? lastPaymentError, + @JsonKey(name: "latest_charge") + String? latestCharge, bool livemode, Map metadata, - @JsonKey(name: "next_action") dynamic nextAction, - @JsonKey(name: "on_behalf_of") String? onBehalfOf, - @JsonKey(name: "payment_method") String? paymentMethod, - @JsonKey(name: "payment_method_options") dynamic paymentMethodOptions, - @JsonKey(name: "payment_method_types") List paymentMethodTypes, + @JsonKey(name: "next_action") + dynamic nextAction, + @JsonKey(name: "on_behalf_of") + String? onBehalfOf, + @JsonKey(name: "payment_method") + String? paymentMethod, + @JsonKey(name: "payment_method_options") + dynamic paymentMethodOptions, + @JsonKey(name: "payment_method_types") + List paymentMethodTypes, dynamic processing, - @JsonKey(name: "receipt_email") String? receiptEmail, + @JsonKey(name: "receipt_email") + String? receiptEmail, String? review, @JsonKey(name: "setup_future_usage") - PaymentIntentSetupFutureUsage? setupFutureUsage, + PaymentIntentSetupFutureUsage? setupFutureUsage, ShippingDetails? shipping, - @JsonKey(name: "statement_descriptor") String? statementDescriptor, + @JsonKey(name: "statement_descriptor") + String? statementDescriptor, @JsonKey(name: "statement_descriptor_suffix") - String? statementDescriptorSuffix, + String? statementDescriptorSuffix, PaymentIntentsStatus status, - @JsonKey(name: "transfer_data") dynamic transferData, - @JsonKey(name: "transfer_group") dynamic transferGroup}); + @JsonKey(name: "transfer_data") + dynamic transferData, + @JsonKey(name: "transfer_group") + dynamic transferGroup}); $PaymentIntentAutomaticPaymentMethodsCopyWith<$Res>? get automaticPaymentMethods; @@ -531,45 +548,62 @@ abstract class _$$_PaymentIntentCopyWith<$Res> {String id, String object, int amount, - @JsonKey(name: "amount_capturable") int? amountCapturable, - @JsonKey(name: "amount_received") int? amountReceived, + @JsonKey(name: "amount_capturable") + int? amountCapturable, + @JsonKey(name: "amount_received") + int? amountReceived, String? application, - @JsonKey(name: "application_fee_amount") int? applicationFeeAmount, + @JsonKey(name: "application_fee_amount") + int? applicationFeeAmount, @JsonKey(name: "automatic_payment_methods") - PaymentIntentAutomaticPaymentMethods? automaticPaymentMethods, - @JsonKey(name: "canceled_at") int? canceledAt, + PaymentIntentAutomaticPaymentMethods? automaticPaymentMethods, + @JsonKey(name: "canceled_at") + int? canceledAt, @JsonKey(name: "cancellation_reason") - PaymentIntentCancellationReason? cancellationReason, - @JsonKey(name: "client_secret") String clientSecret, - @JsonKey(name: "capture_method") PaymentIntentCaptureMethod captureMethod, + PaymentIntentCancellationReason? cancellationReason, + @JsonKey(name: "client_secret") + String clientSecret, + @JsonKey(name: "capture_method") + PaymentIntentCaptureMethod captureMethod, @JsonKey(name: "confirmation_method") - PaymentIntentConfirmationMethod confirmationMethod, + PaymentIntentConfirmationMethod confirmationMethod, int? created, String currency, String? customer, String? description, String? invoice, - @JsonKey(name: "last_payment_error") Error? lastPaymentError, - @JsonKey(name: "latest_charge") String? latestCharge, + @JsonKey(name: "last_payment_error") + Error? lastPaymentError, + @JsonKey(name: "latest_charge") + String? latestCharge, bool livemode, Map metadata, - @JsonKey(name: "next_action") dynamic nextAction, - @JsonKey(name: "on_behalf_of") String? onBehalfOf, - @JsonKey(name: "payment_method") String? paymentMethod, - @JsonKey(name: "payment_method_options") dynamic paymentMethodOptions, - @JsonKey(name: "payment_method_types") List paymentMethodTypes, + @JsonKey(name: "next_action") + dynamic nextAction, + @JsonKey(name: "on_behalf_of") + String? onBehalfOf, + @JsonKey(name: "payment_method") + String? paymentMethod, + @JsonKey(name: "payment_method_options") + dynamic paymentMethodOptions, + @JsonKey(name: "payment_method_types") + List paymentMethodTypes, dynamic processing, - @JsonKey(name: "receipt_email") String? receiptEmail, + @JsonKey(name: "receipt_email") + String? receiptEmail, String? review, @JsonKey(name: "setup_future_usage") - PaymentIntentSetupFutureUsage? setupFutureUsage, + PaymentIntentSetupFutureUsage? setupFutureUsage, ShippingDetails? shipping, - @JsonKey(name: "statement_descriptor") String? statementDescriptor, + @JsonKey(name: "statement_descriptor") + String? statementDescriptor, @JsonKey(name: "statement_descriptor_suffix") - String? statementDescriptorSuffix, + String? statementDescriptorSuffix, PaymentIntentsStatus status, - @JsonKey(name: "transfer_data") dynamic transferData, - @JsonKey(name: "transfer_group") dynamic transferGroup}); + @JsonKey(name: "transfer_data") + dynamic transferData, + @JsonKey(name: "transfer_group") + dynamic transferGroup}); @override $PaymentIntentAutomaticPaymentMethodsCopyWith<$Res>? @@ -787,44 +821,62 @@ class _$_PaymentIntent implements _PaymentIntent { {required this.id, required this.object, required this.amount, - @JsonKey(name: "amount_capturable") this.amountCapturable, - @JsonKey(name: "amount_received") this.amountReceived, + @JsonKey(name: "amount_capturable") + this.amountCapturable, + @JsonKey(name: "amount_received") + this.amountReceived, this.application, - @JsonKey(name: "application_fee_amount") this.applicationFeeAmount, - @JsonKey(name: "automatic_payment_methods") this.automaticPaymentMethods, - @JsonKey(name: "canceled_at") this.canceledAt, - @JsonKey(name: "cancellation_reason") this.cancellationReason, - @JsonKey(name: "client_secret") required this.clientSecret, + @JsonKey(name: "application_fee_amount") + this.applicationFeeAmount, + @JsonKey(name: "automatic_payment_methods") + this.automaticPaymentMethods, + @JsonKey(name: "canceled_at") + this.canceledAt, + @JsonKey(name: "cancellation_reason") + this.cancellationReason, + @JsonKey(name: "client_secret") + required this.clientSecret, @JsonKey(name: "capture_method") - this.captureMethod = PaymentIntentCaptureMethod.automatic, + this.captureMethod = PaymentIntentCaptureMethod.automatic, @JsonKey(name: "confirmation_method") - this.confirmationMethod = PaymentIntentConfirmationMethod.automatic, + this.confirmationMethod = PaymentIntentConfirmationMethod.automatic, this.created, required this.currency, this.customer, this.description, this.invoice, - @JsonKey(name: "last_payment_error") this.lastPaymentError, - @JsonKey(name: "latest_charge") this.latestCharge, + @JsonKey(name: "last_payment_error") + this.lastPaymentError, + @JsonKey(name: "latest_charge") + this.latestCharge, required this.livemode, final Map metadata = const {}, - @JsonKey(name: "next_action") this.nextAction, - @JsonKey(name: "on_behalf_of") this.onBehalfOf, - @JsonKey(name: "payment_method") this.paymentMethod, - @JsonKey(name: "payment_method_options") this.paymentMethodOptions, + @JsonKey(name: "next_action") + this.nextAction, + @JsonKey(name: "on_behalf_of") + this.onBehalfOf, + @JsonKey(name: "payment_method") + this.paymentMethod, + @JsonKey(name: "payment_method_options") + this.paymentMethodOptions, @JsonKey(name: "payment_method_types") - final List paymentMethodTypes = const [], + final List paymentMethodTypes = const [], this.processing, - @JsonKey(name: "receipt_email") this.receiptEmail, + @JsonKey(name: "receipt_email") + this.receiptEmail, this.review, - @JsonKey(name: "setup_future_usage") this.setupFutureUsage, + @JsonKey(name: "setup_future_usage") + this.setupFutureUsage, this.shipping, - @JsonKey(name: "statement_descriptor") this.statementDescriptor, + @JsonKey(name: "statement_descriptor") + this.statementDescriptor, @JsonKey(name: "statement_descriptor_suffix") - this.statementDescriptorSuffix, + this.statementDescriptorSuffix, required this.status, - @JsonKey(name: "transfer_data") this.transferData, - @JsonKey(name: "transfer_group") this.transferGroup}) + @JsonKey(name: "transfer_data") + this.transferData, + @JsonKey(name: "transfer_group") + this.transferGroup}) : _metadata = metadata, _paymentMethodTypes = paymentMethodTypes; @@ -1228,49 +1280,62 @@ abstract class _PaymentIntent implements PaymentIntent { {required final String id, required final String object, required final int amount, - @JsonKey(name: "amount_capturable") final int? amountCapturable, - @JsonKey(name: "amount_received") final int? amountReceived, + @JsonKey(name: "amount_capturable") + final int? amountCapturable, + @JsonKey(name: "amount_received") + final int? amountReceived, final String? application, - @JsonKey(name: "application_fee_amount") final int? applicationFeeAmount, + @JsonKey(name: "application_fee_amount") + final int? applicationFeeAmount, @JsonKey(name: "automatic_payment_methods") - final PaymentIntentAutomaticPaymentMethods? automaticPaymentMethods, - @JsonKey(name: "canceled_at") final int? canceledAt, + final PaymentIntentAutomaticPaymentMethods? automaticPaymentMethods, + @JsonKey(name: "canceled_at") + final int? canceledAt, @JsonKey(name: "cancellation_reason") - final PaymentIntentCancellationReason? cancellationReason, - @JsonKey(name: "client_secret") required final String clientSecret, + final PaymentIntentCancellationReason? cancellationReason, + @JsonKey(name: "client_secret") + required final String clientSecret, @JsonKey(name: "capture_method") - final PaymentIntentCaptureMethod captureMethod, + final PaymentIntentCaptureMethod captureMethod, @JsonKey(name: "confirmation_method") - final PaymentIntentConfirmationMethod confirmationMethod, + final PaymentIntentConfirmationMethod confirmationMethod, final int? created, required final String currency, final String? customer, final String? description, final String? invoice, - @JsonKey(name: "last_payment_error") final dynamic lastPaymentError, - @JsonKey(name: "latest_charge") final String? latestCharge, + @JsonKey(name: "last_payment_error") + final dynamic lastPaymentError, + @JsonKey(name: "latest_charge") + final String? latestCharge, required final bool livemode, final Map metadata, - @JsonKey(name: "next_action") final dynamic nextAction, - @JsonKey(name: "on_behalf_of") final String? onBehalfOf, - @JsonKey(name: "payment_method") final String? paymentMethod, + @JsonKey(name: "next_action") + final dynamic nextAction, + @JsonKey(name: "on_behalf_of") + final String? onBehalfOf, + @JsonKey(name: "payment_method") + final String? paymentMethod, @JsonKey(name: "payment_method_options") - final dynamic paymentMethodOptions, + final dynamic paymentMethodOptions, @JsonKey(name: "payment_method_types") - final List paymentMethodTypes, + final List paymentMethodTypes, final dynamic processing, - @JsonKey(name: "receipt_email") final String? receiptEmail, + @JsonKey(name: "receipt_email") + final String? receiptEmail, final String? review, @JsonKey(name: "setup_future_usage") - final PaymentIntentSetupFutureUsage? setupFutureUsage, + final PaymentIntentSetupFutureUsage? setupFutureUsage, final ShippingDetails? shipping, - @JsonKey(name: "statement_descriptor") final String? statementDescriptor, + @JsonKey(name: "statement_descriptor") + final String? statementDescriptor, @JsonKey(name: "statement_descriptor_suffix") - final String? statementDescriptorSuffix, + final String? statementDescriptorSuffix, required final PaymentIntentsStatus status, - @JsonKey(name: "transfer_data") final dynamic transferData, + @JsonKey(name: "transfer_data") + final dynamic transferData, @JsonKey(name: "transfer_group") - final dynamic transferGroup}) = _$_PaymentIntent; + final dynamic transferGroup}) = _$_PaymentIntent; factory _PaymentIntent.fromJson(Map json) = _$_PaymentIntent.fromJson; 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 8190aaa78..c748e4025 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 @@ -91,7 +91,7 @@ class SetupIntent with _$SetupIntent { /// Reason for cancellation of this SetupIntent, /// one of abandoned, requested_by_customer, or duplicate. @JsonKey(name: "cancellation_reason") - SetupIntentCancellationReason? cancellationReason, + SetupIntentCancellationReason? cancellationReason, /// The client secret of this SetupIntent. /// Used for client-side retrieval using a publishable key. @@ -121,7 +121,7 @@ class SetupIntent with _$SetupIntent { /// You can include both if you intend to use the payment /// method for both purposes @JsonKey(name: "flow_directions") - List? flowDirections, + List? flowDirections, /// The error encountered in the previous SetupIntent confirmation. @JsonKey(name: "last_setup_error") dynamic lastSetupError, @@ -159,7 +159,7 @@ class SetupIntent with _$SetupIntent { /// is allowed to set up. @JsonKey(name: "payment_method_types") @Default([]) - List paymentMethodTypes, + List paymentMethodTypes, /// ID of the single_use Mandate generated by the SetupIntent. @JsonKey(name: "single_use_mandate") String? singleUseMandate, diff --git a/packages/stripe_js/lib/src/api/setup_intents/setup_intent.freezed.dart b/packages/stripe_js/lib/src/api/setup_intents/setup_intent.freezed.dart index 834982582..de499e7ba 100644 --- a/packages/stripe_js/lib/src/api/setup_intents/setup_intent.freezed.dart +++ b/packages/stripe_js/lib/src/api/setup_intents/setup_intent.freezed.dart @@ -155,27 +155,36 @@ abstract class $SetupIntentCopyWith<$Res> { {String id, String object, String? application, - @JsonKey(name: "attach_to_self") String? attachToSelf, + @JsonKey(name: "attach_to_self") + String? attachToSelf, @JsonKey(name: "cancellation_reason") - SetupIntentCancellationReason? cancellationReason, - @JsonKey(name: "client_secret") String clientSecret, + SetupIntentCancellationReason? cancellationReason, + @JsonKey(name: "client_secret") + String clientSecret, int? created, String? customer, String? description, @JsonKey(name: "flow_directions") - List? flowDirections, - @JsonKey(name: "last_setup_error") dynamic lastSetupError, - @JsonKey(name: "latest_attempt") String? latestAttempt, + List? flowDirections, + @JsonKey(name: "last_setup_error") + dynamic lastSetupError, + @JsonKey(name: "latest_attempt") + String? latestAttempt, bool livemode, String? mandate, Map metadata, - @JsonKey(name: "next_action") dynamic nextAction, - @JsonKey(name: "on_behalf_of") String? onBehalfOf, - @JsonKey(name: "payment_method") String? paymentMethod, - @JsonKey(name: "payment_method_options") dynamic paymentMethodOptions, + @JsonKey(name: "next_action") + dynamic nextAction, + @JsonKey(name: "on_behalf_of") + String? onBehalfOf, + @JsonKey(name: "payment_method") + String? paymentMethod, + @JsonKey(name: "payment_method_options") + dynamic paymentMethodOptions, @JsonKey(name: "payment_method_types") - List paymentMethodTypes, - @JsonKey(name: "single_use_mandate") String? singleUseMandate, + List paymentMethodTypes, + @JsonKey(name: "single_use_mandate") + String? singleUseMandate, SetupIntentsStatus status, SetupIntentUsage usage}); } @@ -326,27 +335,36 @@ abstract class _$$_SetupIntentCopyWith<$Res> {String id, String object, String? application, - @JsonKey(name: "attach_to_self") String? attachToSelf, + @JsonKey(name: "attach_to_self") + String? attachToSelf, @JsonKey(name: "cancellation_reason") - SetupIntentCancellationReason? cancellationReason, - @JsonKey(name: "client_secret") String clientSecret, + SetupIntentCancellationReason? cancellationReason, + @JsonKey(name: "client_secret") + String clientSecret, int? created, String? customer, String? description, @JsonKey(name: "flow_directions") - List? flowDirections, - @JsonKey(name: "last_setup_error") dynamic lastSetupError, - @JsonKey(name: "latest_attempt") String? latestAttempt, + List? flowDirections, + @JsonKey(name: "last_setup_error") + dynamic lastSetupError, + @JsonKey(name: "latest_attempt") + String? latestAttempt, bool livemode, String? mandate, Map metadata, - @JsonKey(name: "next_action") dynamic nextAction, - @JsonKey(name: "on_behalf_of") String? onBehalfOf, - @JsonKey(name: "payment_method") String? paymentMethod, - @JsonKey(name: "payment_method_options") dynamic paymentMethodOptions, + @JsonKey(name: "next_action") + dynamic nextAction, + @JsonKey(name: "on_behalf_of") + String? onBehalfOf, + @JsonKey(name: "payment_method") + String? paymentMethod, + @JsonKey(name: "payment_method_options") + dynamic paymentMethodOptions, @JsonKey(name: "payment_method_types") - List paymentMethodTypes, - @JsonKey(name: "single_use_mandate") String? singleUseMandate, + List paymentMethodTypes, + @JsonKey(name: "single_use_mandate") + String? singleUseMandate, SetupIntentsStatus status, SetupIntentUsage usage}); } @@ -490,26 +508,36 @@ class _$_SetupIntent implements _SetupIntent { {required this.id, this.object = "setup_intent", this.application, - @JsonKey(name: "attach_to_self") this.attachToSelf, - @JsonKey(name: "cancellation_reason") this.cancellationReason, - @JsonKey(name: "client_secret") required this.clientSecret, + @JsonKey(name: "attach_to_self") + this.attachToSelf, + @JsonKey(name: "cancellation_reason") + this.cancellationReason, + @JsonKey(name: "client_secret") + required this.clientSecret, this.created, this.customer, this.description, @JsonKey(name: "flow_directions") - final List? flowDirections, - @JsonKey(name: "last_setup_error") this.lastSetupError, - @JsonKey(name: "latest_attempt") this.latestAttempt, + final List? flowDirections, + @JsonKey(name: "last_setup_error") + this.lastSetupError, + @JsonKey(name: "latest_attempt") + this.latestAttempt, this.livemode = true, this.mandate, final Map metadata = const {}, - @JsonKey(name: "next_action") this.nextAction, - @JsonKey(name: "on_behalf_of") this.onBehalfOf, - @JsonKey(name: "payment_method") this.paymentMethod, - @JsonKey(name: "payment_method_options") this.paymentMethodOptions, + @JsonKey(name: "next_action") + this.nextAction, + @JsonKey(name: "on_behalf_of") + this.onBehalfOf, + @JsonKey(name: "payment_method") + this.paymentMethod, + @JsonKey(name: "payment_method_options") + this.paymentMethodOptions, @JsonKey(name: "payment_method_types") - final List paymentMethodTypes = const [], - @JsonKey(name: "single_use_mandate") this.singleUseMandate, + final List paymentMethodTypes = const [], + @JsonKey(name: "single_use_mandate") + this.singleUseMandate, required this.status, this.usage = SetupIntentUsage.offSession}) : _flowDirections = flowDirections, @@ -795,28 +823,36 @@ abstract class _SetupIntent implements SetupIntent { {required final String id, final String object, final String? application, - @JsonKey(name: "attach_to_self") final String? attachToSelf, + @JsonKey(name: "attach_to_self") + final String? attachToSelf, @JsonKey(name: "cancellation_reason") - final SetupIntentCancellationReason? cancellationReason, - @JsonKey(name: "client_secret") required final String clientSecret, + final SetupIntentCancellationReason? cancellationReason, + @JsonKey(name: "client_secret") + required final String clientSecret, final int? created, final String? customer, final String? description, @JsonKey(name: "flow_directions") - final List? flowDirections, - @JsonKey(name: "last_setup_error") final dynamic lastSetupError, - @JsonKey(name: "latest_attempt") final String? latestAttempt, + final List? flowDirections, + @JsonKey(name: "last_setup_error") + final dynamic lastSetupError, + @JsonKey(name: "latest_attempt") + final String? latestAttempt, final bool livemode, final String? mandate, final Map metadata, - @JsonKey(name: "next_action") final dynamic nextAction, - @JsonKey(name: "on_behalf_of") final String? onBehalfOf, - @JsonKey(name: "payment_method") final String? paymentMethod, + @JsonKey(name: "next_action") + final dynamic nextAction, + @JsonKey(name: "on_behalf_of") + final String? onBehalfOf, + @JsonKey(name: "payment_method") + final String? paymentMethod, @JsonKey(name: "payment_method_options") - final dynamic paymentMethodOptions, + final dynamic paymentMethodOptions, @JsonKey(name: "payment_method_types") - final List paymentMethodTypes, - @JsonKey(name: "single_use_mandate") final String? singleUseMandate, + final List paymentMethodTypes, + @JsonKey(name: "single_use_mandate") + final String? singleUseMandate, required final SetupIntentsStatus status, final SetupIntentUsage usage}) = _$_SetupIntent; 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 00b01cd14..912e5771e 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 @@ -15,7 +15,7 @@ class CreateTokenBankAccountData with _$CreateTokenBankAccountData { @JsonKey(name: "account_number") required String accountNumber, @JsonKey(name: "account_holder_name") String? accountHolderName, @JsonKey(name: "account_holder_type") - BankAccountHolderType? accountHolderType, + BankAccountHolderType? accountHolderType, @JsonKey(name: "account_type") String? accountType, }) = _CreateTokenBankAccountData; diff --git a/packages/stripe_js/lib/src/api/tokens/create_token_bank_account_data.freezed.dart b/packages/stripe_js/lib/src/api/tokens/create_token_bank_account_data.freezed.dart index ecc693cab..0a4b9db3a 100644 --- a/packages/stripe_js/lib/src/api/tokens/create_token_bank_account_data.freezed.dart +++ b/packages/stripe_js/lib/src/api/tokens/create_token_bank_account_data.freezed.dart @@ -53,12 +53,16 @@ abstract class $CreateTokenBankAccountDataCopyWith<$Res> { $Res call( {String country, String currency, - @JsonKey(name: "routing_number") String? routingNumber, - @JsonKey(name: "account_number") String accountNumber, - @JsonKey(name: "account_holder_name") String? accountHolderName, + @JsonKey(name: "routing_number") + String? routingNumber, + @JsonKey(name: "account_number") + String accountNumber, + @JsonKey(name: "account_holder_name") + String? accountHolderName, @JsonKey(name: "account_holder_type") - BankAccountHolderType? accountHolderType, - @JsonKey(name: "account_type") String? accountType}); + BankAccountHolderType? accountHolderType, + @JsonKey(name: "account_type") + String? accountType}); } /// @nodoc @@ -128,12 +132,16 @@ abstract class _$$_CreateTokenBankAccountDataCopyWith<$Res> $Res call( {String country, String currency, - @JsonKey(name: "routing_number") String? routingNumber, - @JsonKey(name: "account_number") String accountNumber, - @JsonKey(name: "account_holder_name") String? accountHolderName, + @JsonKey(name: "routing_number") + String? routingNumber, + @JsonKey(name: "account_number") + String accountNumber, + @JsonKey(name: "account_holder_name") + String? accountHolderName, @JsonKey(name: "account_holder_type") - BankAccountHolderType? accountHolderType, - @JsonKey(name: "account_type") String? accountType}); + BankAccountHolderType? accountHolderType, + @JsonKey(name: "account_type") + String? accountType}); } /// @nodoc @@ -275,15 +283,18 @@ class _$_CreateTokenBankAccountData implements _CreateTokenBankAccountData { abstract class _CreateTokenBankAccountData implements CreateTokenBankAccountData { const factory _CreateTokenBankAccountData( - {required final String country, - required final String currency, - @JsonKey(name: "routing_number") final String? routingNumber, - @JsonKey(name: "account_number") required final String accountNumber, - @JsonKey(name: "account_holder_name") final String? accountHolderName, - @JsonKey(name: "account_holder_type") + {required final String country, + required final String currency, + @JsonKey(name: "routing_number") + final String? routingNumber, + @JsonKey(name: "account_number") + required final String accountNumber, + @JsonKey(name: "account_holder_name") + final String? accountHolderName, + @JsonKey(name: "account_holder_type") final BankAccountHolderType? accountHolderType, - @JsonKey(name: "account_type") final String? accountType}) = - _$_CreateTokenBankAccountData; + @JsonKey(name: "account_type") + final String? accountType}) = _$_CreateTokenBankAccountData; factory _CreateTokenBankAccountData.fromJson(Map json) = _$_CreateTokenBankAccountData.fromJson; diff --git a/packages/stripe_js/lib/src/api/tokens/create_token_pii_data.freezed.dart b/packages/stripe_js/lib/src/api/tokens/create_token_pii_data.freezed.dart index a05633be8..3cc8713b6 100644 --- a/packages/stripe_js/lib/src/api/tokens/create_token_pii_data.freezed.dart +++ b/packages/stripe_js/lib/src/api/tokens/create_token_pii_data.freezed.dart @@ -144,7 +144,7 @@ class _$_CreateTokenPIIData implements _CreateTokenPIIData { abstract class _CreateTokenPIIData implements CreateTokenPIIData { const factory _CreateTokenPIIData( {@JsonKey(name: "personal_id_number") - required final String personalIdNumber}) = _$_CreateTokenPIIData; + required final String personalIdNumber}) = _$_CreateTokenPIIData; factory _CreateTokenPIIData.fromJson(Map json) = _$_CreateTokenPIIData.fromJson; diff --git a/packages/stripe_js/lib/src/api/tokens/token.dart b/packages/stripe_js/lib/src/api/tokens/token.dart index 1d30d531c..2e111c360 100644 --- a/packages/stripe_js/lib/src/api/tokens/token.dart +++ b/packages/stripe_js/lib/src/api/tokens/token.dart @@ -81,7 +81,7 @@ class BankAccountToken with _$BankAccountToken { /// The type of entity that holds the account. /// This can be either individual or company. @JsonKey(name: "account_holder_type") - BankAccountHolderType? accountHolderType, + BankAccountHolderType? accountHolderType, /// The bank account type. /// This can only be checking or savings in most countries. @@ -235,7 +235,7 @@ class CardToken with _$CardToken { /// Can be android_pay (includes Google Pay), apple_pay, masterpass, /// visa_checkout, or null. @JsonKey(name: "tokenization_method") - CardTokenizationMethod? tokenizationMethod, + CardTokenizationMethod? tokenizationMethod, }) = _CardToken; factory CardToken.fromJson(Map json) => diff --git a/packages/stripe_js/lib/src/api/tokens/token.freezed.dart b/packages/stripe_js/lib/src/api/tokens/token.freezed.dart index befc6672b..0b3264462 100644 --- a/packages/stripe_js/lib/src/api/tokens/token.freezed.dart +++ b/packages/stripe_js/lib/src/api/tokens/token.freezed.dart @@ -506,16 +506,20 @@ abstract class $BankAccountTokenCopyWith<$Res> { $Res call( {String id, String object, - @JsonKey(name: "account_holder_name") String? accountHolderName, + @JsonKey(name: "account_holder_name") + String? accountHolderName, @JsonKey(name: "account_holder_type") - BankAccountHolderType? accountHolderType, - @JsonKey(name: "account_type") String? accountType, - @JsonKey(name: "bank_name") String? bankName, + BankAccountHolderType? accountHolderType, + @JsonKey(name: "account_type") + String? accountType, + @JsonKey(name: "bank_name") + String? bankName, String? country, String? currency, String? fingerprint, String? last4, - @JsonKey(name: "routing_number") String? routingNumber, + @JsonKey(name: "routing_number") + String? routingNumber, BankAccountStatus? status}); } @@ -609,16 +613,20 @@ abstract class _$$_BankAccountTokenCopyWith<$Res> $Res call( {String id, String object, - @JsonKey(name: "account_holder_name") String? accountHolderName, + @JsonKey(name: "account_holder_name") + String? accountHolderName, @JsonKey(name: "account_holder_type") - BankAccountHolderType? accountHolderType, - @JsonKey(name: "account_type") String? accountType, - @JsonKey(name: "bank_name") String? bankName, + BankAccountHolderType? accountHolderType, + @JsonKey(name: "account_type") + String? accountType, + @JsonKey(name: "bank_name") + String? bankName, String? country, String? currency, String? fingerprint, String? last4, - @JsonKey(name: "routing_number") String? routingNumber, + @JsonKey(name: "routing_number") + String? routingNumber, BankAccountStatus? status}); } @@ -866,16 +874,20 @@ abstract class _BankAccountToken implements BankAccountToken { const factory _BankAccountToken( {required final String id, final String object, - @JsonKey(name: "account_holder_name") final String? accountHolderName, + @JsonKey(name: "account_holder_name") + final String? accountHolderName, @JsonKey(name: "account_holder_type") - final BankAccountHolderType? accountHolderType, - @JsonKey(name: "account_type") final String? accountType, - @JsonKey(name: "bank_name") final String? bankName, + final BankAccountHolderType? accountHolderType, + @JsonKey(name: "account_type") + final String? accountType, + @JsonKey(name: "bank_name") + final String? bankName, final String? country, final String? currency, final String? fingerprint, final String? last4, - @JsonKey(name: "routing_number") final String? routingNumber, + @JsonKey(name: "routing_number") + final String? routingNumber, final BankAccountStatus? status}) = _$_BankAccountToken; factory _BankAccountToken.fromJson(Map json) = @@ -1099,29 +1111,40 @@ abstract class $CardTokenCopyWith<$Res> { $Res call( {String id, String object, - @JsonKey(name: "address_city") String? addressCity, - @JsonKey(name: "address_country") String? addressCountry, - @JsonKey(name: "address_line1") String? addressLine1, + @JsonKey(name: "address_city") + String? addressCity, + @JsonKey(name: "address_country") + String? addressCountry, + @JsonKey(name: "address_line1") + String? addressLine1, @JsonKey(name: "address_line1_check") - VerificationCheck? addressLine1Check, - @JsonKey(name: "address_line2") String? addressLine2, - @JsonKey(name: "address_state") String? addressState, - @JsonKey(name: "address_zip") String? addressZip, - @JsonKey(name: "address_zip_check") VerificationCheck? addressZipCheck, + VerificationCheck? addressLine1Check, + @JsonKey(name: "address_line2") + String? addressLine2, + @JsonKey(name: "address_state") + String? addressState, + @JsonKey(name: "address_zip") + String? addressZip, + @JsonKey(name: "address_zip_check") + VerificationCheck? addressZipCheck, CardTokenBrand? brand, String? country, String? currency, - @JsonKey(name: "cvc_check") VerificationCheck? cvcCheck, - @JsonKey(name: "dynamic_last4") String? dynamicLast4, - @JsonKey(name: "exp_month") int? expMonth, - @JsonKey(name: "exp_year") int? expYear, + @JsonKey(name: "cvc_check") + VerificationCheck? cvcCheck, + @JsonKey(name: "dynamic_last4") + String? dynamicLast4, + @JsonKey(name: "exp_month") + int? expMonth, + @JsonKey(name: "exp_year") + int? expYear, String? fingerprint, CardFundingType? funding, String? last4, Map metadata, String? name, @JsonKey(name: "tokenization_method") - CardTokenizationMethod? tokenizationMethod}); + CardTokenizationMethod? tokenizationMethod}); } /// @nodoc @@ -1268,29 +1291,40 @@ abstract class _$$_CardTokenCopyWith<$Res> implements $CardTokenCopyWith<$Res> { $Res call( {String id, String object, - @JsonKey(name: "address_city") String? addressCity, - @JsonKey(name: "address_country") String? addressCountry, - @JsonKey(name: "address_line1") String? addressLine1, + @JsonKey(name: "address_city") + String? addressCity, + @JsonKey(name: "address_country") + String? addressCountry, + @JsonKey(name: "address_line1") + String? addressLine1, @JsonKey(name: "address_line1_check") - VerificationCheck? addressLine1Check, - @JsonKey(name: "address_line2") String? addressLine2, - @JsonKey(name: "address_state") String? addressState, - @JsonKey(name: "address_zip") String? addressZip, - @JsonKey(name: "address_zip_check") VerificationCheck? addressZipCheck, + VerificationCheck? addressLine1Check, + @JsonKey(name: "address_line2") + String? addressLine2, + @JsonKey(name: "address_state") + String? addressState, + @JsonKey(name: "address_zip") + String? addressZip, + @JsonKey(name: "address_zip_check") + VerificationCheck? addressZipCheck, CardTokenBrand? brand, String? country, String? currency, - @JsonKey(name: "cvc_check") VerificationCheck? cvcCheck, - @JsonKey(name: "dynamic_last4") String? dynamicLast4, - @JsonKey(name: "exp_month") int? expMonth, - @JsonKey(name: "exp_year") int? expYear, + @JsonKey(name: "cvc_check") + VerificationCheck? cvcCheck, + @JsonKey(name: "dynamic_last4") + String? dynamicLast4, + @JsonKey(name: "exp_month") + int? expMonth, + @JsonKey(name: "exp_year") + int? expYear, String? fingerprint, CardFundingType? funding, String? last4, Map metadata, String? name, @JsonKey(name: "tokenization_method") - CardTokenizationMethod? tokenizationMethod}); + CardTokenizationMethod? tokenizationMethod}); } /// @nodoc @@ -1698,30 +1732,40 @@ abstract class _CardToken implements CardToken { const factory _CardToken( {required final String id, final String object, - @JsonKey(name: "address_city") final String? addressCity, - @JsonKey(name: "address_country") final String? addressCountry, - @JsonKey(name: "address_line1") final String? addressLine1, + @JsonKey(name: "address_city") + final String? addressCity, + @JsonKey(name: "address_country") + final String? addressCountry, + @JsonKey(name: "address_line1") + final String? addressLine1, @JsonKey(name: "address_line1_check") - final VerificationCheck? addressLine1Check, - @JsonKey(name: "address_line2") final String? addressLine2, - @JsonKey(name: "address_state") final String? addressState, - @JsonKey(name: "address_zip") final String? addressZip, + final VerificationCheck? addressLine1Check, + @JsonKey(name: "address_line2") + final String? addressLine2, + @JsonKey(name: "address_state") + final String? addressState, + @JsonKey(name: "address_zip") + final String? addressZip, @JsonKey(name: "address_zip_check") - final VerificationCheck? addressZipCheck, + final VerificationCheck? addressZipCheck, final CardTokenBrand? brand, final String? country, final String? currency, - @JsonKey(name: "cvc_check") final VerificationCheck? cvcCheck, - @JsonKey(name: "dynamic_last4") final String? dynamicLast4, - @JsonKey(name: "exp_month") final int? expMonth, - @JsonKey(name: "exp_year") final int? expYear, + @JsonKey(name: "cvc_check") + final VerificationCheck? cvcCheck, + @JsonKey(name: "dynamic_last4") + final String? dynamicLast4, + @JsonKey(name: "exp_month") + final int? expMonth, + @JsonKey(name: "exp_year") + final int? expYear, final String? fingerprint, final CardFundingType? funding, final String? last4, final Map metadata, final String? name, @JsonKey(name: "tokenization_method") - final CardTokenizationMethod? tokenizationMethod}) = _$_CardToken; + final CardTokenizationMethod? tokenizationMethod}) = _$_CardToken; factory _CardToken.fromJson(Map json) = _$_CardToken.fromJson; diff --git a/packages/stripe_js/lib/src/js/payment_intents/confirm_klarna_payment.dart b/packages/stripe_js/lib/src/js/payment_intents/confirm_klarna_payment.dart new file mode 100644 index 000000000..f4419875f --- /dev/null +++ b/packages/stripe_js/lib/src/js/payment_intents/confirm_klarna_payment.dart @@ -0,0 +1,45 @@ +import 'package:js/js.dart'; +import 'package:stripe_js/stripe_api.dart'; +import 'package:stripe_js/stripe_js.dart'; +import '../utils/utils.dart'; + +extension ExtensionKlarnaPayment on Stripe { + _JS get js => this as _JS; + + /// Use stripe.confirmKlarnaPayment in the Klarna payment method creation + /// flow when the customer submits your payment form. When called, it will + /// confirm the PaymentIntent with data you provide, and it will automatically + /// redirect the customer to authorize the transaction. Once authorization is + /// complete, the customer will be redirected back to your specified + /// return_url. + /// + /// When you confirm a PaymentIntent, it needs to have an attached + /// PaymentMethod. In addition to confirming the PaymentIntent, + /// this method can automatically create and attach a new PaymentMethod for + /// you. If you have already attached a PaymentMethod you can call this + /// method without needing to provide any additional data. These use cases + /// are detailed in the sections that follow. + /// + /// https://stripe.com/docs/js/payment_intents/confirm_klarna_payment + Future confirmKlarnaPayment( + String clientSecret, { + ConfirmKlarnaPaymentData? data, + ConfirmKlarnaPaymentOptions? options, + }) { + final jsData = jsify(data?.toJson() ?? {}); + final jsOptions = jsify(options?.toJson() ?? {}); + return parseIntentResponse( + js.confirmKlarnaPayment(clientSecret, jsData, jsOptions), + ); + } +} + +@anonymous +@JS() +abstract class _JS { + external Promise confirmKlarnaPayment( + String clientSecret, [ + dynamic data, + dynamic options, + ]); +} diff --git a/packages/stripe_js/lib/src/js/payment_intents/payment_intents.dart b/packages/stripe_js/lib/src/js/payment_intents/payment_intents.dart index 7a2a6e8ee..3907a5a54 100644 --- a/packages/stripe_js/lib/src/js/payment_intents/payment_intents.dart +++ b/packages/stripe_js/lib/src/js/payment_intents/payment_intents.dart @@ -2,6 +2,7 @@ export 'confirm_acss_debit_payment.dart'; export 'confirm_alipay_payment.dart'; export 'confirm_card_payment.dart'; export 'confirm_ideal_payment.dart'; +export 'confirm_klarna_payment.dart'; export 'confirm_payment.dart'; export 'confirm_sepa_debit_payment.dart'; export 'handle_card_action.dart'; diff --git a/packages/stripe_web/lib/src/web_stripe.dart b/packages/stripe_web/lib/src/web_stripe.dart index f5fc889bd..d95518e58 100644 --- a/packages/stripe_web/lib/src/web_stripe.dart +++ b/packages/stripe_web/lib/src/web_stripe.dart @@ -90,7 +90,6 @@ class WebStripe extends StripePlatform { if (response.error != null) { throw response.error!; } - print(response); return response.paymentMethod!.parse(); } catch (e) { dev.log('Error $e'); @@ -167,6 +166,18 @@ class WebStripe extends StripePlatform { ), ); }, + klarna: (paymentMethodData) { + // https://stripe.com/docs/js/payment_intents/confirm_klarna_payment#stripe_confirm_klarna_payment-options + return js.confirmKlarnaPayment( + paymentIntentClientSecret, + data: stripe_js.ConfirmKlarnaPaymentData( + paymentMethod: stripe_js.KlarnaPaymentMethodDetails( + billingDetails: paymentMethodData.billingDetails?.toJs(), + ), + returnUrl: urlScheme, + ), + ); + }, orElse: () { throw WebUnsupportedError(); }, @@ -226,6 +237,30 @@ class WebStripe extends StripePlatform { return response.paymentIntent!.parse(); } + Future confirmKlarnaPayment( + String paymentIntentClientSecret, PaymentMethodData paymentData, + {String? returnUrl}) async { + // https://stripe.com/docs/js/payment_intents/confirm_alipay_payment#stripe_confirm_alipay_payment-options + final response = await js.confirmKlarnaPayment( + paymentIntentClientSecret, + data: stripe_js.ConfirmKlarnaPaymentData( + paymentMethod: stripe_js.KlarnaPaymentMethodDetails( + billingDetails: paymentData.billingDetails?.toJs(), + ), + returnUrl: returnUrl ?? urlScheme, + ), + ); + + if (response.error != null) { + throw StripeError( + message: response.error!.message ?? '', + code: response.error!.code, + ); + } + + return response.paymentIntent!.parse(); + } + @override Future confirmSetupIntent( String setupIntentClientSecret, @@ -356,7 +391,11 @@ class WebStripe extends StripePlatform { @override Future retrievePaymentIntent(String clientSecret) async { - throw UnimplementedError(); + final response = await js.retrievePaymentIntent(clientSecret); + if (response.error != null) { + throw response.error!; + } + return response.paymentIntent!.parse(); } @override