Stripe.Order (stripity_stripe v2.17.2) View Source

Work with Stripe orders.

Stripe API reference: https://stripe.com/docs/api#orders

Link to this section Summary

Link to this section Types

Specs

card_info() :: %{
  exp_month: number(),
  exp_year: number(),
  number: String.t(),
  object: String.t(),
  cvc: String.t(),
  address_city: String.t() | nil,
  address_country: String.t() | nil,
  address_line1: String.t() | nil,
  address_line2: String.t() | nil,
  name: String.t() | nil,
  address_state: String.t() | nil,
  address_zip: String.t() | nil
}

Specs

t() :: %Stripe.Order{
  amount: pos_integer(),
  amount_returned: non_neg_integer(),
  application: Stripe.id(),
  application_fee: non_neg_integer(),
  charge: Stripe.id() | Stripe.Charge.t(),
  created: Stripe.timestamp(),
  currency: String.t(),
  customer: Stripe.id() | Stripe.Customer.t(),
  email: String.t(),
  external_coupon_code: String.t(),
  id: Stripe.id(),
  items: Stripe.List.t(Stripe.OrderItem.t()),
  livemode: boolean(),
  metadata: Stripe.Types.metadata(),
  object: String.t(),
  returns: Stripe.List.t(Stripe.OrderReturn.t()),
  selected_shipping_method: String.t(),
  shipping: %{
    address: %{
      city: String.t(),
      country: String.t(),
      line1: String.t(),
      line2: String.t(),
      postal_code: String.t(),
      state: String.t()
    },
    carrier: String.t(),
    name: String.t(),
    phone: String.t(),
    tracking_number: String.t()
  },
  shipping_methods: [
    %{
      id: String.t(),
      amount: pos_integer(),
      currency: String.t(),
      delivery_estimate: %{
        date: String.t(),
        earliest: String.t(),
        latest: String.t(),
        type: String.t()
      },
      description: String.t()
    }
  ],
  status: String.t(),
  status_transitions: %{
    canceled: Stripe.timestamp(),
    fulfiled: Stripe.timestamp(),
    paid: Stripe.timestamp(),
    returned: Stripe.timestamp()
  },
  updated: Stripe.timestamp(),
  upstream_id: String.t()
}

Link to this section Functions

Link to this function

create(params, opts \\ [])

View Source

Specs

create(params, Keyword.t()) :: {:ok, t()} | {:error, Stripe.Error.t()}
when params: %{
       :currency => String.t(),
       optional(:coupon) => Stripe.id() | Stripe.Coupon.t(),
       optional(:customer) => Stripe.id() | Stripe.Customer.t(),
       optional(:email) => String.t(),
       optional(:items) => Stripe.List.t(Stripe.OrderItem.t()),
       optional(:metadata) => Stripe.Types.metadata(),
       optional(:shipping) => map()
     }

Create a order.

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(:customer) => Stripe.id() | Stripe.Customer.t(),
       optional(:ending_before) => t() | Stripe.id(),
       optional(:ids) => Stripe.List.t(Stripe.id()),
       optional(:limit) => 1..100,
       optional(:starting_after) => t() | Stripe.id(),
       optional(:status) => String.t(),
       optional(:status_transitions) => map(),
       optional(:upstream_ids) => Stripe.List.t(Stripe.id())
     }

List all orders.

Link to this function

pay(id, params \\ %{}, opts \\ [])

View Source

Specs

pay(Stripe.id() | t(), params, Stripe.options()) ::
  {:ok, t()} | {:error, Stripe.Error.t()}
when params: %{
       optional(:application_fee) => non_neg_integer(),
       optional(:customer) => Stripe.id() | Stripe.Customer.t(),
       optional(:source) =>
         Stripe.id() | Stripe.Card.t() | Stripe.Customer.t() | card_info(),
       optional(:email) => String.t(),
       optional(:metadata) => Stripe.Types.metadata()
     }

Pay an order.

Link to this function

retrieve(id, opts \\ [])

View Source

Specs

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

Retrieve a order.

Link to this function

return(id, params \\ %{}, opts \\ [])

View Source

Specs

return(Stripe.id() | t(), params, Stripe.options()) ::
  {:ok, t()} | {:error, Stripe.Error.t()}
when params: %{optional(:items) => Stripe.List.t(Stripe.OrderItem.t())}

return an order.

Link to this function

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

View Source

Specs

update(Stripe.id() | t(), params, Stripe.options()) ::
  {:ok, t()} | {:error, Stripe.Error.t()}
when params: %{
       optional(:coupon) => Stripe.id() | Stripe.Coupon.t(),
       optional(:metadata) => Stripe.Types.metadata(),
       optional(:selected_shipping_method) => String.t(),
       optional(:shipping) => map(),
       optional(:status) => String.t()
     }

Update a order.

Takes the id and a map of changes