Skip to content

Commit

Permalink
Add P24 confirm payment functionality for web integration
Browse files Browse the repository at this point in the history
  • Loading branch information
amadeuszblanik committed Dec 6, 2024
1 parent 9c2e704 commit ca7bd06
Show file tree
Hide file tree
Showing 10 changed files with 630 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import 'package:freezed_annotation/freezed_annotation.dart';
import 'package:stripe_js/stripe_api.dart';

part 'confirm_p24_payment_data.freezed.dart';
part 'confirm_p24_payment_data.g.dart';

@freezed
class ConfirmP24PaymentData with _$ConfirmP24PaymentData {
const factory ConfirmP24PaymentData({
/// Either the ID of an existing PaymentMethod, or an object containing
/// data to create a PaymentMethod with.
///
/// This is required to process the payment. If you already have a PaymentMethod
/// attached to the PaymentIntent, you do not need to specify this field.
///
/// See the official Stripe documentation for additional details:
/// https://stripe.com/docs/payments/p24
@paymentMethodDetailJsonKey P24PaymentMethodDetails? paymentMethod,

/// The url your customer will be directed to after they complete authentication.
@JsonKey(name: "return_url") String? returnUrl,

/// To set up a SEPA Direct Debit payment method using the bank details
/// from this P24 payment, set this parameter to off_session.
/// When using this parameter, a customer will need to be set on the
/// PaymentIntent. The newly created SEPA Direct Debit PaymentMethod
/// will be attached to this customer.
@JsonKey(name: "setup_future_usage")
PaymentIntentSetupFutureUsage? setupFutureUsage,
}) = _ConfirmP24PaymentData;

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

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

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,16 @@
import 'package:freezed_annotation/freezed_annotation.dart';

part 'confirm_p24_payment_options.freezed.dart';
part 'confirm_p24_payment_options.g.dart';

@freezed
class ConfirmP24PaymentOptions with _$ConfirmP24PaymentOptions {
const factory ConfirmP24PaymentOptions({
/// Set this to false if you want to manually handle
/// the authorization redirect. Default is true.
@Default(true) bool? handleActions,
}) = _ConfirmP24PaymentOptions;

factory ConfirmP24PaymentOptions.fromJson(Map<String, dynamic> json) =>
_$ConfirmP24PaymentOptionsFromJson(json);
}
Loading

0 comments on commit ca7bd06

Please sign in to comment.