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/CHANGELOG.md b/packages/stripe_js/CHANGELOG.md index 75d7eefc7..b99e58e8f 100644 --- a/packages/stripe_js/CHANGELOG.md +++ b/packages/stripe_js/CHANGELOG.md @@ -1,3 +1,8 @@ +## 3.2.0 +**Features** +- Adds support for Klarna on web +- Adds support for retrievePaymentIntent on web + ## 3.1.0 - Makes WebStripe a singleton accessible by WebStripe.instance - Allows to change the layout for the payment element. Closes [#1260](https://github.com/flutter-stripe/flutter_stripe/pull/1270#:~:text=Makes%20a%20singleton,flow%C2%A0%231075) 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..1eae3e4cd 100644 --- a/packages/stripe_js/lib/src/api/elements/payment_element_options.dart +++ b/packages/stripe_js/lib/src/api/elements/payment_element_options.dart @@ -174,13 +174,14 @@ class PaymentElementFields with _$PaymentElementFields { @freezed class BillingDetailsFields with _$BillingDetailsFields { const factory BillingDetailsFields({ - @Default(PaymentElementFieldRequired.auto) PaymentElementFieldRequired name, @Default(PaymentElementFieldRequired.auto) - PaymentElementFieldRequired email, + PaymentElementFieldRequired name, @Default(PaymentElementFieldRequired.auto) - PaymentElementFieldRequired phone, + PaymentElementFieldRequired email, + @Default(PaymentElementFieldRequired.auto) + PaymentElementFieldRequired phone, @Default(PaymentElementAddressFields.auto) - PaymentElementAddressFields address, + PaymentElementAddressFields address, }) = _BillingDetailsFields; static const auto = BillingDetailsFields(); @@ -193,16 +194,17 @@ class BillingDetailsFields with _$BillingDetailsFields { class PaymentElementAddressFields with _$PaymentElementAddressFields { const factory PaymentElementAddressFields({ @Default(PaymentElementFieldRequired.auto) - PaymentElementFieldRequired line1, + PaymentElementFieldRequired line1, + @Default(PaymentElementFieldRequired.auto) + PaymentElementFieldRequired line2, @Default(PaymentElementFieldRequired.auto) - PaymentElementFieldRequired line2, - @Default(PaymentElementFieldRequired.auto) PaymentElementFieldRequired city, + 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..3a9fe9d2c 100644 --- a/packages/stripe_js/lib/src/api/payment_intents/confirm_card_payment_data.dart +++ b/packages/stripe_js/lib/src/api/payment_intents/confirm_card_payment_data.dart @@ -10,7 +10,8 @@ class ConfirmCardPaymentData with _$ConfirmCardPaymentData { /// Either the id of an existing PaymentMethod, or an object containing /// data to create a PaymentMethod with. /// See the use case sections below for details. - @paymentMethodDetailJsonKey CardPaymentMethodDetails? paymentMethod, + @paymentMethodDetailJsonKey + CardPaymentMethodDetails? paymentMethod, /// The shipping details for the payment, if collected. ShippingDetails? shipping, @@ -18,10 +19,12 @@ class ConfirmCardPaymentData with _$ConfirmCardPaymentData { /// If you are handling next actions yourself, pass in a return_url. /// If the subsequent action is redirect_to_url, /// this URL will be used on the return path for the redirect. - @JsonKey(name: "return_url") String? returnUrl, + @JsonKey(name: "return_url") + String? returnUrl, /// Email address that the receipt for the resulting payment will be sent to. - @JsonKey(name: "receipt_email") String? receiptEmail, + @JsonKey(name: "receipt_email") + String? receiptEmail, /// Indicates that you intend to make future payments with this /// PaymentIntent's payment method. @@ -38,11 +41,12 @@ 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. - @JsonKey(name: "payment_method_options") dynamic paymentMethodOptions, + @JsonKey(name: "payment_method_options") + dynamic paymentMethodOptions, }) = _ConfirmCardPaymentData; factory ConfirmCardPaymentData.fromJson(Map json) => diff --git a/packages/stripe_js/lib/src/api/payment_intents/confirm_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..35f25101c 100644 --- a/packages/stripe_js/lib/src/api/payment_intents/confirm_ideal_payment_data.dart +++ b/packages/stripe_js/lib/src/api/payment_intents/confirm_ideal_payment_data.dart @@ -10,10 +10,12 @@ class ConfirmIdealPaymentData with _$ConfirmIdealPaymentData { /// Either the id of an existing PaymentMethod, or an object containing /// data to create a PaymentMethod with. /// See the use case sections below for details. - @paymentMethodDetailJsonKey IdealPaymentMethodDetails? paymentMethod, + @paymentMethodDetailJsonKey + IdealPaymentMethodDetails? paymentMethod, /// The url your customer will be directed to after they complete authentication. - @JsonKey(name: "return_url") String? returnUrl, + @JsonKey(name: "return_url") + String? returnUrl, /// To set up a SEPA Direct Debit payment method using the bank details /// from this iDEAL payment, set this parameter to off_session. @@ -21,7 +23,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..a990711cb 100644 --- a/packages/stripe_js/lib/src/api/payment_intents/confirm_sepa_debit_payment_data.dart +++ b/packages/stripe_js/lib/src/api/payment_intents/confirm_sepa_debit_payment_data.dart @@ -11,7 +11,8 @@ class ConfirmSepaDebitPaymentData with _$ConfirmSepaDebitPaymentData { /// Either the id of an existing PaymentMethod, or an object containing /// data to create a PaymentMethod with. /// See the use case sections below for details. - @paymentMethodDetailJsonKey SepaDebitPaymentMethodDetails? paymentMethod, + @paymentMethodDetailJsonKey + SepaDebitPaymentMethodDetails? paymentMethod, /// To set up the SEPA Direct Debit account for reuse, set this parameter /// to off_session. SEPA Direct Debit only accepts an off_session value @@ -19,7 +20,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..1ef483efc 100644 --- a/packages/stripe_js/lib/src/api/payment_intents/payment_intent.dart +++ b/packages/stripe_js/lib/src/api/payment_intents/payment_intent.dart @@ -77,7 +77,8 @@ class PaymentIntent with _$PaymentIntent { /// String representing the object’s type. /// Objects of the same type share the same value. /// Value is "payment_intent". - @Default("payment_intent") String object, + @Default("payment_intent") + String object, /// Amount intended to be collected by this PaymentIntent. /// A positive integer representing how much to charge in the @@ -89,15 +90,17 @@ class PaymentIntent with _$PaymentIntent { required int amount, /// The amount that can be captured with from this PaymentIntent (in cents). - @JsonKey(name: "amount_capturable") int? amountCapturable, + @JsonKey(name: "amount_capturable") + int? amountCapturable, /// Details about items included in the amount @Default(PaymentIntentAmountDetails()) @JsonKey(name: "amount_details") - PaymentIntentAmountDetails? amountDetails, + PaymentIntentAmountDetails? amountDetails, /// The amount that was collected from this PaymentIntent (in cents). - @JsonKey(name: "amount_received") int? amountReceived, + @JsonKey(name: "amount_received") + int? amountReceived, /// CONNECT ONLY /// ID of the Connect application that created the PaymentIntent. @@ -110,16 +113,18 @@ class PaymentIntent with _$PaymentIntent { /// capped at the total payment amount. /// For more information, see the PaymentIntents use /// case for connected accounts.. - @JsonKey(name: "application_fee_amount") int? applicationFeeAmount, + @JsonKey(name: "application_fee_amount") + int? applicationFeeAmount, /// Settings to configure compatible payment methods from the /// Stripe Dashboard @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. - @JsonKey(name: "canceled_at") int? canceledAt, + @JsonKey(name: "canceled_at") + int? canceledAt, /// Reason for cancellation of this PaymentIntent, /// either user-provided @@ -127,7 +132,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. @@ -138,15 +143,16 @@ class PaymentIntent with _$PaymentIntent { /// /// Refer to our docs to accept a payment and learn about how `client_secret` /// should be handled. - @JsonKey(name: "client_secret") required String clientSecret, + @JsonKey(name: "client_secret") + required String clientSecret, /// Controls when the funds will be captured from the customer’s account. @JsonKey(name: "capture_method") @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. @@ -175,10 +181,12 @@ class PaymentIntent with _$PaymentIntent { /// The payment error encountered in the previous PaymentIntent confirmation. /// It will be cleared if the PaymentIntent is later updated for any reason. - @JsonKey(name: "last_payment_error") StripeError? lastPaymentError, + @JsonKey(name: "last_payment_error") + StripeError? lastPaymentError, /// The latest charge created by this payment intent. - @JsonKey(name: "latest_charge") String? latestCharge, + @JsonKey(name: "latest_charge") + String? latestCharge, /// Has the value true if the object exists in live mode or the /// value false if the object exists in test mode. @@ -187,32 +195,36 @@ class PaymentIntent with _$PaymentIntent { /// Set of key-value pairs that you can attach to an object. /// This can be useful for storing additional information about the /// object in a structured format. - @Default({}) Map metadata, + @Default({}) + Map metadata, /// If present, this property tells you what actions you need to /// take in order for your customer to fulfill a payment using the /// provided source. - @JsonKey(name: "next_action") dynamic nextAction, + @JsonKey(name: "next_action") + dynamic nextAction, /// CONNECT ONLY /// The account (if any) for which the funds of the PaymentIntent are /// intended. See the PaymentIntents use case for connected accounts /// for details. - @JsonKey(name: "on_behalf_of") String? onBehalfOf, + @JsonKey(name: "on_behalf_of") + String? onBehalfOf, /// ID of the payment method used in this PaymentIntent. - @JsonKey(name: "payment_method") String? paymentMethod, + @JsonKey(name: "payment_method") + String? paymentMethod, /// Payment-method-specific configuration for this PaymentIntent. @Default({}) @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, @@ -220,7 +232,8 @@ class PaymentIntent with _$PaymentIntent { /// Email address that the receipt for the resulting payment will be sent to. /// If receipt_email is specified for a payment in live mode, a receipt /// will be sent regardless of your email settings. - @JsonKey(name: "receipt_email") String? receiptEmail, + @JsonKey(name: "receipt_email") + String? receiptEmail, // ID of the review associated with this PaymentIntent, if any. String? review, @@ -236,7 +249,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, @@ -244,7 +257,8 @@ class PaymentIntent with _$PaymentIntent { /// For non-card charges, you can use this value as the complete /// description that appears on your customers’ statements. /// Must contain at least one letter, maximum 22 characters. - @JsonKey(name: "statement_descriptor") String? statementDescriptor, + @JsonKey(name: "statement_descriptor") + String? statementDescriptor, /// Provides information about a card payment that customers see on /// their statements. @@ -252,7 +266,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, @@ -263,12 +277,14 @@ class PaymentIntent with _$PaymentIntent { /// The data with which to automatically create a Transfer when the payment /// is finalized. See the PaymentIntents use case for connected /// accounts for details. - @JsonKey(name: "transfer_data") dynamic transferData, + @JsonKey(name: "transfer_data") + dynamic transferData, /// CONNECT ONLY /// A string that identifies the resulting payment as part of a group. /// See the PaymentIntents use case for connected accounts for details. - @JsonKey(name: "transfer_group") dynamic transferGroup, + @JsonKey(name: "transfer_group") + dynamic transferGroup, }) = _PaymentIntent; factory PaymentIntent.fromJson(Map json) => diff --git a/packages/stripe_js/lib/src/api/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..fd4426bbb 100644 --- a/packages/stripe_js/lib/src/api/setup_intents/setup_intent.dart +++ b/packages/stripe_js/lib/src/api/setup_intents/setup_intent.dart @@ -74,7 +74,8 @@ class SetupIntent with _$SetupIntent { /// String representing the object’s type. /// Objects of the same type share the same value. /// Value is "setup_intent". - @Default("setup_intent") String object, + @Default("setup_intent") + String object, /// CONNECT ONLY /// ID of the Connect application that created the SetupIntent. @@ -86,12 +87,13 @@ class SetupIntent with _$SetupIntent { /// flows like InboundTransfer and OutboundTransfers. /// It cannot be set to true when setting up a PaymentMethod for a Customer, /// and defaults to false when attaching a PaymentMethod to a Customer. - @JsonKey(name: "attach_to_self") String? attachToSelf, + @JsonKey(name: "attach_to_self") + String? attachToSelf, /// Reason for cancellation of this SetupIntent, /// one of abandoned, requested_by_customer, or duplicate. @JsonKey(name: "cancellation_reason") - SetupIntentCancellationReason? cancellationReason, + SetupIntentCancellationReason? cancellationReason, /// The client secret of this SetupIntent. /// Used for client-side retrieval using a publishable key. @@ -99,7 +101,8 @@ class SetupIntent with _$SetupIntent { /// It should not be stored, logged, or exposed to anyone other than the /// customer. Make sure that you have TLS enabled on any page that includes /// the client secret. - @JsonKey(name: "client_secret") required String clientSecret, + @JsonKey(name: "client_secret") + required String clientSecret, /// Time at which the object was created. Measured in seconds since the /// Unix epoch. @@ -121,17 +124,20 @@ 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, + @JsonKey(name: "last_setup_error") + dynamic lastSetupError, /// The most recent SetupAttempt for this SetupIntent. - @JsonKey(name: "latest_attempt") String? latestAttempt, + @JsonKey(name: "latest_attempt") + String? latestAttempt, /// Has the value true if the object exists in live mode or the /// value false if the object exists in test mode. - @Default(true) bool livemode, + @Default(true) + bool livemode, /// ID of the multi use Mandate generated by the SetupIntent. String? mandate, @@ -139,30 +145,36 @@ class SetupIntent with _$SetupIntent { /// Set of key-value pairs that you can attach to an object. /// This can be useful for storing additional information about the /// object in a structured format. - @Default({}) Map metadata, + @Default({}) + Map metadata, /// If present, this property tells you what actions you need to /// take in order for your customer to continue payment setup. - @JsonKey(name: "next_action") dynamic nextAction, + @JsonKey(name: "next_action") + dynamic nextAction, /// CONNECT ONLY /// The account (if any) for which the setup is intended. - @JsonKey(name: "on_behalf_of") String? onBehalfOf, + @JsonKey(name: "on_behalf_of") + String? onBehalfOf, /// ID of the payment method used in this SetupIntent. - @JsonKey(name: "payment_method") String? paymentMethod, + @JsonKey(name: "payment_method") + String? paymentMethod, /// Payment-method-specific configuration for this SetupIntent. - @JsonKey(name: "payment_method_options") dynamic paymentMethodOptions, + @JsonKey(name: "payment_method_options") + dynamic paymentMethodOptions, /// The list of payment method types (e.g. card) that this SetupIntent /// is allowed to set up. @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, + @JsonKey(name: "single_use_mandate") + String? singleUseMandate, /// Status of this SetupIntent, one of requires_payment_method, /// requires_confirmation, requires_action, processing, canceled, or @@ -174,7 +186,8 @@ class SetupIntent with _$SetupIntent { /// the customer is in your checkout flow. /// Use off_session if your customer may or may not be in your checkout flow. /// If not provided, this value defaults to off_session. - @Default(SetupIntentUsage.offSession) SetupIntentUsage usage, + @Default(SetupIntentUsage.offSession) + SetupIntentUsage usage, }) = _SetupIntent; factory SetupIntent.fromJson(Map json) => diff --git a/packages/stripe_js/lib/src/api/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..1156eb250 100644 --- a/packages/stripe_js/lib/src/api/tokens/create_token_bank_account_data.dart +++ b/packages/stripe_js/lib/src/api/tokens/create_token_bank_account_data.dart @@ -11,12 +11,16 @@ class CreateTokenBankAccountData with _$CreateTokenBankAccountData { /// Three character currency code (e.g., usd). required String currency, - @JsonKey(name: "routing_number") String? routingNumber, - @JsonKey(name: "account_number") required String accountNumber, - @JsonKey(name: "account_holder_name") String? accountHolderName, + @JsonKey(name: "routing_number") + String? routingNumber, + @JsonKey(name: "account_number") + required String accountNumber, + @JsonKey(name: "account_holder_name") + String? accountHolderName, @JsonKey(name: "account_holder_type") - BankAccountHolderType? accountHolderType, - @JsonKey(name: "account_type") String? accountType, + BankAccountHolderType? accountHolderType, + @JsonKey(name: "account_type") + String? accountType, }) = _CreateTokenBankAccountData; factory CreateTokenBankAccountData.fromJson(Map json) => 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..0f9e8c294 100644 --- a/packages/stripe_js/lib/src/api/tokens/token.dart +++ b/packages/stripe_js/lib/src/api/tokens/token.dart @@ -73,23 +73,27 @@ class BankAccountToken with _$BankAccountToken { /// String representing the object’s type. /// Objects of the same type share the same value. /// Value is "bank_account". - @Default("bank_account") String object, + @Default("bank_account") + String object, /// The name of the person or business that owns the bank account. - @JsonKey(name: "account_holder_name") String? accountHolderName, + @JsonKey(name: "account_holder_name") + String? accountHolderName, /// The type of entity that holds the account. /// This can be either individual or company. @JsonKey(name: "account_holder_type") - BankAccountHolderType? accountHolderType, + BankAccountHolderType? accountHolderType, /// The bank account type. /// This can only be checking or savings in most countries. /// In Japan, this can only be futsu or toza. - @JsonKey(name: "account_type") String? accountType, + @JsonKey(name: "account_type") + String? accountType, /// Name of the bank associated with the routing number (e.g., WELLS FARGO). - @JsonKey(name: "bank_name") String? bankName, + @JsonKey(name: "bank_name") + String? bankName, /// Two-letter ISO code representing the country the bank account is /// located in. @@ -107,7 +111,8 @@ class BankAccountToken with _$BankAccountToken { String? last4, /// The routing transit number for the bank account. - @JsonKey(name: "routing_number") String? routingNumber, + @JsonKey(name: "routing_number") + String? routingNumber, /// For bank accounts, possible values are new, validated, verified, /// verification_failed, or errored. @@ -145,37 +150,47 @@ class CardToken with _$CardToken { /// String representing the object’s type. /// Objects of the same type share the same value. /// Value is "card". - @Default("card") String object, + @Default("card") + String object, /// City/District/Suburb/Town/Village. - @JsonKey(name: "address_city") String? addressCity, + @JsonKey(name: "address_city") + String? addressCity, /// Billing address country, if provided when creating card. - @JsonKey(name: "address_country") String? addressCountry, + @JsonKey(name: "address_country") + String? addressCountry, /// Address line 1 (Street address/PO Box/Company name). - @JsonKey(name: "address_line1") String? addressLine1, + @JsonKey(name: "address_line1") + String? addressLine1, /// If address_line1 was provided, results of the check: /// pass, fail, unavailable, or unchecked. - @JsonKey(name: "address_line1_check") VerificationCheck? addressLine1Check, + @JsonKey(name: "address_line1_check") + VerificationCheck? addressLine1Check, /// Address line 2 (Apartment/Suite/Unit/Building). - @JsonKey(name: "address_line2") String? addressLine2, + @JsonKey(name: "address_line2") + String? addressLine2, /// State/County/Province/Region. - @JsonKey(name: "address_state") String? addressState, + @JsonKey(name: "address_state") + String? addressState, /// ZIP or postal code. - @JsonKey(name: "address_zip") String? addressZip, + @JsonKey(name: "address_zip") + String? addressZip, /// If address_zip was provided, results of the check: /// pass, fail, unavailable, or unchecked. - @JsonKey(name: "address_zip_check") VerificationCheck? addressZipCheck, + @JsonKey(name: "address_zip_check") + VerificationCheck? addressZipCheck, /// If address_zip was provided, results of the check: /// pass, fail, unavailable, or unchecked. - @Default(CardTokenBrand.unknown) CardTokenBrand? brand, + @Default(CardTokenBrand.unknown) + CardTokenBrand? brand, /// Two-letter ISO code representing the country of the card. /// You could use this attribute to get a sense of the @@ -194,17 +209,21 @@ class CardToken with _$CardToken { /// object, or when creating a charge. For more details, see /// Check if a card is valid without a charge. /// https://support.stripe.com/questions/check-if-a-card-is-valid-without-a-charge - @JsonKey(name: "cvc_check") VerificationCheck? cvcCheck, + @JsonKey(name: "cvc_check") + VerificationCheck? cvcCheck, /// (For tokenized numbers only.) /// The last four digits of the device account number. - @JsonKey(name: "dynamic_last4") String? dynamicLast4, + @JsonKey(name: "dynamic_last4") + String? dynamicLast4, /// Two-digit number representing the card’s expiration month. - @JsonKey(name: "exp_month") int? expMonth, + @JsonKey(name: "exp_month") + int? expMonth, /// Four-digit number representing the card’s expiration year. - @JsonKey(name: "exp_year") int? expYear, + @JsonKey(name: "exp_year") + int? expYear, /// Uniquely identifies this particular card number. /// You can use this attribute to check whether two customers who’ve @@ -226,7 +245,8 @@ class CardToken with _$CardToken { /// Set of key-value pairs that you can attach to an object. /// This can be useful for storing additional information about the object /// in a structured forma - @Default({}) Map metadata, + @Default({}) + Map metadata, /// Cardholder name. String? name, @@ -235,7 +255,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_js/pubspec.yaml b/packages/stripe_js/pubspec.yaml index 42f1eeb01..bd25014da 100644 --- a/packages/stripe_js/pubspec.yaml +++ b/packages/stripe_js/pubspec.yaml @@ -1,6 +1,6 @@ name: stripe_js description: Stripe.js bindings for dart. This package is used by Stripe web so that the Stripe js sdk can be invoked directly. -version: 3.1.0 +version: 3.2.0 homepage: https://github.com/flutter-stripe/flutter_stripe environment: diff --git a/packages/stripe_web/CHANGELOG.md b/packages/stripe_web/CHANGELOG.md index c3c0862ec..00279b540 100644 --- a/packages/stripe_web/CHANGELOG.md +++ b/packages/stripe_web/CHANGELOG.md @@ -1,3 +1,8 @@ +## 4.3.0 +**Features** +- Adds support for Klarna on web +- Adds support for retrievePaymentIntent on web + ## 4.2.0 **Fixes for web** - Makes WebStripe a singleton accessible by WebStripe.instance 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 diff --git a/packages/stripe_web/pubspec.yaml b/packages/stripe_web/pubspec.yaml index c6f181d22..ebf5e6c2d 100644 --- a/packages/stripe_web/pubspec.yaml +++ b/packages/stripe_web/pubspec.yaml @@ -1,6 +1,6 @@ name: flutter_stripe_web description: Stripe sdk bindings for the Flutter web platform. This package contains the implementation of the platform interface for web. -version: 4.2.0 +version: 4.3.0 homepage: https://github.com/flutter-stripe/flutter_stripe environment: @@ -15,7 +15,7 @@ dependencies: freezed_annotation: ^2.0.3 stripe_platform_interface: ^9.2.1 js: ^0.6.3 - stripe_js: ^3.1.0 + stripe_js: ^3.2.0 dev_dependencies: flutter_test: