encode<V> static method
V
encode<
V>( - PaymentIntent instance,
- Encoder<V> encoder
)
override
Implementation
static V encode<V>(
PaymentIntent instance,
Encoder<V> encoder,
) {
final container = encoder.container<String>();
container.encodeInt(
'amount',
instance.amount,
);
container.encodeInt(
'amount_capturable',
instance.amountCapturable,
);
if (instance.amountDetails != null) {
PaymentFlowsAmountDetails.encode(
instance.amountDetails!,
container.nestedSingleValueContainer('amount_details').encoder,
);
}
container.encodeInt(
'amount_received',
instance.amountReceived,
);
if (instance.application != null) {
ApplicationOrId.encode(
instance.application!,
container.nestedSingleValueContainer('application').encoder,
);
}
if (instance.applicationFeeAmount != null) {
container.encodeInt(
'application_fee_amount',
instance.applicationFeeAmount!,
);
}
if (instance.automaticPaymentMethods != null) {
PaymentFlowsAutomaticPaymentMethodsPaymentIntent.encode(
instance.automaticPaymentMethods!,
container
.nestedSingleValueContainer('automatic_payment_methods')
.encoder,
);
}
if (instance.canceledAt != null) {
container.encodeDateTime(
'canceled_at',
instance.canceledAt!,
);
}
if (instance.cancellationReason != null) {
container.encodeString(
'cancellation_reason',
instance.cancellationReason!,
);
}
container.encodeString(
'capture_method',
instance.captureMethod,
);
if (instance.clientSecret != null) {
container.encodeString(
'client_secret',
instance.clientSecret!,
);
}
CustomerBalanceCustomerBalanceSettingsReconciliationMode.encode(
instance.confirmationMethod,
container.nestedSingleValueContainer('confirmation_method').encoder,
);
container.encodeDateTime(
'created',
instance.created,
);
container.encodeString(
'currency',
instance.currency,
);
if (instance.customer != null) {
BankAccountCustomerOrId.encode(
instance.customer!,
container.nestedSingleValueContainer('customer').encoder,
);
}
if (instance.description != null) {
container.encodeString(
'description',
instance.description!,
);
}
container.encodeString(
'id',
instance.id,
);
if (instance.invoice != null) {
InvoiceOrId.encode(
instance.invoice!,
container.nestedSingleValueContainer('invoice').encoder,
);
}
if (instance.lastPaymentError != null) {
ApiErrors.encode(
instance.lastPaymentError!,
container.nestedSingleValueContainer('last_payment_error').encoder,
);
}
if (instance.latestCharge != null) {
ChargeOrId.encode(
instance.latestCharge!,
container.nestedSingleValueContainer('latest_charge').encoder,
);
}
container.encodeBool(
'livemode',
instance.livemode,
);
container.encodeMap(
'metadata',
(container) => instance.metadata.forEach((
key,
value,
) =>
container.encodeString(
key,
value,
)),
);
if (instance.nextAction != null) {
PaymentIntentNextAction.encode(
instance.nextAction!,
container.nestedSingleValueContainer('next_action').encoder,
);
}
container.encodeString(
'object',
'payment_intent',
);
if (instance.onBehalfOf != null) {
AccountOrId.encode(
instance.onBehalfOf!,
container.nestedSingleValueContainer('on_behalf_of').encoder,
);
}
if (instance.paymentMethod != null) {
PaymentMethodOrId.encode(
instance.paymentMethod!,
container.nestedSingleValueContainer('payment_method').encoder,
);
}
if (instance.paymentMethodConfigurationDetails != null) {
CheckoutSessionPaymentMethodConfigurationDetails.encode(
instance.paymentMethodConfigurationDetails!,
container
.nestedSingleValueContainer('payment_method_configuration_details')
.encoder,
);
}
if (instance.paymentMethodOptions != null) {
PaymentIntentPaymentMethodOptions.encode(
instance.paymentMethodOptions!,
container.nestedSingleValueContainer('payment_method_options').encoder,
);
}
container.encodeList(
'payment_method_types',
(container) => instance.paymentMethodTypes
.forEach((el) => container.encodeString(el)),
);
if (instance.processing != null) {
PaymentIntentProcessing.encode(
instance.processing!,
container.nestedSingleValueContainer('processing').encoder,
);
}
if (instance.receiptEmail != null) {
container.encodeString(
'receipt_email',
instance.receiptEmail!,
);
}
if (instance.review != null) {
ReviewOrId.encode(
instance.review!,
container.nestedSingleValueContainer('review').encoder,
);
}
if (instance.setupFutureUsage != null) {
ConfirmationTokenSetupFutureUsage.encode(
instance.setupFutureUsage!,
container.nestedSingleValueContainer('setup_future_usage').encoder,
);
}
if (instance.shipping != null) {
ChargeShipping.encode(
instance.shipping!,
container.nestedSingleValueContainer('shipping').encoder,
);
}
if (instance.source != null) {
PaymentIntentSourceOrId.encode(
instance.source!,
container.nestedSingleValueContainer('source').encoder,
);
}
if (instance.statementDescriptor != null) {
container.encodeString(
'statement_descriptor',
instance.statementDescriptor!,
);
}
if (instance.statementDescriptorSuffix != null) {
container.encodeString(
'statement_descriptor_suffix',
instance.statementDescriptorSuffix!,
);
}
container.encodeString(
'status',
instance.status,
);
if (instance.transferData != null) {
PaymentIntentTransferData.encode(
instance.transferData!,
container.nestedSingleValueContainer('transfer_data').encoder,
);
}
if (instance.transferGroup != null) {
container.encodeString(
'transfer_group',
instance.transferGroup!,
);
}
return container.value;
}