Initial commit
This commit is contained in:
@@ -0,0 +1,14 @@
|
||||
import 'currency.dart';
|
||||
|
||||
class Amount {
|
||||
double value;
|
||||
Currency currency;
|
||||
|
||||
Amount({required this.value, required this.currency});
|
||||
|
||||
Map<String, dynamic> toJson() =>
|
||||
{
|
||||
'value': value,
|
||||
'currency': currency.value
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
class Currency {
|
||||
final String value;
|
||||
const Currency(this.value);
|
||||
|
||||
static const Currency rub = Currency('RUB');
|
||||
static const Currency usd = Currency('USD');
|
||||
static const Currency eur = Currency('EUR');
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
|
||||
class CustomizationSettings {
|
||||
final Color mainScheme;
|
||||
final bool showYooKassaLogo;
|
||||
|
||||
const CustomizationSettings([this.mainScheme = const Color.fromARGB(255, 0, 112, 240), this.showYooKassaLogo = true]);
|
||||
|
||||
Map<String, dynamic> toJson() =>
|
||||
{
|
||||
'mainScheme' : {
|
||||
'red': mainScheme.red,
|
||||
'blue': mainScheme.blue,
|
||||
'green': mainScheme.green,
|
||||
'alpha': mainScheme.alpha
|
||||
},
|
||||
'showYooKassaLogo': showYooKassaLogo
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
class GooglePayParameters {
|
||||
final List<GooglePayCardNetwork> paymentSystems;
|
||||
const GooglePayParameters([this.paymentSystems = const [GooglePayCardNetwork.mastercard, GooglePayCardNetwork.visa]]);
|
||||
|
||||
List<String> jsonList() {
|
||||
return paymentSystems.map((e) => e.toString()).toList();
|
||||
}
|
||||
}
|
||||
|
||||
enum GooglePayCardNetwork {
|
||||
amex,
|
||||
discover,
|
||||
jcb,
|
||||
mastercard,
|
||||
visa,
|
||||
interac,
|
||||
other
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
class HostParameters {
|
||||
|
||||
String host;
|
||||
String paymentAuthorizationHost;
|
||||
String authHost;
|
||||
String configHost;
|
||||
|
||||
HostParameters(
|
||||
this.host,
|
||||
this.paymentAuthorizationHost,
|
||||
this.authHost,
|
||||
this.configHost,
|
||||
);
|
||||
|
||||
Map<String, dynamic> toJson() =>
|
||||
{
|
||||
'apiHost': host,
|
||||
'paymentAuthApiHost': paymentAuthorizationHost,
|
||||
'authApiHost': authHost,
|
||||
'configHost': configHost
|
||||
};
|
||||
|
||||
factory HostParameters.fromJson(Map<String, dynamic> json) {
|
||||
return HostParameters(
|
||||
json['apiHost'] as String,
|
||||
json['paymentAuthApiHost'] as String,
|
||||
json['authApiHost'] as String,
|
||||
json['configHost'] as String,
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
enum SavePaymentMethod {
|
||||
off,
|
||||
on,
|
||||
userSelects
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
class PaymentMethodTypes {
|
||||
final List<PaymentMethod> paymentMethodTypes;
|
||||
const PaymentMethodTypes(this.paymentMethodTypes);
|
||||
|
||||
List<String> jsonList() {
|
||||
return paymentMethodTypes.map((e) => e.toString()).toList();
|
||||
}
|
||||
|
||||
static const PaymentMethodTypes bankCard = PaymentMethodTypes([PaymentMethod.bankCard]);
|
||||
static const PaymentMethodTypes yooMoney = PaymentMethodTypes([PaymentMethod.yooMoney]);
|
||||
static const PaymentMethodTypes sberbank = PaymentMethodTypes([PaymentMethod.sberbank]);
|
||||
static const PaymentMethodTypes applePay = PaymentMethodTypes([PaymentMethod.applePay]);
|
||||
static const PaymentMethodTypes googlePay = PaymentMethodTypes([PaymentMethod.googlePay]);
|
||||
static const PaymentMethodTypes all = PaymentMethodTypes([
|
||||
PaymentMethod.bankCard,
|
||||
PaymentMethod.yooMoney,
|
||||
PaymentMethod.sberbank,
|
||||
PaymentMethod.applePay,
|
||||
PaymentMethod.googlePay
|
||||
]);
|
||||
}
|
||||
|
||||
enum PaymentMethod {
|
||||
bankCard,
|
||||
yooMoney,
|
||||
applePay,
|
||||
googlePay,
|
||||
sberbank
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
import 'amount.dart';
|
||||
|
||||
class TestModeSettings {
|
||||
bool paymentAuthorizationPassed;
|
||||
int cardsCount;
|
||||
Amount charge;
|
||||
bool enablePaymentError;
|
||||
|
||||
TestModeSettings(this.paymentAuthorizationPassed, this.cardsCount, this.charge, this.enablePaymentError);
|
||||
|
||||
Map<String, dynamic> toJson() =>
|
||||
{
|
||||
'paymentAuthorizationPassed': paymentAuthorizationPassed,
|
||||
'cardsCount': cardsCount,
|
||||
'charge': charge.toJson(),
|
||||
'enablePaymentError': enablePaymentError
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
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);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
import 'payment_method_types.dart';
|
||||
|
||||
class TokenizationSettings {
|
||||
final PaymentMethodTypes paymentMethodTypes;
|
||||
|
||||
const TokenizationSettings([this.paymentMethodTypes = PaymentMethodTypes.all]);
|
||||
|
||||
Map<String, dynamic> toJson() =>
|
||||
{
|
||||
'paymentMethodTypes': paymentMethodTypes.jsonList(),
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user