encode<V> static method
Implementation
static V encode<V>(
CheckoutSessionCreateOptions instance,
Encoder<V> encoder,
) {
final container = encoder.container<String>();
if (instance.afterExpiration != null) {
SessionAfterExpiration.encode(
instance.afterExpiration!,
container.nestedSingleValueContainer('after_expiration').encoder,
);
}
if (instance.allowPromotionCodes != null) {
container.encodeBool(
'allow_promotion_codes',
instance.allowPromotionCodes!,
);
}
if (instance.automaticTax != null) {
SessionAutomaticTax.encode(
instance.automaticTax!,
container.nestedSingleValueContainer('automatic_tax').encoder,
);
}
if (instance.billingAddressCollection != null) {
PaymentLinkBillingAddressCollection.encode(
instance.billingAddressCollection!,
container
.nestedSingleValueContainer('billing_address_collection')
.encoder,
);
}
if (instance.cancelUrl != null) {
container.encodeString(
'cancel_url',
instance.cancelUrl!,
);
}
if (instance.clientReferenceId != null) {
container.encodeString(
'client_reference_id',
instance.clientReferenceId!,
);
}
if (instance.consentCollection != null) {
SessionConsentCollection.encode(
instance.consentCollection!,
container.nestedSingleValueContainer('consent_collection').encoder,
);
}
if (instance.currency != null) {
container.encodeString(
'currency',
instance.currency!,
);
}
if (instance.customFields != null) {
container.encodeList(
'custom_fields',
(container) => instance.customFields!
.forEach((el) => SessionCustomFieldsItem.encode(
el,
container.nestedSingleValueContainer().encoder,
)),
);
}
if (instance.customText != null) {
SessionCustomText.encode(
instance.customText!,
container.nestedSingleValueContainer('custom_text').encoder,
);
}
if (instance.customer != null) {
container.encodeString(
'customer',
instance.customer!,
);
}
if (instance.customerCreation != null) {
PaymentLinkCustomerCreation.encode(
instance.customerCreation!,
container.nestedSingleValueContainer('customer_creation').encoder,
);
}
if (instance.customerEmail != null) {
container.encodeString(
'customer_email',
instance.customerEmail!,
);
}
if (instance.customerUpdate != null) {
SessionCustomerUpdate.encode(
instance.customerUpdate!,
container.nestedSingleValueContainer('customer_update').encoder,
);
}
if (instance.discounts != null) {
container.encodeList(
'discounts',
(container) =>
instance.discounts!.forEach((el) => SessionDiscountsItem.encode(
el,
container.nestedSingleValueContainer().encoder,
)),
);
}
if (instance.expand != null) {
container.encodeList(
'expand',
(container) =>
instance.expand!.forEach((el) => container.encodeString(el)),
);
}
if (instance.expiresAt != null) {
container.encodeDateTime(
'expires_at',
instance.expiresAt!,
);
}
if (instance.invoiceCreation != null) {
SessionInvoiceCreation.encode(
instance.invoiceCreation!,
container.nestedSingleValueContainer('invoice_creation').encoder,
);
}
if (instance.lineItems != null) {
container.encodeList(
'line_items',
(container) =>
instance.lineItems!.forEach((el) => SessionLineItemsItem.encode(
el,
container.nestedSingleValueContainer().encoder,
)),
);
}
if (instance.locale != null) {
container.encodeString(
'locale',
instance.locale!,
);
}
if (instance.metadata != null) {
container.encodeMap(
'metadata',
(container) => instance.metadata!.forEach((
key,
value,
) =>
container.encodeString(
key,
value,
)),
);
}
if (instance.mode != null) {
CheckoutSessionMode.encode(
instance.mode!,
container.nestedSingleValueContainer('mode').encoder,
);
}
if (instance.paymentIntentData != null) {
SessionPaymentIntentData.encode(
instance.paymentIntentData!,
container.nestedSingleValueContainer('payment_intent_data').encoder,
);
}
if (instance.paymentMethodCollection != null) {
PaymentLinkCustomerCreation.encode(
instance.paymentMethodCollection!,
container
.nestedSingleValueContainer('payment_method_collection')
.encoder,
);
}
if (instance.paymentMethodConfiguration != null) {
container.encodeString(
'payment_method_configuration',
instance.paymentMethodConfiguration!,
);
}
if (instance.paymentMethodOptions != null) {
SessionPaymentMethodOptions.encode(
instance.paymentMethodOptions!,
container.nestedSingleValueContainer('payment_method_options').encoder,
);
}
if (instance.paymentMethodTypes != null) {
container.encodeList(
'payment_method_types',
(container) => instance.paymentMethodTypes!
.forEach((el) => container.encodeString(el)),
);
}
if (instance.phoneNumberCollection != null) {
PortalSubscriptionPause.encode(
instance.phoneNumberCollection!,
container.nestedSingleValueContainer('phone_number_collection').encoder,
);
}
if (instance.redirectOnCompletion != null) {
CheckoutSessionRedirectOnCompletion.encode(
instance.redirectOnCompletion!,
container.nestedSingleValueContainer('redirect_on_completion').encoder,
);
}
if (instance.returnUrl != null) {
container.encodeString(
'return_url',
instance.returnUrl!,
);
}
if (instance.setupIntentData != null) {
SessionSetupIntentData.encode(
instance.setupIntentData!,
container.nestedSingleValueContainer('setup_intent_data').encoder,
);
}
if (instance.shippingAddressCollection != null) {
PaymentPagesCheckoutSessionShippingAddressCollection.encode(
instance.shippingAddressCollection!,
container
.nestedSingleValueContainer('shipping_address_collection')
.encoder,
);
}
if (instance.shippingOptions != null) {
container.encodeList(
'shipping_options',
(container) => instance.shippingOptions!
.forEach((el) => SessionShippingOptionsItem.encode(
el,
container.nestedSingleValueContainer().encoder,
)),
);
}
if (instance.submitType != null) {
PaymentLinkSubmitType.encode(
instance.submitType!,
container.nestedSingleValueContainer('submit_type').encoder,
);
}
if (instance.subscriptionData != null) {
SessionSubscriptionData.encode(
instance.subscriptionData!,
container.nestedSingleValueContainer('subscription_data').encoder,
);
}
if (instance.successUrl != null) {
container.encodeString(
'success_url',
instance.successUrl!,
);
}
if (instance.taxIdCollection != null) {
PortalSubscriptionPause.encode(
instance.taxIdCollection!,
container.nestedSingleValueContainer('tax_id_collection').encoder,
);
}
if (instance.uiMode != null) {
container.encodeString(
'ui_mode',
instance.uiMode!,
);
}
return container.value;
}