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

Fix: #1459 allow image to be null #1466

Merged
merged 2 commits into from
Nov 15, 2023
Merged
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
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,
}) {
return _then(_value.copyWith(
label: null == label
? _value.label
: label // ignore: cast_nullable_to_non_nullable
as String,
image: null == image
image: freezed == image
? _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,
}) {
return _then(_$_PaymentSheetPaymentOption(
label: null == label
? _value.label
: label // ignore: cast_nullable_to_non_nullable
as String,
image: null == image
image: freezed == image
? _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.

Loading