Skip to content

Commit

Permalink
feat: add klarna for web
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesblasco committed Jun 29, 2023
1 parent f2c17ee commit e6f4d43
Show file tree
Hide file tree
Showing 35 changed files with 1,786 additions and 437 deletions.
1 change: 0 additions & 1 deletion example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ void main() async {
WidgetsFlutterBinding.ensureInitialized();
Stripe.publishableKey = stripePublishableKey;
Stripe.merchantIdentifier = 'merchant.flutter.stripe.test';
Stripe.urlScheme = 'flutterstripe';
await Stripe.instance.applySettings();
runApp(const App());
}
Expand Down
1 change: 0 additions & 1 deletion example/lib/screens/screens.dart
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,6 @@ class Example extends StatelessWidget {
width: 48,
),
builder: (contex) => KlarnaScreen(),
platformsSupported: [DevicePlatform.android, DevicePlatform.ios],
),
Example(
title: 'PayPal',
Expand Down
1 change: 1 addition & 0 deletions packages/stripe/lib/src/stripe.dart
Original file line number Diff line number Diff line change
Expand Up @@ -709,5 +709,6 @@ class Stripe {
ValueNotifier<bool>? _isPlatformPaySupported;

// Internal use only
@internal
static final buildWebCard = _platform.buildCard;
}
Original file line number Diff line number Diff line change
Expand Up @@ -176,11 +176,11 @@ class BillingDetailsFields with _$BillingDetailsFields {
const factory BillingDetailsFields({
@Default(PaymentElementFieldRequired.auto) PaymentElementFieldRequired name,
@Default(PaymentElementFieldRequired.auto)
PaymentElementFieldRequired email,
PaymentElementFieldRequired email,
@Default(PaymentElementFieldRequired.auto)
PaymentElementFieldRequired phone,
PaymentElementFieldRequired phone,
@Default(PaymentElementAddressFields.auto)
PaymentElementAddressFields address,
PaymentElementAddressFields address,
}) = _BillingDetailsFields;

static const auto = BillingDetailsFields();
Expand All @@ -193,16 +193,16 @@ class BillingDetailsFields with _$BillingDetailsFields {
class PaymentElementAddressFields with _$PaymentElementAddressFields {
const factory PaymentElementAddressFields({
@Default(PaymentElementFieldRequired.auto)
PaymentElementFieldRequired line1,
PaymentElementFieldRequired line1,
@Default(PaymentElementFieldRequired.auto)
PaymentElementFieldRequired line2,
PaymentElementFieldRequired line2,
@Default(PaymentElementFieldRequired.auto) PaymentElementFieldRequired city,
@Default(PaymentElementFieldRequired.auto)
PaymentElementFieldRequired state,
PaymentElementFieldRequired state,
@Default(PaymentElementFieldRequired.auto)
PaymentElementFieldRequired country,
PaymentElementFieldRequired country,
@Default(PaymentElementFieldRequired.auto)
PaymentElementFieldRequired postalCode,
PaymentElementFieldRequired postalCode,
}) = _PaymentElementAddressFields;

static const auto = PaymentElementAddressFields();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class ConfirmCardPaymentData with _$ConfirmCardPaymentData {
/// and comply with regional legislation and network rules. For example, if
/// your customer is impacted by SCA, using off_session will ensure that they are authenticated while processing this PaymentIntent. You will then be able to collect off-session payments for this customer.
@JsonKey(name: "setup_future_usage")
PaymentIntentSetupFutureUsage? setupFutureUsage,
PaymentIntentSetupFutureUsage? setupFutureUsage,

/// An object containing payment-method-specific configuration to
/// confirm the PaymentIntent with.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,13 +77,17 @@ abstract class $ConfirmCardPaymentDataCopyWith<$Res> {
_$ConfirmCardPaymentDataCopyWithImpl<$Res, ConfirmCardPaymentData>;
@useResult
$Res call(
{@paymentMethodDetailJsonKey CardPaymentMethodDetails? paymentMethod,
{@paymentMethodDetailJsonKey
CardPaymentMethodDetails? paymentMethod,
ShippingDetails? shipping,
@JsonKey(name: "return_url") String? returnUrl,
@JsonKey(name: "receipt_email") String? receiptEmail,
@JsonKey(name: "return_url")
String? returnUrl,
@JsonKey(name: "receipt_email")
String? receiptEmail,
@JsonKey(name: "setup_future_usage")
PaymentIntentSetupFutureUsage? setupFutureUsage,
@JsonKey(name: "payment_method_options") dynamic paymentMethodOptions});
PaymentIntentSetupFutureUsage? setupFutureUsage,
@JsonKey(name: "payment_method_options")
dynamic paymentMethodOptions});

$CardPaymentMethodDetailsCopyWith<$Res>? get paymentMethod;
$ShippingDetailsCopyWith<$Res>? get shipping;
Expand Down Expand Up @@ -173,13 +177,17 @@ abstract class _$$_ConfirmCardPaymentDataCopyWith<$Res>
@override
@useResult
$Res call(
{@paymentMethodDetailJsonKey CardPaymentMethodDetails? paymentMethod,
{@paymentMethodDetailJsonKey
CardPaymentMethodDetails? paymentMethod,
ShippingDetails? shipping,
@JsonKey(name: "return_url") String? returnUrl,
@JsonKey(name: "receipt_email") String? receiptEmail,
@JsonKey(name: "return_url")
String? returnUrl,
@JsonKey(name: "receipt_email")
String? receiptEmail,
@JsonKey(name: "setup_future_usage")
PaymentIntentSetupFutureUsage? setupFutureUsage,
@JsonKey(name: "payment_method_options") dynamic paymentMethodOptions});
PaymentIntentSetupFutureUsage? setupFutureUsage,
@JsonKey(name: "payment_method_options")
dynamic paymentMethodOptions});

@override
$CardPaymentMethodDetailsCopyWith<$Res>? get paymentMethod;
Expand Down Expand Up @@ -349,14 +357,16 @@ class _$_ConfirmCardPaymentData implements _ConfirmCardPaymentData {
abstract class _ConfirmCardPaymentData implements ConfirmCardPaymentData {
const factory _ConfirmCardPaymentData(
{@paymentMethodDetailJsonKey
final CardPaymentMethodDetails? paymentMethod,
final CardPaymentMethodDetails? paymentMethod,
final ShippingDetails? shipping,
@JsonKey(name: "return_url") final String? returnUrl,
@JsonKey(name: "receipt_email") final String? receiptEmail,
@JsonKey(name: "return_url")
final String? returnUrl,
@JsonKey(name: "receipt_email")
final String? receiptEmail,
@JsonKey(name: "setup_future_usage")
final PaymentIntentSetupFutureUsage? setupFutureUsage,
final PaymentIntentSetupFutureUsage? setupFutureUsage,
@JsonKey(name: "payment_method_options")
final dynamic paymentMethodOptions}) = _$_ConfirmCardPaymentData;
final dynamic paymentMethodOptions}) = _$_ConfirmCardPaymentData;

factory _ConfirmCardPaymentData.fromJson(Map<String, dynamic> json) =
_$_ConfirmCardPaymentData.fromJson;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class ConfirmIdealPaymentData with _$ConfirmIdealPaymentData {
/// PaymentIntent. The newly created SEPA Direct Debit PaymentMethod
/// will be attached to this customer.
@JsonKey(name: "setup_future_usage")
PaymentIntentSetupFutureUsage? setupFutureUsage,
PaymentIntentSetupFutureUsage? setupFutureUsage,
}) = _ConfirmIdealPaymentData;

factory ConfirmIdealPaymentData.fromJson(Map<String, dynamic> json) =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,12 @@ abstract class $ConfirmIdealPaymentDataCopyWith<$Res> {
_$ConfirmIdealPaymentDataCopyWithImpl<$Res, ConfirmIdealPaymentData>;
@useResult
$Res call(
{@paymentMethodDetailJsonKey IdealPaymentMethodDetails? paymentMethod,
@JsonKey(name: "return_url") String? returnUrl,
{@paymentMethodDetailJsonKey
IdealPaymentMethodDetails? paymentMethod,
@JsonKey(name: "return_url")
String? returnUrl,
@JsonKey(name: "setup_future_usage")
PaymentIntentSetupFutureUsage? setupFutureUsage});
PaymentIntentSetupFutureUsage? setupFutureUsage});

$IdealPaymentMethodDetailsCopyWith<$Res>? get paymentMethod;
}
Expand Down Expand Up @@ -119,10 +121,12 @@ abstract class _$$_ConfirmIdealPaymentDataCopyWith<$Res>
@override
@useResult
$Res call(
{@paymentMethodDetailJsonKey IdealPaymentMethodDetails? paymentMethod,
@JsonKey(name: "return_url") String? returnUrl,
{@paymentMethodDetailJsonKey
IdealPaymentMethodDetails? paymentMethod,
@JsonKey(name: "return_url")
String? returnUrl,
@JsonKey(name: "setup_future_usage")
PaymentIntentSetupFutureUsage? setupFutureUsage});
PaymentIntentSetupFutureUsage? setupFutureUsage});

@override
$IdealPaymentMethodDetailsCopyWith<$Res>? get paymentMethod;
Expand Down Expand Up @@ -235,10 +239,11 @@ class _$_ConfirmIdealPaymentData implements _ConfirmIdealPaymentData {
abstract class _ConfirmIdealPaymentData implements ConfirmIdealPaymentData {
const factory _ConfirmIdealPaymentData(
{@paymentMethodDetailJsonKey
final IdealPaymentMethodDetails? paymentMethod,
@JsonKey(name: "return_url") final String? returnUrl,
final IdealPaymentMethodDetails? paymentMethod,
@JsonKey(name: "return_url")
final String? returnUrl,
@JsonKey(name: "setup_future_usage")
final PaymentIntentSetupFutureUsage? setupFutureUsage}) =
final PaymentIntentSetupFutureUsage? setupFutureUsage}) =
_$_ConfirmIdealPaymentData;

factory _ConfirmIdealPaymentData.fromJson(Map<String, dynamic> json) =
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import 'package:freezed_annotation/freezed_annotation.dart';
import 'package:stripe_js/stripe_api.dart';

part 'confirm_klarna_payment_data.freezed.dart';
part 'confirm_klarna_payment_data.g.dart';

@freezed
class ConfirmKlarnaPaymentData with _$ConfirmKlarnaPaymentData {
const factory ConfirmKlarnaPaymentData({
/// Either the id of an existing PaymentMethod, or an object containing
/// data to create a PaymentMethod with.
/// See the use case sections below for details.
@paymentMethodDetailJsonKey KlarnaPaymentMethodDetails? paymentMethod,

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

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

0 comments on commit e6f4d43

Please sign in to comment.