python-terminusgps 1.9.5__py3-none-any.whl → 1.9.7__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.
- {python_terminusgps-1.9.5.dist-info → python_terminusgps-1.9.7.dist-info}/METADATA +1 -1
- {python_terminusgps-1.9.5.dist-info → python_terminusgps-1.9.7.dist-info}/RECORD +11 -10
- terminusgps/authorizenet/auth.py +8 -16
- terminusgps/authorizenet/profiles/__init__.py +3 -0
- terminusgps/authorizenet/profiles/addresses.py +52 -44
- terminusgps/authorizenet/profiles/base.py +52 -32
- terminusgps/authorizenet/profiles/customers.py +34 -37
- terminusgps/authorizenet/profiles/payments.py +60 -54
- terminusgps/settings.py +0 -2
- {python_terminusgps-1.9.5.dist-info → python_terminusgps-1.9.7.dist-info}/WHEEL +0 -0
- {python_terminusgps-1.9.5.dist-info → python_terminusgps-1.9.7.dist-info}/licenses/COPYING +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.7
|
|
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,11 +1,12 @@
|
|
|
1
1
|
terminusgps/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
2
|
-
terminusgps/settings.py,sha256=
|
|
2
|
+
terminusgps/settings.py,sha256=Mdeuo6ghfW28QVrBqe5mwwX2_Lk79fJ5kLfR9LV7zZM,314
|
|
3
3
|
terminusgps/authorizenet/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
4
|
-
terminusgps/authorizenet/auth.py,sha256=
|
|
5
|
-
terminusgps/authorizenet/profiles/
|
|
6
|
-
terminusgps/authorizenet/profiles/
|
|
7
|
-
terminusgps/authorizenet/profiles/
|
|
8
|
-
terminusgps/authorizenet/profiles/
|
|
4
|
+
terminusgps/authorizenet/auth.py,sha256=kWsqRT9OVEAQuNxDzQNzY1x2SqmvJr-HAbLwgkILntk,997
|
|
5
|
+
terminusgps/authorizenet/profiles/__init__.py,sha256=QKjMKcXpCSCEhv6LBCz0yGP8t0VxAyKyYRS4_HLYnxQ,114
|
|
6
|
+
terminusgps/authorizenet/profiles/addresses.py,sha256=ffAi3LcEOB3Xsr9f4N_PfjSZcN3I9dTKNamoAmnLpo4,3838
|
|
7
|
+
terminusgps/authorizenet/profiles/base.py,sha256=Uk_VwtEVOomyV92ljVn7vcRn8BfwWHu80Jnct0NNlmw,2491
|
|
8
|
+
terminusgps/authorizenet/profiles/customers.py,sha256=iEuNFP6PHuGdFQftgxxKpQFYaGw8IWLjsOaugvEOA-g,4513
|
|
9
|
+
terminusgps/authorizenet/profiles/payments.py,sha256=qOWp-gO6qBCADP98WjoNCHm-jtq7DY5-moiPsOnT5yI,5263
|
|
9
10
|
terminusgps/aws/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
10
11
|
terminusgps/aws/secrets.py,sha256=kgRA77rs0mD4berWRLkPtJLOe4Grf--o5f8NzwQqXCk,360
|
|
11
12
|
terminusgps/wialon/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
@@ -22,7 +23,7 @@ terminusgps/wialon/items/route.py,sha256=qOHPN_rejwiGqvwWzlwmUIAIyc3lKavCalf8ki6
|
|
|
22
23
|
terminusgps/wialon/items/unit.py,sha256=wzcLa0adMTKX6rtO4Vz6ntaxgY50rLk2KK_VBXlW_lQ,4680
|
|
23
24
|
terminusgps/wialon/items/unit_group.py,sha256=1yc7ldPIgGbtiTj0djRDWmt6Q9K_VT9sxOaioasbbLY,5212
|
|
24
25
|
terminusgps/wialon/items/user.py,sha256=bkcMw_YiocaMuhP_pBfB7apjAZwnsOzGScnGkn8Ybbw,6107
|
|
25
|
-
python_terminusgps-1.9.
|
|
26
|
-
python_terminusgps-1.9.
|
|
27
|
-
python_terminusgps-1.9.
|
|
28
|
-
python_terminusgps-1.9.
|
|
26
|
+
python_terminusgps-1.9.7.dist-info/METADATA,sha256=AM9Wj1ho_7YrRdExekgsaiPG6zL8rrYRQfago0bpc6Q,882
|
|
27
|
+
python_terminusgps-1.9.7.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
|
28
|
+
python_terminusgps-1.9.7.dist-info/licenses/COPYING,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
|
|
29
|
+
python_terminusgps-1.9.7.dist-info/RECORD,,
|
terminusgps/authorizenet/auth.py
CHANGED
|
@@ -1,23 +1,17 @@
|
|
|
1
1
|
from authorizenet.apicontractsv1 import merchantAuthenticationType
|
|
2
2
|
from authorizenet.constants import constants
|
|
3
3
|
|
|
4
|
-
from django.conf import
|
|
4
|
+
from django.conf import settings
|
|
5
|
+
from django.core.exceptions import ImproperlyConfigured
|
|
5
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.")
|
|
6
13
|
|
|
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
14
|
|
|
15
|
-
return wrapped
|
|
16
|
-
|
|
17
|
-
return decorator
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
@settings_required(["MERCHANT_AUTH_LOGIN_ID", "MERCHANT_AUTH_TRANSACTION_KEY"])
|
|
21
15
|
def get_merchant_auth() -> merchantAuthenticationType:
|
|
22
16
|
return merchantAuthenticationType(
|
|
23
17
|
name=str(settings.MERCHANT_AUTH_LOGIN_ID),
|
|
@@ -25,11 +19,9 @@ def get_merchant_auth() -> merchantAuthenticationType:
|
|
|
25
19
|
)
|
|
26
20
|
|
|
27
21
|
|
|
28
|
-
@settings_required(["DEBUG"])
|
|
29
22
|
def get_environment() -> str:
|
|
30
23
|
return constants.SANDBOX if settings.DEBUG else constants.PRODUCTION
|
|
31
24
|
|
|
32
25
|
|
|
33
|
-
@settings_required(["DEBUG"])
|
|
34
26
|
def get_validation_mode() -> str:
|
|
35
27
|
return "testMode" if settings.DEBUG else "liveMode"
|
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
from authorizenet
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
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):
|
|
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):
|
|
19
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
20
|
shipping_addr = kwargs.get("shipping_addr")
|
|
21
21
|
|
|
22
22
|
if not shipping_addr:
|
|
@@ -27,57 +27,65 @@ class AddressProfile(AuthorizenetCustomerProfileBase):
|
|
|
27
27
|
f"'shipping_addr' must be customerAddressType, got '{type(shipping_addr)}'."
|
|
28
28
|
)
|
|
29
29
|
|
|
30
|
-
|
|
30
|
+
response = self._authorizenet_create_shipping_address(shipping_addr)
|
|
31
|
+
return int(response.customerAddressId)
|
|
31
32
|
|
|
32
|
-
def
|
|
33
|
-
|
|
33
|
+
def update(self, shipping_addr: customerAddressType) -> dict:
|
|
34
|
+
"""Updates the Authorize.NET payment profile."""
|
|
35
|
+
return self._authorizenet_update_shipping_address(shipping_addr)
|
|
34
36
|
|
|
35
|
-
def
|
|
36
|
-
|
|
37
|
+
def delete(self) -> dict:
|
|
38
|
+
"""Deletes the Authorize.NET payment profile."""
|
|
39
|
+
return self._authorizenet_delete_shipping_address()
|
|
37
40
|
|
|
38
41
|
def get_details(self) -> dict:
|
|
39
42
|
return self._authorizenet_get_shipping_address()
|
|
40
43
|
|
|
41
|
-
def
|
|
42
|
-
|
|
44
|
+
def _authorizenet_get_shipping_address(self) -> dict:
|
|
45
|
+
assert self.id, "'id' was not set."
|
|
46
|
+
|
|
47
|
+
request = apicontractsv1.getCustomerShippingAddressRequest(
|
|
43
48
|
merchantAuthentication=self.merchantAuthentication,
|
|
44
49
|
customerProfileId=self.customerProfileId,
|
|
45
|
-
|
|
46
|
-
defaultShippingAddress=self.default,
|
|
50
|
+
customerAddressId=self.id,
|
|
47
51
|
)
|
|
48
|
-
controller =
|
|
52
|
+
controller = apicontrollers.getCustomerShippingAddressController(request)
|
|
49
53
|
response = self.execute_controller(controller)
|
|
50
|
-
return
|
|
54
|
+
return response
|
|
51
55
|
|
|
52
|
-
def
|
|
53
|
-
|
|
54
|
-
addr.customerAddressId = self.id
|
|
55
|
-
request = updateCustomerShippingAddressRequest(
|
|
56
|
+
def _authorizenet_create_shipping_address(self, addr: customerAddressType) -> dict:
|
|
57
|
+
request = apicontractsv1.createCustomerShippingAddressRequest(
|
|
56
58
|
merchantAuthentication=self.merchantAuthentication,
|
|
57
59
|
customerProfileId=self.customerProfileId,
|
|
58
60
|
address=addr,
|
|
59
|
-
|
|
61
|
+
defaultShippingAddress=self.default,
|
|
60
62
|
)
|
|
61
|
-
controller =
|
|
62
|
-
self.execute_controller(controller)
|
|
63
|
+
controller = apicontrollers.createCustomerShippingAddressController(request)
|
|
64
|
+
response = self.execute_controller(controller)
|
|
65
|
+
return response
|
|
63
66
|
|
|
64
|
-
def
|
|
67
|
+
def _authorizenet_update_shipping_address(self, addr: customerAddressType) -> dict:
|
|
65
68
|
assert self.id, "'id' was not set."
|
|
66
|
-
|
|
69
|
+
addr.customerAddressId = self.id
|
|
70
|
+
|
|
71
|
+
request = apicontractsv1.updateCustomerShippingAddressRequest(
|
|
67
72
|
merchantAuthentication=self.merchantAuthentication,
|
|
68
73
|
customerProfileId=self.customerProfileId,
|
|
69
|
-
|
|
74
|
+
address=addr,
|
|
75
|
+
default=self.default,
|
|
70
76
|
)
|
|
71
|
-
controller =
|
|
77
|
+
controller = apicontrollers.updateCustomerShippingAddressController(request)
|
|
72
78
|
response = self.execute_controller(controller)
|
|
73
79
|
return response
|
|
74
80
|
|
|
75
|
-
def _authorizenet_delete_shipping_address(self) ->
|
|
81
|
+
def _authorizenet_delete_shipping_address(self) -> dict:
|
|
76
82
|
assert self.id, "'id' was not set."
|
|
77
|
-
|
|
83
|
+
|
|
84
|
+
request = apicontractsv1.deleteCustomerShippingAddressRequest(
|
|
78
85
|
merchantAuthentication=self.merchantAuthentication,
|
|
79
86
|
customerProfileId=self.customerProfileId,
|
|
80
87
|
customerAddressId=self.id,
|
|
81
88
|
)
|
|
82
|
-
controller = deleteCustomerShippingAddressController(request)
|
|
83
|
-
self.execute_controller(controller)
|
|
89
|
+
controller = apicontrollers.deleteCustomerShippingAddressController(request)
|
|
90
|
+
response = self.execute_controller(controller)
|
|
91
|
+
return response
|
|
@@ -1,62 +1,82 @@
|
|
|
1
|
+
from abc import abstractmethod
|
|
2
|
+
|
|
1
3
|
from authorizenet.apicontractsv1 import merchantAuthenticationType
|
|
2
|
-
from
|
|
4
|
+
from authorizenet.apicontrollersbase import APIOperationBase
|
|
5
|
+
|
|
6
|
+
from ..auth import get_merchant_auth, get_environment, get_validation_mode
|
|
3
7
|
|
|
4
8
|
|
|
5
9
|
class AuthorizenetProfileBase:
|
|
6
|
-
def __init__(
|
|
7
|
-
self
|
|
8
|
-
|
|
9
|
-
self.merchant_id = merchant_id
|
|
10
|
-
self.id = str(id) if id else str(self.create(**kwargs))
|
|
10
|
+
def __init__(self, merchant_id: int | str, id: int | str | None = None) -> None:
|
|
11
|
+
self._merchantCustomerId = merchant_id
|
|
12
|
+
self._id = id
|
|
11
13
|
|
|
12
14
|
def __str__(self) -> str:
|
|
13
15
|
return f"#{self.id}"
|
|
14
16
|
|
|
17
|
+
def execute_controller(self, controller: APIOperationBase) -> dict:
|
|
18
|
+
"""
|
|
19
|
+
Executes an Authorize.NET controller and returns its response.
|
|
20
|
+
|
|
21
|
+
:param controller: An Authorize.NET API controller.
|
|
22
|
+
:raises ValueError: If the API call fails.
|
|
23
|
+
:returns: The Authorize.NET API response.
|
|
24
|
+
:rtype: :py:obj:`dict`
|
|
25
|
+
|
|
26
|
+
"""
|
|
27
|
+
controller.setenvironment(self.environment)
|
|
28
|
+
controller.execute()
|
|
29
|
+
response = controller.getresponse()
|
|
30
|
+
|
|
31
|
+
if response.messages.resultCode != "Ok":
|
|
32
|
+
raise ValueError(response.messages.message[0]["text"].text)
|
|
33
|
+
return response
|
|
34
|
+
|
|
15
35
|
@property
|
|
16
|
-
def
|
|
17
|
-
return
|
|
36
|
+
def merchantCustomerId(self) -> str:
|
|
37
|
+
return str(self._merchantCustomerId)
|
|
18
38
|
|
|
19
39
|
@property
|
|
20
|
-
def
|
|
21
|
-
return
|
|
40
|
+
def id(self) -> str:
|
|
41
|
+
return str(self._id)
|
|
22
42
|
|
|
23
43
|
@property
|
|
24
|
-
def
|
|
25
|
-
return
|
|
44
|
+
def merchantAuthentication(self) -> merchantAuthenticationType:
|
|
45
|
+
return get_merchant_auth()
|
|
26
46
|
|
|
27
47
|
@property
|
|
28
|
-
def
|
|
29
|
-
return
|
|
48
|
+
def environment(self) -> str:
|
|
49
|
+
return get_environment()
|
|
30
50
|
|
|
51
|
+
@abstractmethod
|
|
31
52
|
def create(self, **kwargs) -> int:
|
|
32
53
|
raise NotImplementedError("Subclasses must implement this method.")
|
|
33
54
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
55
|
+
@abstractmethod
|
|
56
|
+
def update(self, *args, **kwargs) -> dict:
|
|
57
|
+
raise NotImplementedError("Subclasses must implement this method.")
|
|
58
|
+
|
|
59
|
+
@abstractmethod
|
|
60
|
+
def delete(self, *args, **kwargs) -> dict:
|
|
61
|
+
raise NotImplementedError("Subclasses must implement this method.")
|
|
41
62
|
|
|
42
63
|
|
|
43
|
-
class
|
|
64
|
+
class AuthorizenetSubProfileBase(AuthorizenetProfileBase):
|
|
44
65
|
def __init__(
|
|
45
|
-
self, customer_profile_id: int | str, default: bool
|
|
66
|
+
self, customer_profile_id: int | str, default: bool, *args, **kwargs
|
|
46
67
|
) -> None:
|
|
47
|
-
|
|
48
|
-
raise ValueError(
|
|
49
|
-
f"'customer_profile_id' must be a digit, got '{customer_profile_id}'."
|
|
50
|
-
)
|
|
51
|
-
|
|
68
|
+
self._customerProfileId = customer_profile_id
|
|
52
69
|
self._default = default
|
|
53
|
-
|
|
54
|
-
return super().__init__(**kwargs)
|
|
70
|
+
return super().__init__(*args, **kwargs)
|
|
55
71
|
|
|
56
72
|
@property
|
|
57
|
-
def
|
|
58
|
-
return
|
|
73
|
+
def validationMode(self) -> str:
|
|
74
|
+
return get_validation_mode()
|
|
59
75
|
|
|
60
76
|
@property
|
|
61
77
|
def default(self) -> str:
|
|
62
78
|
return str(self._default).lower()
|
|
79
|
+
|
|
80
|
+
@property
|
|
81
|
+
def customerProfileId(self) -> str:
|
|
82
|
+
return str(self._customerProfileId)
|
|
@@ -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
|
|
@@ -1,25 +1,26 @@
|
|
|
1
|
+
from authorizenet import apicontractsv1, apicontrollers
|
|
1
2
|
from authorizenet.apicontractsv1 import (
|
|
2
|
-
createCustomerPaymentProfileRequest,
|
|
3
3
|
customerAddressType,
|
|
4
|
-
deleteCustomerPaymentProfileRequest,
|
|
5
|
-
getCustomerPaymentProfileRequest,
|
|
6
|
-
paymentType,
|
|
7
4
|
customerPaymentProfileType,
|
|
8
|
-
|
|
9
|
-
updateCustomerPaymentProfileRequest,
|
|
10
|
-
)
|
|
11
|
-
from authorizenet.apicontrollers import (
|
|
12
|
-
createCustomerPaymentProfileController,
|
|
13
|
-
deleteCustomerPaymentProfileController,
|
|
14
|
-
getCustomerPaymentProfileController,
|
|
15
|
-
updateCustomerPaymentProfileController,
|
|
16
|
-
validateCustomerPaymentProfileController,
|
|
5
|
+
paymentType,
|
|
17
6
|
)
|
|
18
|
-
|
|
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,43 +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
60
|
paymentProfile=customerPaymentProfileType(
|
|
59
|
-
billTo=billing_addr, payment=payment
|
|
61
|
+
billTo=billing_addr, payment=payment, defaultPaymentProfile=self.default
|
|
60
62
|
),
|
|
61
63
|
validationMode=self.validationMode,
|
|
62
64
|
)
|
|
63
|
-
controller = createCustomerPaymentProfileController(request)
|
|
65
|
+
controller = apicontrollers.createCustomerPaymentProfileController(request)
|
|
64
66
|
response = self.execute_controller(controller)
|
|
65
|
-
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
|
|
66
81
|
|
|
67
82
|
def _authorizenet_update_payment_profile(
|
|
68
83
|
self, billing_addr: customerAddressType, payment: paymentType
|
|
69
|
-
) ->
|
|
70
|
-
"""Executes an :py:obj:`~authorizenet.apicontractsv1.updateCustomerPaymentProfileRequest` using the Authorize.NET API."""
|
|
84
|
+
) -> dict:
|
|
71
85
|
assert self.id, "'id' was not set."
|
|
72
|
-
|
|
86
|
+
|
|
87
|
+
request = apicontractsv1.updateCustomerPaymentProfileRequest(
|
|
73
88
|
merchantAuthentication=self.merchantAuthentication,
|
|
74
89
|
customerProfileId=self.customerProfileId,
|
|
75
|
-
paymentProfile=
|
|
90
|
+
paymentProfile=customerPaymentProfileType(
|
|
76
91
|
billTo=billing_addr,
|
|
77
92
|
payment=payment,
|
|
78
93
|
defaultPaymentProfile=self.default,
|
|
@@ -80,40 +95,31 @@ class PaymentProfile(AuthorizenetCustomerProfileBase):
|
|
|
80
95
|
),
|
|
81
96
|
validationMode=self.validationMode,
|
|
82
97
|
)
|
|
83
|
-
controller = updateCustomerPaymentProfileController(request)
|
|
84
|
-
self.execute_controller(controller)
|
|
98
|
+
controller = apicontrollers.updateCustomerPaymentProfileController(request)
|
|
99
|
+
response = self.execute_controller(controller)
|
|
100
|
+
return response
|
|
85
101
|
|
|
86
|
-
def
|
|
87
|
-
"""Executes a :py:obj:`~authorizenet.apicontractsv1.getCustomerPaymentProfileRequest` using the Authorize.NET API."""
|
|
102
|
+
def _authorizenet_validate_payment_profile(self) -> dict:
|
|
88
103
|
assert self.id, "'id' was not set."
|
|
89
|
-
request = getCustomerPaymentProfileRequest(
|
|
90
|
-
merchantAuthentication=self.merchantAuthentication,
|
|
91
|
-
customerProfileId=self.customerProfileId,
|
|
92
|
-
customerPaymentProfileId=self.id,
|
|
93
|
-
includeIssuerInfo=str(issuer_info).lower(),
|
|
94
|
-
)
|
|
95
|
-
controller = getCustomerPaymentProfileController(request)
|
|
96
|
-
return self.execute_controller(controller)
|
|
97
104
|
|
|
98
|
-
|
|
99
|
-
"""Executes a :py:obj:`~authorizenet.apicontractsv1.validateCustomerPaymentProfileRequest` using the Authorize.NET API."""
|
|
100
|
-
assert self.id, "'id' was not set."
|
|
101
|
-
request = validateCustomerPaymentProfileRequest(
|
|
105
|
+
request = apicontractsv1.validateCustomerPaymentProfileRequest(
|
|
102
106
|
merchantAuthentication=self.merchantAuthentication,
|
|
103
107
|
customerProfileId=self.customerProfileId,
|
|
104
108
|
customerPaymentProfileId=self.id,
|
|
105
109
|
validationMode=self.validationMode,
|
|
106
110
|
)
|
|
107
|
-
controller = validateCustomerPaymentProfileController(request)
|
|
108
|
-
self.execute_controller(controller)
|
|
111
|
+
controller = apicontrollers.validateCustomerPaymentProfileController(request)
|
|
112
|
+
response = self.execute_controller(controller)
|
|
113
|
+
return response
|
|
109
114
|
|
|
110
|
-
def _authorizenet_delete_payment_profile(self) ->
|
|
111
|
-
"""Executes a :py:obj:`~authorizenet.apicontractsv1.deleteCustomerPaymentProfileRequest` using the Authorize.NET API."""
|
|
115
|
+
def _authorizenet_delete_payment_profile(self) -> dict:
|
|
112
116
|
assert self.id, "'id' was not set."
|
|
113
|
-
|
|
117
|
+
|
|
118
|
+
request = apicontractsv1.deleteCustomerPaymentProfileRequest(
|
|
114
119
|
merchantAuthentication=self.merchantAuthentication,
|
|
115
120
|
customerProfileId=self.customerProfileId,
|
|
116
121
|
customerPaymentProfileId=self.id,
|
|
117
122
|
)
|
|
118
|
-
controller = deleteCustomerPaymentProfileController(request)
|
|
119
|
-
self.execute_controller(controller)
|
|
123
|
+
controller = apicontrollers.deleteCustomerPaymentProfileController(request)
|
|
124
|
+
response = self.execute_controller(controller)
|
|
125
|
+
return response
|
terminusgps/settings.py
CHANGED
|
@@ -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")
|
|
File without changes
|
|
File without changes
|