73 lines
1.9 KiB
Dart
73 lines
1.9 KiB
Dart
/// Transaction de paiement externe (rechargement wallet).
|
|
class PaymentTransaction {
|
|
const PaymentTransaction({
|
|
required this.uuid,
|
|
required this.provider,
|
|
required this.amount,
|
|
required this.currency,
|
|
required this.status,
|
|
this.providerPaymentId,
|
|
this.stripe,
|
|
});
|
|
|
|
final String uuid;
|
|
final String provider;
|
|
final String? providerPaymentId;
|
|
final double amount;
|
|
final String currency;
|
|
final String status;
|
|
final StripePaymentDetails? stripe;
|
|
|
|
factory PaymentTransaction.fromJson(Map<String, dynamic> json) {
|
|
final stripeJson = json['stripe'];
|
|
return PaymentTransaction(
|
|
uuid: json['uuid'] as String,
|
|
provider: json['provider'] as String,
|
|
providerPaymentId: json['provider_payment_id'] as String?,
|
|
amount: (json['amount'] as num).toDouble(),
|
|
currency: json['currency'] as String,
|
|
status: json['status'] as String,
|
|
stripe: stripeJson is Map<String, dynamic>
|
|
? StripePaymentDetails.fromJson(stripeJson)
|
|
: null,
|
|
);
|
|
}
|
|
}
|
|
|
|
class StripePaymentDetails {
|
|
const StripePaymentDetails({
|
|
required this.paymentIntentId,
|
|
required this.clientSecret,
|
|
required this.publishableKey,
|
|
});
|
|
|
|
final String paymentIntentId;
|
|
final String clientSecret;
|
|
final String publishableKey;
|
|
|
|
factory StripePaymentDetails.fromJson(Map<String, dynamic> json) {
|
|
return StripePaymentDetails(
|
|
paymentIntentId: json['payment_intent_id'] as String,
|
|
clientSecret: json['client_secret'] as String,
|
|
publishableKey: json['publishable_key'] as String,
|
|
);
|
|
}
|
|
}
|
|
|
|
class TopUpResult {
|
|
const TopUpResult({
|
|
required this.payment,
|
|
required this.balance,
|
|
});
|
|
|
|
final PaymentTransaction payment;
|
|
final double balance;
|
|
|
|
factory TopUpResult.fromJson(Map<String, dynamic> json) {
|
|
return TopUpResult(
|
|
payment: PaymentTransaction.fromJson(json['payment'] as Map<String, dynamic>),
|
|
balance: (json['balance'] as num).toDouble(),
|
|
);
|
|
}
|
|
}
|