Skip to content

Commit

Permalink
fix: confirmation redirect and stripeAccountId (#1201)
Browse files Browse the repository at this point in the history
* fix: confirmation redirect and stripeAccountId

* doc: publish web versions

* fix: versioning problem
  • Loading branch information
jamesblasco authored Apr 12, 2023
1 parent 9fbb7a4 commit 3f93fbe
Show file tree
Hide file tree
Showing 10 changed files with 35 additions and 33 deletions.
4 changes: 2 additions & 2 deletions example/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 6 additions & 0 deletions packages/stripe_js/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -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

Expand Down
3 changes: 3 additions & 0 deletions packages/stripe_js/lib/src/js/stripe.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion packages/stripe_js/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -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:
Expand All @@ -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
Expand Down
8 changes: 8 additions & 0 deletions packages/stripe_web/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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.

Expand Down
2 changes: 1 addition & 1 deletion packages/stripe_web/lib/src/parser/token.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down
8 changes: 6 additions & 2 deletions packages/stripe_web/lib/src/web_stripe.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
6 changes: 3 additions & 3 deletions packages/stripe_web/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -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:
Expand All @@ -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:
Expand Down

0 comments on commit 3f93fbe

Please sign in to comment.