TokenizationResult.fromJson constructor
TokenizationResult.fromJson(
- Map<String, dynamic> json
)
Implementation
factory TokenizationResult.fromJson(Map<String, dynamic> json) {
final status = json['status'];
switch (status) {
case 'success':
{
final token = json['paymentToken'];
PaymentMethod? paymentMethodType =
_paymentMethodFromString(json['paymentMethodType']);
return TokenizationResult.success(token, paymentMethodType);
}
case 'canceled':
return TokenizationResult.canceled();
default:
return TokenizationResult.error(json['error'] ?? 'Unknown error');
}
}