yoomoney_flutter/lib/models/tokenization_result.dart

35 lines
955 B
Dart
Raw Normal View History

2022-07-03 20:52:22 +03:00
import 'package:yookassa_payments_flutter/models/payment_method_types.dart';
class TokenizationResult {
String token;
PaymentMethod? paymentMethodType;
TokenizationResult(this.token, this.paymentMethodType);
factory TokenizationResult.fromJson(Map<String, dynamic> json) {
var token = json['paymentToken'];
PaymentMethod? paymentMethodType;
switch(json['paymentMethodType']){
case "sberbank":
paymentMethodType = PaymentMethod.sberbank;
break;
case "bank_card":
paymentMethodType = PaymentMethod.bankCard;
break;
case "yoo_money":
paymentMethodType = PaymentMethod.yooMoney;
break;
case "apple_pay":
paymentMethodType = PaymentMethod.applePay;
break;
case "google_pay":
paymentMethodType = PaymentMethod.googlePay;
break;
default:
break;
}
return TokenizationResult(token, paymentMethodType);
}
}