CheckoutSession.fromJson constructor
CheckoutSession.fromJson(
- Object? json
Implementation
factory CheckoutSession.fromJson(Object? json) {
final map = (json as Map).cast<String, Object?>();
return CheckoutSession(
afterExpiration: map['after_expiration'] == null
? null
: CheckoutSessionAfterExpiration.fromJson(map['after_expiration']),
allowPromotionCodes: map['allow_promotion_codes'] == null
? null
: (map['allow_promotion_codes'] as bool),
amountSubtotal: map['amount_subtotal'] == null
? null
: (map['amount_subtotal'] as num).toInt(),
amountTotal: map['amount_total'] == null
? null
: (map['amount_total'] as num).toInt(),
automaticTax: PaymentPagesCheckoutSessionAutomaticTax.fromJson(
map['automatic_tax']),
billingAddressCollection: map['billing_address_collection'] == null
? null
: CheckoutSessionBillingAddressCollection.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),
clientSecret: map['client_secret'] == null
? null
: (map['client_secret'] as String),
consent: map['consent'] == null
? null
: CheckoutSessionConsent.fromJson(map['consent']),
consentCollection: map['consent_collection'] == null
? null
: CheckoutSessionConsentCollection.fromJson(
map['consent_collection']),
created:
DateTime.fromMillisecondsSinceEpoch((map['created'] as int).toInt()),
currency: map['currency'] == null ? null : (map['currency'] as String),
currencyConversion: map['currency_conversion'] == null
? null
: CheckoutSessionCurrencyConversion.fromJson(
map['currency_conversion']),
customFields: (map['custom_fields'] as List<Object?>)
.map((el) => PaymentPagesCheckoutSessionCustomFields.fromJson(el))
.toList(),
customText:
PaymentPagesCheckoutSessionCustomText.fromJson(map['custom_text']),
customer: map['customer'] == null
? null
: BankAccountCustomerOrId.fromJson(map['customer']),
customerCreation: map['customer_creation'] == null
? null
: CheckoutSessionCustomerCreation.fromJson(map['customer_creation']),
customerDetails: map['customer_details'] == null
? null
: CheckoutSessionCustomerDetails.fromJson(map['customer_details']),
customerEmail: map['customer_email'] == null
? null
: (map['customer_email'] as String),
expiresAt: DateTime.fromMillisecondsSinceEpoch(
(map['expires_at'] as int).toInt()),
id: (map['id'] as String),
invoice:
map['invoice'] == null ? null : InvoiceOrId.fromJson(map['invoice']),
invoiceCreation: map['invoice_creation'] == null
? null
: CheckoutSessionInvoiceCreation.fromJson(map['invoice_creation']),
lineItems: map['line_items'] == null
? null
: CheckoutSessionLineItems.fromJson(map['line_items']),
livemode: (map['livemode'] as bool),
locale: map['locale'] == null
? null
: CheckoutSessionLocale.fromJson(map['locale']),
metadata: map['metadata'] == null
? null
: (map['metadata'] as Map).cast<String, Object?>().map((
key,
value,
) =>
MapEntry(
key,
(value as String),
)),
mode: CheckoutSessionMode.fromJson(map['mode']),
paymentIntent: map['payment_intent'] == null
? null
: PaymentIntentOrId.fromJson(map['payment_intent']),
paymentLink: map['payment_link'] == null
? null
: PaymentLinkOrId.fromJson(map['payment_link']),
paymentMethodCollection: map['payment_method_collection'] == null
? null
: CheckoutSessionCustomerCreation.fromJson(
map['payment_method_collection']),
paymentMethodConfigurationDetails:
map['payment_method_configuration_details'] == null
? null
: CheckoutSessionPaymentMethodConfigurationDetails.fromJson(
map['payment_method_configuration_details']),
paymentMethodOptions: map['payment_method_options'] == null
? null
: CheckoutSessionPaymentMethodOptions.fromJson(
map['payment_method_options']),
paymentMethodTypes: (map['payment_method_types'] as List<Object?>)
.map((el) => (el as String))
.toList(),
paymentStatus:
CheckoutSessionPaymentStatus.fromJson(map['payment_status']),
phoneNumberCollection: map['phone_number_collection'] == null
? null
: PaymentPagesCheckoutSessionPhoneNumberCollection.fromJson(
map['phone_number_collection']),
recoveredFrom: map['recovered_from'] == null
? null
: (map['recovered_from'] as String),
redirectOnCompletion: map['redirect_on_completion'] == null
? null
: CheckoutSessionRedirectOnCompletion.fromJson(
map['redirect_on_completion']),
returnUrl:
map['return_url'] == null ? null : (map['return_url'] as String),
setupIntent: map['setup_intent'] == null
? null
: SetupIntentOrId.fromJson(map['setup_intent']),
shippingAddressCollection: map['shipping_address_collection'] == null
? null
: CheckoutSessionShippingAddressCollection.fromJson(
map['shipping_address_collection']),
shippingCost: map['shipping_cost'] == null
? null
: CheckoutSessionShippingCost.fromJson(map['shipping_cost']),
shippingDetails: map['shipping_details'] == null
? null
: ChargeShipping.fromJson(map['shipping_details']),
shippingOptions: (map['shipping_options'] as List<Object?>)
.map((el) => PaymentPagesCheckoutSessionShippingOption.fromJson(el))
.toList(),
status: map['status'] == null
? null
: CheckoutSessionStatus.fromJson(map['status']),
submitType: map['submit_type'] == null
? null
: CheckoutSessionSubmitType.fromJson(map['submit_type']),
subscription: map['subscription'] == null
? null
: SubscriptionOrId.fromJson(map['subscription']),
successUrl:
map['success_url'] == null ? null : (map['success_url'] as String),
taxIdCollection: map['tax_id_collection'] == null
? null
: PaymentPagesCheckoutSessionTaxIdCollection.fromJson(
map['tax_id_collection']),
totalDetails: map['total_details'] == null
? null
: CheckoutSessionTotalDetails.fromJson(map['total_details']),
uiMode: map['ui_mode'] == null
? null
: CheckoutSessionUiMode.fromJson(map['ui_mode']),
url: map['url'] == null ? null : (map['url'] as String),
);
}