encode<V> static method
V
encode<
V>( - PaymentLink instance,
- Encoder<V> encoder
)
override
Implementation
static V encode<V>(
PaymentLink instance,
Encoder<V> encoder,
) {
final container = encoder.container<String>();
container.encodeBool(
'active',
instance.active,
);
PaymentLinksResourceAfterCompletion.encode(
instance.afterCompletion,
container.nestedSingleValueContainer('after_completion').encoder,
);
container.encodeBool(
'allow_promotion_codes',
instance.allowPromotionCodes,
);
if (instance.application != null) {
BillingPortalConfigurationApplicationOrId.encode(
instance.application!,
container.nestedSingleValueContainer('application').encoder,
);
}
if (instance.applicationFeeAmount != null) {
container.encodeInt(
'application_fee_amount',
instance.applicationFeeAmount!,
);
}
if (instance.applicationFeePercent != null) {
container.encodeDouble(
'application_fee_percent',
instance.applicationFeePercent!,
);
}
PaymentLinksResourceAutomaticTax.encode(
instance.automaticTax,
container.nestedSingleValueContainer('automatic_tax').encoder,
);
container.encodeString(
'billing_address_collection',
instance.billingAddressCollection,
);
if (instance.consentCollection != null) {
CheckoutSessionConsentCollection.encode(
instance.consentCollection!,
container.nestedSingleValueContainer('consent_collection').encoder,
);
}
container.encodeString(
'currency',
instance.currency,
);
container.encodeList(
'custom_fields',
(container) => instance.customFields
.forEach((el) => PaymentLinksResourceCustomFields.encode(
el,
container.nestedSingleValueContainer().encoder,
)),
);
PaymentLinksResourceCustomText.encode(
instance.customText,
container.nestedSingleValueContainer('custom_text').encoder,
);
container.encodeString(
'customer_creation',
instance.customerCreation,
);
container.encodeString(
'id',
instance.id,
);
if (instance.inactiveMessage != null) {
container.encodeString(
'inactive_message',
instance.inactiveMessage!,
);
}
if (instance.invoiceCreation != null) {
PaymentLinkInvoiceCreation.encode(
instance.invoiceCreation!,
container.nestedSingleValueContainer('invoice_creation').encoder,
);
}
if (instance.lineItems != null) {
CheckoutSessionLineItems.encode(
instance.lineItems!,
container.nestedSingleValueContainer('line_items').encoder,
);
}
container.encodeBool(
'livemode',
instance.livemode,
);
container.encodeMap(
'metadata',
(container) => instance.metadata.forEach((
key,
value,
) =>
container.encodeString(
key,
value,
)),
);
container.encodeString(
'object',
'payment_link',
);
if (instance.onBehalfOf != null) {
AccountOrId.encode(
instance.onBehalfOf!,
container.nestedSingleValueContainer('on_behalf_of').encoder,
);
}
if (instance.paymentIntentData != null) {
PaymentLinkPaymentIntentData.encode(
instance.paymentIntentData!,
container.nestedSingleValueContainer('payment_intent_data').encoder,
);
}
PaymentLinkCustomerCreation.encode(
instance.paymentMethodCollection,
container.nestedSingleValueContainer('payment_method_collection').encoder,
);
if (instance.paymentMethodTypes != null) {
container.encodeList(
'payment_method_types',
(container) => instance.paymentMethodTypes!
.forEach((el) => container.encodeString(el)),
);
}
PaymentLinksResourcePhoneNumberCollection.encode(
instance.phoneNumberCollection,
container.nestedSingleValueContainer('phone_number_collection').encoder,
);
if (instance.restrictions != null) {
PaymentLinkRestrictions.encode(
instance.restrictions!,
container.nestedSingleValueContainer('restrictions').encoder,
);
}
if (instance.shippingAddressCollection != null) {
CheckoutSessionShippingAddressCollection.encode(
instance.shippingAddressCollection!,
container
.nestedSingleValueContainer('shipping_address_collection')
.encoder,
);
}
container.encodeList(
'shipping_options',
(container) => instance.shippingOptions
.forEach((el) => PaymentLinksResourceShippingOption.encode(
el,
container.nestedSingleValueContainer().encoder,
)),
);
container.encodeString(
'submit_type',
instance.submitType,
);
if (instance.subscriptionData != null) {
PaymentLinkSubscriptionData.encode(
instance.subscriptionData!,
container.nestedSingleValueContainer('subscription_data').encoder,
);
}
PaymentLinksResourceTaxIdCollection.encode(
instance.taxIdCollection,
container.nestedSingleValueContainer('tax_id_collection').encoder,
);
if (instance.transferData != null) {
InvoiceTransferData.encode(
instance.transferData!,
container.nestedSingleValueContainer('transfer_data').encoder,
);
}
container.encodeString(
'url',
instance.url,
);
return container.value;
}