Chargebeex.Subscription (chargebeex v0.6.0)

View Source

Summary

Types

"not_paid" | "no_card" | "fraud_review_failed" | "non_compliant_eu_customer" | "tax_calculation_failed" | "currency_incompatible_with_gateway" | "non_compliant_customer"

"web" | "app_store" | "play_store"

"day" | "week" | "month" | "year"

"future" | "in_trial" | "active" | "non_renewing" | "paused" | "cancelled"

t()

"site_default" | "plan_default" | "activate_subscription" | "cancel_subscription"

Types

cancel_reason()

@type cancel_reason() :: String.t()

"not_paid" | "no_card" | "fraud_review_failed" | "non_compliant_eu_customer" | "tax_calculation_failed" | "currency_incompatible_with_gateway" | "non_compliant_customer"

channel()

@type channel() :: String.t()

"web" | "app_store" | "play_store"

period_unit()

@type period_unit() :: String.t()

"day" | "week" | "month" | "year"

status()

@type status() :: String.t()

"future" | "in_trial" | "active" | "non_renewing" | "paused" | "cancelled"

t()

@type t() :: %Chargebeex.Subscription{
  activated_at: non_neg_integer() | nil,
  auto_close_invoices: boolean() | nil,
  base_currency_code: String.t() | nil,
  billing_period: String.t() | nil,
  billing_period_unit: period_unit() | nil,
  business_entity_id: String.t() | nil,
  cancel_reason: cancel_reason() | nil,
  cancel_reason_code: String.t() | nil,
  cancel_schedule_created_at: non_neg_integer() | nil,
  cancelled_at: non_neg_integer() | nil,
  changes_scheduled_at: non_neg_integer() | nil,
  channel: channel() | nil,
  charged_items: list() | nil,
  contract_term: map(),
  contract_term_billing_cycle_on_renewal: non_neg_integer() | nil,
  coupons: list() | nil,
  create_pending_invoices: boolean() | nil,
  created_at: non_neg_integer() | nil,
  created_from_ip: String.t() | nil,
  currency_code: String.t() | nil,
  current_term_end: non_neg_integer() | nil,
  current_term_start: non_neg_integer() | nil,
  custom_fields: map(),
  customer_id: String.t() | nil,
  deleted: boolean() | nil,
  due_invoices_count: integer() | nil,
  due_since: non_neg_integer() | nil,
  exchange_rate: float() | nil,
  free_period: integer() | nil,
  free_period_unit: period_unit() | nil,
  has_scheduled_advance_invoices: boolean() | nil,
  has_scheduled_changes: boolean() | nil,
  id: String.t() | nil,
  invoice_notes: String.t() | nil,
  item_tiers: list() | nil,
  metadata: map(),
  mrr: non_neg_integer() | nil,
  net_term_days: non_neg_integer() | nil,
  next_billing_at: non_neg_integer() | nil,
  object: String.t() | nil,
  override_relationship: boolean() | nil,
  pause_date: non_neg_integer() | nil,
  payment_source_id: String.t() | nil,
  plan_amount_in_decimal: String.t() | nil,
  plan_free_quantity_in_decimal: String.t() | nil,
  plan_quantity_in_decimal: String.t() | nil,
  plan_unit_price_in_decimal: String.t() | nil,
  po_number: String.t() | nil,
  referral_info: map(),
  remaining_billing_cycles: non_neg_integer() | nil,
  resource_version: non_neg_integer() | nil,
  resume_date: non_neg_integer() | nil,
  shipping_address: map(),
  start_date: non_neg_integer() | nil,
  started_at: non_neg_integer() | nil,
  status: status() | nil,
  subscription_items: list() | nil,
  total_dues: non_neg_integer() | nil,
  trial_end: non_neg_integer() | nil,
  trial_end_action: trial_end_action() | nil,
  trial_start: String.t() | nil,
  updated_at: non_neg_integer() | nil
}

trial_end_action()

@type trial_end_action() :: String.t()

"site_default" | "plan_default" | "activate_subscription" | "cancel_subscription"

Functions

build(raw_data)

Callback implementation for Chargebeex.Resource.build/1.

build(map_or_kwlist, opts \\ [])

@spec build(ExConstructor.map_or_kwlist(), Keyword.t()) :: %Chargebeex.Subscription{
  activated_at: term(),
  auto_close_invoices: term(),
  base_currency_code: term(),
  billing_period: term(),
  billing_period_unit: term(),
  business_entity_id: term(),
  cancel_reason: term(),
  cancel_reason_code: term(),
  cancel_schedule_created_at: term(),
  cancelled_at: term(),
  changes_scheduled_at: term(),
  channel: term(),
  charged_items: term(),
  contract_term: term(),
  contract_term_billing_cycle_on_renewal: term(),
  coupons: term(),
  create_pending_invoices: term(),
  created_at: term(),
  created_from_ip: term(),
  currency_code: term(),
  current_term_end: term(),
  current_term_start: term(),
  custom_fields: term(),
  customer_id: term(),
  deleted: term(),
  due_invoices_count: term(),
  due_since: term(),
  exchange_rate: term(),
  free_period: term(),
  free_period_unit: term(),
  has_scheduled_advance_invoices: term(),
  has_scheduled_changes: term(),
  id: term(),
  invoice_notes: term(),
  item_tiers: term(),
  metadata: term(),
  mrr: term(),
  net_term_days: term(),
  next_billing_at: term(),
  object: term(),
  override_relationship: term(),
  pause_date: term(),
  payment_source_id: term(),
  plan_amount_in_decimal: term(),
  plan_free_quantity_in_decimal: term(),
  plan_quantity_in_decimal: term(),
  plan_unit_price_in_decimal: term(),
  po_number: term(),
  referral_info: term(),
  remaining_billing_cycles: term(),
  resource_version: term(),
  resume_date: term(),
  shipping_address: term(),
  start_date: term(),
  started_at: term(),
  status: term(),
  subscription_items: term(),
  total_dues: term(),
  trial_end: term(),
  trial_end_action: term(),
  trial_start: term(),
  updated_at: term()
}

create_with_items(customer_id, params, opts \\ [])

Creates a Subcription with items for a Customer

Examples

iex> Chargebeex.Subscription.create_with_items("169ljDT1Op0yuxET", %{
           subscription_items: [
             %{
               item_price_id: "DEF789LMN012",
               quantity: 1
             }
           ]
         })
{:ok, %Chargebeex.Subscription{
    subscription_items: [
      %{
        "amount" => 100,
        "free_quantity" => 0,
        "item_price_id" => "DEF789LMN012",
        "item_type" => "plan",
        "object" => "subscription_item",
        "quantity" => 1,
        "trial_end" => 1705877999,
        "unit_price" => 100
      }
    ],
    customer_id: "169ljDT1Op0yuxET",
    ...
  }}

list(params \\ %{}, opts \\ [])

Callback implementation for Chargebeex.Resource.list/2.

retrieve(id, opts \\ [])

Callback implementation for Chargebeex.Resource.retrieve/2.

update(id, params, opts \\ [])

Callback implementation for Chargebeex.Resource.update/3.

update_for_items(subscription_id, params, opts \\ [])