Stripe.Session (stripity_stripe v2.17.2) View Source

Work with Stripe Checkout Session objects.

You can:

  • Create a new session
  • Retrieve a session

Stripe API reference: https://stripe.com/docs/api/checkout/sessions

Link to this section Summary

Types

One of "interval", "sporadic", or "combined"`.

One of "personal" or "business"`.

One of "automatic", "instant", or "microdeposits"`.

One of "requires_location_inputs", "complete", "failed".

One of "auto" or "required"

One of "if_required", or "always".

One of "payment", "setup", or "subscription".

One of "paid", "unpaid", or "no_payment_required".

One of "open", "complete", or "expired".

For sessions in payment mode only. One of "auto", "pay", "book", or "donate".

t()

Functions

Invalidates a session

See Stripe.Checkout.Session.LineItems.list/2.

Retrieve a session.

Link to this section Types

Specs

acss_debit() :: %{
  currency: String.t() | nil,
  mandate_options: acss_mandate_options() | nil,
  verification_method: acss_verification_method()
}
Link to this type

acss_mandate_options()

View Source

Specs

acss_mandate_options() :: %{
  url: String.t(),
  default_for: [String.t()],
  interval_description: String.t() | nil,
  payment_schedule: acss_mandate_payment_schedule() | nil,
  transaction_type: acss_mandate_transaction_type()
}
Link to this type

acss_mandate_payment_schedule()

View Source

Specs

acss_mandate_payment_schedule() :: String.t()

One of "interval", "sporadic", or "combined"`.

Link to this type

acss_mandate_transaction_type()

View Source

Specs

acss_mandate_transaction_type() :: String.t()

One of "personal" or "business"`.

Link to this type

acss_verification_method()

View Source

Specs

acss_verification_method() :: String.t()

One of "automatic", "instant", or "microdeposits"`.

Specs

adjustable_quantity() :: %{
  :enabled => boolean(),
  optional(:maximum) => integer(),
  optional(:minimum) => integer()
}

Specs

automatic_tax() :: %{enabled: boolean(), status: automatic_tax_status() | nil}

Specs

automatic_tax_param() :: %{enabled: boolean()}
Link to this type

automatic_tax_status()

View Source

Specs

automatic_tax_status() :: String.t()

One of "requires_location_inputs", "complete", "failed".

Link to this type

billing_address_collection()

View Source

Specs

billing_address_collection() :: String.t()

One of "auto" or "required"

Specs

boleto() :: %{expires_after_days: non_neg_integer() | nil}

Specs

breakdown_discount() :: %{amount: integer(), discount: Stripe.Discount.t()}

Specs

breakdown_tax() :: %{amount: integer(), rate: Stripe.TaxID.t()}

Specs

capture_method() :: :automatic | :manual

Specs

consent() :: %{promotions: String.t()}

Specs

consent_collection() :: %{promotions: String.t(), terms_of_service: String.t()}

Specs

create_params() :: %{
  :cancel_url => String.t(),
  optional(:payment_method_types) => [String.t()],
  :success_url => String.t(),
  optional(:mode) => String.t(),
  optional(:client_reference_id) => String.t(),
  optional(:currency) => String.t(),
  optional(:customer) => String.t(),
  optional(:customer_email) => String.t(),
  optional(:line_items) => [line_item_data()],
  optional(:locale) => String.t(),
  optional(:metadata) => Stripe.Types.metadata(),
  optional(:after_expiration) => expiration(),
  optional(:allow_promotion_codes) => boolean(),
  optional(:automatic_tax) => automatic_tax_param(),
  optional(:consent_collection) => consent_collection(),
  optional(:customer_update) => customer_update_param(),
  optional(:discounts) => [discount_param()],
  optional(:expires_at) => Stripe.timestamp(),
  optional(:payment_intent_data) => payment_intent_data(),
  optional(:payment_method_options) => payment_method_options(),
  optional(:setup_intent_data) => setup_intent_data(),
  optional(:billing_address_collection) => billing_address_collection(),
  optional(:shipping_address_collection) => shipping_address_collection(),
  optional(:submit_type) => submit_type(),
  optional(:subscription_data) => subscription_data(),
  optional(:tax_id_collection) => tax_id_collection()
}

Specs

customer_creation() :: String.t()

One of "if_required", or "always".

Specs

customer_details() :: %{
  email: String.t() | nil,
  tax_exempt: String.t() | nil,
  tax_ids: [Stripe.TaxID.tax_id_data()]
}
Link to this type

customer_update_param()

View Source

Specs

customer_update_param() :: %{
  optional(:address) => String.t(),
  optional(:name) => String.t(),
  optional(:shipping) => String.t()
}

Specs

discount_param() :: %{
  optional(:coupon) => String.t(),
  optional(:promotion_code) => String.t()
}

Specs

expiration() :: %{
  optional(:recovery) => %{
    optional(:allow_promotion_codes) => boolean(),
    optional(:enabled) => boolean(),
    expires_at: Stripe.timestamp(),
    url: String.t()
  }
}

Specs

item() :: %{:plan => String.t(), optional(:quantity) => integer()}

Specs

line_item() :: %{
  optional(:object) => String.t(),
  optional(:data) => line_item_data(),
  optional(:has_more) => boolean(),
  optional(:url) => String.t()
}

Specs

line_item_data() :: %{
  optional(:id) => Stripe.id(),
  optional(:object) => String.t(),
  optional(:quantity) => integer(),
  optional(:amount_discount) => integer(),
  optional(:amount_subtotal) => integer(),
  optional(:amount_tax) => integer(),
  optional(:amount_total) => integer(),
  optional(:currency) => String.t(),
  optional(:description) => String.t(),
  optional(:discounts) => [map()],
  optional(:dynamic_tax_rates) => [String.t()],
  optional(:price) => String.t(),
  optional(:price_data) => price_data(),
  optional(:taxes) => [map()]
}

Specs

mode() :: String.t()

One of "payment", "setup", or "subscription".

Specs

oxxo() :: %{expires_after_days: non_neg_integer() | nil}

Specs

payment_intent_data() :: %{
  optional(:application_fee_amount) => integer(),
  optional(:capture_method) => capture_method(),
  optional(:description) => String.t(),
  optional(:metadata) => Stripe.Types.metadata(),
  optional(:on_behalf_of) => String.t(),
  optional(:receipt_email) => String.t(),
  optional(:setup_future_usage) => String.t(),
  optional(:shipping) => Stripe.Types.shipping(),
  optional(:statement_descriptor) => String.t(),
  optional(:transfer_data) => transfer_data()
}
Link to this type

payment_method_options()

View Source

Specs

payment_method_options() :: %{
  acss_debit: acss_debit() | nil,
  boleto: boleto() | nil,
  oxxo: oxxo() | nil
}

Specs

payment_status() :: String.t()

One of "paid", "unpaid", or "no_payment_required".

Link to this type

phone_number_collection()

View Source

Specs

phone_number_collection() :: %{enabled: boolean()}

Specs

price_data() :: %{
  :currency => String.t(),
  optional(:product) => String.t(),
  optional(:product_data) => product_data(),
  optional(:unit_amount) => integer(),
  optional(:unit_amount_decimal) => integer(),
  optional(:recurring) => recurring()
}

Specs

product_data() :: %{
  :name => String.t(),
  optional(:description) => String.t(),
  optional(:images) => [String.t()],
  optional(:metadata) => Stripe.Types.metadata()
}

Specs

recurring() :: %{interval: String.t(), interval_count: integer()}

Specs

setup_intent_data() :: %{
  optional(:description) => String.t(),
  optional(:metadata) => Stripe.Types.metadata(),
  optional(:on_behalf_of) => String.t()
}
Link to this type

shipping_address_collection()

View Source

Specs

shipping_address_collection() :: %{allowed_countries: [String.t()]}

Specs

shipping_option() :: %{
  shipping_amount: non_neg_integer(),
  shipping_rate: String.t()
}

Specs

status() :: String.t()

One of "open", "complete", or "expired".

Specs

submit_type() :: String.t()

For sessions in payment mode only. One of "auto", "pay", "book", or "donate".

Specs

subscription_data() :: %{
  optional(:items) => [item()],
  optional(:application_fee_percent) => float(),
  optional(:coupon) => String.t(),
  optional(:default_tax_rates) => [String.t()],
  optional(:metadata) => Stripe.Types.metadata(),
  optional(:trial_end) => integer(),
  optional(:trial_from_plan) => boolean(),
  optional(:trial_period_days) => integer()
}

Specs

t() :: %Stripe.Session{
  after_expiration: expiration() | nil,
  allow_promotion_codes: boolean() | nil,
  amount_subtotal: integer() | nil,
  amount_total: integer() | nil,
  automatic_tax: automatic_tax(),
  billing_address_collection: String.t(),
  cancel_url: boolean(),
  client_reference_id: String.t(),
  consent: consent() | nil,
  consent_collection: consent_collection() | nil,
  currency: String.t(),
  customer: Stripe.id() | Stripe.Customer.t() | nil,
  customer_creation: customer_creation() | nil,
  customer_details: customer_details() | nil,
  customer_email: String.t(),
  expires_at: Stripe.timestamp() | nil,
  id: Stripe.id(),
  line_items: [line_item()],
  livemode: boolean(),
  locale: boolean(),
  metadata: Stripe.Types.metadata(),
  mode: mode(),
  object: String.t(),
  payment_intent: Stripe.id() | Stripe.PaymentIntent.t() | nil,
  payment_link: String.t() | nil,
  payment_method_options: payment_method_options() | nil,
  payment_method_types: [String.t()],
  payment_status: payment_status(),
  phone_number_collection: phone_number_collection() | nil,
  recovered_from: Stripe.id() | nil,
  setup_intent: Stripe.id() | Stripe.SetupIntent.t() | nil,
  shipping: %{address: Stripe.Types.shipping(), name: String.t()},
  shipping_address_collection: shipping_address_collection(),
  shipping_options: [shipping_option()] | nil,
  shipping_rate: String.t() | nil,
  status: status() | nil,
  submit_type: submit_type() | nil,
  subscription: Stripe.id() | Stripe.Subscription.t() | nil,
  success_url: String.t(),
  tax_id_collection: tax_id_collection() | nil,
  total_details: total_details() | nil,
  url: String.t()
}

Specs

tax_id_collection() :: %{enabled: boolean()}

Specs

total_details() :: %{
  :amount_discount => integer(),
  :amount_shipping => integer(),
  :amount_tax => integer(),
  optional(:breakdown) => %{
    discounts: [breakdown_discount()],
    taxes: [breakdown_tax()]
  }
}

Specs

transfer_data() :: %{destination: String.t()}

Link to this section Functions

Link to this function

create(params, opts \\ [])

View Source

Specs

create(create_params(), Stripe.options()) ::
  {:ok, t()} | {:error, Stripe.Error.t()}

Invalidates a session

Link to this function

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

View Source

Specs

list(params, Stripe.options()) ::
  {:ok, Stripe.List.t(t())} | {:error, Stripe.Error.t()}
when params: %{
       optional(:subscription) => Stripe.id() | Stripe.Subscription.t(),
       optional(:payment_intent) => Stripe.id() | Stripe.PaymentIntent.t(),
       optional(:limit) => 1..100,
       optional(:ending_before) => t() | Stripe.id(),
       optional(:starting_after) => t() | Stripe.id()
     }

List all sessions

Link to this function

list_line_items(id, opts \\ [])

View Source

See Stripe.Checkout.Session.LineItems.list/2.

Link to this function

retrieve(id, opts \\ [])

View Source

Specs

retrieve(Stripe.id() | t(), Stripe.options()) ::
  {:ok, t()} | {:error, Stripe.Error.t()}

Retrieve a session.