2025-11-16 11:25:27 +00:00
|
|
|
import 'package:json_annotation/json_annotation.dart';
|
|
|
|
|
import 'package:copy_with_extension/copy_with_extension.dart';
|
|
|
|
|
import 'package:mnemo_cards_common/mnemo_cards_common.dart';
|
|
|
|
|
|
|
|
|
|
import 'product_model.dart';
|
|
|
|
|
|
|
|
|
|
part 'payment.g.dart';
|
|
|
|
|
|
|
|
|
|
@CopyWith()
|
|
|
|
|
class PaymentModel {
|
2025-12-13 20:55:50 +00:00
|
|
|
String? id;
|
2025-11-16 11:25:27 +00:00
|
|
|
final String amount;
|
|
|
|
|
final String currency;
|
|
|
|
|
@JsonKey(unknownEnumValue: PaymentStatus.unknown)
|
|
|
|
|
final PaymentStatus status;
|
|
|
|
|
@JsonKey(unknownEnumValue: PaymentSystem.unknown)
|
|
|
|
|
final PaymentSystem paymentSystem;
|
|
|
|
|
final String? externalToken;
|
|
|
|
|
final String? meta;
|
|
|
|
|
final DateTime date;
|
|
|
|
|
|
2025-12-13 20:55:50 +00:00
|
|
|
final String userId;
|
2025-11-16 11:25:27 +00:00
|
|
|
final List<MnemoCardsProductModelBase> products;
|
|
|
|
|
|
|
|
|
|
PaymentModel({
|
|
|
|
|
required this.amount,
|
|
|
|
|
required this.currency,
|
|
|
|
|
required this.status,
|
|
|
|
|
required this.paymentSystem,
|
|
|
|
|
required this.userId,
|
|
|
|
|
required this.date,
|
|
|
|
|
required this.products,
|
|
|
|
|
this.externalToken,
|
|
|
|
|
this.meta,
|
|
|
|
|
this.id,
|
|
|
|
|
});
|
|
|
|
|
|
2025-12-13 20:55:50 +00:00
|
|
|
// Model to reserve id for future payment
|
2025-11-16 11:25:27 +00:00
|
|
|
factory PaymentModel.empty({
|
2025-12-13 20:55:50 +00:00
|
|
|
required String userId,
|
2025-11-16 11:25:27 +00:00
|
|
|
required DateTime date,
|
|
|
|
|
}) =>
|
|
|
|
|
PaymentModel(
|
|
|
|
|
amount: '',
|
|
|
|
|
currency: '',
|
|
|
|
|
status: PaymentStatus.created,
|
|
|
|
|
paymentSystem: PaymentSystem.unknown,
|
|
|
|
|
products: [],
|
|
|
|
|
userId: userId,
|
|
|
|
|
date: date,
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
factory PaymentModel.promocode({
|
2025-12-13 20:55:50 +00:00
|
|
|
required String userId,
|
2025-11-16 11:25:27 +00:00
|
|
|
required DateTime date,
|
|
|
|
|
required List<MnemoCardsProductModel> products,
|
|
|
|
|
}) =>
|
|
|
|
|
PaymentModel(
|
|
|
|
|
amount: '0',
|
|
|
|
|
currency: 'PROMO',
|
|
|
|
|
status: PaymentStatus.succeeded,
|
|
|
|
|
paymentSystem: PaymentSystem.promoCode,
|
|
|
|
|
userId: userId,
|
|
|
|
|
date: DateTime.now(),
|
|
|
|
|
products: products.toBaseList(),
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
factory PaymentModel.adView({
|
2025-12-13 20:55:50 +00:00
|
|
|
required String userId,
|
2025-11-16 11:25:27 +00:00
|
|
|
required DateTime date,
|
|
|
|
|
required List<MnemoCardsProductModel> products,
|
|
|
|
|
}) =>
|
|
|
|
|
PaymentModel(
|
|
|
|
|
amount: '0',
|
|
|
|
|
currency: 'AD_PROMO',
|
|
|
|
|
status: PaymentStatus.succeeded,
|
|
|
|
|
paymentSystem: PaymentSystem.adView,
|
|
|
|
|
userId: userId,
|
|
|
|
|
date: DateTime.now(),
|
|
|
|
|
products: products.toBaseList(),
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
PaymentModel.yooKassa({
|
|
|
|
|
required this.amount,
|
|
|
|
|
required this.currency,
|
|
|
|
|
required this.userId,
|
|
|
|
|
required this.externalToken,
|
|
|
|
|
required this.date,
|
|
|
|
|
required this.products,
|
|
|
|
|
this.meta,
|
|
|
|
|
this.id,
|
|
|
|
|
}) : paymentSystem = PaymentSystem.yookassa,
|
|
|
|
|
status = PaymentStatus.created;
|
|
|
|
|
|
|
|
|
|
PaymentModel.google({
|
|
|
|
|
required this.amount,
|
|
|
|
|
required this.currency,
|
|
|
|
|
required this.userId,
|
|
|
|
|
required this.externalToken,
|
|
|
|
|
required this.date,
|
|
|
|
|
required this.products,
|
|
|
|
|
this.meta,
|
|
|
|
|
this.id,
|
|
|
|
|
this.status = PaymentStatus.created,
|
|
|
|
|
}) : paymentSystem = PaymentSystem.google;
|
|
|
|
|
|
|
|
|
|
PaymentModel.rustore({
|
|
|
|
|
required this.amount,
|
|
|
|
|
required this.currency,
|
|
|
|
|
required this.userId,
|
|
|
|
|
required this.externalToken,
|
|
|
|
|
required this.date,
|
|
|
|
|
required this.products,
|
|
|
|
|
this.meta,
|
|
|
|
|
this.id,
|
|
|
|
|
this.status = PaymentStatus.created,
|
|
|
|
|
}) : paymentSystem = PaymentSystem.rustore;
|
|
|
|
|
|
|
|
|
|
}
|