diff --git a/CHANGELOG.md b/CHANGELOG.md index 6d90f24d9..e70359aec 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,36 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +## 2024-09-18 + +### Changes + +--- + +Packages with breaking changes: + + - There are no breaking changes in this release. + +Packages with other changes: + + - [`stripe_platform_interface` - `v11.1.1`](#stripe_platform_interface---v1111) + - [`flutter_stripe` - `v11.1.1`](#flutter_stripe---v1111) + - [`flutter_stripe_web` - `v6.1.1`](#flutter_stripe_web---v611) + +Packages with dependency updates only: + +> Packages listed below depend on other packages in this workspace that have had changes. Their versions have been incremented to bump the minimum dependency versions of the packages they depend upon in this project. + + - `flutter_stripe` - `v11.1.1` + - `flutter_stripe_web` - `v6.1.1` + +--- + +#### `stripe_platform_interface` - `v11.1.1` + + - **FIX**: #1912 wallet parsing. + + ## 2024-09-18 ### Changes diff --git a/example/lib/screens/customer_sheet/customer_sheet_screen.dart b/example/lib/screens/customer_sheet/customer_sheet_screen.dart index 4410a98d6..d49262e23 100644 --- a/example/lib/screens/customer_sheet/customer_sheet_screen.dart +++ b/example/lib/screens/customer_sheet/customer_sheet_screen.dart @@ -87,8 +87,9 @@ class _CustomerSheetScreenState extends State { await Stripe.instance.initCustomerSheet( customerSheetInitParams: CustomerSheetInitParams( // Main params - setupIntentClientSecret: data['setupIntent'], + // setupIntentClientSecret: data['setupIntent'], merchantDisplayName: 'Flutter Stripe Store Demo', + allowsRemovalOfLastSavedPaymentMethod: true, // Customer params customerId: data['customer'], customerEphemeralKeySecret: data['ephemeralKeySecret'], diff --git a/example/lib/screens/others/can_add_to_wallet_screen.dart b/example/lib/screens/others/can_add_to_wallet_screen.dart new file mode 100644 index 000000000..96814f67b --- /dev/null +++ b/example/lib/screens/others/can_add_to_wallet_screen.dart @@ -0,0 +1,106 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_stripe/flutter_stripe.dart'; +import 'package:stripe_example/utils.dart'; +import 'package:stripe_example/widgets/example_scaffold.dart'; +import 'package:stripe_example/widgets/loading_button.dart'; +import 'package:stripe_example/widgets/response_card.dart'; + +class CanAddToWalletScreen extends StatefulWidget { + @override + _CanAddToWalletScreenState createState() => _CanAddToWalletScreenState(); +} + +class _CanAddToWalletScreenState extends State { + late TextEditingController _controller; + CanAddCardToWalletResult? canAddCardToWallet; + IsCardInWalletResult? isCardInWallet; + + @override + void initState() { + _controller = TextEditingController(); + super.initState(); + } + + @override + void dispose() { + _controller.dispose(); + super.dispose(); + } + + @override + Widget build(BuildContext context) { + return ExampleScaffold( + title: 'Can add card to wallet', + tags: ['Provisioning'], + padding: EdgeInsets.all(16), + children: [ + TextField( + controller: _controller, + decoration: InputDecoration( + border: OutlineInputBorder(), + labelText: 'Last4', + ), + ), + SizedBox(height: 20), + LoadingButton( + onPressed: () async { + final tmp = await _handleCanAddToWallet(_controller.text); + setState(() { + canAddCardToWallet = tmp; + }); + }, + text: 'Can add card to Wallet', + ), + SizedBox(height: 20), + LoadingButton( + onPressed: () async { + final tmp = await _isCardInToWallet(_controller.text); + setState(() { + isCardInWallet = tmp; + }); + }, + text: 'Is card in Wallet', + ), + SizedBox(height: 20), + if (canAddCardToWallet != null || isCardInWallet != null) + ResponseCard( + response: canAddCardToWallet?.toJson().toPrettyString() ?? + isCardInWallet?.toJson().toPrettyString() ?? + '', + ) + ], + ); + } + + Future _handleCanAddToWallet(String last4) async { + try { + final result = await Stripe.instance.canAddCardToWallet( + CanAddCardToWalletParams( + cardLastFour: last4, + ), + ); + ScaffoldMessenger.of(context).showSnackBar( + SnackBar(content: Text('Can add card to wallet: ${result}')), + ); + return result; + } catch (e) { + ScaffoldMessenger.of(context) + .showSnackBar(SnackBar(content: Text('Error: $e'))); + rethrow; + } + } + + Future _isCardInToWallet(String last4) async { + try { + final result = await Stripe.instance.isCardInWallet(last4); + ScaffoldMessenger.of(context).showSnackBar( + SnackBar(content: Text('Can add card to wallet: ${result}')), + ); + return result; + } catch (e) { + ScaffoldMessenger.of(context) + .showSnackBar(SnackBar(content: Text('Error: $e'))); + rethrow; + } + } +} diff --git a/example/lib/screens/screens.dart b/example/lib/screens/screens.dart index de470f7cd..cbefd798a 100644 --- a/example/lib/screens/screens.dart +++ b/example/lib/screens/screens.dart @@ -1,5 +1,6 @@ import 'package:flutter/material.dart'; import 'package:stripe_example/screens/customer_sheet/customer_sheet_screen.dart'; +import 'package:stripe_example/screens/others/can_add_to_wallet_screen.dart'; import 'package:stripe_example/screens/payment_sheet/payment_element/payment_element.dart'; import 'package:stripe_example/screens/payment_sheet/payment_sheet_deffered_screen.dart'; import 'package:stripe_example/screens/payment_sheet/payment_sheet_screen.dart'; @@ -374,6 +375,14 @@ class Example extends StatelessWidget { DevicePlatform.web, ], ), + Example( + title: 'Can add card to wallet', + builder: (context) => CanAddToWalletScreen(), + platformsSupported: [ + DevicePlatform.android, + DevicePlatform.ios, + ], + ), ]), ]; } diff --git a/example/macos/Runner.xcodeproj/project.pbxproj b/example/macos/Runner.xcodeproj/project.pbxproj index 71c9c0fe7..bbce8f0ed 100644 --- a/example/macos/Runner.xcodeproj/project.pbxproj +++ b/example/macos/Runner.xcodeproj/project.pbxproj @@ -202,7 +202,7 @@ isa = PBXProject; attributes = { LastSwiftUpdateCheck = 0920; - LastUpgradeCheck = 1300; + LastUpgradeCheck = 1510; ORGANIZATIONNAME = ""; TargetAttributes = { 33CC10EC2044A3C60003C045 = { diff --git a/example/macos/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme b/example/macos/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme index 7fd7126b0..ec9aa6bb9 100644 --- a/example/macos/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme +++ b/example/macos/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme @@ -1,6 +1,6 @@ this as _JS; diff --git a/packages/stripe_platform_interface/CHANGELOG.md b/packages/stripe_platform_interface/CHANGELOG.md index 448ef7443..31aa78a90 100644 --- a/packages/stripe_platform_interface/CHANGELOG.md +++ b/packages/stripe_platform_interface/CHANGELOG.md @@ -1,3 +1,7 @@ +## 11.1.1 + + - #1912 wallet parsing. + ## 11.1.0 - Sync with Stripe [0.38.6](https://github.com/stripe/stripe-react-native/releases/tag/v0.38.6). - Minor fixes and improvements. diff --git a/packages/stripe_platform_interface/lib/src/method_channel_stripe.dart b/packages/stripe_platform_interface/lib/src/method_channel_stripe.dart index 5c316eb88..ce017789f 100644 --- a/packages/stripe_platform_interface/lib/src/method_channel_stripe.dart +++ b/packages/stripe_platform_interface/lib/src/method_channel_stripe.dart @@ -636,24 +636,28 @@ class MethodChannelStripe extends StripePlatform { @override Future canAddCardToWallet( CanAddCardToWalletParams params) async { - final result = await _methodChannel.invokeMethod('canAddCardToWallet', { + final result = await _methodChannel + .invokeMapMethod('canAddCardToWallet', { 'params': params.toJson(), }); + if (result!['error'] != null) { + throw StripeException.fromJson(result); + } - return ResultParser( - parseJson: (json) => CanAddCardToWalletResult.fromJson(json)) - .parse(result: result!, successResultKey: 'canAddCardToWalletResult'); + return CanAddCardToWalletResult.fromJson(result); } @override Future isCardInWallet(String cardLastFour) async { - final result = await _methodChannel.invokeMethod('canAddCardToWallet', { + final result = await _methodChannel + .invokeMapMethod('isCardInWallet', { 'params': {'cardLastFour': cardLastFour}, }); + if (result!['error'] != null) { + throw StripeException.fromJson(result); + } - return ResultParser( - parseJson: (json) => IsCardInWalletResult.fromJson(json)) - .parse(result: result!, successResultKey: 'canAddCardToWalletResult'); + return IsCardInWalletResult.fromJson(result); } } diff --git a/packages/stripe_platform_interface/pubspec.yaml b/packages/stripe_platform_interface/pubspec.yaml index 4e7a21ca5..19ad4f90f 100644 --- a/packages/stripe_platform_interface/pubspec.yaml +++ b/packages/stripe_platform_interface/pubspec.yaml @@ -1,6 +1,6 @@ name: stripe_platform_interface description: Platform interface for stripe sdk -version: 11.1.0 +version: 11.1.1 repository: https://github.com/flutter-stripe/flutter_stripe homepage: https://pub.dev/packages/flutter_stripe diff --git a/packages/stripe_web/lib/src/parser/payment_intent.dart b/packages/stripe_web/lib/src/parser/payment_intent.dart index d15ec1611..4d3bb9863 100644 --- a/packages/stripe_web/lib/src/parser/payment_intent.dart +++ b/packages/stripe_web/lib/src/parser/payment_intent.dart @@ -14,8 +14,7 @@ extension PaymentIntentExtension on js.PaymentIntent { latestCharge: latestCharge, //paymentMethodId: payment_method, captureMethod: CaptureMethodExtension.parse(captureMethod.name), - confirmationMethod: - ConfirmationMethodExtension.parse(confirmationMethod.name), + confirmationMethod: ConfirmationMethodExtension.parse(confirmationMethod.name), // description: description, // receiptEmail: receipt_email, @@ -75,6 +74,7 @@ extension CaptureMethodExtension on CaptureMethod { case 'automatic': return CaptureMethod.Automatic; case 'AutomaticAsync': + case 'automaticAsync': case 'automatic_async': return CaptureMethod.AutomaticAsync; case 'Manual': diff --git a/packages/stripe_web/lib/src/widgets/platform_pay_button.dart b/packages/stripe_web/lib/src/widgets/platform_pay_button.dart index b169d64cd..fe811abeb 100644 --- a/packages/stripe_web/lib/src/widgets/platform_pay_button.dart +++ b/packages/stripe_web/lib/src/widgets/platform_pay_button.dart @@ -1,13 +1,11 @@ import 'dart:js_interop'; - -import 'package:web/web.dart' as web; import 'dart:ui' as ui; import 'package:flutter/material.dart'; import 'package:flutter_stripe_web/flutter_stripe_web.dart'; import 'package:flutter_stripe_web/src/parser/payment_request.dart'; - import 'package:stripe_js/stripe_js.dart'; +import 'package:web/web.dart' as web; const kPlatformPayButtonDefaultHeight = 40.0; @@ -76,7 +74,7 @@ class _WebPlatformPayButtonState extends State { height: '${constraints.maxHeight}px', )))) ..on('click', (event) { - //callMethod(event, 'preventDefault', []); + event.toDart['preventDefault'](); widget.onPressed(); }) ..mount('#platform-pay-button'.toJS); diff --git a/packages/stripe_web/pubspec.yaml b/packages/stripe_web/pubspec.yaml index d8ba36b9f..d2e9ce21b 100644 --- a/packages/stripe_web/pubspec.yaml +++ b/packages/stripe_web/pubspec.yaml @@ -13,7 +13,7 @@ dependencies: flutter_web_plugins: sdk: flutter freezed_annotation: ^2.0.3 - stripe_platform_interface: ^11.1.0 + stripe_platform_interface: ^11.1.1 stripe_js: ^6.1.1 web: ^1.0.0