fix
This commit is contained in:
@@ -2,7 +2,7 @@ import '../../domain/entities/payment_card.dart';
|
||||
|
||||
class PaymentCardResponseDto {
|
||||
final int id;
|
||||
final int clientId;
|
||||
final String bindingId;
|
||||
final int expirationMonth;
|
||||
final int expirationYear;
|
||||
final String cardHolder;
|
||||
@@ -12,7 +12,7 @@ class PaymentCardResponseDto {
|
||||
|
||||
PaymentCardResponseDto({
|
||||
required this.id,
|
||||
required this.clientId,
|
||||
required this.bindingId,
|
||||
required this.expirationMonth,
|
||||
required this.expirationYear,
|
||||
required this.cardHolder,
|
||||
@@ -24,7 +24,7 @@ class PaymentCardResponseDto {
|
||||
factory PaymentCardResponseDto.fromJson(Map<String, dynamic> json) {
|
||||
return PaymentCardResponseDto(
|
||||
id: json['id'] as int,
|
||||
clientId: json['clientId'] as int,
|
||||
bindingId: json['bindingId'] as String,
|
||||
expirationMonth: json['expirationMonth'] as int,
|
||||
expirationYear: json['expirationYear'] as int,
|
||||
cardHolder: json['cardHolder'] as String,
|
||||
@@ -37,13 +37,9 @@ class PaymentCardResponseDto {
|
||||
PaymentCard toEntity(String? fullCardNumber) {
|
||||
return PaymentCard(
|
||||
id: id,
|
||||
clientId: clientId,
|
||||
expirationMonth: expirationMonth,
|
||||
expirationYear: expirationYear,
|
||||
cardHolder: cardHolder,
|
||||
bindingId: bindingId,
|
||||
cardLastNumber: cardLastNumber,
|
||||
isMain: isMain,
|
||||
type: type,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -52,7 +52,11 @@ class ApiService {
|
||||
try {
|
||||
final response = await _dio.post(
|
||||
"$baseUrl/auth/client/login",
|
||||
data: {"phone": phone, "model": model, "systemId": systemId},
|
||||
data: {
|
||||
"phone": phone,
|
||||
"model": model,
|
||||
"systemId": systemId
|
||||
},
|
||||
);
|
||||
|
||||
if (response.statusCode == 200 || response.statusCode == 201) {
|
||||
@@ -177,13 +181,9 @@ class ApiService {
|
||||
cardsJson.map((cardJson) async {
|
||||
return PaymentCard(
|
||||
id: cardJson['id'],
|
||||
clientId: cardJson['clientId'],
|
||||
expirationMonth: cardJson['expirationMonth'],
|
||||
expirationYear: cardJson['expirationYear'],
|
||||
cardHolder: cardJson['cardHolder'],
|
||||
bindingId: cardJson['bindingId'],
|
||||
cardLastNumber: cardJson['cardLastNumber'],
|
||||
isMain: cardJson['isMain'],
|
||||
type: cardJson['cardType'],
|
||||
);
|
||||
}),
|
||||
);
|
||||
@@ -517,13 +517,13 @@ class ApiService {
|
||||
}
|
||||
}
|
||||
|
||||
Future<bool> activateSubscription({required int optionId}) async {
|
||||
Future<bool> activateSubscription({required int optionId, required int cardId}) async {
|
||||
const url = "$baseUrl/scootersubscription/client";
|
||||
|
||||
try {
|
||||
final response = await _dio.post(
|
||||
url,
|
||||
data: {"optionId": optionId},
|
||||
data: {"optionId": optionId, "cardId": cardId},
|
||||
options: await _getAuthOptions(),
|
||||
);
|
||||
|
||||
@@ -539,31 +539,25 @@ class ApiService {
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> addPaymentCard({
|
||||
required String cardNumber,
|
||||
required String cardHolder,
|
||||
required int expirationMonth,
|
||||
required int expirationYear,
|
||||
required String cvv,
|
||||
}) async {
|
||||
Future<Map<String, dynamic>> addPaymentCard() async {
|
||||
const url = "$baseUrl/client/card";
|
||||
final cleanCardNumber = cardNumber.replaceAll(' ', '');
|
||||
/*final cleanCardNumber = cardNumber.replaceAll(' ', '');*/
|
||||
|
||||
try {
|
||||
final response = await _dio.post(
|
||||
url,
|
||||
data: {
|
||||
/*data: {
|
||||
"cardNumber": cleanCardNumber,
|
||||
"cardHolder": cardHolder,
|
||||
"expirationMonth": expirationMonth,
|
||||
"expirationYear": expirationYear,
|
||||
"cvv": cvv,
|
||||
},
|
||||
},*/
|
||||
options: await _getAuthOptions(),
|
||||
);
|
||||
|
||||
if (response.statusCode == 200 || response.statusCode == 201) {
|
||||
return;
|
||||
return response.data;
|
||||
}
|
||||
|
||||
throw AuthException('Непредвиденный статус: ${response.statusCode}', 0);
|
||||
|
||||
@@ -32,25 +32,25 @@ class PaymentRepositoryImpl implements PaymentRepository {
|
||||
}
|
||||
|
||||
@override
|
||||
Future<Result<void>> addPaymentCard({
|
||||
required String cardNumber,
|
||||
Future<Result<Map<String, dynamic>>> addPaymentCard(
|
||||
/*required String cardNumber,
|
||||
required String cardHolder,
|
||||
required String expiryMonth,
|
||||
required String expiryYear,
|
||||
required String cvv,
|
||||
}) async {
|
||||
required String cvv,*/
|
||||
) async {
|
||||
try {
|
||||
await apiService.addPaymentCard(
|
||||
cardNumber: cardNumber,
|
||||
final result = await apiService.addPaymentCard(
|
||||
/*cardNumber: cardNumber,
|
||||
cardHolder: cardHolder,
|
||||
expirationMonth: int.parse(expiryMonth),
|
||||
expirationYear: int.parse(expiryYear),
|
||||
cvv: cvv,
|
||||
cvv: cvv,*/
|
||||
);
|
||||
|
||||
// await securityService.saveCardFullNumber(cardId, cardNumber);
|
||||
|
||||
return Success(null);
|
||||
return Success(result);
|
||||
} on AuthException catch (e) {
|
||||
return Failure(AuthFailure(e.attemptsLeft));
|
||||
} on AuthBlockException catch (_) {
|
||||
@@ -98,9 +98,9 @@ class PaymentRepositoryImpl implements PaymentRepository {
|
||||
}
|
||||
|
||||
@override
|
||||
Future<Result<bool>> activateSubscription(int optionId) async {
|
||||
Future<Result<bool>> activateSubscription(int optionId, int cardId) async {
|
||||
try {
|
||||
final success = await apiService.activateSubscription(optionId: optionId);
|
||||
final success = await apiService.activateSubscription(optionId: optionId, cardId: cardId);
|
||||
return Success(success);
|
||||
} on AuthException catch (e) {
|
||||
return Failure(AuthFailure(e.attemptsLeft));
|
||||
|
||||
Reference in New Issue
Block a user