/// 网页收银台相关模型 library; /// 收银台会话创建响应 /// 字段随渠道不同而变化: /// - wechat: [codeUrl] /// - alipay/stripe: [redirectUrl] class CheckoutSessionResponse { final String channel; final String paymentId; final String? codeUrl; final String? redirectUrl; final String? htmlForm; CheckoutSessionResponse({ required this.channel, required this.paymentId, this.codeUrl, this.redirectUrl, this.htmlForm, }); toJson() => { 'channel': channel, 'payment_id': paymentId, 'code_url': codeUrl, 'redirect_url': redirectUrl, 'html_form': htmlForm, }; static CheckoutSessionResponse fromJson(Map json) { return CheckoutSessionResponse( channel: json['channel'], paymentId: json['payment_id'], codeUrl: json['code_url'], redirectUrl: json['redirect_url'], htmlForm: json['html_form'], ); } } /// 收银台会话状态查询响应 class CheckoutSessionStatus { final String paymentId; final bool success; final String note; CheckoutSessionStatus({ required this.paymentId, required this.success, required this.note, }); static CheckoutSessionStatus fromJson(Map json) { return CheckoutSessionStatus( paymentId: json['payment_id'], success: json['success'] ?? false, note: json['note'] ?? '', ); } }