View Source Chargebeex.Subscription (chargebeex v0.4.0)

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

@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"

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

"web" | "app_store" | "play_store"

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

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

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

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

@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
}
@type trial_end_action() :: String.t()

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

Functions

Callback implementation for Chargebeex.Resource.build/1.

Link to this function

build(map_or_kwlist, opts \\ [])

View Source
@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()
}
Link to this function

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

View Source

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{
    id: "GHI456OPQ789",
    contract_term: %{},
    referral_info: %{},
    shipping_address: %{},
    coupons: nil,
    charged_items: nil,
    item_tiers: nil,
    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
      }
    ],
    business_entity_id: "ABC123XYZ456",
    auto_close_invoices: true,
    custom_fields: %{},
    metadata: %{},
    create_pending_invoices: false,
    free_period_unit: nil,
    free_period: nil,
    cancel_reason_code: nil,
    changes_scheduled_at: nil,
    deleted: false,
    invoice_notes: nil,
    base_currency_code: nil,
    exchange_rate: nil,
    mrr: nil,
    total_dues: nil,
    due_since: nil,
    due_invoices_count: 0,
    net_term_days: nil,
    channel: "web",
    cancel_schedule_created_at: nil,
    plan_amount_in_decimal: nil,
    plan_free_quantity_in_decimal: nil,
    payment_source_id: nil,
    has_scheduled_changes: false,
    has_scheduled_advance_invoices: false,
    updated_at: 1705785896,
    resource_version: 1705785896428,
    created_from_ip: nil,
    cancel_reason: nil,
    cancelled_at: nil,
    resume_date: nil,
    pause_date: nil,
    override_relationship: false,
    contract_term_billing_cycle_on_renewal: nil,
    activated_at: nil,
    started_at: 1705705200,
    created_at: 1705785896,
    next_billing_at: 1705878000,
    current_term_end: nil,
    current_term_start: nil,
    trial_end_action: nil,
    currency_code: nil,
    start_date: nil,
    trial_end: nil,
    billing_period: nil,
    billing_period_unit: nil,
    object: nil,
    remaining_billing_cycles: nil,
    po_number: nil,
    plan_quantity_in_decimal: nil,
    plan_unit_price_in_decimal: nil,
    customer_id: nil,
    status: nil,
    trial_start: nil
  }}
Link to this function

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

View Source

Callback implementation for Chargebeex.Resource.list/2.

Link to this function

retrieve(id, opts \\ [])

View Source

Callback implementation for Chargebeex.Resource.retrieve/2.

Link to this function

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

View Source

Callback implementation for Chargebeex.Resource.update/3.

Link to this function

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

View Source