checkout.dart 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. /// 网页收银台相关模型
  2. library;
  3. /// 收银台会话创建响应
  4. /// 字段随渠道不同而变化:
  5. /// - wechat: [codeUrl]
  6. /// - alipay/stripe: [redirectUrl]
  7. class CheckoutSessionResponse {
  8. final String channel;
  9. final String paymentId;
  10. final String? codeUrl;
  11. final String? redirectUrl;
  12. final String? htmlForm;
  13. CheckoutSessionResponse({
  14. required this.channel,
  15. required this.paymentId,
  16. this.codeUrl,
  17. this.redirectUrl,
  18. this.htmlForm,
  19. });
  20. toJson() => {
  21. 'channel': channel,
  22. 'payment_id': paymentId,
  23. 'code_url': codeUrl,
  24. 'redirect_url': redirectUrl,
  25. 'html_form': htmlForm,
  26. };
  27. static CheckoutSessionResponse fromJson(Map<String, dynamic> json) {
  28. return CheckoutSessionResponse(
  29. channel: json['channel'],
  30. paymentId: json['payment_id'],
  31. codeUrl: json['code_url'],
  32. redirectUrl: json['redirect_url'],
  33. htmlForm: json['html_form'],
  34. );
  35. }
  36. }
  37. /// 收银台会话状态查询响应
  38. class CheckoutSessionStatus {
  39. final String paymentId;
  40. final bool success;
  41. final String note;
  42. CheckoutSessionStatus({
  43. required this.paymentId,
  44. required this.success,
  45. required this.note,
  46. });
  47. static CheckoutSessionStatus fromJson(Map<String, dynamic> json) {
  48. return CheckoutSessionStatus(
  49. paymentId: json['payment_id'],
  50. success: json['success'] ?? false,
  51. note: json['note'] ?? '',
  52. );
  53. }
  54. }