CheckoutSessionCreateOptions.fromJson constructor
CheckoutSessionCreateOptions.fromJson(
- Object? json
Implementation
factory CheckoutSessionCreateOptions.fromJson(Object? json) {
final map = (json as Map).cast<String, Object?>();
return CheckoutSessionCreateOptions(
afterExpiration: map['after_expiration'] == null
? null
: SessionAfterExpiration.fromJson(map['after_expiration']),
allowPromotionCodes: map['allow_promotion_codes'] == null
? null
: (map['allow_promotion_codes'] as bool),
automaticTax: map['automatic_tax'] == null
? null
: SessionAutomaticTax.fromJson(map['automatic_tax']),
billingAddressCollection: map['billing_address_collection'] == null
? null
: PaymentLinkBillingAddressCollection.fromJson(
map['billing_address_collection']),
cancelUrl:
map['cancel_url'] == null ? null : (map['cancel_url'] as String),
clientReferenceId: map['client_reference_id'] == null
? null
: (map['client_reference_id'] as String),
consentCollection: map['consent_collection'] == null
? null
: SessionConsentCollection.fromJson(map['consent_collection']),
currency: map['currency'] == null ? null : (map['currency'] as String),
customFields: map['custom_fields'] == null
? null
: (map['custom_fields'] as List<Object?>)
.map((el) => SessionCustomFieldsItem.fromJson(el))
.toList(),
customText: map['custom_text'] == null
? null
: SessionCustomText.fromJson(map['custom_text']),
customer: map['customer'] == null ? null : (map['customer'] as String),
customerCreation: map['customer_creation'] == null
? null
: PaymentLinkCustomerCreation.fromJson(map['customer_creation']),
customerEmail: map['customer_email'] == null
? null
: (map['customer_email'] as String),
customerUpdate: map['customer_update'] == null
? null
: SessionCustomerUpdate.fromJson(map['customer_update']),
discounts: map['discounts'] == null
? null
: (map['discounts'] as List<Object?>)
.map((el) => SessionDiscountsItem.fromJson(el))
.toList(),
expand: map['expand'] == null
? null
: (map['expand'] as List<Object?>)
.map((el) => (el as String))
.toList(),
expiresAt: map['expires_at'] == null
? null
: DateTime.fromMillisecondsSinceEpoch(
(map['expires_at'] as int).toInt()),
invoiceCreation: map['invoice_creation'] == null
? null
: SessionInvoiceCreation.fromJson(map['invoice_creation']),
lineItems: map['line_items'] == null
? null
: (map['line_items'] as List<Object?>)
.map((el) => SessionLineItemsItem.fromJson(el))
.toList(),
locale: map['locale'] == null
? null
: CheckoutSessionCreateOptionsLocale.fromJson(map['locale']),
metadata: map['metadata'] == null
? null
: (map['metadata'] as Map).cast<String, Object?>().map((
key,
value,
) =>
MapEntry(
key,
(value as String),
)),
mode: map['mode'] == null
? null
: CheckoutSessionMode.fromJson(map['mode']),
paymentIntentData: map['payment_intent_data'] == null
? null
: SessionPaymentIntentData.fromJson(map['payment_intent_data']),
paymentMethodCollection: map['payment_method_collection'] == null
? null
: PaymentLinkCustomerCreation.fromJson(
map['payment_method_collection']),
paymentMethodConfiguration: map['payment_method_configuration'] == null
? null
: (map['payment_method_configuration'] as String),
paymentMethodOptions: map['payment_method_options'] == null
? null
: SessionPaymentMethodOptions.fromJson(map['payment_method_options']),
paymentMethodTypes: map['payment_method_types'] == null
? null
: (map['payment_method_types'] as List<Object?>)
.map((el) => SessionPaymentMethodTypesItem.fromJson(el))
.toList(),
phoneNumberCollection: map['phone_number_collection'] == null
? null
: PortalSubscriptionPause.fromJson(map['phone_number_collection']),
redirectOnCompletion: map['redirect_on_completion'] == null
? null
: CheckoutSessionRedirectOnCompletion.fromJson(
map['redirect_on_completion']),
returnUrl:
map['return_url'] == null ? null : (map['return_url'] as String),
setupIntentData: map['setup_intent_data'] == null
? null
: SessionSetupIntentData.fromJson(map['setup_intent_data']),
shippingAddressCollection: map['shipping_address_collection'] == null
? null
: PaymentPagesCheckoutSessionShippingAddressCollection.fromJson(
map['shipping_address_collection']),
shippingOptions: map['shipping_options'] == null
? null
: (map['shipping_options'] as List<Object?>)
.map((el) => SessionShippingOptionsItem.fromJson(el))
.toList(),
submitType: map['submit_type'] == null
? null
: PaymentLinkSubmitType.fromJson(map['submit_type']),
subscriptionData: map['subscription_data'] == null
? null
: SessionSubscriptionData.fromJson(map['subscription_data']),
successUrl:
map['success_url'] == null ? null : (map['success_url'] as String),
taxIdCollection: map['tax_id_collection'] == null
? null
: PortalSubscriptionPause.fromJson(map['tax_id_collection']),
uiMode: map['ui_mode'] == null
? null
: SessionUiMode.fromJson(map['ui_mode']),
);
}