python-terminusgps 42.2.3__py3-none-any.whl → 43.0.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of python-terminusgps might be problematic. Click here for more details.
- {python_terminusgps-42.2.3.dist-info → python_terminusgps-43.0.0.dist-info}/METADATA +1 -1
- {python_terminusgps-42.2.3.dist-info → python_terminusgps-43.0.0.dist-info}/RECORD +14 -14
- terminusgps/authorizenet/api/__init__.py +5 -0
- terminusgps/authorizenet/{profiles/addresses.py → api/address_profiles.py} +45 -44
- terminusgps/authorizenet/api/customer_profiles.py +123 -0
- terminusgps/authorizenet/{profiles/payments.py → api/payment_profiles.py} +72 -60
- terminusgps/authorizenet/{subscriptions.py → api/subscriptions.py} +44 -20
- terminusgps/authorizenet/api/transactions.py +77 -0
- terminusgps/authorizenet/constants.py +9 -13
- terminusgps/authorizenet/controllers.py +8 -30
- terminusgps/authorizenet/validators.py +10 -3
- terminusgps/django/validators.py +9 -9
- terminusgps/authorizenet/profiles/__init__.py +0 -3
- terminusgps/authorizenet/profiles/customers.py +0 -107
- terminusgps/authorizenet/utils.py +0 -172
- {python_terminusgps-42.2.3.dist-info → python_terminusgps-43.0.0.dist-info}/WHEEL +0 -0
- {python_terminusgps-42.2.3.dist-info → python_terminusgps-43.0.0.dist-info}/licenses/COPYING +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: python-terminusgps
|
|
3
|
-
Version:
|
|
3
|
+
Version: 43.0.0
|
|
4
4
|
Summary: Provides abstractions/utilities for working with Wialon API, Authorize.NET API, AWS API, and more.
|
|
5
5
|
Project-URL: Documentation, https://docs.terminusgps.com
|
|
6
6
|
Project-URL: Repository, https://github.com/terminusgps/python-terminusgps
|
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
terminusgps/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
2
2
|
terminusgps/authorizenet/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
3
3
|
terminusgps/authorizenet/auth.py,sha256=CKT_pfDEL-53GceOEaFtIU6IBXVuVd8MVHikpPAX0xY,1184
|
|
4
|
-
terminusgps/authorizenet/constants.py,sha256=
|
|
5
|
-
terminusgps/authorizenet/controllers.py,sha256=
|
|
6
|
-
terminusgps/authorizenet/
|
|
7
|
-
terminusgps/authorizenet/
|
|
8
|
-
terminusgps/authorizenet/
|
|
9
|
-
terminusgps/authorizenet/
|
|
10
|
-
terminusgps/authorizenet/
|
|
11
|
-
terminusgps/authorizenet/
|
|
12
|
-
terminusgps/authorizenet/
|
|
4
|
+
terminusgps/authorizenet/constants.py,sha256=MHAij1DKLJNUFOAbtb1_pKHrfXU2T7L6d0_zM5P15Gw,489
|
|
5
|
+
terminusgps/authorizenet/controllers.py,sha256=oEomwVPu6uT2z5BGKKm-zLWXhODvBajUQ4GxDOHTecQ,2011
|
|
6
|
+
terminusgps/authorizenet/validators.py,sha256=Wq4rqEuqG3JzOO7O1wM6oQ0FciNxxOK0HnJqTuLa8CY,3916
|
|
7
|
+
terminusgps/authorizenet/api/__init__.py,sha256=VXR4Yco1yz5R-R7vgaH2zTP9VFqzfvvGy_XJVjyb3i0,154
|
|
8
|
+
terminusgps/authorizenet/api/address_profiles.py,sha256=yl8aX2Csnlpmk5g0z0Xd2YyqHVuvduCBD_4HU42mFKk,4976
|
|
9
|
+
terminusgps/authorizenet/api/customer_profiles.py,sha256=vWIZS4Z4uKRmi6IDpOoM8PCjGrQFw2lvDjG7UJwQ_3s,4654
|
|
10
|
+
terminusgps/authorizenet/api/payment_profiles.py,sha256=1SmEZtyLxJ5kTZDyBE8gVfC2LVpHWgGabklfqtMQOzE,6681
|
|
11
|
+
terminusgps/authorizenet/api/subscriptions.py,sha256=jMNeLNWJzg38Y4E80Q6E573qPPQMnObIJaQvNw5lgMI,4667
|
|
12
|
+
terminusgps/authorizenet/api/transactions.py,sha256=Hl-MSw9ZjZJKTOJpV1S503h_ZnRzu3ltPg6DMaTF2X0,2848
|
|
13
13
|
terminusgps/django/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
14
14
|
terminusgps/django/mixins.py,sha256=Q9ZJuzpk3d9lDnlVA8ZTVvnZWxB13p08EQ8yVJcztn4,1034
|
|
15
15
|
terminusgps/django/settings.py,sha256=NLjcdnD_Ny_04eNNVWabUwzWvw0zS_-ebXnzhx8PJRU,691
|
|
16
16
|
terminusgps/django/utils.py,sha256=SYDQyHA5tTuVwdpZGsCtf0LpTTD0ilRKoxa8StfSTpQ,156
|
|
17
|
-
terminusgps/django/validators.py,sha256=
|
|
17
|
+
terminusgps/django/validators.py,sha256=chuJ4I1DBQ_H5dwb6CXPEIyv_CUuEzJzRUSijfss1vc,3510
|
|
18
18
|
terminusgps/django/forms/__init__.py,sha256=hh8Z9AC_u2m2bu3h6sdmPyndfQneCEVovENPHmoTDC0,21
|
|
19
19
|
terminusgps/django/forms/fields.py,sha256=BfuPzOZyGvWsEzONW2h4i01fhoL0IS0-gDdBKW4jHgI,2225
|
|
20
20
|
terminusgps/django/forms/forms.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
@@ -36,7 +36,7 @@ terminusgps/wialon/items/route.py,sha256=xixlex6bUeFHXucVQdbfQUSLxI1Rhwk6slhoFP2
|
|
|
36
36
|
terminusgps/wialon/items/unit.py,sha256=kIjnMOjjI3siCaA6wXojzEK2xqFIm5mN4xNqzKDUa1Q,5473
|
|
37
37
|
terminusgps/wialon/items/unit_group.py,sha256=L7-PAVCj8Bf50fa04Ials4VHg8LOWkw6hwNhtSyMksE,2133
|
|
38
38
|
terminusgps/wialon/items/user.py,sha256=hZlFeXCgOAdivl_Anjp_We6Cy5U8IxWNDAgm5MFZfp0,5194
|
|
39
|
-
python_terminusgps-
|
|
40
|
-
python_terminusgps-
|
|
41
|
-
python_terminusgps-
|
|
42
|
-
python_terminusgps-
|
|
39
|
+
python_terminusgps-43.0.0.dist-info/METADATA,sha256=Xi5V8Ce3y79r2JjscFcL2v9WS59UJbqdzPE9pRub0IY,976
|
|
40
|
+
python_terminusgps-43.0.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
|
41
|
+
python_terminusgps-43.0.0.dist-info/licenses/COPYING,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
|
|
42
|
+
python_terminusgps-43.0.0.dist-info/RECORD,,
|
|
@@ -1,64 +1,65 @@
|
|
|
1
1
|
from authorizenet import apicontractsv1, apicontrollers
|
|
2
|
+
from lxml.objectify import ObjectifiedElement
|
|
2
3
|
|
|
3
4
|
from terminusgps.authorizenet.auth import get_merchant_auth
|
|
4
5
|
from terminusgps.authorizenet.controllers import execute_controller
|
|
5
6
|
|
|
6
7
|
__all__ = [
|
|
7
8
|
"create_customer_shipping_address",
|
|
8
|
-
"delete_customer_shipping_address",
|
|
9
9
|
"get_customer_shipping_address",
|
|
10
10
|
"update_customer_shipping_address",
|
|
11
|
+
"delete_customer_shipping_address",
|
|
11
12
|
]
|
|
12
13
|
|
|
13
14
|
|
|
14
15
|
def create_customer_shipping_address(
|
|
15
16
|
customer_profile_id: int,
|
|
16
|
-
|
|
17
|
+
address: apicontractsv1.customerAddressType,
|
|
17
18
|
default: bool = True,
|
|
18
|
-
):
|
|
19
|
+
) -> ObjectifiedElement | None:
|
|
19
20
|
"""
|
|
20
21
|
`createCustomerShippingAddressRequest <https://developer.authorize.net/api/reference/index.html#customer-profiles-create-customer-shipping-address>`_.
|
|
21
22
|
|
|
22
23
|
:param customer_profile_id: An Authorizenet customer profile id.
|
|
23
24
|
:type customer_profile_id: :py:obj:`int`
|
|
24
|
-
:param
|
|
25
|
-
:type
|
|
25
|
+
:param elem: An Authorizenet customer address element.
|
|
26
|
+
:type elem: :py:obj:`~authorizenet.apicontractsv1.customerAddressType`
|
|
26
27
|
:param default: Whether or not to mark the new shipping address as default. Default is :py:obj:`True`.
|
|
27
28
|
:type default: :py:obj:`bool`
|
|
28
29
|
:returns: An Authorizenet createCustomerShippingAddress response.
|
|
29
|
-
:rtype: :py:obj:`
|
|
30
|
+
:rtype: :py:obj:`~lxml.objectify.ObjectifiedElement` | :py:obj:`None`
|
|
30
31
|
|
|
31
32
|
"""
|
|
32
|
-
request = apicontractsv1.createCustomerShippingAddressRequest(
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
33
|
+
request = apicontractsv1.createCustomerShippingAddressRequest()
|
|
34
|
+
request.merchantAuthentication = get_merchant_auth()
|
|
35
|
+
request.customerProfileId = str(customer_profile_id)
|
|
36
|
+
request.address = address
|
|
37
|
+
request.defaultShippingAddress = str(default).lower()
|
|
38
|
+
|
|
38
39
|
return execute_controller(
|
|
39
40
|
apicontrollers.createCustomerShippingAddressController(request)
|
|
40
41
|
)
|
|
41
42
|
|
|
42
43
|
|
|
43
44
|
def get_customer_shipping_address(
|
|
44
|
-
customer_profile_id: int,
|
|
45
|
-
):
|
|
45
|
+
customer_profile_id: int, address_profile_id: int
|
|
46
|
+
) -> ObjectifiedElement | None:
|
|
46
47
|
"""
|
|
47
48
|
`getCustomerShippingAddressRequest <https://developer.authorize.net/api/reference/index.html#customer-profiles-get-customer-shipping-address>`_.
|
|
48
49
|
|
|
49
50
|
:param customer_profile_id: An Authorizenet customer profile id.
|
|
50
51
|
:type customer_profile_id: :py:obj:`int`
|
|
51
|
-
:param
|
|
52
|
-
:type
|
|
52
|
+
:param address_profile_id: An Authorizenet customer address profile id.
|
|
53
|
+
:type address_profile_id: :py:obj:`int`
|
|
53
54
|
:returns: An Authorizenet getCustomerShippingAddress response.
|
|
54
|
-
:rtype: :py:obj:`
|
|
55
|
+
:rtype: :py:obj:`~lxml.objectify.ObjectifiedElement` | :py:obj:`None`
|
|
55
56
|
|
|
56
57
|
"""
|
|
57
|
-
request = apicontractsv1.getCustomerShippingAddressRequest(
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
58
|
+
request = apicontractsv1.getCustomerShippingAddressRequest()
|
|
59
|
+
request.merchantAuthentication = get_merchant_auth()
|
|
60
|
+
request.customerProfileId = str(customer_profile_id)
|
|
61
|
+
request.customerAddressId = str(address_profile_id)
|
|
62
|
+
|
|
62
63
|
return execute_controller(
|
|
63
64
|
apicontrollers.getCustomerShippingAddressController(request)
|
|
64
65
|
)
|
|
@@ -66,52 +67,52 @@ def get_customer_shipping_address(
|
|
|
66
67
|
|
|
67
68
|
def update_customer_shipping_address(
|
|
68
69
|
customer_profile_id: int,
|
|
69
|
-
|
|
70
|
+
address: apicontractsv1.customerAddressType,
|
|
70
71
|
default: bool = False,
|
|
71
|
-
):
|
|
72
|
+
) -> ObjectifiedElement | None:
|
|
72
73
|
"""
|
|
73
74
|
`updateCustomerShippingAddressRequest <https://developer.authorize.net/api/reference/index.html#customer-profiles-update-customer-shipping-address>`_.
|
|
74
75
|
|
|
75
76
|
:param customer_profile_id: An Authorizenet customer profile id.
|
|
76
77
|
:type customer_profile_id: :py:obj:`int`
|
|
77
|
-
:param
|
|
78
|
-
:type
|
|
78
|
+
:param address: An Authorizenet customer address element.
|
|
79
|
+
:type address: :py:obj:`~authorizenet.apicontractsv1.customerAddressType`
|
|
79
80
|
:param default: Whether or not to mark the new shipping address as default. Default is :py:obj:`False`.
|
|
80
81
|
:type default: :py:obj:`bool`
|
|
81
82
|
:returns: An Authorizenet updateCustomerShippingAddress response.
|
|
82
|
-
:rtype: :py:obj:`
|
|
83
|
+
:rtype: :py:obj:`~lxml.objectify.ObjectifiedElement` | :py:obj:`None`
|
|
83
84
|
|
|
84
85
|
"""
|
|
85
|
-
request = apicontractsv1.updateCustomerShippingAddressRequest(
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
86
|
+
request = apicontractsv1.updateCustomerShippingAddressRequest()
|
|
87
|
+
request.merchantAuthentication = get_merchant_auth()
|
|
88
|
+
request.customerProfileId = str(customer_profile_id)
|
|
89
|
+
request.address = address
|
|
90
|
+
request.defaultShippingAddress = str(default).lower()
|
|
91
|
+
|
|
91
92
|
return execute_controller(
|
|
92
93
|
apicontrollers.updateCustomerShippingAddressController(request)
|
|
93
94
|
)
|
|
94
95
|
|
|
95
96
|
|
|
96
97
|
def delete_customer_shipping_address(
|
|
97
|
-
customer_profile_id: int,
|
|
98
|
-
):
|
|
98
|
+
customer_profile_id: int, address_profile_id: int
|
|
99
|
+
) -> ObjectifiedElement | None:
|
|
99
100
|
"""
|
|
100
101
|
`deleteCustomerShippingAddressRequest <https://developer.authorize.net/api/reference/index.html#customer-profiles-delete-customer-shipping-address>`_.
|
|
101
102
|
|
|
102
103
|
:param customer_profile_id: An Authorizenet customer profile id.
|
|
103
104
|
:type customer_profile_id: :py:obj:`int`
|
|
104
|
-
:param
|
|
105
|
-
:type
|
|
106
|
-
:returns: An Authorizenet
|
|
107
|
-
:rtype: :py:obj:`
|
|
105
|
+
:param address_profile_id: An Authorizenet customer address profile id.
|
|
106
|
+
:type address_profile_id: :py:obj:`int`
|
|
107
|
+
:returns: An Authorizenet deleteCustomerShippingAddressResponse element.
|
|
108
|
+
:rtype: :py:obj:`~lxml.objectify.ObjectifiedElement` | :py:obj:`None`
|
|
108
109
|
|
|
109
110
|
"""
|
|
110
|
-
request = apicontractsv1.deleteCustomerShippingAddressRequest(
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
111
|
+
request = apicontractsv1.deleteCustomerShippingAddressRequest()
|
|
112
|
+
request.merchantAuthentication = get_merchant_auth()
|
|
113
|
+
request.customerProfileId = str(customer_profile_id)
|
|
114
|
+
request.customerAddressId = str(address_profile_id)
|
|
115
|
+
|
|
115
116
|
return execute_controller(
|
|
116
117
|
apicontrollers.deleteCustomerShippingAddressController(request)
|
|
117
118
|
)
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
from authorizenet import apicontractsv1, apicontrollers
|
|
2
|
+
from lxml.objectify import ObjectifiedElement
|
|
3
|
+
|
|
4
|
+
from terminusgps.authorizenet.auth import get_merchant_auth
|
|
5
|
+
from terminusgps.authorizenet.controllers import execute_controller
|
|
6
|
+
|
|
7
|
+
__all__ = [
|
|
8
|
+
"create_customer_profile",
|
|
9
|
+
"get_customer_profile",
|
|
10
|
+
"get_customer_profile_ids",
|
|
11
|
+
"update_customer_profile",
|
|
12
|
+
"delete_customer_profile",
|
|
13
|
+
]
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
def create_customer_profile(
|
|
17
|
+
merchant_id: str, email: str, description: str = ""
|
|
18
|
+
) -> ObjectifiedElement | None:
|
|
19
|
+
"""
|
|
20
|
+
`createCustomerProfileRequest <https://developer.authorize.net/api/reference/index.html#customer-profiles-create-customer-profile>`_.
|
|
21
|
+
|
|
22
|
+
:param merchant_id: A merchant designated customer id.
|
|
23
|
+
:type merchant_id: :py:obj:`str`
|
|
24
|
+
:param email: A customer email address.
|
|
25
|
+
:type email: :py:obj:`str`
|
|
26
|
+
:param description: An optional customer description.
|
|
27
|
+
:type description: :py:obj:`str`
|
|
28
|
+
:returns: An Authorizenet createCustomerProfile response.
|
|
29
|
+
:rtype: :py:obj:`~lxml.objectify.ObjectifiedElement` | :py:obj:`None`
|
|
30
|
+
|
|
31
|
+
"""
|
|
32
|
+
request = apicontractsv1.createCustomerProfileRequest()
|
|
33
|
+
request.merchantAuthentication = get_merchant_auth()
|
|
34
|
+
request.profile = apicontractsv1.customerProfileType()
|
|
35
|
+
request.profile.merchantCustomerId = merchant_id
|
|
36
|
+
request.profile.description = description
|
|
37
|
+
request.profile.email = email
|
|
38
|
+
|
|
39
|
+
return execute_controller(
|
|
40
|
+
apicontrollers.createCustomerProfileController(request)
|
|
41
|
+
)
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
def get_customer_profile(
|
|
45
|
+
customer_profile_id: int, include_issuer_info: bool = False
|
|
46
|
+
) -> ObjectifiedElement | None:
|
|
47
|
+
"""
|
|
48
|
+
`getCustomerProfileRequest <https://developer.authorize.net/api/reference/index.html#customer-profiles-get-customer-profile>`_.
|
|
49
|
+
|
|
50
|
+
:param customer_profile_id: An Authorizenet customer profile id.
|
|
51
|
+
:type customer_profile_id: :py:obj:`int`
|
|
52
|
+
:param include_issuer_info: Whether or not to include issuer info in the response. Default is :py:obj:`False`.
|
|
53
|
+
:type include_issuer_info: :py:obj:`bool`
|
|
54
|
+
:returns: An Authorizenet getCustomerProfile response.
|
|
55
|
+
:rtype: :py:obj:`~lxml.objectify.ObjectifiedElement` | :py:obj:`None`
|
|
56
|
+
|
|
57
|
+
"""
|
|
58
|
+
request = apicontractsv1.getCustomerProfileRequest()
|
|
59
|
+
request.merchantAuthentication = get_merchant_auth()
|
|
60
|
+
request.customerProfileId = str(customer_profile_id)
|
|
61
|
+
request.includeIssuerInfo = str(include_issuer_info).lower()
|
|
62
|
+
|
|
63
|
+
return execute_controller(
|
|
64
|
+
apicontrollers.getCustomerProfileController(request)
|
|
65
|
+
)
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
def get_customer_profile_ids() -> ObjectifiedElement | None:
|
|
69
|
+
"""
|
|
70
|
+
`getCustomerProfileIdsRequest <https://developer.authorize.net/api/reference/index.html#customer-profiles-get-customer-profile-ids>`_.
|
|
71
|
+
|
|
72
|
+
:returns: An Authorizenet getCustomerProfileIds response.
|
|
73
|
+
:rtype: :py:obj:`~lxml.objectify.ObjectifiedElement` | :py:obj:`None`
|
|
74
|
+
|
|
75
|
+
"""
|
|
76
|
+
request = apicontractsv1.getCustomerProfileIdsRequest()
|
|
77
|
+
request.merchantAuthentication = get_merchant_auth()
|
|
78
|
+
|
|
79
|
+
return execute_controller(
|
|
80
|
+
apicontrollers.getCustomerProfileIdsController(request)
|
|
81
|
+
)
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
def update_customer_profile(
|
|
85
|
+
profile: apicontractsv1.customerProfileExType,
|
|
86
|
+
) -> ObjectifiedElement | None:
|
|
87
|
+
"""
|
|
88
|
+
`updateCustomerProfileRequest <https://developer.authorize.net/api/reference/index.html#customer-profiles-update-customer-profile>`_.
|
|
89
|
+
|
|
90
|
+
:param profile: An Authorizenet customer profile ex element.
|
|
91
|
+
:type profile: :py:obj:`~authorizenet.apicontractsv1.customerProfileExType`
|
|
92
|
+
:returns: An Authorizenet updateCustomerProfile response.
|
|
93
|
+
:rtype: :py:obj:`~lxml.objectify.ObjectifiedElement` | :py:obj:`None`
|
|
94
|
+
|
|
95
|
+
"""
|
|
96
|
+
request = apicontractsv1.updateCustomerProfileRequest()
|
|
97
|
+
request.merchantAuthentication = get_merchant_auth()
|
|
98
|
+
request.profile = profile
|
|
99
|
+
|
|
100
|
+
return execute_controller(
|
|
101
|
+
apicontrollers.updateCustomerProfileController(request)
|
|
102
|
+
)
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
def delete_customer_profile(
|
|
106
|
+
customer_profile_id: int,
|
|
107
|
+
) -> ObjectifiedElement | None:
|
|
108
|
+
"""
|
|
109
|
+
`deleteCustomerProfileRequest <https://developer.authorize.net/api/reference/index.html#customer-profiles-delete-customer-profile>`_.
|
|
110
|
+
|
|
111
|
+
:param customer_profile_id: An Authorizenet customer profile id.
|
|
112
|
+
:type customer_profile_id: :py:obj:`int`
|
|
113
|
+
:returns: An Authorizenet deleteCustomerProfile response.
|
|
114
|
+
:rtype: :py:obj:`~lxml.objectify.ObjectifiedElement` | :py:obj:`None`
|
|
115
|
+
|
|
116
|
+
"""
|
|
117
|
+
request = apicontractsv1.deleteCustomerProfileRequest()
|
|
118
|
+
request.merchantAuthentication = get_merchant_auth()
|
|
119
|
+
request.customerProfileId = str(customer_profile_id)
|
|
120
|
+
|
|
121
|
+
return execute_controller(
|
|
122
|
+
apicontrollers.deleteCustomerProfileController(request)
|
|
123
|
+
)
|
|
@@ -1,38 +1,44 @@
|
|
|
1
1
|
from authorizenet import apicontractsv1, apicontrollers
|
|
2
|
+
from lxml.objectify import ObjectifiedElement
|
|
2
3
|
|
|
3
|
-
from terminusgps.authorizenet.auth import
|
|
4
|
+
from terminusgps.authorizenet.auth import (
|
|
5
|
+
get_merchant_auth,
|
|
6
|
+
get_validation_mode,
|
|
7
|
+
)
|
|
4
8
|
from terminusgps.authorizenet.controllers import execute_controller
|
|
5
9
|
|
|
6
10
|
__all__ = [
|
|
7
11
|
"create_customer_payment_profile",
|
|
8
|
-
"delete_customer_payment_profile",
|
|
9
12
|
"get_customer_payment_profile",
|
|
10
|
-
"update_customer_payment_profile",
|
|
11
13
|
"validate_customer_payment_profile",
|
|
14
|
+
"update_customer_payment_profile",
|
|
15
|
+
"delete_customer_payment_profile",
|
|
12
16
|
]
|
|
13
17
|
|
|
14
18
|
|
|
15
19
|
def create_customer_payment_profile(
|
|
16
20
|
customer_profile_id: int,
|
|
17
|
-
|
|
18
|
-
|
|
21
|
+
payment_profile: apicontractsv1.customerPaymentProfileType,
|
|
22
|
+
validate: bool = False,
|
|
23
|
+
) -> ObjectifiedElement | None:
|
|
19
24
|
"""
|
|
20
25
|
`createCustomerPaymentProfileRequest <https://developer.authorize.net/api/reference/index.html#customer-profiles-create-customer-payment-profile>`_.
|
|
21
26
|
|
|
22
27
|
:param customer_profile_id: An Authorizenet customer profile id.
|
|
23
28
|
:type customer_profile_id: :py:obj:`int`
|
|
24
|
-
:param
|
|
25
|
-
:type
|
|
29
|
+
:param payment_profile: An Authorizenet payment profile element.
|
|
30
|
+
:type payment_profile: :py:obj:`~authorizenet.apicontractsv1.customerPaymentProfileType`
|
|
26
31
|
:returns: An Authorizenet createCustomerPaymentProfile response.
|
|
27
|
-
:rtype: :py:obj:`
|
|
32
|
+
:rtype: :py:obj:`~lxml.objectify.ObjectifiedElement` | :py:obj:`None`
|
|
28
33
|
|
|
29
34
|
"""
|
|
30
|
-
request = apicontractsv1.createCustomerPaymentProfileRequest(
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
35
|
+
request = apicontractsv1.createCustomerPaymentProfileRequest()
|
|
36
|
+
request.merchantAuthentication = get_merchant_auth()
|
|
37
|
+
request.customerProfileId = str(customer_profile_id)
|
|
38
|
+
request.paymentProfile = payment_profile
|
|
39
|
+
if validate:
|
|
40
|
+
request.validationMode = get_validation_mode()
|
|
41
|
+
|
|
36
42
|
return execute_controller(
|
|
37
43
|
apicontrollers.createCustomerPaymentProfileController(request)
|
|
38
44
|
)
|
|
@@ -40,36 +46,36 @@ def create_customer_payment_profile(
|
|
|
40
46
|
|
|
41
47
|
def get_customer_payment_profile(
|
|
42
48
|
customer_profile_id: int,
|
|
43
|
-
|
|
49
|
+
payment_profile_id: int,
|
|
44
50
|
include_issuer_info: bool = False,
|
|
45
|
-
):
|
|
51
|
+
) -> ObjectifiedElement | None:
|
|
46
52
|
"""
|
|
47
53
|
`getCustomerPaymentProfileRequest <https://developer.authorize.net/api/reference/index.html#customer-profiles-get-customer-payment-profile>`_.
|
|
48
54
|
|
|
49
55
|
:param customer_profile_id: An Authorizenet customer profile id.
|
|
50
56
|
:type customer_profile_id: :py:obj:`int`
|
|
51
|
-
:param
|
|
52
|
-
:type
|
|
53
|
-
:param include_issuer_info: Whether
|
|
57
|
+
:param payment_profile_id: An Authorizenet customer payment profile id.
|
|
58
|
+
:type payment_profile_id: :py:obj:`int`
|
|
59
|
+
:param include_issuer_info: Whether to include issuer info in the response. Default is :py:obj:`False`.
|
|
54
60
|
:type include_issuer_info: :py:obj:`bool`
|
|
55
61
|
:returns: An Authorizenet getCustomerPaymentProfile response.
|
|
56
|
-
:rtype: :py:obj:`
|
|
62
|
+
:rtype: :py:obj:`~lxml.objectify.ObjectifiedElement` | :py:obj:`None`
|
|
57
63
|
|
|
58
64
|
"""
|
|
59
|
-
request = apicontractsv1.getCustomerPaymentProfileRequest(
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
+
request = apicontractsv1.getCustomerPaymentProfileRequest()
|
|
66
|
+
request.merchantAuthentication = get_merchant_auth()
|
|
67
|
+
request.customerProfileId = str(customer_profile_id)
|
|
68
|
+
request.customerPaymentProfileId = str(payment_profile_id)
|
|
69
|
+
request.includeIssuerInfo = str(include_issuer_info).lower()
|
|
70
|
+
|
|
65
71
|
return execute_controller(
|
|
66
72
|
apicontrollers.getCustomerPaymentProfileController(request)
|
|
67
73
|
)
|
|
68
74
|
|
|
69
75
|
|
|
70
76
|
def validate_customer_payment_profile(
|
|
71
|
-
customer_profile_id: int,
|
|
72
|
-
):
|
|
77
|
+
customer_profile_id: int, payment_profile_id: int
|
|
78
|
+
) -> ObjectifiedElement | None:
|
|
73
79
|
"""
|
|
74
80
|
`validateCustomerPaymentProfileRequest <https://developer.authorize.net/api/reference/index.html#customer-profiles-validate-customer-payment-profile>`_.
|
|
75
81
|
|
|
@@ -78,15 +84,15 @@ def validate_customer_payment_profile(
|
|
|
78
84
|
:param customer_payment_profile_id: An Authorizenet customer payment profile id.
|
|
79
85
|
:type customer_payment_profile_id: :py:obj:`int`
|
|
80
86
|
:returns: An Authorizenet validateCustomerPaymentProfile response.
|
|
81
|
-
:rtype: :py:obj:`
|
|
87
|
+
:rtype: :py:obj:`~lxml.objectify.ObjectifiedElement` | :py:obj:`None`
|
|
82
88
|
|
|
83
89
|
"""
|
|
84
|
-
request = apicontractsv1.validateCustomerPaymentProfileRequest(
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
+
request = apicontractsv1.validateCustomerPaymentProfileRequest()
|
|
91
|
+
request.merchantAuthentication = get_merchant_auth()
|
|
92
|
+
request.customerProfileId = str(customer_profile_id)
|
|
93
|
+
request.customerPaymentProfileId = str(payment_profile_id)
|
|
94
|
+
request.validationMode = get_validation_mode()
|
|
95
|
+
|
|
90
96
|
return execute_controller(
|
|
91
97
|
apicontrollers.validateCustomerPaymentProfileController(request)
|
|
92
98
|
)
|
|
@@ -94,53 +100,59 @@ def validate_customer_payment_profile(
|
|
|
94
100
|
|
|
95
101
|
def update_customer_payment_profile(
|
|
96
102
|
customer_profile_id: int,
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
103
|
+
payment_profile_id: int,
|
|
104
|
+
payment_profile: apicontractsv1.customerPaymentProfileType,
|
|
105
|
+
validate: bool = False,
|
|
106
|
+
) -> ObjectifiedElement | None:
|
|
100
107
|
"""
|
|
101
108
|
`updateCustomerPaymentProfileRequest <https://developer.authorize.net/api/reference/index.html#customer-profiles-update-customer-payment-profile>`_.
|
|
102
109
|
|
|
103
110
|
:param customer_profile_id: An Authorizenet customer profile id.
|
|
104
111
|
:type customer_profile_id: :py:obj:`int`
|
|
105
|
-
:param
|
|
106
|
-
:type
|
|
107
|
-
:param
|
|
108
|
-
:type
|
|
112
|
+
:param payment_profile_id: An Authorizenet customer payment profile id.
|
|
113
|
+
:type payment_profile_id: :py:obj:`int`
|
|
114
|
+
:param payment_profile: An Authorizenet payment profile element.
|
|
115
|
+
:type payment_profile: :py:obj:`~authorizenet.apicontractsv1.customerPaymentProfileType`
|
|
116
|
+
:param validate: Whether to validate the updated payment profile. Default is :py:obj:`False`.
|
|
117
|
+
:type validate: :py:obj:`bool`
|
|
109
118
|
:returns: An Authorizenet updateCustomerPaymentProfile response.
|
|
110
|
-
:rtype: :py:obj:`
|
|
119
|
+
:rtype: :py:obj:`~lxml.objectify.ObjectifiedElement` | :py:obj:`None`
|
|
111
120
|
|
|
112
121
|
"""
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
122
|
+
if not hasattr(payment_profile, "customerPaymentProfileId"):
|
|
123
|
+
payment_profile.customerPaymentProfileId = str(payment_profile_id)
|
|
124
|
+
|
|
125
|
+
request = apicontractsv1.updateCustomerPaymentProfileRequest()
|
|
126
|
+
request.merchantAuthentication = get_merchant_auth()
|
|
127
|
+
request.customerProfileId = str(customer_profile_id)
|
|
128
|
+
request.paymentProfile = payment_profile
|
|
129
|
+
if validate:
|
|
130
|
+
request.validationMode = get_validation_mode()
|
|
131
|
+
|
|
120
132
|
return execute_controller(
|
|
121
133
|
apicontrollers.updateCustomerPaymentProfileController(request)
|
|
122
134
|
)
|
|
123
135
|
|
|
124
136
|
|
|
125
137
|
def delete_customer_payment_profile(
|
|
126
|
-
customer_profile_id: int,
|
|
127
|
-
):
|
|
138
|
+
customer_profile_id: int, payment_profile_id: int
|
|
139
|
+
) -> ObjectifiedElement | None:
|
|
128
140
|
"""
|
|
129
141
|
`deleteCustomerPaymentProfileRequest <https://developer.authorize.net/api/reference/index.html#customer-profiles-delete-customer-payment-profile>`_.
|
|
130
142
|
|
|
131
143
|
:param customer_profile_id: An Authorizenet customer profile id.
|
|
132
144
|
:type customer_profile_id: :py:obj:`int`
|
|
133
|
-
:param
|
|
134
|
-
:type
|
|
145
|
+
:param payment_profile_id: An Authorizenet customer payment profile id.
|
|
146
|
+
:type payment_profile_id: :py:obj:`int`
|
|
135
147
|
:returns: An Authorizenet deleteCustomerPaymentProfile response.
|
|
136
|
-
:rtype: :py:obj:`
|
|
148
|
+
:rtype: :py:obj:`~lxml.objectify.ObjectifiedElement` | :py:obj:`None`
|
|
137
149
|
|
|
138
150
|
"""
|
|
139
|
-
request = apicontractsv1.deleteCustomerPaymentProfileRequest(
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
151
|
+
request = apicontractsv1.deleteCustomerPaymentProfileRequest()
|
|
152
|
+
request.merchantAuthentication = get_merchant_auth()
|
|
153
|
+
request.customerProfileId = str(customer_profile_id)
|
|
154
|
+
request.customerPaymentProfileId = str(payment_profile_id)
|
|
155
|
+
|
|
144
156
|
return execute_controller(
|
|
145
157
|
apicontrollers.deleteCustomerPaymentProfileController(request)
|
|
146
158
|
)
|
|
@@ -1,26 +1,42 @@
|
|
|
1
1
|
from authorizenet import apicontractsv1, apicontrollers
|
|
2
|
+
from lxml.objectify import ObjectifiedElement
|
|
2
3
|
|
|
3
4
|
from terminusgps.authorizenet.auth import get_merchant_auth
|
|
4
5
|
from terminusgps.authorizenet.controllers import execute_controller
|
|
5
6
|
|
|
7
|
+
__all__ = [
|
|
8
|
+
"create_subscription",
|
|
9
|
+
"get_subscription",
|
|
10
|
+
"get_subscription_status",
|
|
11
|
+
"update_subscription",
|
|
12
|
+
"cancel_subscription",
|
|
13
|
+
]
|
|
6
14
|
|
|
7
|
-
|
|
15
|
+
|
|
16
|
+
def create_subscription(
|
|
17
|
+
subscription: apicontractsv1.ARBSubscriptionType,
|
|
18
|
+
) -> ObjectifiedElement | None:
|
|
8
19
|
"""
|
|
9
20
|
`ARBCreateSubscriptionRequest <https://developer.authorize.net/api/reference/index.html#recurring-billing-create-a-subscription>`_.
|
|
10
21
|
|
|
11
|
-
:param
|
|
12
|
-
:type
|
|
22
|
+
:param subscription: An Authorizenet ARBSubscriptionType element.
|
|
23
|
+
:type subscription: :py:obj:`~authorizenet.apicontractsv1.ARBSubscriptionType`
|
|
13
24
|
:returns: An Authorizenet ARBCreateSubscription response.
|
|
14
|
-
:rtype: :py:obj:`
|
|
25
|
+
:rtype: :py:obj:`~lxml.objectify.ObjectifiedElement` | :py:obj:`None`
|
|
15
26
|
|
|
16
27
|
"""
|
|
17
|
-
request = apicontractsv1.ARBCreateSubscriptionRequest(
|
|
18
|
-
|
|
28
|
+
request = apicontractsv1.ARBCreateSubscriptionRequest()
|
|
29
|
+
request.merchantAuthentication = get_merchant_auth()
|
|
30
|
+
request.subscription = subscription
|
|
31
|
+
|
|
32
|
+
return execute_controller(
|
|
33
|
+
apicontrollers.ARBCreateSubscriptionController(request)
|
|
19
34
|
)
|
|
20
|
-
return execute_controller(apicontrollers.ARBCreateSubscriptionController(request))
|
|
21
35
|
|
|
22
36
|
|
|
23
|
-
def get_subscription(
|
|
37
|
+
def get_subscription(
|
|
38
|
+
subscription_id: int, include_transactions: bool = True
|
|
39
|
+
) -> ObjectifiedElement | None:
|
|
24
40
|
"""
|
|
25
41
|
`ARBGetSubscriptionRequest <https://developer.authorize.net/api/reference/index.html#recurring-billing-get-subscription>`_.
|
|
26
42
|
|
|
@@ -29,7 +45,7 @@ def get_subscription(subscription_id: int, include_transactions: bool = True):
|
|
|
29
45
|
:param include_transactions: Whether or not to include the subscription transaction list in the response. Default is :py:obj:`True`.
|
|
30
46
|
:type include_transactions: :py:obj:`bool`
|
|
31
47
|
:returns: An Authorizenet ARBGetSubscription response.
|
|
32
|
-
:rtype: :py:obj:`
|
|
48
|
+
:rtype: :py:obj:`~lxml.objectify.ObjectifiedElement` | :py:obj:`None`
|
|
33
49
|
|
|
34
50
|
"""
|
|
35
51
|
request = apicontractsv1.ARBGetSubscriptionRequest(
|
|
@@ -37,21 +53,24 @@ def get_subscription(subscription_id: int, include_transactions: bool = True):
|
|
|
37
53
|
subscriptionId=str(subscription_id),
|
|
38
54
|
includeTransactions=str(include_transactions).lower(),
|
|
39
55
|
)
|
|
40
|
-
return execute_controller(
|
|
56
|
+
return execute_controller(
|
|
57
|
+
apicontrollers.ARBGetSubscriptionController(request)
|
|
58
|
+
)
|
|
41
59
|
|
|
42
60
|
|
|
43
|
-
def get_subscription_status(subscription_id: int):
|
|
61
|
+
def get_subscription_status(subscription_id: int) -> ObjectifiedElement | None:
|
|
44
62
|
"""
|
|
45
63
|
`ARBGetSubscriptionStatusRequest <https://developer.authorize.net/api/reference/index.html#recurring-billing-get-subscription-status>`_.
|
|
46
64
|
|
|
47
65
|
:param subscription_id: An Authorizenet subscription id.
|
|
48
66
|
:type subscription_id: :py:obj:`int`
|
|
49
67
|
:returns: An Authorizenet ARBGetSubscriptionStatus response.
|
|
50
|
-
:rtype: :py:obj:`
|
|
68
|
+
:rtype: :py:obj:`~lxml.objectify.ObjectifiedElement` | :py:obj:`None`
|
|
51
69
|
|
|
52
70
|
"""
|
|
53
71
|
request = apicontractsv1.ARBGetSubscriptionStatusRequest(
|
|
54
|
-
merchantAuthentication=get_merchant_auth(),
|
|
72
|
+
merchantAuthentication=get_merchant_auth(),
|
|
73
|
+
subscriptionId=str(subscription_id),
|
|
55
74
|
)
|
|
56
75
|
return execute_controller(
|
|
57
76
|
apicontrollers.ARBGetSubscriptionStatusController(request)
|
|
@@ -60,7 +79,7 @@ def get_subscription_status(subscription_id: int):
|
|
|
60
79
|
|
|
61
80
|
def update_subscription(
|
|
62
81
|
subscription_id: int, subscription_obj: apicontractsv1.ARBSubscriptionType
|
|
63
|
-
):
|
|
82
|
+
) -> ObjectifiedElement | None:
|
|
64
83
|
"""
|
|
65
84
|
`ARBUpdateSubscriptionRequest <https://developer.authorize.net/api/reference/index.html#recurring-billing-update-a-subscription>`_.
|
|
66
85
|
|
|
@@ -69,7 +88,7 @@ def update_subscription(
|
|
|
69
88
|
:param subscription_obj: An Authorizenet subscription object.
|
|
70
89
|
:type subscription_obj: :py:obj:`~authorizenet.apicontractsv1.ARBSubscriptionType`
|
|
71
90
|
:returns: An Authorizenet ARBUpdateSubscription response.
|
|
72
|
-
:rtype: :py:obj:`
|
|
91
|
+
:rtype: :py:obj:`~lxml.objectify.ObjectifiedElement` | :py:obj:`None`
|
|
73
92
|
|
|
74
93
|
"""
|
|
75
94
|
request = apicontractsv1.ARBUpdateSubscriptionRequest(
|
|
@@ -77,20 +96,25 @@ def update_subscription(
|
|
|
77
96
|
subscriptionId=str(subscription_id),
|
|
78
97
|
subscription=subscription_obj,
|
|
79
98
|
)
|
|
80
|
-
return execute_controller(
|
|
99
|
+
return execute_controller(
|
|
100
|
+
apicontrollers.ARBUpdateSubscriptionController(request)
|
|
101
|
+
)
|
|
81
102
|
|
|
82
103
|
|
|
83
|
-
def cancel_subscription(subscription_id: int):
|
|
104
|
+
def cancel_subscription(subscription_id: int) -> ObjectifiedElement | None:
|
|
84
105
|
"""
|
|
85
106
|
`ARBCancelSubscriptionRequest <https://developer.authorize.net/api/reference/index.html#recurring-billing-cancel-a-subscription>`_.
|
|
86
107
|
|
|
87
108
|
:param subscription_id: An Authorizenet subscription id.
|
|
88
109
|
:type subscription_id: :py:obj:`int`
|
|
89
110
|
:returns: An Authorizenet ARBCancelSubscription response.
|
|
90
|
-
:rtype: :py:obj:`
|
|
111
|
+
:rtype: :py:obj:`~lxml.objectify.ObjectifiedElement` | :py:obj:`None`
|
|
91
112
|
|
|
92
113
|
"""
|
|
93
114
|
request = apicontractsv1.ARBCancelSubscriptionRequest(
|
|
94
|
-
merchantAuthentication=get_merchant_auth(),
|
|
115
|
+
merchantAuthentication=get_merchant_auth(),
|
|
116
|
+
subscriptionId=str(subscription_id),
|
|
117
|
+
)
|
|
118
|
+
return execute_controller(
|
|
119
|
+
apicontrollers.ARBCancelSubscriptionController(request)
|
|
95
120
|
)
|
|
96
|
-
return execute_controller(apicontrollers.ARBCancelSubscriptionController(request))
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
from datetime import datetime
|
|
2
|
+
|
|
3
|
+
from authorizenet import apicontractsv1, apicontrollers
|
|
4
|
+
from lxml.objectify import ObjectifiedElement
|
|
5
|
+
|
|
6
|
+
from terminusgps.authorizenet.auth import get_merchant_auth
|
|
7
|
+
from terminusgps.authorizenet.controllers import execute_controller
|
|
8
|
+
|
|
9
|
+
__all__ = []
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
def get_settled_batch_list(
|
|
13
|
+
start: datetime, end: datetime, include_statistics: bool = False
|
|
14
|
+
) -> ObjectifiedElement | None:
|
|
15
|
+
"""
|
|
16
|
+
`getSettledBatchListRequest <https://developer.authorize.net/api/reference/index.html#transaction-reporting-get-settled-batch-list>`_.
|
|
17
|
+
|
|
18
|
+
:param start: First settlement date.
|
|
19
|
+
:type start: :py:obj:`~datetime.datetime`
|
|
20
|
+
:param end: Last settlement date.
|
|
21
|
+
:type end: :py:obj:`~datetime.datetime`
|
|
22
|
+
:returns: An Authorizenet getSettledBatchListResponse element.
|
|
23
|
+
:rtype: :py:obj:`~lxml.objectify.ObjectifiedElement` | :py:obj:`None`
|
|
24
|
+
|
|
25
|
+
"""
|
|
26
|
+
request = apicontractsv1.getSettledBatchListRequest()
|
|
27
|
+
request.merchantAuthentication = get_merchant_auth()
|
|
28
|
+
request.includeStatistics = str(include_statistics).lower()
|
|
29
|
+
request.firstSettlementDate = start
|
|
30
|
+
request.lastSettlementDate = end
|
|
31
|
+
|
|
32
|
+
return execute_controller(
|
|
33
|
+
apicontrollers.getSettledBatchListController(request)
|
|
34
|
+
)
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
def get_transaction_list(
|
|
38
|
+
batch_id: int,
|
|
39
|
+
ordering: str = "submitTimeUTC",
|
|
40
|
+
descending: bool = False,
|
|
41
|
+
limit: int = 1000,
|
|
42
|
+
offset: int = 0,
|
|
43
|
+
) -> ObjectifiedElement | None:
|
|
44
|
+
"""
|
|
45
|
+
`getTransactionListRequest <https://developer.authorize.net/api/reference/index.html#transaction-reporting-get-transaction-list>`_.
|
|
46
|
+
|
|
47
|
+
:param batch_id: An Authorizenet transaction batch id.
|
|
48
|
+
:type batch_id :py:obj:`int`
|
|
49
|
+
:param ordering: An Authorizenet transaction list ordering string. Default is :py:obj:`"submitTimeUTC"`.
|
|
50
|
+
:type ordering: :py:obj:`str`
|
|
51
|
+
:param descending: Whether to sort the transaction list in descending order. Default is :py:obj:`False` (ascending order).
|
|
52
|
+
:type descending: :py:obj:`bool`
|
|
53
|
+
:param limit: Total number of transactions to return in the list.
|
|
54
|
+
:type limit: :py:obj:`int`
|
|
55
|
+
:param offset: Page number to return results from.
|
|
56
|
+
:type offset: :py:obj:`int`
|
|
57
|
+
:returns: An Authorizenet getTransactionListResponse element.
|
|
58
|
+
:rtype: :py:obj:`~lxml.objectify.ObjectifiedElement` | :py:obj:`None`
|
|
59
|
+
|
|
60
|
+
"""
|
|
61
|
+
sorting = apicontractsv1.TransactionListSorting()
|
|
62
|
+
sorting.orderBy = ordering
|
|
63
|
+
sorting.orderDescending = str(descending).lower()
|
|
64
|
+
|
|
65
|
+
paging = apicontractsv1.Paging()
|
|
66
|
+
paging.limit = str(limit)
|
|
67
|
+
paging.offset = str(offset)
|
|
68
|
+
|
|
69
|
+
request = apicontractsv1.getTransactionListRequest()
|
|
70
|
+
request.merchantAuthentication = get_merchant_auth()
|
|
71
|
+
request.batchId = str(batch_id)
|
|
72
|
+
request.sorting = sorting
|
|
73
|
+
request.paging = paging
|
|
74
|
+
|
|
75
|
+
return execute_controller(
|
|
76
|
+
apicontrollers.getTransactionListController(request)
|
|
77
|
+
)
|
|
@@ -1,19 +1,15 @@
|
|
|
1
|
-
import
|
|
1
|
+
from django.db import models
|
|
2
|
+
from django.utils.translation import gettext_lazy as _
|
|
2
3
|
|
|
3
4
|
ANET_XMLNS = "{AnetApi/xml/v1/schema/AnetApiSchema.xsd}"
|
|
4
5
|
"""Authorizenet XML namespace."""
|
|
5
6
|
|
|
6
7
|
|
|
7
|
-
class AuthorizenetSubscriptionStatus(
|
|
8
|
-
"""Authorizenet subscription
|
|
8
|
+
class AuthorizenetSubscriptionStatus(models.TextChoices):
|
|
9
|
+
"""An Authorizenet subscription status."""
|
|
9
10
|
|
|
10
|
-
ACTIVE = "active"
|
|
11
|
-
""
|
|
12
|
-
|
|
13
|
-
""
|
|
14
|
-
|
|
15
|
-
"""A suspended subscription."""
|
|
16
|
-
CANCELED = "canceled"
|
|
17
|
-
"""A canceled subscription."""
|
|
18
|
-
TERMINATED = "terminated"
|
|
19
|
-
"""A terminated subscription."""
|
|
11
|
+
ACTIVE = "active", _("Active")
|
|
12
|
+
EXPIRED = "expired", _("Expired")
|
|
13
|
+
SUSPENDED = "suspended", _("Suspended")
|
|
14
|
+
CANCELED = "canceled", _("Canceled")
|
|
15
|
+
TERMINATED = "terminated", _("Terminated")
|
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
import typing
|
|
2
|
-
|
|
3
1
|
from authorizenet.apicontrollersbase import APIOperationBase
|
|
2
|
+
from lxml.objectify import ObjectifiedElement
|
|
4
3
|
|
|
5
4
|
from .auth import get_environment
|
|
6
5
|
|
|
7
6
|
|
|
8
|
-
def execute_controller(
|
|
7
|
+
def execute_controller(
|
|
8
|
+
controller: APIOperationBase,
|
|
9
|
+
) -> ObjectifiedElement | None:
|
|
9
10
|
"""
|
|
10
11
|
Executes an Authorizenet API controller and returns its response.
|
|
11
12
|
|
|
@@ -13,15 +14,12 @@ def execute_controller(controller: APIOperationBase) -> dict[str, typing.Any] |
|
|
|
13
14
|
:type controller: :py:obj:`~authorizenet.apicontrollersbase.APIOperationBase`
|
|
14
15
|
:raises AuthorizenetControllerExecutionError: If the API call fails.
|
|
15
16
|
:returns: An Authorizenet API response, if any.
|
|
16
|
-
:rtype: :py:obj
|
|
17
|
+
:rtype: :py:obj:`~lxml.objectify.ObjectifiedElement` | :py:obj:`None`
|
|
17
18
|
|
|
18
19
|
"""
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
response = controller.getresponse()
|
|
23
|
-
except Exception:
|
|
24
|
-
response = None
|
|
20
|
+
controller.setenvironment(get_environment())
|
|
21
|
+
controller.execute()
|
|
22
|
+
response = controller.getresponse()
|
|
25
23
|
|
|
26
24
|
if response is not None and response.messages.resultCode != "Ok":
|
|
27
25
|
raise AuthorizenetControllerExecutionError(
|
|
@@ -31,26 +29,6 @@ def execute_controller(controller: APIOperationBase) -> dict[str, typing.Any] |
|
|
|
31
29
|
return response
|
|
32
30
|
|
|
33
31
|
|
|
34
|
-
class AuthorizenetControllerExecutor:
|
|
35
|
-
"""Allows objects to use :py:meth:`execute_controller` to execute Authorizenet API controllers."""
|
|
36
|
-
|
|
37
|
-
@staticmethod
|
|
38
|
-
def execute_controller(
|
|
39
|
-
controller: APIOperationBase,
|
|
40
|
-
) -> dict[str, typing.Any] | None:
|
|
41
|
-
"""
|
|
42
|
-
Executes an Authorizenet API controller and returns its response.
|
|
43
|
-
|
|
44
|
-
:param controller: An Authorizenet API controller.
|
|
45
|
-
:type controller: :py:obj:`~authorizenet.apicontrollersbase.APIOperationBase`
|
|
46
|
-
:raises AuthorizenetControllerExecutionError: If the API call fails.
|
|
47
|
-
:returns: An Authorizenet API response, if any.
|
|
48
|
-
:rtype: :py:obj:`dict` | :py:obj:`None`
|
|
49
|
-
|
|
50
|
-
"""
|
|
51
|
-
return execute_controller(controller)
|
|
52
|
-
|
|
53
|
-
|
|
54
32
|
class AuthorizenetControllerExecutionError(Exception):
|
|
55
33
|
"""Raised when an Authorizenet API controller fails to execute."""
|
|
56
34
|
|
|
@@ -32,7 +32,10 @@ def validate_credit_card_number(value: str) -> None:
|
|
|
32
32
|
|
|
33
33
|
checksum = 0
|
|
34
34
|
checksum += sum(
|
|
35
|
-
[
|
|
35
|
+
[
|
|
36
|
+
digit * 2 if digit * 2 <= 9 else (digit * 2) % 9 or 9
|
|
37
|
+
for digit in even_digits
|
|
38
|
+
]
|
|
36
39
|
)
|
|
37
40
|
checksum += sum([digit for digit in odd_digits])
|
|
38
41
|
|
|
@@ -61,7 +64,9 @@ def validate_credit_card_expiry_month(value: str) -> None:
|
|
|
61
64
|
)
|
|
62
65
|
if not int(value) > 0:
|
|
63
66
|
raise ValidationError(
|
|
64
|
-
_(
|
|
67
|
+
_(
|
|
68
|
+
"Expiration month can only be a positive value, got '%(value)s'."
|
|
69
|
+
),
|
|
65
70
|
code="invalid",
|
|
66
71
|
params={"value": value},
|
|
67
72
|
)
|
|
@@ -97,7 +102,9 @@ def validate_credit_card_expiry_year(value: str) -> None:
|
|
|
97
102
|
)
|
|
98
103
|
if not int(value) > 0:
|
|
99
104
|
raise ValidationError(
|
|
100
|
-
_(
|
|
105
|
+
_(
|
|
106
|
+
"Expiration year can only be a positive value, got '%(value)s'."
|
|
107
|
+
),
|
|
101
108
|
code="invalid",
|
|
102
109
|
params={"value": value},
|
|
103
110
|
)
|
terminusgps/django/validators.py
CHANGED
|
@@ -30,26 +30,26 @@ def validate_e164_phone_number(value: str) -> None:
|
|
|
30
30
|
code="invalid",
|
|
31
31
|
params={"value": value},
|
|
32
32
|
)
|
|
33
|
-
if len(value) <
|
|
33
|
+
if len(value) < 12:
|
|
34
34
|
raise ValidationError(
|
|
35
35
|
_(
|
|
36
|
-
"E.164 phone number cannot be less than
|
|
36
|
+
"E.164 phone number cannot be less than 12 characters in length, got %(len)s."
|
|
37
37
|
),
|
|
38
38
|
code="invalid",
|
|
39
39
|
params={"len": len(value)},
|
|
40
40
|
)
|
|
41
|
-
if len(value) >
|
|
41
|
+
if len(value) > 15:
|
|
42
42
|
raise ValidationError(
|
|
43
43
|
_(
|
|
44
|
-
"E.164 phone number cannot be greater than
|
|
44
|
+
"E.164 phone number cannot be greater than 15 characters in length, got %(len)s."
|
|
45
45
|
),
|
|
46
46
|
code="invalid",
|
|
47
47
|
params={"len": len(value)},
|
|
48
48
|
)
|
|
49
49
|
|
|
50
|
-
country_code
|
|
51
|
-
area_code
|
|
52
|
-
subscriber_number
|
|
50
|
+
country_code = value[:-10]
|
|
51
|
+
area_code = value[-10:-7]
|
|
52
|
+
subscriber_number = value[-7:]
|
|
53
53
|
|
|
54
54
|
if len(country_code) < 2 or len(country_code) > 5:
|
|
55
55
|
raise ValidationError(
|
|
@@ -77,7 +77,7 @@ def validate_e164_phone_number(value: str) -> None:
|
|
|
77
77
|
)
|
|
78
78
|
if not area_code.isdigit():
|
|
79
79
|
raise ValidationError(
|
|
80
|
-
_("E.164 phone number must have a valid area code, got '%(area_code)s'"),
|
|
80
|
+
_("E.164 phone number must have a valid area code, got '%(area_code)s'."),
|
|
81
81
|
code="invalid",
|
|
82
82
|
params={"area_code": area_code},
|
|
83
83
|
)
|
|
@@ -92,7 +92,7 @@ def validate_e164_phone_number(value: str) -> None:
|
|
|
92
92
|
if not subscriber_number.isdigit():
|
|
93
93
|
raise ValidationError(
|
|
94
94
|
_(
|
|
95
|
-
"E.164 phone number must have a valid subscriber number, got '%(subscriber_number)s'"
|
|
95
|
+
"E.164 phone number must have a valid subscriber number, got '%(subscriber_number)s'."
|
|
96
96
|
),
|
|
97
97
|
code="invalid",
|
|
98
98
|
params={"subscriber_number": subscriber_number},
|
|
@@ -1,107 +0,0 @@
|
|
|
1
|
-
from authorizenet import apicontractsv1, apicontrollers
|
|
2
|
-
|
|
3
|
-
from terminusgps.authorizenet.auth import get_merchant_auth
|
|
4
|
-
from terminusgps.authorizenet.controllers import execute_controller
|
|
5
|
-
|
|
6
|
-
__all__ = [
|
|
7
|
-
"create_customer_profile",
|
|
8
|
-
"delete_customer_profile",
|
|
9
|
-
"get_customer_profile",
|
|
10
|
-
"get_customer_profile_ids",
|
|
11
|
-
"update_customer_profile",
|
|
12
|
-
]
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
def create_customer_profile(merchant_id: int | str, email: str, description: str = ""):
|
|
16
|
-
"""
|
|
17
|
-
`createCustomerProfileRequest <https://developer.authorize.net/api/reference/index.html#customer-profiles-create-customer-profile>`_.
|
|
18
|
-
|
|
19
|
-
:param merchant_id: A merchant designated customer id.
|
|
20
|
-
:type merchant_id: :py:obj:`int` | :py:obj:`str`
|
|
21
|
-
:param email: A customer email address.
|
|
22
|
-
:type email: :py:obj:`str`
|
|
23
|
-
:param description: An optional customer description.
|
|
24
|
-
:type description: :py:obj:`str`
|
|
25
|
-
:returns: An Authorizenet createCustomerProfile response.
|
|
26
|
-
:rtype: :py:obj:`dict`
|
|
27
|
-
|
|
28
|
-
"""
|
|
29
|
-
request = apicontractsv1.createCustomerProfileRequest(
|
|
30
|
-
merchantAuthentication=get_merchant_auth(),
|
|
31
|
-
profile=apicontractsv1.customerProfileType(
|
|
32
|
-
merchantCustomerId=str(merchant_id), description=description, email=email
|
|
33
|
-
),
|
|
34
|
-
)
|
|
35
|
-
return execute_controller(apicontrollers.createCustomerProfileController(request))
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
def get_customer_profile(customer_profile_id: int, include_issuer_info: bool = False):
|
|
39
|
-
"""
|
|
40
|
-
`getCustomerProfileRequest <https://developer.authorize.net/api/reference/index.html#customer-profiles-get-customer-profile>`_.
|
|
41
|
-
|
|
42
|
-
:param customer_profile_id: An Authorizenet customer profile id.
|
|
43
|
-
:type customer_profile_id: :py:obj:`int`
|
|
44
|
-
:param include_issuer_info: Whether or not to include issuer info in the response. Default is :py:obj:`False`.
|
|
45
|
-
:type include_issuer_info: :py:obj:`bool`
|
|
46
|
-
:returns: An Authorizenet getCustomerProfile response.
|
|
47
|
-
:rtype: :py:obj:`dict`
|
|
48
|
-
|
|
49
|
-
"""
|
|
50
|
-
request = apicontractsv1.getCustomerProfileRequest(
|
|
51
|
-
merchantAuthentication=get_merchant_auth(),
|
|
52
|
-
customerProfileId=str(customer_profile_id),
|
|
53
|
-
includeIssuerInfo=str(include_issuer_info).lower(),
|
|
54
|
-
)
|
|
55
|
-
return execute_controller(apicontrollers.getCustomerProfileController(request))
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
def get_customer_profile_ids():
|
|
59
|
-
"""
|
|
60
|
-
`getCustomerProfileIdsRequest <https://developer.authorize.net/api/reference/index.html#customer-profiles-get-customer-profile-ids>`_.
|
|
61
|
-
|
|
62
|
-
:returns: An Authorizenet getCustomerProfileIds response.
|
|
63
|
-
:rtype: :py:obj:`dict`
|
|
64
|
-
|
|
65
|
-
"""
|
|
66
|
-
request = apicontractsv1.getCustomerProfileIdsRequest(
|
|
67
|
-
merchantAuthentication=get_merchant_auth()
|
|
68
|
-
)
|
|
69
|
-
return execute_controller(apicontrollers.getCustomerProfileIdsController(request))
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
def update_customer_profile(
|
|
73
|
-
customer_profile_id: int, new_profile: apicontractsv1.customerProfileExType
|
|
74
|
-
):
|
|
75
|
-
"""
|
|
76
|
-
`updateCustomerProfileRequest <https://developer.authorize.net/api/reference/index.html#customer-profiles-update-customer-profile>`_.
|
|
77
|
-
|
|
78
|
-
:param customer_profile_id: An Authorizenet customer profile id.
|
|
79
|
-
:type customer_profile_id: :py:obj:`int`
|
|
80
|
-
:param new_profile: An Authorizenet customer profile ex object.
|
|
81
|
-
:type new_profile: :py:obj:`~authorizenet.apicontractsv1.customerProfileExType`
|
|
82
|
-
:returns: An Authorizenet updateCustomerProfile response.
|
|
83
|
-
:rtype: :py:obj:`dict`
|
|
84
|
-
|
|
85
|
-
"""
|
|
86
|
-
new_profile.customerProfileId = str(customer_profile_id)
|
|
87
|
-
request = apicontractsv1.updateCustomerProfileRequest(
|
|
88
|
-
merchantAuthentication=get_merchant_auth(), profile=new_profile
|
|
89
|
-
)
|
|
90
|
-
return execute_controller(apicontrollers.updateCustomerProfileController(request))
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
def delete_customer_profile(customer_profile_id: int):
|
|
94
|
-
"""
|
|
95
|
-
`deleteCustomerProfileRequest <https://developer.authorize.net/api/reference/index.html#customer-profiles-delete-customer-profile>`_.
|
|
96
|
-
|
|
97
|
-
:param customer_profile_id: An Authorizenet customer profile id.
|
|
98
|
-
:type customer_profile_id: :py:obj:`int`
|
|
99
|
-
:returns: An Authorizenet deleteCustomerProfile response.
|
|
100
|
-
:rtype: :py:obj:`dict`
|
|
101
|
-
|
|
102
|
-
"""
|
|
103
|
-
request = apicontractsv1.deleteCustomerProfileRequest(
|
|
104
|
-
merchantAuthentication=get_merchant_auth(),
|
|
105
|
-
customerProfileId=str(customer_profile_id),
|
|
106
|
-
)
|
|
107
|
-
return execute_controller(apicontrollers.deleteCustomerProfileController(request))
|
|
@@ -1,172 +0,0 @@
|
|
|
1
|
-
import datetime
|
|
2
|
-
import decimal
|
|
3
|
-
|
|
4
|
-
from authorizenet import apicontractsv1, apicontrollers
|
|
5
|
-
from django import forms
|
|
6
|
-
from django.conf import settings
|
|
7
|
-
|
|
8
|
-
from .auth import get_merchant_auth
|
|
9
|
-
from .controllers import AuthorizenetControllerExecutor
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
def calculate_amount_plus_tax(
|
|
13
|
-
amount: decimal.Decimal, tax_rate: decimal.Decimal | None = None
|
|
14
|
-
) -> decimal.Decimal:
|
|
15
|
-
"""
|
|
16
|
-
Returns the amount + tax. Uses :confval:`DEFAULT_TAX_RATE` if ``tax_rate`` wasn't provided.
|
|
17
|
-
|
|
18
|
-
:param amount: Amount to add tax to.
|
|
19
|
-
:type amount: :py:obj:`~decimal.Decimal`
|
|
20
|
-
:param tax_rate: A tax rate to use in the calculation.
|
|
21
|
-
:type tax_rate: :py:obj:`~decimal.Decimal` | :py:obj:`None`
|
|
22
|
-
:returns: The amount + tax.
|
|
23
|
-
:rtype: :py:obj:`~decimal.Decimal`
|
|
24
|
-
|
|
25
|
-
"""
|
|
26
|
-
if tax_rate is None:
|
|
27
|
-
tax_rate = settings.DEFAULT_TAX_RATE
|
|
28
|
-
return round(amount * (1 + tax_rate), ndigits=2)
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
def get_merchant_details() -> dict | None:
|
|
32
|
-
"""
|
|
33
|
-
Returns Authorizenet merchant details.
|
|
34
|
-
|
|
35
|
-
`getMerchantDetailsRequest <http://developer.authorize.net/api/reference/index.html#transaction-reporting-get-merchant-details>`_
|
|
36
|
-
|
|
37
|
-
:raises AuthorizenetControllerExecutionError: If the API call fails.
|
|
38
|
-
:returns: A merchant details object, if found.
|
|
39
|
-
:rtype: :py:obj:`dict` | :py:obj:`None`
|
|
40
|
-
|
|
41
|
-
"""
|
|
42
|
-
request = apicontractsv1.getMerchantDetailsRequest(
|
|
43
|
-
merchantAuthentication=get_merchant_auth()
|
|
44
|
-
)
|
|
45
|
-
controller = apicontrollers.getMerchantDetailsController(request)
|
|
46
|
-
return AuthorizenetControllerExecutor.execute_controller(controller)
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
def get_transaction(id: int | str) -> dict | None:
|
|
50
|
-
"""
|
|
51
|
-
Returns Authorizenet transaction details by id.
|
|
52
|
-
|
|
53
|
-
`getTransactionDetailsRequest <https://developer.authorize.net/api/reference/index.html#transaction-reporting-get-transaction-details>`_
|
|
54
|
-
|
|
55
|
-
:param id: An Authorizenet transaction id.
|
|
56
|
-
:type id: :py:obj:`int` | :py:obj:`str`
|
|
57
|
-
:raises ValueError: If ``id`` was provided as a string containing non-digits.
|
|
58
|
-
:raises AuthorizenetControllerExecutionError: If the API call fails.
|
|
59
|
-
:returns: A transaction object, if found.
|
|
60
|
-
:rtype: :py:obj:`dict` | :py:obj:`None`
|
|
61
|
-
|
|
62
|
-
"""
|
|
63
|
-
if isinstance(id, str) and not id.isdigit():
|
|
64
|
-
raise ValueError(f"'id' can only contain digits, got '{id}'.")
|
|
65
|
-
|
|
66
|
-
request = apicontractsv1.getTransactionDetailsRequest(
|
|
67
|
-
merchantAuthentication=get_merchant_auth(), transId=str(id)
|
|
68
|
-
)
|
|
69
|
-
controller = apicontrollers.getTransactionDetailsController(request)
|
|
70
|
-
return AuthorizenetControllerExecutor.execute_controller(controller)
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
def generate_monthly_subscription_schedule(
|
|
74
|
-
start_date: datetime.date, total_occurrences: int = 9999, trial_occurrences: int = 0
|
|
75
|
-
) -> apicontractsv1.paymentScheduleType:
|
|
76
|
-
return apicontractsv1.paymentScheduleType(
|
|
77
|
-
interval=apicontractsv1.paymentScheduleTypeInterval(
|
|
78
|
-
length=1, unit=apicontractsv1.ARBSubscriptionUnitEnum.months
|
|
79
|
-
),
|
|
80
|
-
startDate=f"{start_date:%Y-%m-%d}",
|
|
81
|
-
totalOccurrences=str(total_occurrences),
|
|
82
|
-
trialOccurrences=str(trial_occurrences),
|
|
83
|
-
)
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
def get_customer_profile_ids() -> list[int]:
|
|
87
|
-
"""
|
|
88
|
-
Returns a list of all customer profile ids in Authorizenet.
|
|
89
|
-
|
|
90
|
-
:raises AuthorizenetControllerExecutionError: If the API call fails.
|
|
91
|
-
:returns: A list of all customer profile ids in Authorizenet.
|
|
92
|
-
:rtype: :py:obj:`list`
|
|
93
|
-
|
|
94
|
-
"""
|
|
95
|
-
request = apicontractsv1.getCustomerProfileIdsRequest(
|
|
96
|
-
merchantAuthentication=get_merchant_auth()
|
|
97
|
-
)
|
|
98
|
-
controller = apicontrollers.getCustomerProfileIdsController(request)
|
|
99
|
-
response = AuthorizenetControllerExecutor.execute_controller(controller)
|
|
100
|
-
if response is None or "ids" not in response.getchildren():
|
|
101
|
-
return []
|
|
102
|
-
return [int(id) for id in response.ids.getchildren()]
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
def generate_customer_address(form: forms.Form) -> apicontractsv1.customerAddressType:
|
|
106
|
-
"""
|
|
107
|
-
Takes a form and returns a :py:obj:`~authorizenet.apicontractsv1.customerAddressType`.
|
|
108
|
-
|
|
109
|
-
Required form fields:
|
|
110
|
-
|
|
111
|
-
+----------------+------------------------------------------------------------+
|
|
112
|
-
| name | type |
|
|
113
|
-
+================+============================================================+
|
|
114
|
-
| ``address`` | :py:obj:`~authorizenet.apicontractsv1.customerAddressType` |
|
|
115
|
-
+----------------+------------------------------------------------------------+
|
|
116
|
-
| ``first_name`` | :py:obj:`str` |
|
|
117
|
-
+----------------+------------------------------------------------------------+
|
|
118
|
-
| ``last_name`` | :py:obj:`str` |
|
|
119
|
-
+----------------+------------------------------------------------------------+
|
|
120
|
-
|
|
121
|
-
:param form: A Django form.
|
|
122
|
-
:type form: :py:obj:`~django.forms.Form`
|
|
123
|
-
:raises ValueError: If ``address`` wasn't in the form.
|
|
124
|
-
:raises ValueError: If ``first_name`` wasn't in the form.
|
|
125
|
-
:raises ValueError: If ``last_name`` wasn't in the form.
|
|
126
|
-
:returns: A customer address object.
|
|
127
|
-
:rtype: :py:obj:`~authorizenet.apicontractsv1.customerAddressType`
|
|
128
|
-
|
|
129
|
-
"""
|
|
130
|
-
required_fields: list[str] = ["address", "first_name", "last_name"]
|
|
131
|
-
for field in required_fields:
|
|
132
|
-
if field not in form.cleaned_data or form.cleaned_data.get(field) is None:
|
|
133
|
-
raise ValueError(
|
|
134
|
-
f"'{field}' was not provided by the form, got '{form.cleaned_data.get(field)}'."
|
|
135
|
-
)
|
|
136
|
-
|
|
137
|
-
address: apicontractsv1.customerAddressType = form.cleaned_data["address"]
|
|
138
|
-
address.firstName = form.cleaned_data["first_name"]
|
|
139
|
-
address.lastName = form.cleaned_data["last_name"]
|
|
140
|
-
if form.cleaned_data.get("phone"):
|
|
141
|
-
address.phone = form.cleaned_data["phone"]
|
|
142
|
-
return address
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
def generate_customer_payment(form: forms.Form) -> apicontractsv1.paymentType:
|
|
146
|
-
"""
|
|
147
|
-
Takes a form and returns a :py:obj:`~authorizenet.apicontractsv1.paymentType`.
|
|
148
|
-
|
|
149
|
-
Required form fields:
|
|
150
|
-
|
|
151
|
-
+-----------------+-------------------------------------------------------+
|
|
152
|
-
| name | type |
|
|
153
|
-
+=================+=======================================================+
|
|
154
|
-
| ``credit_card`` | :py:obj:`~authorizenet.apicontractsv1.creditCardType` |
|
|
155
|
-
+-----------------+-------------------------------------------------------+
|
|
156
|
-
|
|
157
|
-
:param form: A Django form.
|
|
158
|
-
:type form: :py:obj:`~django.forms.Form`
|
|
159
|
-
:raises ValueError: If ``credit_card`` wasn't in the form.
|
|
160
|
-
:returns: A payment object.
|
|
161
|
-
:rtype: :py:obj:`~authorizenet.apicontractsv1.paymentType`
|
|
162
|
-
|
|
163
|
-
"""
|
|
164
|
-
required_fields: list[str] = ["credit_card"]
|
|
165
|
-
for field in required_fields:
|
|
166
|
-
if field not in form.cleaned_data or form.cleaned_data.get(field) is None:
|
|
167
|
-
raise ValueError(
|
|
168
|
-
f"'{field}' was not provided by the form, got '{form.cleaned_data.get(field)}'."
|
|
169
|
-
)
|
|
170
|
-
|
|
171
|
-
credit_card: apicontractsv1.creditCardType = form.cleaned_data["credit_card"]
|
|
172
|
-
return apicontractsv1.paymentType(creditCard=credit_card)
|
|
File without changes
|
{python_terminusgps-42.2.3.dist-info → python_terminusgps-43.0.0.dist-info}/licenses/COPYING
RENAMED
|
File without changes
|