python-terminusgps 1.9.4__tar.gz → 1.9.8__tar.gz
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.
- {python_terminusgps-1.9.4 → python_terminusgps-1.9.8}/PKG-INFO +1 -1
- {python_terminusgps-1.9.4 → python_terminusgps-1.9.8}/pyproject.toml +1 -1
- python_terminusgps-1.9.8/terminusgps/authorizenet/auth.py +27 -0
- python_terminusgps-1.9.8/terminusgps/authorizenet/profiles/__init__.py +3 -0
- python_terminusgps-1.9.8/terminusgps/authorizenet/profiles/addresses.py +91 -0
- python_terminusgps-1.9.8/terminusgps/authorizenet/profiles/base.py +84 -0
- {python_terminusgps-1.9.4 → python_terminusgps-1.9.8}/terminusgps/authorizenet/profiles/customers.py +34 -37
- {python_terminusgps-1.9.4 → python_terminusgps-1.9.8}/terminusgps/authorizenet/profiles/payments.py +62 -54
- {python_terminusgps-1.9.4 → python_terminusgps-1.9.8}/terminusgps/settings.py +0 -2
- {python_terminusgps-1.9.4 → python_terminusgps-1.9.8}/uv.lock +1 -1
- python_terminusgps-1.9.4/terminusgps/authorizenet/auth.py +0 -35
- python_terminusgps-1.9.4/terminusgps/authorizenet/profiles/addresses.py +0 -83
- python_terminusgps-1.9.4/terminusgps/authorizenet/profiles/base.py +0 -62
- {python_terminusgps-1.9.4 → python_terminusgps-1.9.8}/.gitignore +0 -0
- {python_terminusgps-1.9.4 → python_terminusgps-1.9.8}/COPYING +0 -0
- {python_terminusgps-1.9.4 → python_terminusgps-1.9.8}/README.md +0 -0
- {python_terminusgps-1.9.4 → python_terminusgps-1.9.8}/requirements.txt +0 -0
- {python_terminusgps-1.9.4 → python_terminusgps-1.9.8}/terminusgps/__init__.py +0 -0
- {python_terminusgps-1.9.4 → python_terminusgps-1.9.8}/terminusgps/authorizenet/__init__.py +0 -0
- {python_terminusgps-1.9.4 → python_terminusgps-1.9.8}/terminusgps/aws/__init__.py +0 -0
- {python_terminusgps-1.9.4 → python_terminusgps-1.9.8}/terminusgps/aws/secrets.py +0 -0
- {python_terminusgps-1.9.4 → python_terminusgps-1.9.8}/terminusgps/wialon/__init__.py +0 -0
- {python_terminusgps-1.9.4 → python_terminusgps-1.9.8}/terminusgps/wialon/constants.py +0 -0
- {python_terminusgps-1.9.4 → python_terminusgps-1.9.8}/terminusgps/wialon/errors.py +0 -0
- {python_terminusgps-1.9.4 → python_terminusgps-1.9.8}/terminusgps/wialon/flags.py +0 -0
- {python_terminusgps-1.9.4 → python_terminusgps-1.9.8}/terminusgps/wialon/items/__init__.py +0 -0
- {python_terminusgps-1.9.4 → python_terminusgps-1.9.8}/terminusgps/wialon/items/base.py +0 -0
- {python_terminusgps-1.9.4 → python_terminusgps-1.9.8}/terminusgps/wialon/items/resource.py +0 -0
- {python_terminusgps-1.9.4 → python_terminusgps-1.9.8}/terminusgps/wialon/items/retranslator.py +0 -0
- {python_terminusgps-1.9.4 → python_terminusgps-1.9.8}/terminusgps/wialon/items/route.py +0 -0
- {python_terminusgps-1.9.4 → python_terminusgps-1.9.8}/terminusgps/wialon/items/unit.py +0 -0
- {python_terminusgps-1.9.4 → python_terminusgps-1.9.8}/terminusgps/wialon/items/unit_group.py +0 -0
- {python_terminusgps-1.9.4 → python_terminusgps-1.9.8}/terminusgps/wialon/items/user.py +0 -0
- {python_terminusgps-1.9.4 → python_terminusgps-1.9.8}/terminusgps/wialon/session.py +0 -0
- {python_terminusgps-1.9.4 → python_terminusgps-1.9.8}/terminusgps/wialon/utils.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: python-terminusgps
|
|
3
|
-
Version: 1.9.
|
|
3
|
+
Version: 1.9.8
|
|
4
4
|
Summary: Provides abstractions/utilities for working with Wialon API, Authorize.NET API, AWS API, and more.
|
|
5
5
|
Project-URL: Documentation, https://app.terminusgps.com/docs/apps/python-terminusgps/index.html
|
|
6
6
|
Project-URL: Repository, https://github.com/terminusgps/python-terminusgps
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "python-terminusgps"
|
|
3
|
-
version = "1.9.
|
|
3
|
+
version = "1.9.8"
|
|
4
4
|
description = "Provides abstractions/utilities for working with Wialon API, Authorize.NET API, AWS API, and more."
|
|
5
5
|
readme = "README.md"
|
|
6
6
|
authors = [ {name = "Blake Nall", email = "blake@terminusgps.com" } ]
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
from authorizenet.apicontractsv1 import merchantAuthenticationType
|
|
2
|
+
from authorizenet.constants import constants
|
|
3
|
+
|
|
4
|
+
from django.conf import settings
|
|
5
|
+
from django.core.exceptions import ImproperlyConfigured
|
|
6
|
+
|
|
7
|
+
if not hasattr(settings, "DEBUG"):
|
|
8
|
+
raise ImproperlyConfigured("'DEBUG' setting is required.")
|
|
9
|
+
if not hasattr(settings, "MERCHANT_AUTH_LOGIN_ID"):
|
|
10
|
+
raise ImproperlyConfigured("'MERCHANT_AUTH_LOGIN_ID' setting is required.")
|
|
11
|
+
if not hasattr(settings, "MERCHANT_AUTH_TRANSACTION_KEY"):
|
|
12
|
+
raise ImproperlyConfigured("'MERCHANT_AUTH_TRANSACTION_KEY' setting is required.")
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
def get_merchant_auth() -> merchantAuthenticationType:
|
|
16
|
+
return merchantAuthenticationType(
|
|
17
|
+
name=str(settings.MERCHANT_AUTH_LOGIN_ID),
|
|
18
|
+
transactionKey=str(settings.MERCHANT_AUTH_TRANSACTION_KEY),
|
|
19
|
+
)
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
def get_environment() -> str:
|
|
23
|
+
return constants.SANDBOX if settings.DEBUG else constants.PRODUCTION
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
def get_validation_mode() -> str:
|
|
27
|
+
return "testMode" if settings.DEBUG else "liveMode"
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
from authorizenet import apicontractsv1, apicontrollers
|
|
2
|
+
from authorizenet.apicontractsv1 import customerAddressType
|
|
3
|
+
|
|
4
|
+
from terminusgps.authorizenet.profiles.base import AuthorizenetSubProfileBase
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
class AddressProfile(AuthorizenetSubProfileBase):
|
|
8
|
+
def create(self, **kwargs) -> int:
|
|
9
|
+
"""
|
|
10
|
+
Creates an Authorize.NET address profile.
|
|
11
|
+
|
|
12
|
+
:param shipping_addr: An Authorize.NET customer address.
|
|
13
|
+
:type shipping_addr: :py:obj:`~authorizenet.apicontractsv1.customerAddressType`
|
|
14
|
+
:raises ValueError: If no customer address was provided.
|
|
15
|
+
:raises TypeError: If the customer address is not a :py:obj:`~authorizenet.apicontractsv1.customerAddressType` object.
|
|
16
|
+
:returns: The new address profile's id.
|
|
17
|
+
:rtype: :py:obj:`int`
|
|
18
|
+
|
|
19
|
+
"""
|
|
20
|
+
shipping_addr = kwargs.get("shipping_addr")
|
|
21
|
+
|
|
22
|
+
if not shipping_addr:
|
|
23
|
+
raise ValueError("'shipping_addr' is required on creation.")
|
|
24
|
+
|
|
25
|
+
if not isinstance(shipping_addr, customerAddressType):
|
|
26
|
+
raise TypeError(
|
|
27
|
+
f"'shipping_addr' must be customerAddressType, got '{type(shipping_addr)}'."
|
|
28
|
+
)
|
|
29
|
+
|
|
30
|
+
response = self._authorizenet_create_shipping_address(shipping_addr)
|
|
31
|
+
return int(response.customerAddressId)
|
|
32
|
+
|
|
33
|
+
def update(self, shipping_addr: customerAddressType) -> dict:
|
|
34
|
+
"""Updates the Authorize.NET payment profile."""
|
|
35
|
+
return self._authorizenet_update_shipping_address(shipping_addr)
|
|
36
|
+
|
|
37
|
+
def delete(self) -> dict:
|
|
38
|
+
"""Deletes the Authorize.NET payment profile."""
|
|
39
|
+
return self._authorizenet_delete_shipping_address()
|
|
40
|
+
|
|
41
|
+
def get_details(self) -> dict:
|
|
42
|
+
return self._authorizenet_get_shipping_address()
|
|
43
|
+
|
|
44
|
+
def _authorizenet_get_shipping_address(self) -> dict:
|
|
45
|
+
assert self.id, "'id' was not set."
|
|
46
|
+
|
|
47
|
+
request = apicontractsv1.getCustomerShippingAddressRequest(
|
|
48
|
+
merchantAuthentication=self.merchantAuthentication,
|
|
49
|
+
customerProfileId=self.customerProfileId,
|
|
50
|
+
customerAddressId=self.id,
|
|
51
|
+
)
|
|
52
|
+
controller = apicontrollers.getCustomerShippingAddressController(request)
|
|
53
|
+
response = self.execute_controller(controller)
|
|
54
|
+
return response
|
|
55
|
+
|
|
56
|
+
def _authorizenet_create_shipping_address(self, addr: customerAddressType) -> dict:
|
|
57
|
+
request = apicontractsv1.createCustomerShippingAddressRequest(
|
|
58
|
+
merchantAuthentication=self.merchantAuthentication,
|
|
59
|
+
customerProfileId=self.customerProfileId,
|
|
60
|
+
address=addr,
|
|
61
|
+
defaultShippingAddress=self.default,
|
|
62
|
+
)
|
|
63
|
+
controller = apicontrollers.createCustomerShippingAddressController(request)
|
|
64
|
+
response = self.execute_controller(controller)
|
|
65
|
+
return response
|
|
66
|
+
|
|
67
|
+
def _authorizenet_update_shipping_address(self, addr: customerAddressType) -> dict:
|
|
68
|
+
assert self.id, "'id' was not set."
|
|
69
|
+
addr.customerAddressId = self.id
|
|
70
|
+
|
|
71
|
+
request = apicontractsv1.updateCustomerShippingAddressRequest(
|
|
72
|
+
merchantAuthentication=self.merchantAuthentication,
|
|
73
|
+
customerProfileId=self.customerProfileId,
|
|
74
|
+
address=addr,
|
|
75
|
+
default=self.default,
|
|
76
|
+
)
|
|
77
|
+
controller = apicontrollers.updateCustomerShippingAddressController(request)
|
|
78
|
+
response = self.execute_controller(controller)
|
|
79
|
+
return response
|
|
80
|
+
|
|
81
|
+
def _authorizenet_delete_shipping_address(self) -> dict:
|
|
82
|
+
assert self.id, "'id' was not set."
|
|
83
|
+
|
|
84
|
+
request = apicontractsv1.deleteCustomerShippingAddressRequest(
|
|
85
|
+
merchantAuthentication=self.merchantAuthentication,
|
|
86
|
+
customerProfileId=self.customerProfileId,
|
|
87
|
+
customerAddressId=self.id,
|
|
88
|
+
)
|
|
89
|
+
controller = apicontrollers.deleteCustomerShippingAddressController(request)
|
|
90
|
+
response = self.execute_controller(controller)
|
|
91
|
+
return response
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
from abc import abstractmethod
|
|
2
|
+
|
|
3
|
+
from authorizenet.apicontractsv1 import merchantAuthenticationType
|
|
4
|
+
from authorizenet.apicontrollersbase import APIOperationBase
|
|
5
|
+
|
|
6
|
+
from ..auth import get_merchant_auth, get_environment, get_validation_mode
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class AuthorizenetProfileBase:
|
|
10
|
+
def __init__(
|
|
11
|
+
self, merchant_id: int | str, id: int | str | None = None, **kwargs
|
|
12
|
+
) -> None:
|
|
13
|
+
self._merchantCustomerId = merchant_id
|
|
14
|
+
self._id = str(id) if id else self.create(**kwargs)
|
|
15
|
+
|
|
16
|
+
def __str__(self) -> str:
|
|
17
|
+
return f"#{self.id}"
|
|
18
|
+
|
|
19
|
+
def execute_controller(self, controller: APIOperationBase) -> dict:
|
|
20
|
+
"""
|
|
21
|
+
Executes an Authorize.NET controller and returns its response.
|
|
22
|
+
|
|
23
|
+
:param controller: An Authorize.NET API controller.
|
|
24
|
+
:raises ValueError: If the API call fails.
|
|
25
|
+
:returns: The Authorize.NET API response.
|
|
26
|
+
:rtype: :py:obj:`dict`
|
|
27
|
+
|
|
28
|
+
"""
|
|
29
|
+
controller.setenvironment(self.environment)
|
|
30
|
+
controller.execute()
|
|
31
|
+
response = controller.getresponse()
|
|
32
|
+
|
|
33
|
+
if response.messages.resultCode != "Ok":
|
|
34
|
+
raise ValueError(response.messages.message[0]["text"].text)
|
|
35
|
+
return response
|
|
36
|
+
|
|
37
|
+
@property
|
|
38
|
+
def merchantCustomerId(self) -> str:
|
|
39
|
+
return str(self._merchantCustomerId)
|
|
40
|
+
|
|
41
|
+
@property
|
|
42
|
+
def id(self) -> str:
|
|
43
|
+
return str(self._id)
|
|
44
|
+
|
|
45
|
+
@property
|
|
46
|
+
def merchantAuthentication(self) -> merchantAuthenticationType:
|
|
47
|
+
return get_merchant_auth()
|
|
48
|
+
|
|
49
|
+
@property
|
|
50
|
+
def environment(self) -> str:
|
|
51
|
+
return get_environment()
|
|
52
|
+
|
|
53
|
+
@abstractmethod
|
|
54
|
+
def create(self, **kwargs) -> int:
|
|
55
|
+
raise NotImplementedError("Subclasses must implement this method.")
|
|
56
|
+
|
|
57
|
+
@abstractmethod
|
|
58
|
+
def update(self, *args, **kwargs) -> dict:
|
|
59
|
+
raise NotImplementedError("Subclasses must implement this method.")
|
|
60
|
+
|
|
61
|
+
@abstractmethod
|
|
62
|
+
def delete(self, *args, **kwargs) -> dict:
|
|
63
|
+
raise NotImplementedError("Subclasses must implement this method.")
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
class AuthorizenetSubProfileBase(AuthorizenetProfileBase):
|
|
67
|
+
def __init__(
|
|
68
|
+
self, customer_profile_id: int | str, default: bool, *args, **kwargs
|
|
69
|
+
) -> None:
|
|
70
|
+
self._customerProfileId = customer_profile_id
|
|
71
|
+
self._default = default
|
|
72
|
+
return super().__init__(*args, **kwargs)
|
|
73
|
+
|
|
74
|
+
@property
|
|
75
|
+
def validationMode(self) -> str:
|
|
76
|
+
return get_validation_mode()
|
|
77
|
+
|
|
78
|
+
@property
|
|
79
|
+
def default(self) -> str:
|
|
80
|
+
return str(self._default).lower()
|
|
81
|
+
|
|
82
|
+
@property
|
|
83
|
+
def customerProfileId(self) -> str:
|
|
84
|
+
return str(self._customerProfileId)
|
{python_terminusgps-1.9.4 → python_terminusgps-1.9.8}/terminusgps/authorizenet/profiles/customers.py
RENAMED
|
@@ -1,16 +1,5 @@
|
|
|
1
|
-
from authorizenet
|
|
2
|
-
|
|
3
|
-
deleteCustomerProfileController,
|
|
4
|
-
getCustomerProfileController,
|
|
5
|
-
updateCustomerProfileController,
|
|
6
|
-
)
|
|
7
|
-
from authorizenet.apicontractsv1 import (
|
|
8
|
-
customerProfileType,
|
|
9
|
-
createCustomerProfileRequest,
|
|
10
|
-
deleteCustomerProfileRequest,
|
|
11
|
-
getCustomerProfileRequest,
|
|
12
|
-
updateCustomerProfileRequest,
|
|
13
|
-
)
|
|
1
|
+
from authorizenet import apicontractsv1, apicontrollers
|
|
2
|
+
from authorizenet.apicontractsv1 import customerProfileType
|
|
14
3
|
|
|
15
4
|
from terminusgps.authorizenet.profiles.base import AuthorizenetProfileBase
|
|
16
5
|
|
|
@@ -31,15 +20,16 @@ class CustomerProfile(AuthorizenetProfileBase):
|
|
|
31
20
|
if not kwargs.get("email"):
|
|
32
21
|
raise ValueError("'email' is required for creation.")
|
|
33
22
|
|
|
34
|
-
|
|
35
|
-
kwargs["email"], kwargs.get("desc", "")
|
|
23
|
+
response = self._authorizenet_create_customer_profile(
|
|
24
|
+
email=kwargs["email"], desc=kwargs.get("desc", "")
|
|
36
25
|
)
|
|
26
|
+
return int(response.customerProfileId)
|
|
37
27
|
|
|
38
|
-
def update(self, email: str, desc: str = "") ->
|
|
28
|
+
def update(self, email: str, desc: str = "") -> dict:
|
|
39
29
|
"""Updates the customer profile."""
|
|
40
30
|
return self._authorizenet_update_customer_profile(email, desc)
|
|
41
31
|
|
|
42
|
-
def delete(self) ->
|
|
32
|
+
def delete(self) -> dict:
|
|
43
33
|
"""Deletes the customer profile."""
|
|
44
34
|
return self._authorizenet_delete_customer_profile()
|
|
45
35
|
|
|
@@ -57,9 +47,11 @@ class CustomerProfile(AuthorizenetProfileBase):
|
|
|
57
47
|
)
|
|
58
48
|
return addresses if addresses else None
|
|
59
49
|
|
|
60
|
-
def _authorizenet_create_customer_profile(
|
|
50
|
+
def _authorizenet_create_customer_profile(
|
|
51
|
+
self, email: str, desc: str = ""
|
|
52
|
+
) -> dict[str, str]:
|
|
61
53
|
"""Executes a :py:obj:`~authorizenet.apicontractsv1.createCustomerProfileRequest` using the Authorize.NET API."""
|
|
62
|
-
request = createCustomerProfileRequest(
|
|
54
|
+
request = apicontractsv1.createCustomerProfileRequest(
|
|
63
55
|
merchantAuthentication=self.merchantAuthentication,
|
|
64
56
|
profile=customerProfileType(
|
|
65
57
|
merchantCustomerId=self.merchantCustomerId,
|
|
@@ -67,36 +59,28 @@ class CustomerProfile(AuthorizenetProfileBase):
|
|
|
67
59
|
description=desc,
|
|
68
60
|
),
|
|
69
61
|
)
|
|
70
|
-
controller = createCustomerProfileController(request)
|
|
62
|
+
controller = apicontrollers.createCustomerProfileController(request)
|
|
71
63
|
response = self.execute_controller(controller)
|
|
72
|
-
return
|
|
73
|
-
|
|
74
|
-
def _authorizenet_delete_customer_profile(self) -> None:
|
|
75
|
-
"""Executes a :py:obj:`~authorizenet.apicontractsv1.deleteCustomerProfileRequest` using the Authorize.NET API."""
|
|
76
|
-
assert self.id, "'id' was not set."
|
|
77
|
-
request = deleteCustomerProfileRequest(
|
|
78
|
-
merchantAuthentication=self.merchantAuthentication,
|
|
79
|
-
customerProfileId=str(self.id),
|
|
80
|
-
)
|
|
81
|
-
controller = deleteCustomerProfileController(request)
|
|
82
|
-
self.execute_controller(controller)
|
|
64
|
+
return response
|
|
83
65
|
|
|
84
66
|
def _authorizenet_get_customer_profile(self, issuer_info: bool = True) -> dict:
|
|
85
67
|
"""Executes a :py:obj:`~authorizenet.apicontractsv1.getCustomerProfileRequest` using the Authorize.NET API."""
|
|
86
68
|
assert self.id, "'id' was not set."
|
|
87
|
-
|
|
69
|
+
|
|
70
|
+
request = apicontractsv1.getCustomerProfileRequest(
|
|
88
71
|
merchantAuthentication=self.merchantAuthentication,
|
|
89
72
|
customerProfileId=self.id,
|
|
90
73
|
includeIssuerInfo=str(issuer_info).lower(),
|
|
91
74
|
)
|
|
92
|
-
controller = getCustomerProfileController(request)
|
|
75
|
+
controller = apicontrollers.getCustomerProfileController(request)
|
|
93
76
|
response = self.execute_controller(controller)
|
|
94
77
|
return response
|
|
95
78
|
|
|
96
|
-
def _authorizenet_update_customer_profile(self, email: str, desc: str = "") ->
|
|
79
|
+
def _authorizenet_update_customer_profile(self, email: str, desc: str = "") -> dict:
|
|
97
80
|
"""Executes an :py:obj:`~authorizenet.apicontractsv1.updateCustomerProfileRequest` using the Authorize.NET API."""
|
|
98
81
|
assert self.id, "'id' was not set."
|
|
99
|
-
|
|
82
|
+
|
|
83
|
+
request = apicontractsv1.updateCustomerProfileRequest(
|
|
100
84
|
merchantAuthentication=self.merchantAuthentication,
|
|
101
85
|
profile=customerProfileType(
|
|
102
86
|
merchantCustomerId=self.merchantCustomerId,
|
|
@@ -105,5 +89,18 @@ class CustomerProfile(AuthorizenetProfileBase):
|
|
|
105
89
|
customerProfileId=self.id,
|
|
106
90
|
),
|
|
107
91
|
)
|
|
108
|
-
controller = updateCustomerProfileController(request)
|
|
109
|
-
self.execute_controller(controller)
|
|
92
|
+
controller = apicontrollers.updateCustomerProfileController(request)
|
|
93
|
+
response = self.execute_controller(controller)
|
|
94
|
+
return response
|
|
95
|
+
|
|
96
|
+
def _authorizenet_delete_customer_profile(self) -> dict:
|
|
97
|
+
"""Executes a :py:obj:`~authorizenet.apicontractsv1.deleteCustomerProfileRequest` using the Authorize.NET API."""
|
|
98
|
+
assert self.id, "'id' was not set."
|
|
99
|
+
|
|
100
|
+
request = apicontractsv1.deleteCustomerProfileRequest(
|
|
101
|
+
merchantAuthentication=self.merchantAuthentication,
|
|
102
|
+
customerProfileId=self.id,
|
|
103
|
+
)
|
|
104
|
+
controller = apicontrollers.deleteCustomerProfileController(request)
|
|
105
|
+
response = self.execute_controller(controller)
|
|
106
|
+
return response
|
{python_terminusgps-1.9.4 → python_terminusgps-1.9.8}/terminusgps/authorizenet/profiles/payments.py
RENAMED
|
@@ -1,25 +1,26 @@
|
|
|
1
|
+
from authorizenet import apicontractsv1, apicontrollers
|
|
1
2
|
from authorizenet.apicontractsv1 import (
|
|
2
|
-
createCustomerPaymentProfileRequest,
|
|
3
3
|
customerAddressType,
|
|
4
|
-
|
|
5
|
-
getCustomerPaymentProfileRequest,
|
|
6
|
-
paymentProfile,
|
|
4
|
+
customerPaymentProfileType,
|
|
7
5
|
paymentType,
|
|
8
|
-
validateCustomerPaymentProfileRequest,
|
|
9
|
-
updateCustomerPaymentProfileRequest,
|
|
10
6
|
)
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
deleteCustomerPaymentProfileController,
|
|
14
|
-
getCustomerPaymentProfileController,
|
|
15
|
-
updateCustomerPaymentProfileController,
|
|
16
|
-
validateCustomerPaymentProfileController,
|
|
17
|
-
)
|
|
18
|
-
from terminusgps.authorizenet.profiles.base import AuthorizenetCustomerProfileBase
|
|
7
|
+
|
|
8
|
+
from terminusgps.authorizenet.profiles.base import AuthorizenetSubProfileBase
|
|
19
9
|
|
|
20
10
|
|
|
21
|
-
class PaymentProfile(
|
|
11
|
+
class PaymentProfile(AuthorizenetSubProfileBase):
|
|
22
12
|
def create(self, **kwargs) -> int:
|
|
13
|
+
"""
|
|
14
|
+
Creates an Authorize.NET payment profile.
|
|
15
|
+
|
|
16
|
+
:param billing_addr: An Authorize.NET customer address.
|
|
17
|
+
:type billing_addr: :py:obj:`~authorizenet.apicontractsv1.customerAddressType`
|
|
18
|
+
:param payment: An Authorize.NET API payment.
|
|
19
|
+
:type payment: :py:obj:`~authorizenet.apicontractsv1.paymentType`
|
|
20
|
+
:returns: The new payment profile's id.
|
|
21
|
+
:rtype: :py:obj:`int`
|
|
22
|
+
|
|
23
|
+
"""
|
|
23
24
|
billing_addr = kwargs.get("billing_addr")
|
|
24
25
|
payment = kwargs.get("payment")
|
|
25
26
|
if not billing_addr:
|
|
@@ -36,41 +37,57 @@ class PaymentProfile(AuthorizenetCustomerProfileBase):
|
|
|
36
37
|
f"'payment' must be customerAddressType, got '{type(payment)}'"
|
|
37
38
|
)
|
|
38
39
|
|
|
39
|
-
|
|
40
|
+
response = self._authorizenet_create_payment_profile(billing_addr, payment)
|
|
41
|
+
return int(response.customerPaymentProfileId)
|
|
40
42
|
|
|
41
|
-
def update(self, billing_addr: customerAddressType, payment: paymentType) ->
|
|
42
|
-
|
|
43
|
+
def update(self, billing_addr: customerAddressType, payment: paymentType) -> dict:
|
|
44
|
+
"""Updates the Authorize.NET payment profile."""
|
|
45
|
+
return self._authorizenet_update_payment_profile(billing_addr, payment)
|
|
43
46
|
|
|
44
|
-
def delete(self) ->
|
|
45
|
-
|
|
47
|
+
def delete(self) -> dict:
|
|
48
|
+
"""Deletes the Authorize.NET payment profile."""
|
|
49
|
+
return self._authorizenet_delete_payment_profile()
|
|
46
50
|
|
|
47
51
|
def get_details(self, issuer_info: bool = False) -> dict:
|
|
48
52
|
return self._authorizenet_get_payment_profile(issuer_info)
|
|
49
53
|
|
|
50
54
|
def _authorizenet_create_payment_profile(
|
|
51
55
|
self, billing_addr: customerAddressType, payment: paymentType
|
|
52
|
-
) ->
|
|
53
|
-
|
|
54
|
-
request = createCustomerPaymentProfileRequest(
|
|
56
|
+
) -> dict:
|
|
57
|
+
request = apicontractsv1.createCustomerPaymentProfileRequest(
|
|
55
58
|
customerProfileId=self.customerProfileId,
|
|
56
|
-
defaultPaymentProfile=self.default,
|
|
57
59
|
merchantAuthentication=self.merchantAuthentication,
|
|
58
|
-
paymentProfile=
|
|
60
|
+
paymentProfile=customerPaymentProfileType(
|
|
61
|
+
billTo=billing_addr, payment=payment, defaultPaymentProfile=self.default
|
|
62
|
+
),
|
|
59
63
|
validationMode=self.validationMode,
|
|
60
64
|
)
|
|
61
|
-
controller = createCustomerPaymentProfileController(request)
|
|
65
|
+
controller = apicontrollers.createCustomerPaymentProfileController(request)
|
|
62
66
|
response = self.execute_controller(controller)
|
|
63
|
-
return
|
|
67
|
+
return response
|
|
68
|
+
|
|
69
|
+
def _authorizenet_get_payment_profile(self, issuer_info: bool = False) -> dict:
|
|
70
|
+
assert self.id, "'id' was not set."
|
|
71
|
+
|
|
72
|
+
request = apicontractsv1.getCustomerPaymentProfileRequest(
|
|
73
|
+
merchantAuthentication=self.merchantAuthentication,
|
|
74
|
+
customerProfileId=self.customerProfileId,
|
|
75
|
+
customerPaymentProfileId=self.id,
|
|
76
|
+
includeIssuerInfo=str(issuer_info).lower(),
|
|
77
|
+
)
|
|
78
|
+
controller = apicontrollers.getCustomerPaymentProfileController(request)
|
|
79
|
+
response = self.execute_controller(controller)
|
|
80
|
+
return response
|
|
64
81
|
|
|
65
82
|
def _authorizenet_update_payment_profile(
|
|
66
83
|
self, billing_addr: customerAddressType, payment: paymentType
|
|
67
|
-
) ->
|
|
68
|
-
"""Executes an :py:obj:`~authorizenet.apicontractsv1.updateCustomerPaymentProfileRequest` using the Authorize.NET API."""
|
|
84
|
+
) -> dict:
|
|
69
85
|
assert self.id, "'id' was not set."
|
|
70
|
-
|
|
86
|
+
|
|
87
|
+
request = apicontractsv1.updateCustomerPaymentProfileRequest(
|
|
71
88
|
merchantAuthentication=self.merchantAuthentication,
|
|
72
89
|
customerProfileId=self.customerProfileId,
|
|
73
|
-
paymentProfile=
|
|
90
|
+
paymentProfile=customerPaymentProfileType(
|
|
74
91
|
billTo=billing_addr,
|
|
75
92
|
payment=payment,
|
|
76
93
|
defaultPaymentProfile=self.default,
|
|
@@ -78,40 +95,31 @@ class PaymentProfile(AuthorizenetCustomerProfileBase):
|
|
|
78
95
|
),
|
|
79
96
|
validationMode=self.validationMode,
|
|
80
97
|
)
|
|
81
|
-
controller = updateCustomerPaymentProfileController(request)
|
|
82
|
-
self.execute_controller(controller)
|
|
98
|
+
controller = apicontrollers.updateCustomerPaymentProfileController(request)
|
|
99
|
+
response = self.execute_controller(controller)
|
|
100
|
+
return response
|
|
83
101
|
|
|
84
|
-
def
|
|
85
|
-
"""Executes a :py:obj:`~authorizenet.apicontractsv1.getCustomerPaymentProfileRequest` using the Authorize.NET API."""
|
|
102
|
+
def _authorizenet_validate_payment_profile(self) -> dict:
|
|
86
103
|
assert self.id, "'id' was not set."
|
|
87
|
-
request = getCustomerPaymentProfileRequest(
|
|
88
|
-
merchantAuthentication=self.merchantAuthentication,
|
|
89
|
-
customerProfileId=self.customerProfileId,
|
|
90
|
-
customerPaymentProfileId=self.id,
|
|
91
|
-
includeIssuerInfo=str(issuer_info).lower(),
|
|
92
|
-
)
|
|
93
|
-
controller = getCustomerPaymentProfileController(request)
|
|
94
|
-
return self.execute_controller(controller)
|
|
95
104
|
|
|
96
|
-
|
|
97
|
-
"""Executes a :py:obj:`~authorizenet.apicontractsv1.validateCustomerPaymentProfileRequest` using the Authorize.NET API."""
|
|
98
|
-
assert self.id, "'id' was not set."
|
|
99
|
-
request = validateCustomerPaymentProfileRequest(
|
|
105
|
+
request = apicontractsv1.validateCustomerPaymentProfileRequest(
|
|
100
106
|
merchantAuthentication=self.merchantAuthentication,
|
|
101
107
|
customerProfileId=self.customerProfileId,
|
|
102
108
|
customerPaymentProfileId=self.id,
|
|
103
109
|
validationMode=self.validationMode,
|
|
104
110
|
)
|
|
105
|
-
controller = validateCustomerPaymentProfileController(request)
|
|
106
|
-
self.execute_controller(controller)
|
|
111
|
+
controller = apicontrollers.validateCustomerPaymentProfileController(request)
|
|
112
|
+
response = self.execute_controller(controller)
|
|
113
|
+
return response
|
|
107
114
|
|
|
108
|
-
def _authorizenet_delete_payment_profile(self) ->
|
|
109
|
-
"""Executes a :py:obj:`~authorizenet.apicontractsv1.deleteCustomerPaymentProfileRequest` using the Authorize.NET API."""
|
|
115
|
+
def _authorizenet_delete_payment_profile(self) -> dict:
|
|
110
116
|
assert self.id, "'id' was not set."
|
|
111
|
-
|
|
117
|
+
|
|
118
|
+
request = apicontractsv1.deleteCustomerPaymentProfileRequest(
|
|
112
119
|
merchantAuthentication=self.merchantAuthentication,
|
|
113
120
|
customerProfileId=self.customerProfileId,
|
|
114
121
|
customerPaymentProfileId=self.id,
|
|
115
122
|
)
|
|
116
|
-
controller = deleteCustomerPaymentProfileController(request)
|
|
117
|
-
self.execute_controller(controller)
|
|
123
|
+
controller = apicontrollers.deleteCustomerPaymentProfileController(request)
|
|
124
|
+
response = self.execute_controller(controller)
|
|
125
|
+
return response
|
|
@@ -6,5 +6,3 @@ WIALON_ADMIN_ID = getenv("WIALON_ADMIN_ID")
|
|
|
6
6
|
WIALON_TOKEN = getenv("WIALON_TOKEN")
|
|
7
7
|
MERCHANT_AUTH_LOGIN_ID = getenv("MERCHANT_AUTH_LOGIN_ID")
|
|
8
8
|
MERCHANT_AUTH_TRANSACTION_KEY = getenv("MERCHANT_AUTH_TRANSACTION_KEY")
|
|
9
|
-
QB_CLIENT_ID = getenv("QB_CLIENT_ID")
|
|
10
|
-
QB_CLIENT_SECRET = getenv("QB_CLIENT_ID")
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
from authorizenet.apicontractsv1 import merchantAuthenticationType
|
|
2
|
-
from authorizenet.constants import constants
|
|
3
|
-
|
|
4
|
-
from django.conf import ImproperlyConfigured, settings
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
def settings_required(settings_list: list[str]):
|
|
8
|
-
def decorator(func):
|
|
9
|
-
def wrapped(*args, **kwargs):
|
|
10
|
-
for setting_name in settings_list:
|
|
11
|
-
if not hasattr(settings, setting_name):
|
|
12
|
-
raise ImproperlyConfigured(f"'{setting_name}' setting is required.")
|
|
13
|
-
return func(*args, **kwargs)
|
|
14
|
-
|
|
15
|
-
return wrapped
|
|
16
|
-
|
|
17
|
-
return decorator
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
@settings_required(["MERCHANT_AUTH_LOGIN_ID", "MERCHANT_AUTH_TRANSACTION_KEY"])
|
|
21
|
-
def get_merchant_auth() -> merchantAuthenticationType:
|
|
22
|
-
return merchantAuthenticationType(
|
|
23
|
-
name=str(settings.MERCHANT_AUTH_LOGIN_ID),
|
|
24
|
-
transactionKey=str(settings.MERCHANT_AUTH_TRANSACTION_KEY),
|
|
25
|
-
)
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
@settings_required(["DEBUG"])
|
|
29
|
-
def get_environment() -> str:
|
|
30
|
-
return constants.SANDBOX if settings.DEBUG else constants.PRODUCTION
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
@settings_required(["DEBUG"])
|
|
34
|
-
def get_validation_mode() -> str:
|
|
35
|
-
return "testMode" if settings.DEBUG else "liveMode"
|
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
from authorizenet.apicontractsv1 import (
|
|
2
|
-
createCustomerShippingAddressRequest,
|
|
3
|
-
customerAddressType,
|
|
4
|
-
deleteCustomerShippingAddressRequest,
|
|
5
|
-
updateCustomerShippingAddressRequest,
|
|
6
|
-
getCustomerShippingAddressRequest,
|
|
7
|
-
getCustomerShippingAddressResponse,
|
|
8
|
-
)
|
|
9
|
-
from authorizenet.apicontrollers import (
|
|
10
|
-
createCustomerShippingAddressController,
|
|
11
|
-
deleteCustomerShippingAddressController,
|
|
12
|
-
getCustomerShippingAddressController,
|
|
13
|
-
updateCustomerShippingAddressController,
|
|
14
|
-
)
|
|
15
|
-
from terminusgps.authorizenet.profiles.base import AuthorizenetCustomerProfileBase
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
class AddressProfile(AuthorizenetCustomerProfileBase):
|
|
19
|
-
def create(self, **kwargs) -> int:
|
|
20
|
-
shipping_addr = kwargs.get("shipping_addr")
|
|
21
|
-
|
|
22
|
-
if not shipping_addr:
|
|
23
|
-
raise ValueError("'shipping_addr' is required on creation.")
|
|
24
|
-
|
|
25
|
-
if not isinstance(shipping_addr, customerAddressType):
|
|
26
|
-
raise TypeError(
|
|
27
|
-
f"'shipping_addr' must be customerAddressType, got '{type(shipping_addr)}'."
|
|
28
|
-
)
|
|
29
|
-
|
|
30
|
-
return self._authorizenet_create_shipping_address(shipping_addr)
|
|
31
|
-
|
|
32
|
-
def delete(self) -> None:
|
|
33
|
-
self._authorizenet_delete_shipping_address()
|
|
34
|
-
|
|
35
|
-
def update(self, shipping_addr: customerAddressType) -> None:
|
|
36
|
-
self._authorizenet_update_shipping_address(shipping_addr)
|
|
37
|
-
|
|
38
|
-
def get_details(self) -> dict:
|
|
39
|
-
return self._authorizenet_get_shipping_address()
|
|
40
|
-
|
|
41
|
-
def _authorizenet_create_shipping_address(self, addr: customerAddressType) -> int:
|
|
42
|
-
request = createCustomerShippingAddressRequest(
|
|
43
|
-
merchantAuthentication=self.merchantAuthentication,
|
|
44
|
-
customerProfileId=self.customerProfileId,
|
|
45
|
-
address=addr,
|
|
46
|
-
defaultShippingAddress=self.default,
|
|
47
|
-
)
|
|
48
|
-
controller = createCustomerShippingAddressController(request)
|
|
49
|
-
response = self.execute_controller(controller)
|
|
50
|
-
return int(response.customerAddressId)
|
|
51
|
-
|
|
52
|
-
def _authorizenet_update_shipping_address(self, addr: customerAddressType) -> None:
|
|
53
|
-
assert self.id, "'id' was not set."
|
|
54
|
-
addr.customerAddressId = self.id
|
|
55
|
-
request = updateCustomerShippingAddressRequest(
|
|
56
|
-
merchantAuthentication=self.merchantAuthentication,
|
|
57
|
-
customerProfileId=self.customerProfileId,
|
|
58
|
-
address=addr,
|
|
59
|
-
default=self.default,
|
|
60
|
-
)
|
|
61
|
-
controller = updateCustomerShippingAddressController(request)
|
|
62
|
-
self.execute_controller(controller)
|
|
63
|
-
|
|
64
|
-
def _authorizenet_get_shipping_address(self) -> dict:
|
|
65
|
-
assert self.id, "'id' was not set."
|
|
66
|
-
request = getCustomerShippingAddressRequest(
|
|
67
|
-
merchantAuthentication=self.merchantAuthentication,
|
|
68
|
-
customerProfileId=self.customerProfileId,
|
|
69
|
-
customerAddressId=self.id,
|
|
70
|
-
)
|
|
71
|
-
controller = getCustomerShippingAddressController(request)
|
|
72
|
-
response = self.execute_controller(controller)
|
|
73
|
-
return response
|
|
74
|
-
|
|
75
|
-
def _authorizenet_delete_shipping_address(self) -> None:
|
|
76
|
-
assert self.id, "'id' was not set."
|
|
77
|
-
request = deleteCustomerShippingAddressRequest(
|
|
78
|
-
merchantAuthentication=self.merchantAuthentication,
|
|
79
|
-
customerProfileId=self.customerProfileId,
|
|
80
|
-
customerAddressId=self.id,
|
|
81
|
-
)
|
|
82
|
-
controller = deleteCustomerShippingAddressController(request)
|
|
83
|
-
self.execute_controller(controller)
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
from authorizenet.apicontractsv1 import merchantAuthenticationType
|
|
2
|
-
from ..auth import get_environment, get_merchant_auth, get_validation_mode
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
class AuthorizenetProfileBase:
|
|
6
|
-
def __init__(
|
|
7
|
-
self, merchant_id: int | str, id: int | str | None = None, **kwargs
|
|
8
|
-
) -> None:
|
|
9
|
-
self.merchant_id = merchant_id
|
|
10
|
-
self.id = str(id) if id else str(self.create(**kwargs))
|
|
11
|
-
|
|
12
|
-
def __str__(self) -> str:
|
|
13
|
-
return f"#{self.id}"
|
|
14
|
-
|
|
15
|
-
@property
|
|
16
|
-
def environment(self) -> str:
|
|
17
|
-
return get_environment()
|
|
18
|
-
|
|
19
|
-
@property
|
|
20
|
-
def merchantAuthentication(self) -> merchantAuthenticationType:
|
|
21
|
-
return get_merchant_auth()
|
|
22
|
-
|
|
23
|
-
@property
|
|
24
|
-
def validationMode(self) -> str:
|
|
25
|
-
return get_validation_mode()
|
|
26
|
-
|
|
27
|
-
@property
|
|
28
|
-
def merchantCustomerId(self) -> str:
|
|
29
|
-
return str(self.merchant_id)
|
|
30
|
-
|
|
31
|
-
def create(self, **kwargs) -> int:
|
|
32
|
-
raise NotImplementedError("Subclasses must implement this method.")
|
|
33
|
-
|
|
34
|
-
def execute_controller(self, controller):
|
|
35
|
-
controller.setenvironment(self.environment)
|
|
36
|
-
controller.execute()
|
|
37
|
-
response = controller.getresponse()
|
|
38
|
-
if response.messages.resultCode != "Ok":
|
|
39
|
-
raise ValueError(response.messages.message[0]["text"].text)
|
|
40
|
-
return response
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
class AuthorizenetCustomerProfileBase(AuthorizenetProfileBase):
|
|
44
|
-
def __init__(
|
|
45
|
-
self, customer_profile_id: int | str, default: bool = False, **kwargs
|
|
46
|
-
) -> None:
|
|
47
|
-
if isinstance(customer_profile_id, str) and not customer_profile_id.isdigit():
|
|
48
|
-
raise ValueError(
|
|
49
|
-
f"'customer_profile_id' must be a digit, got '{customer_profile_id}'."
|
|
50
|
-
)
|
|
51
|
-
|
|
52
|
-
self._default = default
|
|
53
|
-
self.customer_profile_id = customer_profile_id
|
|
54
|
-
return super().__init__(**kwargs)
|
|
55
|
-
|
|
56
|
-
@property
|
|
57
|
-
def customerProfileId(self) -> str:
|
|
58
|
-
return str(self.customer_profile_id)
|
|
59
|
-
|
|
60
|
-
@property
|
|
61
|
-
def default(self) -> str:
|
|
62
|
-
return str(self._default).lower()
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{python_terminusgps-1.9.4 → python_terminusgps-1.9.8}/terminusgps/wialon/items/retranslator.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{python_terminusgps-1.9.4 → python_terminusgps-1.9.8}/terminusgps/wialon/items/unit_group.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|