Coverage for functions \ flipdare \ payments \ payment_types.py: 100%

67 statements  

« prev     ^ index     » next       coverage.py v7.13.0, created at 2026-05-08 12:22 +1000

1#!/usr/bin/env python 

2# Copyright (c) 2026 Flipdare Pty Ltd. All rights reserved. 

3# 

4# This file is part of Flipdare's proprietary software and contains 

5# confidential and copyrighted material. Unauthorised copying, 

6# modification, distribution, or use of this file is strictly 

7# prohibited without prior written permission from Flipdare Pty Ltd. 

8# 

9# This software includes third-party components licensed under MIT, 

10# BSD, and Apache 2.0 licences. See THIRD_PARTY_NOTICES for details. 

11# 

12 

13from __future__ import annotations 

14from typing import TYPE_CHECKING, NamedTuple, final 

15from dataclasses import dataclass 

16from datetime import datetime 

17import stripe._error as s 

18from flipdare.generated import ( 

19 StripeAccountType, 

20 StripeCurrencyCode, 

21) 

22from flipdare.generated.model.payment.audit_info_model import AuditInfoModel 

23 

24if TYPE_CHECKING: 

25 from flipdare.generated.model.payment.payment_model import PaymentModel 

26 from flipdare.generated.model.payment.risk_assessment_model import RiskAssessmentModel 

27 from flipdare.wrapper.user_wrapper import UserWrapper 

28 from flipdare.generated.shared.model.user.app_fee_type import AppFeeType 

29 

30 

31__all__ = [ 

32 "KnownStripeErrorType", 

33 "AccountRiskInfo", 

34 "AppPaymentIntent", 

35 "StripeRegionFee", 

36 "RefundResult", 

37 "PaymentResult", 

38 "StripeLinkInfo", 

39 "AppReceipt", 

40] 

41 

42type KnownStripeErrorType = ( 

43 s.CardError 

44 | s.RateLimitError 

45 | s.InvalidRequestError 

46 | s.AuthenticationError 

47 | s.APIConnectionError 

48 | s.StripeError 

49) 

50 

51 

52class StripeRegionFee(NamedTuple): 

53 base_rate: float 

54 fixed_fee: float 

55 intl_surcharge: float 

56 currency_surcharge: float 

57 

58 

59@final 

60@dataclass(frozen=True, slots=True) 

61class AccountRiskInfo: 

62 user: UserWrapper 

63 risk_assessment: RiskAssessmentModel 

64 

65 

66@final 

67@dataclass(frozen=True, slots=True) 

68class AppPaymentIntent: 

69 amount: int 

70 currency: StripeCurrencyCode 

71 ephemeral_key: str 

72 client_secret: str 

73 

74 

75@final 

76@dataclass(frozen=True, slots=True) 

77class RefundResult: 

78 app_fee_amount: int 

79 refunded_app_fee_amount: int 

80 stripe_fee: int 

81 

82 

83@final 

84@dataclass(frozen=True, slots=True) 

85class PaymentResult: 

86 app_fee_amount: int 

87 amount_captured: int 

88 

89 

90@final 

91@dataclass(frozen=True, slots=True) 

92class ValidatedPaymentInfo: 

93 payment: PaymentModel 

94 audit_info: AuditInfoModel 

95 risk_assessment: RiskAssessmentModel 

96 payment_intent_id: str 

97 payment_method_id: str 

98 needs_recheck: bool 

99 can_try_capture: bool 

100 

101 

102@final 

103@dataclass(frozen=True, slots=True) 

104class StripeLinkInfo: 

105 uid: str 

106 stripe_account_id: str 

107 account_type: StripeAccountType 

108 

109 

110@final 

111@dataclass(frozen=True, slots=True) 

112class AppReceipt: 

113 receipt_date: datetime 

114 receipt_id: str 

115 first_name: str 

116 last_name: str 

117 fee_type: AppFeeType 

118 customer_id: str 

119 account_id: str 

120 dare_id: str 

121 dare_description: str 

122 amount: int 

123 currency_code: StripeCurrencyCode = StripeCurrencyCode.USD