Utilities

terminusgps.authorizenet.utils.calculate_amount_plus_tax(amount: Decimal, tax_rate: Decimal | None = None) Decimal[source]

Returns the amount + tax. Uses DEFAULT_TAX_RATE if tax_rate wasn’t provided.

Parameters:
  • amount (Decimal) – Amount to add tax to.

  • tax_rate (Decimal | None) – A tax rate to use in the calculation.

Returns:

The amount + tax.

Return type:

Decimal

terminusgps.authorizenet.utils.generate_customer_address(form: Form) customerAddressType[source]

Takes a form and returns a customerAddressType.

Required form fields:

name

type

address

customerAddressType

first_name

str

last_name

str

Parameters:

form (Form) – A Django form.

Raises:
  • ValueError – If address wasn’t in the form.

  • ValueError – If first_name wasn’t in the form.

  • ValueError – If last_name wasn’t in the form.

Returns:

A customer address object.

Return type:

customerAddressType

terminusgps.authorizenet.utils.generate_customer_payment(form: Form) paymentType[source]

Takes a form and returns a paymentType.

Required form fields:

name

type

credit_card

creditCardType

Parameters:

form (Form) – A Django form.

Raises:

ValueError – If credit_card wasn’t in the form.

Returns:

A payment object.

Return type:

paymentType

terminusgps.authorizenet.utils.get_customer_profile_ids() list[int][source]

Returns a list of all customer profile ids in Authorizenet.

Raises:

AuthorizenetControllerExecutionError – If the API call fails.

Returns:

A list of all customer profile ids in Authorizenet.

Return type:

list

terminusgps.authorizenet.utils.get_days_between(start_date: date, end_date: date) int[source]

Returns the total number of days between two dates.

Parameters:
  • start_date (date) – Start date.

  • end_date (date) – End date.

Returns:

The number of days between the dates as an integer.

Return type:

int

terminusgps.authorizenet.utils.get_merchant_details() dict | None[source]

Returns Authorizenet merchant details.

getMerchantDetailsRequest

Raises:

AuthorizenetControllerExecutionError – If the API call fails.

Returns:

A merchant details object, if found.

Return type:

dict | None

terminusgps.authorizenet.utils.get_transaction(id: int | str) dict | None[source]

Returns Authorizenet transaction details by id.

getTransactionDetailsRequest

Parameters:

id (int | str) – An Authorizenet transaction id.

Raises:
Returns:

A transaction object, if found.

Return type:

dict | None