Skip to content

# Subscriptions

class terminusgps.authorizenet.subscriptions.subscriptions.Subscription(id: str | int | None = None, *args, **kwargs)

  Public Data Attributes:

  `merchantAuthentication` | Merchant authentication for API calls.
  `status` | Current status of the subscription.
  `transactions` | Transactions for the subscription.

  Public Methods:

  `__init__`([id]) |
  `create`(name, amount, schedule, profile_id, ...) | Creates a subscription in Authorizenet.
  `cancel`() | Cancels the subscription.

  Inherited from `ControllerExecutionMixin`

  `execute_controller`(controller) | Executes an Authorizenet controller and returns its response.

  Private Methods:

  `_authorizenet_get_subscription`([...]) | Executes a `ARBGetSubscriptionRequest` using the Authorizenet API.
  `_authorizenet_get_subscription_status`() | Executes a `ARBGetSubscriptionStatusRequest` using the Authorizenet API.
  `_authorizenet_update_subscription`(subscription) | Executes a `ARBUpdateSubscriptionRequest` using the Authorizenet API.
  `_authorizenet_cancel_subscription`() | Executes a `ARBCancelSubscriptionRequest` using the Authorizenet API.

  _authorizenet_cancel_subscription() → dict | None

    Executes a `ARBCancelSubscriptionRequest` using the Authorizenet API.

    ARBCancelSubscriptionRequest

    Raises:

      - AssertionError – If `id` wasn’t set.

      - ControllerExecutionError – If something goes wrong during an Authorizenet API call.

    Returns:

      An Authorizenet API response, if any.

    Return type:

      `dict` | `None`

  _authorizenet_get_subscription(include_transactions: bool = False) → dict | None

    Executes a `ARBGetSubscriptionRequest` using the Authorizenet API.

    ARBGetSubscriptionRequest

    Raises:

      - AssertionError – If `id` wasn’t set.

      - ControllerExecutionError – If something goes wrong during an Authorizenet API call.

    Returns:

      An Authorizenet API response, if any.

    Return type:

      `dict` | `None`

  _authorizenet_get_subscription_status() → dict | None

    Executes a `ARBGetSubscriptionStatusRequest` using the Authorizenet API.

    ARBGetSubscriptionStatusRequest

    Raises:

      - AssertionError – If `id` wasn’t set.

      - ControllerExecutionError – If something goes wrong during an Authorizenet API call.

    Returns:

      An Authorizenet API response, if any.

    Return type:

      `dict` | `None`

  _authorizenet_update_subscription(subscription: ARBSubscriptionType) → dict | None

    Executes a `ARBUpdateSubscriptionRequest` using the Authorizenet API.

    ARBUpdateSubscriptionRequest

    Raises:

      - AssertionError – If `id` wasn’t set.

      - ControllerExecutionError – If something goes wrong during an Authorizenet API call.

    Returns:

      An Authorizenet API response, if any.

    Return type:

      `dict` | `None`

  cancel() → None

    Cancels the subscription.

    Raises:

      - AssertionError – If `id` wasn’t set.

      - ControllerExecutionError – If something goes wrong during an Authorizenet API call.

    Returns:

      Nothing.

    Return type:

      `None`

  create(name: str, amount: Decimal, schedule: paymentScheduleType, profile_id: int | str, payment_id: int | str, address_id: int | str, trial_amount: Decimal = Decimal('0')) → int

    Creates a subscription in Authorizenet.

    Parameters:

      - name (`str`) – A name for the subscription.

      - amount (`paymentScheduleType`) – An amount of money paid per occurrence of the subscription.

      - schedule – A payment schedule for the subscription.

      - profile_id (`int` | `str`) – An Authoriznet customer profile id.

      - payment_id (`int` | `str`) – An Authoriznet customer payment profile id.

      - address_id (`int` | `str`) – An Authoriznet customer address profile id.

      - trial_amount (`Decimal`) – Trial amount for the subscription. Default is `0.00`.

    Raises:

      - ControllerExecutionError – If something goes wrong during an Authorizenet API call.

      - ValueError – If `profile_id` wasn’t a digit.

      - ValueError – If `payment_id` wasn’t a digit.

      - ValueError – If `address_id` wasn’t a digit.

      - ValueError – If the Authorizenet API response was not retrieved.

    Returns:

      An Authorizenet subscription id.

    Return type:

      `int`

  property merchantAuthentication: merchantAuthenticationType

    Merchant authentication for API calls.

  property status: str | None

    Current status of the subscription.

  property transactions: list | None

    Transactions for the subscription.