Skip to content

Commit

Permalink
feat: tokens for web (#1079)
Browse files Browse the repository at this point in the history
* feat: implement tokens for stripe web

* fix: bank account tokens

* feat: example enable tokens for webs

* fix: update js union classes

* fix: melos breaking

* fix: analyzer issues
  • Loading branch information
jamesblasco authored Apr 11, 2023
1 parent db72f0e commit 49d03ca
Show file tree
Hide file tree
Showing 83 changed files with 5,483 additions and 1,219 deletions.
4 changes: 2 additions & 2 deletions example/lib/screens/others/setup_future_payment_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -146,10 +146,10 @@ class _SetupFuturePaymentScreenState extends State<SetupFuturePaymentScreen> {
step = 1;
_setupIntentResult = setupIntentResult;
});
} catch (error, s) {
log('Error while saving payment', error: error, stackTrace: s);
} catch (error) {
ScaffoldMessenger.of(context)
.showSnackBar(SnackBar(content: Text('Error code: $error')));
rethrow;
}
}

Expand Down
19 changes: 15 additions & 4 deletions example/lib/screens/screens.dart
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,6 @@ class Example extends StatelessWidget {
width: 48,
),
builder: (context) => IdealScreen(),
platformsSupported: [DevicePlatform.android, DevicePlatform.ios],
),
Example(
title: 'Sofort',
Expand All @@ -239,6 +238,7 @@ class Example extends StatelessWidget {
Example(
title: 'Aubecs',
builder: (context) => AubecsExample(),
platformsSupported: [DevicePlatform.android, DevicePlatform.ios],
),
Example(
title: 'Fpx',
Expand All @@ -247,6 +247,7 @@ class Example extends StatelessWidget {
width: 48,
),
builder: (contex) => FpxScreen(),
platformsSupported: [DevicePlatform.android, DevicePlatform.ios],
),
Example(
title: 'Grab pay',
Expand All @@ -255,6 +256,7 @@ class Example extends StatelessWidget {
width: 48,
),
builder: (contex) => GrabPayScreen(),
platformsSupported: [DevicePlatform.android, DevicePlatform.ios],
),
Example(
title: 'Klarna',
Expand All @@ -263,6 +265,7 @@ class Example extends StatelessWidget {
width: 48,
),
builder: (contex) => KlarnaScreen(),
platformsSupported: [DevicePlatform.android, DevicePlatform.ios],
),
Example(
title: 'PayPal',
Expand All @@ -276,6 +279,7 @@ class Example extends StatelessWidget {
Example(
title: 'Us bank accounts (ACH)',
builder: (contex) => UsBankAccountScreen(),
platformsSupported: [DevicePlatform.android, DevicePlatform.ios],
),
// TODO: uncomment when we can re-enable wechat pay
// Example(
Expand Down Expand Up @@ -304,7 +308,6 @@ class Example extends StatelessWidget {
Example(
title: 'Setup Future Payment',
builder: (c) => SetupFuturePaymentScreen(),
platformsSupported: [DevicePlatform.android, DevicePlatform.ios],
),
Example(
title: 'Re-collect CVC',
Expand All @@ -314,12 +317,20 @@ class Example extends StatelessWidget {
Example(
title: 'Create token for card (legacy)',
builder: (context) => LegacyTokenCardScreen(),
platformsSupported: [DevicePlatform.android, DevicePlatform.ios],
platformsSupported: [
DevicePlatform.android,
DevicePlatform.ios,
DevicePlatform.web,
],
),
Example(
title: 'Create token for bank (legacy)',
builder: (context) => LegacyTokenBankScreen(),
platformsSupported: [DevicePlatform.android, DevicePlatform.ios],
platformsSupported: [
DevicePlatform.android,
DevicePlatform.ios,
DevicePlatform.web,
],
),
]),
Example(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import 'checkout.dart';
/// session in your server
///
/// To have a custom route transition use [CheckoutPage] directly
@Deprecated('Use CheckoutPage instead')
Future<CheckoutResponse> redirectToCheckout({
required BuildContext context,
required String sessionId,
Expand Down
1 change: 1 addition & 0 deletions packages/stripe_checkout/lib/stripe_checkout.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ Future<CheckoutResponse> redirectToCheckout({
String? successUrl,
String? canceledUrl,
}) {
// ignore: deprecated_member_use_from_same_package
return stripe.redirectToCheckout(
context: context,
sessionId: sessionId,
Expand Down
1 change: 1 addition & 0 deletions packages/stripe_js/lib/src/api/api.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
export 'elements/elements.dart';
export 'core/core.dart';
export 'tokens/tokens.dart';
export 'payment_methods/payment_methods.dart';
export 'payment_intents/payment_intents.dart';
export 'setup_intents/setup_intents.dart';
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// 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
// 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 'billing_details.dart';

Expand Down
2 changes: 1 addition & 1 deletion packages/stripe_js/lib/src/api/core/error.freezed.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// 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
// 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 'error.dart';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// 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
// 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 'shipping_details.dart';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// 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
// 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 'card_element_change_event.dart';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// 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
// 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 'card_element_options.dart';

Expand Down Expand Up @@ -68,7 +68,7 @@ class _$CardElementOptionsCopyWithImpl<$Res, $Val extends CardElementOptions>
@override
$Res call({
Object? classes = freezed,
Object? style = null,
Object? style = freezed,
Object? value = freezed,
Object? hidePostalCode = freezed,
Object? iconStyle = freezed,
Expand All @@ -80,7 +80,7 @@ class _$CardElementOptionsCopyWithImpl<$Res, $Val extends CardElementOptions>
? _value.classes
: classes // ignore: cast_nullable_to_non_nullable
as CardElementClasses?,
style: null == style
style: freezed == style
? _value.style
: style // ignore: cast_nullable_to_non_nullable
as dynamic,
Expand Down Expand Up @@ -153,7 +153,7 @@ class __$$_CardElementOptionsCopyWithImpl<$Res>
@override
$Res call({
Object? classes = freezed,
Object? style = null,
Object? style = freezed,
Object? value = freezed,
Object? hidePostalCode = freezed,
Object? iconStyle = freezed,
Expand All @@ -165,7 +165,7 @@ class __$$_CardElementOptionsCopyWithImpl<$Res>
? _value.classes
: classes // ignore: cast_nullable_to_non_nullable
as CardElementClasses?,
style: null == style
style: freezed == style
? _value.style
: style // ignore: cast_nullable_to_non_nullable
as dynamic,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// 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
// 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 'payment_element_change_event.dart';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// 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
// 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 'payment_element_options.dart';

Expand Down Expand Up @@ -99,11 +99,11 @@ class _$PaymentElementOptionsCopyWithImpl<$Res,
Object? layout = freezed,
Object? defaultValues = freezed,
Object? business = freezed,
Object? paymentMethodOrder = null,
Object? paymentMethodOrder = freezed,
Object? fields = freezed,
Object? readOnly = null,
Object? terms = null,
Object? wallets = null,
Object? readOnly = freezed,
Object? terms = freezed,
Object? wallets = freezed,
}) {
return _then(_value.copyWith(
layout: freezed == layout
Expand All @@ -118,23 +118,23 @@ class _$PaymentElementOptionsCopyWithImpl<$Res,
? _value.business
: business // ignore: cast_nullable_to_non_nullable
as PaymentElementBusiness?,
paymentMethodOrder: null == paymentMethodOrder
paymentMethodOrder: freezed == paymentMethodOrder
? _value.paymentMethodOrder
: paymentMethodOrder // ignore: cast_nullable_to_non_nullable
as dynamic,
fields: freezed == fields
? _value.fields
: fields // ignore: cast_nullable_to_non_nullable
as PaymentElementFields?,
readOnly: null == readOnly
readOnly: freezed == readOnly
? _value.readOnly
: readOnly // ignore: cast_nullable_to_non_nullable
as dynamic,
terms: null == terms
terms: freezed == terms
? _value.terms
: terms // ignore: cast_nullable_to_non_nullable
as dynamic,
wallets: null == wallets
wallets: freezed == wallets
? _value.wallets
: wallets // ignore: cast_nullable_to_non_nullable
as dynamic,
Expand Down Expand Up @@ -233,11 +233,11 @@ class __$$_PaymentElementOptionsCopyWithImpl<$Res>
Object? layout = freezed,
Object? defaultValues = freezed,
Object? business = freezed,
Object? paymentMethodOrder = null,
Object? paymentMethodOrder = freezed,
Object? fields = freezed,
Object? readOnly = null,
Object? terms = null,
Object? wallets = null,
Object? readOnly = freezed,
Object? terms = freezed,
Object? wallets = freezed,
}) {
return _then(_$_PaymentElementOptions(
layout: freezed == layout
Expand All @@ -252,23 +252,23 @@ class __$$_PaymentElementOptionsCopyWithImpl<$Res>
? _value.business
: business // ignore: cast_nullable_to_non_nullable
as PaymentElementBusiness?,
paymentMethodOrder: null == paymentMethodOrder
paymentMethodOrder: freezed == paymentMethodOrder
? _value.paymentMethodOrder
: paymentMethodOrder // ignore: cast_nullable_to_non_nullable
as dynamic,
fields: freezed == fields
? _value.fields
: fields // ignore: cast_nullable_to_non_nullable
as PaymentElementFields?,
readOnly: null == readOnly
readOnly: freezed == readOnly
? _value.readOnly
: readOnly // ignore: cast_nullable_to_non_nullable
as dynamic,
terms: null == terms
terms: freezed == terms
? _value.terms
: terms // ignore: cast_nullable_to_non_nullable
as dynamic,
wallets: null == wallets
wallets: freezed == wallets
? _value.wallets
: wallets // ignore: cast_nullable_to_non_nullable
as dynamic,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// 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
// 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 'payment_intent_shipping_information.dart';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// 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
// 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_acss_debit_payment_data.dart';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// 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
// 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_acss_debit_payment_options.dart';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// 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
// 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_alipay_payment_data.dart';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// 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
// 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_alipay_payment_options.dart';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,13 @@ import 'package:freezed_annotation/freezed_annotation.dart';
part 'confirm_card_payment_data.freezed.dart';
part 'confirm_card_payment_data.g.dart';

class CardPaymentMethodRefConverter
extends PaymentMethodRefConverter<CardPaymentMethodDetails> {
const CardPaymentMethodRefConverter();
}

typedef CardPaymentMethodRef = PaymentMethodRef<CardPaymentMethodDetails>;

@freezed
class ConfirmCardPaymentData with _$ConfirmCardPaymentData {
const factory 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.
@JsonKey(name: "payment_method")
@CardPaymentMethodRefConverter()
CardPaymentMethodRef? paymentMethod,
@paymentMethodDetailJsonKey CardPaymentMethodDetails? paymentMethod,

/// The shipping details for the payment, if collected.
ShippingDetails? shipping,
Expand Down
Loading

0 comments on commit 49d03ca

Please sign in to comment.