PaymentLink.fromJson constructor

PaymentLink.fromJson(
  1. Object? json
)

Implementation

factory PaymentLink.fromJson(Object? json) {
  final map = (json as Map).cast<String, Object?>();
  return PaymentLink(
    active: (map['active'] as bool),
    afterCompletion:
        PaymentLinksResourceAfterCompletion.fromJson(map['after_completion']),
    allowPromotionCodes: (map['allow_promotion_codes'] as bool),
    application: map['application'] == null
        ? null
        : BillingPortalConfigurationApplicationOrId.fromJson(
            map['application']),
    applicationFeeAmount: map['application_fee_amount'] == null
        ? null
        : (map['application_fee_amount'] as num).toInt(),
    applicationFeePercent: map['application_fee_percent'] == null
        ? null
        : (map['application_fee_percent'] as num).toDouble(),
    automaticTax:
        PaymentLinksResourceAutomaticTax.fromJson(map['automatic_tax']),
    billingAddressCollection: PaymentLinkBillingAddressCollection.fromJson(
        map['billing_address_collection']),
    consentCollection: map['consent_collection'] == null
        ? null
        : CheckoutSessionConsentCollection.fromJson(
            map['consent_collection']),
    currency: (map['currency'] as String),
    customFields: (map['custom_fields'] as List<Object?>)
        .map((el) => PaymentLinksResourceCustomFields.fromJson(el))
        .toList(),
    customText: PaymentLinksResourceCustomText.fromJson(map['custom_text']),
    customerCreation:
        PaymentLinkCustomerCreation.fromJson(map['customer_creation']),
    id: (map['id'] as String),
    inactiveMessage: map['inactive_message'] == null
        ? null
        : (map['inactive_message'] as String),
    invoiceCreation: map['invoice_creation'] == null
        ? null
        : PaymentLinkInvoiceCreation.fromJson(map['invoice_creation']),
    lineItems: map['line_items'] == null
        ? null
        : CheckoutSessionLineItems.fromJson(map['line_items']),
    livemode: (map['livemode'] as bool),
    metadata: (map['metadata'] as Map).cast<String, Object?>().map((
          key,
          value,
        ) =>
            MapEntry(
              key,
              (value as String),
            )),
    onBehalfOf: map['on_behalf_of'] == null
        ? null
        : AccountOrId.fromJson(map['on_behalf_of']),
    paymentIntentData: map['payment_intent_data'] == null
        ? null
        : PaymentLinkPaymentIntentData.fromJson(map['payment_intent_data']),
    paymentMethodCollection: PaymentLinkCustomerCreation.fromJson(
        map['payment_method_collection']),
    paymentMethodTypes: map['payment_method_types'] == null
        ? null
        : (map['payment_method_types'] as List<Object?>)
            .map((el) => PaymentLinkPaymentMethodTypesItem.fromJson(el))
            .toList(),
    phoneNumberCollection: PaymentLinksResourcePhoneNumberCollection.fromJson(
        map['phone_number_collection']),
    restrictions: map['restrictions'] == null
        ? null
        : PaymentLinkRestrictions.fromJson(map['restrictions']),
    shippingAddressCollection: map['shipping_address_collection'] == null
        ? null
        : CheckoutSessionShippingAddressCollection.fromJson(
            map['shipping_address_collection']),
    shippingOptions: (map['shipping_options'] as List<Object?>)
        .map((el) => PaymentLinksResourceShippingOption.fromJson(el))
        .toList(),
    submitType: PaymentLinkSubmitType.fromJson(map['submit_type']),
    subscriptionData: map['subscription_data'] == null
        ? null
        : PaymentLinkSubscriptionData.fromJson(map['subscription_data']),
    taxIdCollection: PaymentLinksResourceTaxIdCollection.fromJson(
        map['tax_id_collection']),
    transferData: map['transfer_data'] == null
        ? null
        : InvoiceTransferData.fromJson(map['transfer_data']),
    url: (map['url'] as String),
  );
}