Coverage for functions \ flipdare \ payments \ dto \ customer_create_dto.py: 100%
24 statements
« prev ^ index » next coverage.py v7.13.0, created at 2026-05-08 12:22 +1000
« 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#
12from stripe.params.v2.core import AccountCreateParams
13from flipdare.generated.shared.stripe.stripe_country_code import StripeCountryCode
14from flipdare.payments.core.stripe_account_params import StripeAccountParams
17class CustomerCreateDTO:
18 __slots__ = (
19 "_country",
20 "_email",
21 "_invoice_prefix",
22 "_name",
23 "_test_clock",
24 "_tokens",
25 "_uid",
26 )
28 def __init__(
29 self,
30 uid: str,
31 email: str,
32 name: str,
33 country: StripeCountryCode,
34 tokens: tuple[str, str] | None = None,
35 test_clock: str | None = None,
36 ) -> None:
37 self._uid = uid
38 self._email = email
39 self._name = name
40 self._tokens = tokens
41 self._country = country
42 self._test_clock = test_clock
44 def to_params(self) -> AccountCreateParams:
45 name = self._name
46 uid = self._uid
47 tokens = self._tokens
48 email = self._email
49 country = self._country
50 test_clock = self._test_clock
52 # uid is not needed for customer params
53 account_params = StripeAccountParams.create(
54 uid=uid,
55 name=name,
56 email=email,
57 tokens=tokens,
58 )
59 params: AccountCreateParams = {
60 "contact_email": email,
61 "display_name": account_params.display_name,
62 "identity": {
63 "country": country.value,
64 },
65 "configuration": {
66 "customer": {"billing": {"invoice": {"prefix": account_params.invoice_prefix}}}
67 },
68 }
70 if test_clock is not None:
71 params["configuration"]["customer"]["test_clock"] = test_clock
72 return params