123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220 |
- 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<String, dynamic> 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<String> 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<String, dynamic> 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<dynamic>)
- .map((e) => e.toString())
- .toList(),
- );
- }
- }
- class PaymentProducts {
- final List<PaymentProduct> 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<String, dynamic> json) {
- return PaymentProducts(
- (json['consume'] as List<dynamic>)
- .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<String, dynamic> 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<String, dynamic> 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<String, dynamic> json) {
- return StripePaymentCreatedResponse(
- json['payment_id'],
- json['customer'],
- json['payment_intent'],
- json['ephemeral_key'],
- json['publishable_key'],
- json['proxy_url'] ?? '',
- );
- }
- }
|