LokotroPayOnResponse.fromJson constructor

LokotroPayOnResponse.fromJson(
  1. Map<String, dynamic> json
)

Factory constructor to create from raw API JSON response

Implementation

factory LokotroPayOnResponse.fromJson(Map<String, dynamic> json) {
  return LokotroPayOnResponse(
    message: json['message'] ?? '-',
    title: json['title'] ?? 'Payment',
    customRef: json['customer_reference'] ?? json['custom_ref'] ?? '-',
    amount: double.tryParse(json['amount']?.toString() ?? '0') ?? 0.0,
    apiResponseCode: parseApiResponseCode(json['api_response_code']),
    currency: json['currency'] ?? json['currency_str'] ?? '-',
    paymentStatus: parsePaymentStatus(json['status'] ?? json['payment_status']),
    systemRef: json['system_reference'] ?? json['system_ref'] ?? json['payment_id'] ?? '-',
    transactionId: json['transaction_id'] ?? json['payment_id'],
    identifier: json['identifier'],
    customerReference: json['customer_reference'],
    successRedirectUrl: json['success_redirect_url'],
    failRedirectUrl: json['fail_redirect_url'],
    timestamp: json['timestamp'] != null
        ? DateTime.tryParse(json['timestamp'])
        : DateTime.now(),
  );
}