From 3f93fbe81599f5dfc3631b15f94bc07aea2621a5 Mon Sep 17 00:00:00 2001 From: Jaime Blasco Date: Wed, 12 Apr 2023 09:50:08 +0200 Subject: [PATCH] fix: confirmation redirect and stripeAccountId (#1201) * fix: confirmation redirect and stripeAccountId * doc: publish web versions * fix: versioning problem --- example/pubspec.yaml | 4 +-- packages/stripe_js/CHANGELOG.md | 6 +++++ .../confirm_payment_options.dart | 1 + .../setup_intents/setup_intent.freezed.dart | 27 +++---------------- packages/stripe_js/lib/src/js/stripe.dart | 3 +++ packages/stripe_js/pubspec.yaml | 3 ++- packages/stripe_web/CHANGELOG.md | 8 ++++++ packages/stripe_web/lib/src/parser/token.dart | 2 +- packages/stripe_web/lib/src/web_stripe.dart | 8 ++++-- packages/stripe_web/pubspec.yaml | 6 ++--- 10 files changed, 35 insertions(+), 33 deletions(-) diff --git a/example/pubspec.yaml b/example/pubspec.yaml index 76c0179c1..6e6f3eed5 100644 --- a/example/pubspec.yaml +++ b/example/pubspec.yaml @@ -10,8 +10,8 @@ environment: dependencies: flutter: sdk: flutter - flutter_stripe: ^8.0.0+1 - flutter_stripe_web: ^3.0.0 + flutter_stripe: ^9.0.0+1 + flutter_stripe_web: ^4.0.0 stripe_checkout: ^1.0.0 pay: ^1.1.0 http: ^0.13.1 diff --git a/packages/stripe_js/CHANGELOG.md b/packages/stripe_js/CHANGELOG.md index a3921a9c9..7013575f3 100644 --- a/packages/stripe_js/CHANGELOG.md +++ b/packages/stripe_js/CHANGELOG.md @@ -1,2 +1,8 @@ +## 3.0.0 +- Adds support for SetupIntent +- Adds support for Tokens Api +- Removes $expanded and $id methods to build payment methods. Use the specific payment method for the endpoint (eg CardPaymentMethodDetails.id/CardPaymentMethodDetails.token) +- Allows to dynamically change the stripeAccountId for Connect users + ## 2.0.1 - Preview of Stripe.js port diff --git a/packages/stripe_js/lib/src/api/payment_intents/confirm_payment_options.dart b/packages/stripe_js/lib/src/api/payment_intents/confirm_payment_options.dart index 7a321e2b4..eba1bb947 100644 --- a/packages/stripe_js/lib/src/api/payment_intents/confirm_payment_options.dart +++ b/packages/stripe_js/lib/src/api/payment_intents/confirm_payment_options.dart @@ -50,5 +50,6 @@ class ConfirmPaymentParams with _$ConfirmPaymentParams { /// will only redirect if your user chooses a redirect-based payment method. enum PaymentConfirmationRedirect { always, + @JsonKey(name: 'if_required') ifRequired, } 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 32f00fd43..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 @@ -60,14 +60,7 @@ mixin _$SetupIntent { /// Unix epoch. int? get created => throw _privateConstructorUsedError; - /// The client secret of this SetupIntent. - /// Used for client-side retrieval using a publishable key. - /// The client secret can be used to complete payment setup from your - /// frontend. - /// 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. + /// The ID of the Customer this SetupIntent belongs to. String? get customer => throw _privateConstructorUsedError; /// An arbitrary string attached to the object. @@ -601,14 +594,7 @@ class _$_SetupIntent implements _SetupIntent { @override final int? created; - /// The client secret of this SetupIntent. - /// Used for client-side retrieval using a publishable key. - /// The client secret can be used to complete payment setup from your - /// frontend. - /// 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. + /// The ID of the Customer this SetupIntent belongs to. @override final String? customer; @@ -921,14 +907,7 @@ abstract class _SetupIntent implements SetupIntent { int? get created; @override - /// The client secret of this SetupIntent. - /// Used for client-side retrieval using a publishable key. - /// The client secret can be used to complete payment setup from your - /// frontend. - /// 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. + /// The ID of the Customer this SetupIntent belongs to. String? get customer; @override diff --git a/packages/stripe_js/lib/src/js/stripe.dart b/packages/stripe_js/lib/src/js/stripe.dart index 61be81aae..03665c5df 100644 --- a/packages/stripe_js/lib/src/js/stripe.dart +++ b/packages/stripe_js/lib/src/js/stripe.dart @@ -19,6 +19,9 @@ class Stripe { external static num get version; external StripeElements elements([ElementsCreateOptions options]); + + external String? get stripeAccount; + external set stripeAccount(String? stripeAccount); } @anonymous diff --git a/packages/stripe_js/pubspec.yaml b/packages/stripe_js/pubspec.yaml index fa1f3d6c8..d5e47ee02 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: 2.0.1 +version: 3.0.0 homepage: https://github.com/flutter-stripe/flutter_stripe environment: @@ -10,6 +10,7 @@ dependencies: freezed_annotation: ^2.2.0 js: ^0.6.3 json_annotation: ^4.5.0 + meta: ^1.0.0 dev_dependencies: build_runner: ^2.3.2 diff --git a/packages/stripe_web/CHANGELOG.md b/packages/stripe_web/CHANGELOG.md index 40c6e8e97..106b37777 100644 --- a/packages/stripe_web/CHANGELOG.md +++ b/packages/stripe_web/CHANGELOG.md @@ -1,3 +1,11 @@ +## 4.0.0 +- Adds support for SetupIntent +- Adds support for Tokens Api +- Adds support for PaymentElement +- Allows to dynamically change the stripeAccountId for Connect users +- Fixes PaymentConfirmationRedirect.ifRequired parsing error +- Bump "stripe_js" to `3.0.0`. + ## 3.0.0 - Comply to breaking changes in platform interface. No changes further. diff --git a/packages/stripe_web/lib/src/parser/token.dart b/packages/stripe_web/lib/src/parser/token.dart index 04939ff79..b8d754376 100644 --- a/packages/stripe_web/lib/src/parser/token.dart +++ b/packages/stripe_web/lib/src/parser/token.dart @@ -5,7 +5,7 @@ extension Token on js.Token { TokenData parse() { return TokenData( id: id, - createdDateTime: created.toString(), + createdDateTime: created ?? 0, livemode: livemode, type: type.parse(), card: card?.parse(), diff --git a/packages/stripe_web/lib/src/web_stripe.dart b/packages/stripe_web/lib/src/web_stripe.dart index 31e22e651..a6c7911f6 100644 --- a/packages/stripe_web/lib/src/web_stripe.dart +++ b/packages/stripe_web/lib/src/web_stripe.dart @@ -42,14 +42,18 @@ class WebStripe extends StripePlatform { String? urlScheme, bool? setReturnUrlSchemeOnAndroid, }) async { + this.urlScheme = urlScheme; + if (__stripe != null) { + __stripe!.stripeAccount = stripeAccountId; + return; + } + await stripe_js.loadStripe(); - if (__stripe != null) return; final stripeOption = stripe_js.StripeOptions(); if (stripeAccountId != null) { stripeOption.stripeAccount = stripeAccountId; } __stripe = stripe_js.Stripe(publishableKey, stripeOption); - this.urlScheme = urlScheme; } static stripe_js.StripeElement? element; diff --git a/packages/stripe_web/pubspec.yaml b/packages/stripe_web/pubspec.yaml index 3325b37b1..e33b6b25e 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: 3.0.0 +version: 4.0.0 homepage: https://github.com/flutter-stripe/flutter_stripe environment: @@ -13,9 +13,9 @@ dependencies: flutter_web_plugins: sdk: flutter freezed_annotation: ^2.0.3 - stripe_platform_interface: ^8.0.0 + stripe_platform_interface: ^9.0.0 js: ^0.6.3 - stripe_js: ^2.0.1 + stripe_js: ^3.0.0 dev_dependencies: flutter_test: