PaymentIntentAttachResponseAttributes.fromMap constructor

PaymentIntentAttachResponseAttributes.fromMap(
  1. Map<String, dynamic> map
)

Response from payment intent attach

Implementation

factory PaymentIntentAttachResponseAttributes.fromMap(
  Map<String, dynamic> map,
) {
  return PaymentIntentAttachResponseAttributes(
    amount: map['amount'],
    currency: map['currency'] ?? '',
    description: map['description'] ?? '',
    statementDescriptor: map['statement_descriptor'] ?? '',
    status: map['status'] ?? '',
    livemode: map['livemode'] ?? false,
    clientKey: map['client_key'] ?? '',
    createdAt: fromTimeStamp(map['created_at']) ?? DateTime.now(),
    updatedAt: fromTimeStamp(map['updated_at']) ?? DateTime.now(),
    lastPaymentError: map['last_payment_error'] ?? '',
    paymentMethodAllowed:
        List<String>.from(map['payment_method_allowed'] ?? const []),
    payments: List<Map<String, dynamic>>.from(
      map['payments'] ?? [],
    ).map(CreatePaymentResponse.fromMap).toList(),
    nextAction: map['next_action'] != null
        ? PaymentIntentNextAction.fromMap(map['next_action'])
        : null,
    paymentMethodOptions: map['payment_method_options'] != null
        ? PaymentMethodOptions.fromMap(map['payment_method_options'])
        : const PaymentMethodOptions(),
    metadata: Map<String, dynamic>.from(map['metadata'] ?? const {}),
  );
}