class OtherPayCreatedReponse { String params; String paymentId; bool sandbox; OtherPayCreatedReponse(this.params, this.paymentId, {this.sandbox = false}); toJson() => { 'params': params, 'payment_id': paymentId, 'sandbox': sandbox, }; static OtherPayCreatedReponse fromJson(Map json) { return OtherPayCreatedReponse( json['params'], json['payment_id'], sandbox: json['sandbox'] ?? false, ); } } class PaymentProduct { String id; String name; int quota; int retailPrice; int retailPriceUSD; String expirePolicy; String expirePolicyText; bool recommend; String? description; List methods; PaymentProduct({ required this.id, required this.name, required this.quota, required this.retailPrice, required this.expirePolicy, required this.expirePolicyText, this.recommend = false, this.description, this.retailPriceUSD = 0, this.methods = const [], }); String get retailPriceText => '¥${(retailPrice / 100).toStringAsFixed(0)}'; String get retailPriceUSDText => '\$${(retailPriceUSD / 100).toStringAsFixed(2)}'; /// 是否支持 Stripe 支付 bool get supportStripe => methods.contains('stripe') || methods.isEmpty; toJson() => { 'id': id, 'name': name, 'quota': quota, 'retail_price': retailPrice, 'retail_price_usd': retailPriceUSD, 'expire_policy': expirePolicy, 'expire_policy_text': expirePolicyText, 'recommend': recommend, 'description': description, 'methods': methods, }; static PaymentProduct fromJson(Map json) { return PaymentProduct( id: json['id'], name: json['name'], quota: json['quota'], retailPrice: json['retail_price'], retailPriceUSD: json['retail_price_usd'] ?? 0, expirePolicy: json['expire_policy'], expirePolicyText: json['expire_policy_text'], recommend: json['recommend'] ?? false, description: json['description'], methods: ((json['methods'] ?? []) as List) .map((e) => e.toString()) .toList(), ); } } class PaymentProducts { final List consume; final String? note; final bool preferUSD; PaymentProducts(this.consume, {this.note, this.preferUSD = false}); toJson() => { 'consume': consume, 'note': note, 'prefer_usd': preferUSD, }; static PaymentProducts fromJson(Map json) { return PaymentProducts( (json['consume'] as List) .map((e) => PaymentProduct.fromJson(e)) .toList(), note: json['note'], preferUSD: json['prefer_usd'] ?? false, ); } } class PaymentStatus { final bool success; final String? note; PaymentStatus(this.success, {this.note}); toJson() => { 'success': success, 'note': note, }; static PaymentStatus fromJson(Map json) { return PaymentStatus( json['success'], note: json['note'], ); } } class WechatPaymentCreatedResponse { final String paymentId; final bool sandbox; final String? codeUrl; final String? prepayId; final String? package; final String? partnerId; final String? appId; final String? noncestr; final String? timestamp; final String? sign; WechatPaymentCreatedResponse( this.paymentId, this.sandbox, { this.codeUrl, this.prepayId, this.package, this.partnerId, this.appId, this.noncestr, this.timestamp, this.sign, }); toJson() => { 'payment_id': paymentId, 'sandbox': sandbox, 'code_url': codeUrl, 'prepay_id': prepayId, 'package': package, 'partner_id': partnerId, 'app_id': appId, 'noncestr': noncestr, 'timestamp': timestamp, 'sign': sign, }; static WechatPaymentCreatedResponse fromJson(Map json) { return WechatPaymentCreatedResponse( json['payment_id'], json['sandbox'] ?? false, codeUrl: json['code_url'], prepayId: json['prepay_id'], package: json['package'], partnerId: json['partner_id'], appId: json['app_id'], noncestr: json['noncestr'], timestamp: json['timestamp'], sign: json['sign'], ); } } class StripePaymentCreatedResponse { final String paymentId; final String customer; final String paymentIntent; final String ephemeralKey; final String publishableKey; final String proxyUrl; StripePaymentCreatedResponse( this.paymentId, this.customer, this.paymentIntent, this.ephemeralKey, this.publishableKey, this.proxyUrl, ); toJson() => { 'payment_id': paymentId, 'customer': customer, 'payment_intent': paymentIntent, 'ephemeral_key': ephemeralKey, 'publishable_key': publishableKey, 'proxy_url': proxyUrl, }; static StripePaymentCreatedResponse fromJson(Map json) { return StripePaymentCreatedResponse( json['payment_id'], json['customer'], json['payment_intent'], json['ephemeral_key'], json['publishable_key'], json['proxy_url'] ?? '', ); } }