Skip to content

Commit

Permalink
add_confirm_setup
Browse files Browse the repository at this point in the history
  • Loading branch information
cedvandenbosch committed Oct 13, 2024
1 parent aa7ba40 commit 38720d1
Show file tree
Hide file tree
Showing 7 changed files with 642 additions and 0 deletions.

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

0 comments on commit 38720d1

Please sign in to comment.