-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #12 from MadBrains/closing_receipt
[3.0.1] Add SendClosingReceipt endpoint. Small fixes
- Loading branch information
Showing
21 changed files
with
315 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,3 @@ | ||
The [Example](../../../example/lib/main.dart) is in the corresponding folder | ||
The [Example][example] is in the corresponding folder | ||
|
||
[example]: https://github.com/MadBrains/Tinkoff-Acquiring-SDK-Flutter/tree/main/example |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
69 changes: 69 additions & 0 deletions
69
...koff_acquiring/lib/src/core/models/send_closing_receipt/send_closing_receipt_request.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
import 'package:json_annotation/json_annotation.dart'; | ||
|
||
import '../../../constants.dart'; | ||
import '../../../utils/extensions.dart'; | ||
import '../base/acquiring_request.dart'; | ||
import '../common/receipt.dart'; | ||
|
||
part 'send_closing_receipt_request.g.dart'; | ||
|
||
/// Метод позволяет отправить закрывающий чек в кассу. | ||
/// Условия работы метода: | ||
/// 1. Закрывающий чек может быть отправлен если платежная сессия по первому чеку находится в статусе CONFIRMED. | ||
/// 2. В платежной сессии был передан объект Receipt. | ||
/// 3. В объекте Receipt был передан хотя бы один объект Receipt.Items.PaymentMethod = "full_prepayment" или "prepayment" или "advance" | ||
/// | ||
/// [SendClosingReceiptRequest](https://www.tinkoff.ru/kassa/develop/api/payments/SendClosingReceipt-request/) | ||
@JsonSerializable(includeIfNull: false) | ||
class SendClosingReceiptRequest extends AcquiringRequest { | ||
/// Создает экземпляр метода по отправке закрывающего чека в кассу | ||
SendClosingReceiptRequest({ | ||
required this.paymentId, | ||
required this.receipt, | ||
String? signToken, | ||
}) : super(signToken) { | ||
validate(); | ||
} | ||
|
||
/// Преобразование json в модель | ||
factory SendClosingReceiptRequest.fromJson(Map<String, dynamic> json) => | ||
_$SendClosingReceiptRequestFromJson(json); | ||
|
||
@override | ||
String get apiMethod => ApiMethods.sendClosingReceipt; | ||
|
||
@override | ||
Map<String, dynamic> toJson() => _$SendClosingReceiptRequestToJson(this); | ||
|
||
@override | ||
Map<String, Object?> get equals => <String, Object?>{ | ||
...super.equals, | ||
JsonKeys.paymentId: paymentId, | ||
JsonKeys.receipt: receipt, | ||
}; | ||
|
||
@override | ||
SendClosingReceiptRequest copyWith({ | ||
int? paymentId, | ||
Receipt? receipt, | ||
}) { | ||
return SendClosingReceiptRequest( | ||
paymentId: paymentId ?? this.paymentId, | ||
receipt: receipt ?? this.receipt, | ||
); | ||
} | ||
|
||
@override | ||
void validate() { | ||
assert(paymentId.length <= 20); | ||
receipt.validate(); | ||
} | ||
|
||
/// Идентификатор платежа в системе банка | ||
@JsonKey(name: JsonKeys.paymentId) | ||
final int paymentId; | ||
|
||
/// Данные чека | ||
@JsonKey(name: JsonKeys.receipt) | ||
final Receipt receipt; | ||
} |
32 changes: 32 additions & 0 deletions
32
...ff_acquiring/lib/src/core/models/send_closing_receipt/send_closing_receipt_request.g.dart
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
34 changes: 34 additions & 0 deletions
34
...off_acquiring/lib/src/core/models/send_closing_receipt/send_closing_receipt_response.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import 'package:json_annotation/json_annotation.dart'; | ||
|
||
import '../base/acquiring_response.dart'; | ||
import '../enums/status.dart'; | ||
|
||
part 'send_closing_receipt_response.g.dart'; | ||
|
||
/// Ответ от сервера на закрывающий чек в кассу | ||
/// | ||
/// [SendClosingReceiptResponse](https://www.tinkoff.ru/kassa/develop/api/payments/SendClosingReceipt-response/) | ||
@JsonSerializable() | ||
class SendClosingReceiptResponse extends AcquiringResponse { | ||
/// Создает экземпляр ответа от сервера на закрывающий чек в кассу | ||
SendClosingReceiptResponse({ | ||
Status? status, | ||
bool? success, | ||
String? errorCode, | ||
String? message, | ||
String? details, | ||
}) : super( | ||
status: status, | ||
success: success, | ||
errorCode: errorCode, | ||
message: message, | ||
details: details, | ||
); | ||
|
||
/// Преобразование json в модель | ||
factory SendClosingReceiptResponse.fromJson(Map<String, dynamic> json) => | ||
_$SendClosingReceiptResponseFromJson(json); | ||
|
||
@override | ||
Map<String, dynamic> toJson() => _$SendClosingReceiptResponseToJson(this); | ||
} |
87 changes: 87 additions & 0 deletions
87
...f_acquiring/lib/src/core/models/send_closing_receipt/send_closing_receipt_response.g.dart
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.