Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[draft] do not merge - Setup confirm stripe_web #1960

Open
wants to merge 11 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions packages/stripe_js/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 6.2.1
**Features**
- Add support for any kind of payment method in setup intent with [confirmSetup]

## 6.2.0
**Features**
- Add basic support for Expresscheckout on the web
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
import 'package:stripe_js/src/api/converters/js_converter.dart';
import 'package:stripe_js/stripe_api.dart';

import 'package:freezed_annotation/freezed_annotation.dart';

part 'confirm_setup_options.freezed.dart';
part 'confirm_setup_options.g.dart';

@freezed
class ConfirmSetupOptions with _$ConfirmSetupOptions {
const factory ConfirmSetupOptions({
/// Required if you collect payment details before creating an Intent. It's always required if you don't provide a clientSecret.
@ElementsConverter() required Elements elements,

/// Required if you collect payment details before creating an Intent.
/// It's always required if you don't provide an elements instance containing a client secret.
String? clientSecret,

/// Parameters that will be passed on to the Stripe API.
/// Refer to the Payment Intents API for a full list of parameters.
required ConfirmSetupParams confirmParams,

/// By default, stripe.confirmSetup will always redirect to your return_url
/// after a successful confirmation. If you set redirect: "if_required",
/// then stripe.confirmSetup will only redirect if your user chooses a
/// redirect-based payment method.

/// Note: Setting if_required requires that you handle successful confirmations
/// for redirect-based and non-redirect based payment methods separately.
/// When a non-redirect based payment method is successfully confirmed,
/// stripe.confirmSetup will resolve with a {setupIntent} object.
SetupConfirmationRedirect? redirect,
}) = _ConfirmSetupOptions;

factory ConfirmSetupOptions.fromJson(Map<String, dynamic> json) =>
_$ConfirmSetupOptionsFromJson(json);
}

@freezed
class ConfirmSetupParams with _$ConfirmSetupParams {
const factory ConfirmSetupParams({
/// The url your customer will be directed to after they complete authentication.
required String return_url,

/// If collected previously, the ID of the ConfirmationToken to use to confirm this SetupIntent.
/// This is mutually exclusive with the elements parameter.
String? confirmation_token,
}) = _ConfirmSetupParams;

factory ConfirmSetupParams.fromJson(Map<String, dynamic> json) =>
_$ConfirmSetupParamsFromJson(json);
}

/// By default, stripe.confirmPayment will always redirect to
/// your return_url after a successful confirmation.
/// If you set redirect: "if_required", then stripe.confirmPayment
/// will only redirect if your user chooses a redirect-based payment method.
enum SetupConfirmationRedirect {
always,
@JsonValue('if_required')
ifRequired,
}
Loading
Loading