LokotroPaymentResponse.fromJson constructor
LokotroPaymentResponse.fromJson(
- Map<String, dynamic> json
)
Implementation
factory LokotroPaymentResponse.fromJson(Map<String, dynamic> json) {
// Handle both nested 'data' response format and flat response format
final data = json['data'] as Map<String, dynamic>? ?? json;
return LokotroPaymentResponse(
success: json['status_code'] == 200 || data['success'] == true,
transactionId: data['transaction_id'] as String? ?? json['payment_id'] as String? ?? '',
status: data['status'] as String? ?? 'unknown',
amount: (data['amount'] as num?)?.toDouble() ?? 0.0,
currency: data['currency'] as String? ?? json['currency_str'] as String? ?? data['currency_str'] as String? ?? 'USD',
createdAt: data['created_at'] as String?,
message: json['message'] as String? ?? data['message'] as String? ?? '',
);
}