Skip to content

Commit

Permalink
Fix: #1459 allow image to be null
Browse files Browse the repository at this point in the history
  • Loading branch information
Remon committed Oct 26, 2023
1 parent 129669b commit a8c573d
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 16 deletions.
28 changes: 28 additions & 0 deletions example/server/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -746,6 +746,34 @@ app.post('/create-checkout-session', async (req, res) => {
});
});

app.post('/customer-sheet', async (_, res) => {
const { secret_key } = getKeys();

const stripe = new Stripe(secret_key as string, {
apiVersion: '2023-08-16',
typescript: true,
});

// Use an existing Customer ID if this is a returning customer.
const customer = await stripe.customers.create();

// Use the same version as the SDK
const ephemeralKey = await stripe.ephemeralKeys.create(
{ customer: customer.id },
{ apiVersion: '2020-08-27' }
);

const setupIntent = await stripe.setupIntents.create({
customer: customer.id,
});

res.json({
customer: customer.id,
ephemeralKeySecret: ephemeralKey.secret,
setupIntent: setupIntent.client_secret,
});
});

app.post('/fetch-payment-methods', async (req, res) => {
const { secret_key } = getKeys();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -457,7 +457,7 @@ class PaymentSheetPaymentOption with _$PaymentSheetPaymentOption {
required String label,

/// String decoding of the image
required String image,
String? image,
}) = _PaymentSheetPaymentOption;

factory PaymentSheetPaymentOption.fromJson(Map<String, dynamic> json) =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4471,7 +4471,7 @@ mixin _$PaymentSheetPaymentOption {
String get label => throw _privateConstructorUsedError;

/// String decoding of the image
String get image => throw _privateConstructorUsedError;
String? get image => throw _privateConstructorUsedError;

Map<String, dynamic> toJson() => throw _privateConstructorUsedError;
@JsonKey(ignore: true)
Expand All @@ -4485,7 +4485,7 @@ abstract class $PaymentSheetPaymentOptionCopyWith<$Res> {
$Res Function(PaymentSheetPaymentOption) then) =
_$PaymentSheetPaymentOptionCopyWithImpl<$Res, PaymentSheetPaymentOption>;
@useResult
$Res call({String label, String image});
$Res call({String label, String? image});
}

/// @nodoc
Expand All @@ -4503,17 +4503,17 @@ class _$PaymentSheetPaymentOptionCopyWithImpl<$Res,
@override
$Res call({
Object? label = null,
Object? image = null,
Object? image = freezed,

Check warning on line 4506 in packages/stripe_platform_interface/lib/src/models/payment_sheet.freezed.dart

View workflow job for this annotation

GitHub Actions / Typo CI

freezed

"freezed" is a typo. Did you mean "freezes"?
}) {
return _then(_value.copyWith(
label: null == label
? _value.label
: label // ignore: cast_nullable_to_non_nullable
as String,
image: null == image
image: freezed == image

Check warning on line 4513 in packages/stripe_platform_interface/lib/src/models/payment_sheet.freezed.dart

View workflow job for this annotation

GitHub Actions / Typo CI

freezed

"freezed" is a typo. Did you mean "freezes"?
? _value.image
: image // ignore: cast_nullable_to_non_nullable
as String,
as String?,
) as $Val);
}
}
Expand All @@ -4527,7 +4527,7 @@ abstract class _$$_PaymentSheetPaymentOptionCopyWith<$Res>
__$$_PaymentSheetPaymentOptionCopyWithImpl<$Res>;
@override
@useResult
$Res call({String label, String image});
$Res call({String label, String? image});
}

/// @nodoc
Expand All @@ -4544,17 +4544,17 @@ class __$$_PaymentSheetPaymentOptionCopyWithImpl<$Res>
@override
$Res call({
Object? label = null,
Object? image = null,
Object? image = freezed,

Check warning on line 4547 in packages/stripe_platform_interface/lib/src/models/payment_sheet.freezed.dart

View workflow job for this annotation

GitHub Actions / Typo CI

freezed

"freezed" is a typo. Did you mean "freezes"?
}) {
return _then(_$_PaymentSheetPaymentOption(
label: null == label
? _value.label
: label // ignore: cast_nullable_to_non_nullable
as String,
image: null == image
image: freezed == image

Check warning on line 4554 in packages/stripe_platform_interface/lib/src/models/payment_sheet.freezed.dart

View workflow job for this annotation

GitHub Actions / Typo CI

freezed

"freezed" is a typo. Did you mean "freezes"?
? _value.image
: image // ignore: cast_nullable_to_non_nullable
as String,
as String?,
));
}
}
Expand All @@ -4563,8 +4563,7 @@ class __$$_PaymentSheetPaymentOptionCopyWithImpl<$Res>
@JsonSerializable(explicitToJson: true)
class _$_PaymentSheetPaymentOption implements _PaymentSheetPaymentOption {
const _$_PaymentSheetPaymentOption(
{required this.label, required this.image});
const _$_PaymentSheetPaymentOption({required this.label, this.image});

factory _$_PaymentSheetPaymentOption.fromJson(Map<String, dynamic> json) =>
_$$_PaymentSheetPaymentOptionFromJson(json);
Expand All @@ -4575,7 +4574,7 @@ class _$_PaymentSheetPaymentOption implements _PaymentSheetPaymentOption {

/// String decoding of the image
@override
final String image;
final String? image;

@override
String toString() {
Expand Down Expand Up @@ -4613,7 +4612,7 @@ class _$_PaymentSheetPaymentOption implements _PaymentSheetPaymentOption {
abstract class _PaymentSheetPaymentOption implements PaymentSheetPaymentOption {
const factory _PaymentSheetPaymentOption(
{required final String label,
required final String image}) = _$_PaymentSheetPaymentOption;
final String? image}) = _$_PaymentSheetPaymentOption;

factory _PaymentSheetPaymentOption.fromJson(Map<String, dynamic> json) =
_$_PaymentSheetPaymentOption.fromJson;
Expand All @@ -4625,7 +4624,7 @@ abstract class _PaymentSheetPaymentOption implements PaymentSheetPaymentOption {
@override

/// String decoding of the image
String get image;
String? get image;
@override
@JsonKey(ignore: true)
_$$_PaymentSheetPaymentOptionCopyWith<_$_PaymentSheetPaymentOption>
Expand Down

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

0 comments on commit a8c573d

Please sign in to comment.