57 lines
1.7 KiB
Dart
57 lines
1.7 KiB
Dart
|
|
class VerifyTransactionRequest {
|
||
|
|
const VerifyTransactionRequest({
|
||
|
|
required this.productCode,
|
||
|
|
required this.appStoreProductId,
|
||
|
|
required this.transactionId,
|
||
|
|
required this.signedTransactionInfo,
|
||
|
|
this.appAccountToken,
|
||
|
|
});
|
||
|
|
|
||
|
|
final String productCode;
|
||
|
|
final String appStoreProductId;
|
||
|
|
final String transactionId;
|
||
|
|
final String signedTransactionInfo;
|
||
|
|
final String? appAccountToken;
|
||
|
|
|
||
|
|
Map<String, dynamic> toJson() => {
|
||
|
|
'productCode': productCode,
|
||
|
|
'appStoreProductId': appStoreProductId,
|
||
|
|
'transactionId': transactionId,
|
||
|
|
'signedTransactionInfo': signedTransactionInfo,
|
||
|
|
if (appAccountToken != null) 'appAccountToken': appAccountToken,
|
||
|
|
};
|
||
|
|
}
|
||
|
|
|
||
|
|
enum VerifyTransactionStatus { granted, alreadyGranted }
|
||
|
|
|
||
|
|
class VerifyTransactionResponse {
|
||
|
|
const VerifyTransactionResponse({
|
||
|
|
required this.status,
|
||
|
|
required this.productCode,
|
||
|
|
required this.transactionId,
|
||
|
|
required this.creditsAdded,
|
||
|
|
required this.newBalance,
|
||
|
|
required this.ledgerEventId,
|
||
|
|
});
|
||
|
|
|
||
|
|
final VerifyTransactionStatus status;
|
||
|
|
final String productCode;
|
||
|
|
final String transactionId;
|
||
|
|
final int creditsAdded;
|
||
|
|
final int newBalance;
|
||
|
|
final String ledgerEventId;
|
||
|
|
|
||
|
|
factory VerifyTransactionResponse.fromJson(Map<String, dynamic> json) {
|
||
|
|
return VerifyTransactionResponse(
|
||
|
|
status: json['status'] == 'already_granted'
|
||
|
|
? VerifyTransactionStatus.alreadyGranted
|
||
|
|
: VerifyTransactionStatus.granted,
|
||
|
|
productCode: json['productCode'] as String,
|
||
|
|
transactionId: json['transactionId'] as String,
|
||
|
|
creditsAdded: json['creditsAdded'] as int,
|
||
|
|
newBalance: json['newBalance'] as int,
|
||
|
|
ledgerEventId: json['ledgerEventId'] as String,
|
||
|
|
);
|
||
|
|
}
|
||
|
|
}
|