Packages
stripity_stripe
3.3.2
3.3.2
3.3.1
3.2.0
3.1.1
3.1.0
3.0.0
2.17.3
2.17.2
2.17.1
2.17.0
2.16.0
2.15.1
2.15.0
2.14.1
2.14.0
2.13.0
2.12.1
2.12.0
2.11.0
2.10.0
2.9.0
2.8.0
2.7.2
2.7.1
2.7.0
2.6.0
2.5.0
2.4.0
2.3.0
2.2.3
2.2.2
2.2.1
2.2.0
2.1.0
2.0.1
2.0.0
2.0.0-alpha.11
2.0.0-alpha.10
2.0.0-alpha.9
2.0.0-alpha.8
2.0.0-alpha.7
2.0.0-alpha.6
2.0.0-alpha.5
2.0.0-alpha.4
2.0.0-alpha.3
2.0.0-alpha.2
2.0.0-alpha.1
1.6.2
1.6.1
1.6.0
1.4.0
1.3.0
1.2.0
1.1.0
0.5.0
0.4.0
0.3.0
0.2.0
A Stripe client for Elixir.
Current section
Files
Jump to
Current section
Files
lib/generated/customer_session.ex
defmodule Stripe.CustomerSession do
use Stripe.Entity
@moduledoc "A Customer Session allows you to grant Stripe's frontend SDKs (like Stripe.js) client-side access\ncontrol over a Customer.\n\nRelated guides: [Customer Session with the Payment Element](/payments/accept-a-payment-deferred?platform=web&type=payment#save-payment-methods),\n[Customer Session with the Pricing Table](/payments/checkout/pricing-table#customer-session),\n[Customer Session with the Buy Button](/payment-links/buy-button#pass-an-existing-customer)."
(
defstruct [:client_secret, :components, :created, :customer, :expires_at, :livemode, :object]
@typedoc "The `customer_session` type.\n\n * `client_secret` The client secret of this Customer Session. Used on the client to set up secure access to the given `customer`.\n\nThe client secret can be used to provide access to `customer` from your frontend. It should not be stored, logged, or exposed to anyone other than the relevant customer. Make sure that you have TLS enabled on any page that includes the client secret.\n * `components` \n * `created` Time at which the object was created. Measured in seconds since the Unix epoch.\n * `customer` The Customer the Customer Session was created for.\n * `expires_at` The timestamp at which this Customer Session will expire.\n * `livemode` Has the value `true` if the object exists in live mode or the value `false` if the object exists in test mode.\n * `object` String representing the object's type. Objects of the same type share the same value.\n"
@type t :: %__MODULE__{
client_secret: binary,
components: term,
created: integer,
customer: binary | Stripe.Customer.t(),
expires_at: integer,
livemode: boolean,
object: binary
}
)
(
@typedoc "Configuration for buy button."
@type buy_button :: %{optional(:enabled) => boolean}
)
(
@typedoc "Configuration for each component. At least 1 component must be enabled."
@type components :: %{
optional(:buy_button) => buy_button,
optional(:customer_sheet) => customer_sheet,
optional(:mobile_payment_element) => mobile_payment_element,
optional(:payment_element) => payment_element,
optional(:pricing_table) => pricing_table
}
)
(
@typedoc "Configuration for the customer sheet."
@type customer_sheet :: %{optional(:enabled) => boolean, optional(:features) => features}
)
(
@typedoc "This hash defines whether the Payment Element supports certain features."
@type features :: %{
optional(:payment_method_allow_redisplay_filters) =>
list(:always | :limited | :unspecified),
optional(:payment_method_redisplay) => :disabled | :enabled,
optional(:payment_method_redisplay_limit) => integer,
optional(:payment_method_remove) => :disabled | :enabled,
optional(:payment_method_save) => :disabled | :enabled,
optional(:payment_method_save_usage) => :off_session | :on_session
}
)
(
@typedoc "Configuration for the mobile payment element."
@type mobile_payment_element :: %{
optional(:enabled) => boolean,
optional(:features) => features
}
)
(
@typedoc "Configuration for the Payment Element."
@type payment_element :: %{optional(:enabled) => boolean, optional(:features) => features}
)
(
@typedoc "Configuration for the pricing table."
@type pricing_table :: %{optional(:enabled) => boolean}
)
(
nil
@doc "<p>Creates a Customer Session object that includes a single-use client secret that you can use on your front-end to grant client-side API access for certain customer resources.</p>\n\n#### Details\n\n * Method: `post`\n * Path: `/v1/customer_sessions`\n"
(
@spec create(
params :: %{
optional(:components) => components,
optional(:customer) => binary,
optional(:expand) => list(binary)
},
opts :: Keyword.t()
) ::
{:ok, Stripe.CustomerSession.t()}
| {:error, Stripe.ApiErrors.t()}
| {:error, term()}
def create(params \\ %{}, opts \\ []) do
path = Stripe.OpenApi.Path.replace_path_params("/v1/customer_sessions", [], [])
Stripe.Request.new_request(opts)
|> Stripe.Request.put_endpoint(path)
|> Stripe.Request.put_params(params)
|> Stripe.Request.put_method(:post)
|> Stripe.Request.make_request()
end
)
)
end