python-terminusgps 1.9.6__py3-none-any.whl → 1.9.8__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: python-terminusgps
3
- Version: 1.9.6
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,11 +1,12 @@
1
1
  terminusgps/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
- terminusgps/settings.py,sha256=fxU6VuJVJaB_tHcIksH-3XPrFQHRD57nW7_9vMsZ6Ag,394
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=yznomWGTRbFiTDiugsRw1HqxJAV4aJKZFN3Bzdt_V8E,1119
5
- terminusgps/authorizenet/profiles/addresses.py,sha256=ir3GPdsSQtezQnM6IgavHj6Ii8uhOWGswIp_8KiN5OE,3377
6
- terminusgps/authorizenet/profiles/base.py,sha256=LIPDK78HqzYanoZF_gtbmLBEB_YF_MM7CNWvharPrMk,1974
7
- terminusgps/authorizenet/profiles/customers.py,sha256=vAD-bxUcNvAoIEQDdnu3QESiHPAjEV1g1i5l0tY5lVk,4536
8
- terminusgps/authorizenet/profiles/payments.py,sha256=qXCXDAH9bEw6Y9tnupHpxinfdbLwDZrDCm2uSa-JTBc,5451
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=IooSz_PTeq23IIgq6upx2CcpWEOXgK3mFNylADYlF3I,2553
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.6.dist-info/METADATA,sha256=bBw4kY5gV0PFXUj1FAmS6cdEbhEYhFhhvO5o2KR46mI,882
26
- python_terminusgps-1.9.6.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
27
- python_terminusgps-1.9.6.dist-info/licenses/COPYING,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
28
- python_terminusgps-1.9.6.dist-info/RECORD,,
26
+ python_terminusgps-1.9.8.dist-info/METADATA,sha256=LuMGvDMdgCMd1dCFqaXQDHGSd0YRkS_1S_PEe561X2c,882
27
+ python_terminusgps-1.9.8.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
28
+ python_terminusgps-1.9.8.dist-info/licenses/COPYING,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
29
+ python_terminusgps-1.9.8.dist-info/RECORD,,
@@ -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 ImproperlyConfigured, settings
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"
@@ -0,0 +1,3 @@
1
+ from .addresses import AddressProfile
2
+ from .customers import CustomerProfile
3
+ from .payments import PaymentProfile
@@ -1,22 +1,22 @@
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):
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
- return self._authorizenet_create_shipping_address(shipping_addr)
30
+ response = self._authorizenet_create_shipping_address(shipping_addr)
31
+ return int(response.customerAddressId)
31
32
 
32
- def delete(self) -> None:
33
- self._authorizenet_delete_shipping_address()
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 update(self, shipping_addr: customerAddressType) -> None:
36
- self._authorizenet_update_shipping_address(shipping_addr)
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 _authorizenet_create_shipping_address(self, addr: customerAddressType) -> int:
42
- request = createCustomerShippingAddressRequest(
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
- address=addr,
46
- defaultShippingAddress=self.default,
50
+ customerAddressId=self.id,
47
51
  )
48
- controller = createCustomerShippingAddressController(request)
52
+ controller = apicontrollers.getCustomerShippingAddressController(request)
49
53
  response = self.execute_controller(controller)
50
- return int(response.customerAddressId)
54
+ return response
51
55
 
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
+ 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
- default=self.default,
61
+ defaultShippingAddress=self.default,
60
62
  )
61
- controller = updateCustomerShippingAddressController(request)
62
- self.execute_controller(controller)
63
+ controller = apicontrollers.createCustomerShippingAddressController(request)
64
+ response = self.execute_controller(controller)
65
+ return response
63
66
 
64
- def _authorizenet_get_shipping_address(self) -> dict:
67
+ def _authorizenet_update_shipping_address(self, addr: customerAddressType) -> dict:
65
68
  assert self.id, "'id' was not set."
66
- request = getCustomerShippingAddressRequest(
69
+ addr.customerAddressId = self.id
70
+
71
+ request = apicontractsv1.updateCustomerShippingAddressRequest(
67
72
  merchantAuthentication=self.merchantAuthentication,
68
73
  customerProfileId=self.customerProfileId,
69
- customerAddressId=self.id,
74
+ address=addr,
75
+ default=self.default,
70
76
  )
71
- controller = getCustomerShippingAddressController(request)
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) -> None:
81
+ def _authorizenet_delete_shipping_address(self) -> dict:
76
82
  assert self.id, "'id' was not set."
77
- request = deleteCustomerShippingAddressRequest(
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,84 @@
1
+ from abc import abstractmethod
2
+
1
3
  from authorizenet.apicontractsv1 import merchantAuthenticationType
2
- from ..auth import get_environment, get_merchant_auth, get_validation_mode
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
10
  def __init__(
7
11
  self, merchant_id: int | str, id: int | str | None = None, **kwargs
8
12
  ) -> None:
9
- self.merchant_id = merchant_id
10
- self.id = str(id) if id else str(self.create(**kwargs))
13
+ self._merchantCustomerId = merchant_id
14
+ self._id = str(id) if id else self.create(**kwargs)
11
15
 
12
16
  def __str__(self) -> str:
13
17
  return f"#{self.id}"
14
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
+
15
37
  @property
16
- def environment(self) -> str:
17
- return get_environment()
38
+ def merchantCustomerId(self) -> str:
39
+ return str(self._merchantCustomerId)
18
40
 
19
41
  @property
20
- def merchantAuthentication(self) -> merchantAuthenticationType:
21
- return get_merchant_auth()
42
+ def id(self) -> str:
43
+ return str(self._id)
22
44
 
23
45
  @property
24
- def validationMode(self) -> str:
25
- return get_validation_mode()
46
+ def merchantAuthentication(self) -> merchantAuthenticationType:
47
+ return get_merchant_auth()
26
48
 
27
49
  @property
28
- def merchantCustomerId(self) -> str:
29
- return str(self.merchant_id)
50
+ def environment(self) -> str:
51
+ return get_environment()
30
52
 
53
+ @abstractmethod
31
54
  def create(self, **kwargs) -> int:
32
55
  raise NotImplementedError("Subclasses must implement this method.")
33
56
 
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
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.")
41
64
 
42
65
 
43
- class AuthorizenetCustomerProfileBase(AuthorizenetProfileBase):
66
+ class AuthorizenetSubProfileBase(AuthorizenetProfileBase):
44
67
  def __init__(
45
- self, customer_profile_id: int | str, default: bool = False, **kwargs
68
+ self, customer_profile_id: int | str, default: bool, *args, **kwargs
46
69
  ) -> 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
-
70
+ self._customerProfileId = customer_profile_id
52
71
  self._default = default
53
- self.customer_profile_id = customer_profile_id
54
- return super().__init__(**kwargs)
72
+ return super().__init__(*args, **kwargs)
55
73
 
56
74
  @property
57
- def customerProfileId(self) -> str:
58
- return str(self.customer_profile_id)
75
+ def validationMode(self) -> str:
76
+ return get_validation_mode()
59
77
 
60
78
  @property
61
79
  def default(self) -> str:
62
80
  return str(self._default).lower()
81
+
82
+ @property
83
+ def customerProfileId(self) -> str:
84
+ return str(self._customerProfileId)
@@ -1,16 +1,5 @@
1
- from authorizenet.apicontrollers import (
2
- createCustomerProfileController,
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
- return self._authorizenet_create_customer_profile(
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 = "") -> None:
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) -> None:
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(self, email: str, desc: str = "") -> int:
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 int(response.customerProfileId)
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
- request = getCustomerProfileRequest(
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 = "") -> None:
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
- request = updateCustomerProfileRequest(
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
- validateCustomerPaymentProfileRequest,
9
- updateCustomerPaymentProfileRequest,
10
- )
11
- from authorizenet.apicontrollers import (
12
- createCustomerPaymentProfileController,
13
- deleteCustomerPaymentProfileController,
14
- getCustomerPaymentProfileController,
15
- updateCustomerPaymentProfileController,
16
- validateCustomerPaymentProfileController,
5
+ paymentType,
17
6
  )
18
- from terminusgps.authorizenet.profiles.base import AuthorizenetCustomerProfileBase
7
+
8
+ from terminusgps.authorizenet.profiles.base import AuthorizenetSubProfileBase
19
9
 
20
10
 
21
- class PaymentProfile(AuthorizenetCustomerProfileBase):
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,22 +37,24 @@ class PaymentProfile(AuthorizenetCustomerProfileBase):
36
37
  f"'payment' must be customerAddressType, got '{type(payment)}'"
37
38
  )
38
39
 
39
- return self._authorizenet_create_payment_profile(billing_addr, payment)
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) -> None:
42
- self._authorizenet_update_payment_profile(billing_addr, payment)
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) -> None:
45
- self._authorizenet_delete_payment_profile()
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
- ) -> int:
53
- """Executes a :py:obj:`~authorizenet.apicontractsv1.createCustomerPaymentProfileRequest` using the Authorize.NET API."""
54
- request = createCustomerPaymentProfileRequest(
56
+ ) -> dict:
57
+ request = apicontractsv1.createCustomerPaymentProfileRequest(
55
58
  customerProfileId=self.customerProfileId,
56
59
  merchantAuthentication=self.merchantAuthentication,
57
60
  paymentProfile=customerPaymentProfileType(
@@ -59,16 +62,29 @@ class PaymentProfile(AuthorizenetCustomerProfileBase):
59
62
  ),
60
63
  validationMode=self.validationMode,
61
64
  )
62
- controller = createCustomerPaymentProfileController(request)
65
+ controller = apicontrollers.createCustomerPaymentProfileController(request)
63
66
  response = self.execute_controller(controller)
64
- return int(response.customerPaymentProfileId)
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
65
81
 
66
82
  def _authorizenet_update_payment_profile(
67
83
  self, billing_addr: customerAddressType, payment: paymentType
68
- ) -> None:
69
- """Executes an :py:obj:`~authorizenet.apicontractsv1.updateCustomerPaymentProfileRequest` using the Authorize.NET API."""
84
+ ) -> dict:
70
85
  assert self.id, "'id' was not set."
71
- request = updateCustomerPaymentProfileRequest(
86
+
87
+ request = apicontractsv1.updateCustomerPaymentProfileRequest(
72
88
  merchantAuthentication=self.merchantAuthentication,
73
89
  customerProfileId=self.customerProfileId,
74
90
  paymentProfile=customerPaymentProfileType(
@@ -79,40 +95,31 @@ class PaymentProfile(AuthorizenetCustomerProfileBase):
79
95
  ),
80
96
  validationMode=self.validationMode,
81
97
  )
82
- controller = updateCustomerPaymentProfileController(request)
83
- self.execute_controller(controller)
98
+ controller = apicontrollers.updateCustomerPaymentProfileController(request)
99
+ response = self.execute_controller(controller)
100
+ return response
84
101
 
85
- def _authorizenet_get_payment_profile(self, issuer_info: bool = False) -> dict:
86
- """Executes a :py:obj:`~authorizenet.apicontractsv1.getCustomerPaymentProfileRequest` using the Authorize.NET API."""
102
+ def _authorizenet_validate_payment_profile(self) -> dict:
87
103
  assert self.id, "'id' was not set."
88
- request = getCustomerPaymentProfileRequest(
89
- merchantAuthentication=self.merchantAuthentication,
90
- customerProfileId=self.customerProfileId,
91
- customerPaymentProfileId=self.id,
92
- includeIssuerInfo=str(issuer_info).lower(),
93
- )
94
- controller = getCustomerPaymentProfileController(request)
95
- return self.execute_controller(controller)
96
104
 
97
- def _authorizenet_validate_payment_profile(self) -> None:
98
- """Executes a :py:obj:`~authorizenet.apicontractsv1.validateCustomerPaymentProfileRequest` using the Authorize.NET API."""
99
- assert self.id, "'id' was not set."
100
- request = validateCustomerPaymentProfileRequest(
105
+ request = apicontractsv1.validateCustomerPaymentProfileRequest(
101
106
  merchantAuthentication=self.merchantAuthentication,
102
107
  customerProfileId=self.customerProfileId,
103
108
  customerPaymentProfileId=self.id,
104
109
  validationMode=self.validationMode,
105
110
  )
106
- controller = validateCustomerPaymentProfileController(request)
107
- self.execute_controller(controller)
111
+ controller = apicontrollers.validateCustomerPaymentProfileController(request)
112
+ response = self.execute_controller(controller)
113
+ return response
108
114
 
109
- def _authorizenet_delete_payment_profile(self) -> None:
110
- """Executes a :py:obj:`~authorizenet.apicontractsv1.deleteCustomerPaymentProfileRequest` using the Authorize.NET API."""
115
+ def _authorizenet_delete_payment_profile(self) -> dict:
111
116
  assert self.id, "'id' was not set."
112
- request = deleteCustomerPaymentProfileRequest(
117
+
118
+ request = apicontractsv1.deleteCustomerPaymentProfileRequest(
113
119
  merchantAuthentication=self.merchantAuthentication,
114
120
  customerProfileId=self.customerProfileId,
115
121
  customerPaymentProfileId=self.id,
116
122
  )
117
- controller = deleteCustomerPaymentProfileController(request)
118
- 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")