Stripe.PaymentIntent (stripity_stripe v2.17.3) View Source

Work with Stripe payment_intent objects. You can:

Link to this section Summary

Functions

A PaymentIntent object can be canceled when it is in one of these statuses: requires_payment_method, requires_capture, requires_confirmation, requires_action. Once canceled, no additional charges will be made by the PaymentIntent and any operations on the PaymentIntent will fail with an error. For PaymentIntents with status='requires_capture', the remaining amount_capturable will automatically be refunded. See the Stripe docs.

Capture the funds of an existing uncaptured PaymentIntent where required_action="requires_capture". Uncaptured PaymentIntents will be canceled exactly seven days after they are created. See the Stripe docs.

Confirm that your customer intends to pay with current or provided source. Upon confirmation, the PaymentIntent will attempt to initiate a payment. If the selected source requires additional authentication steps, the PaymentIntent will transition to the requires_action status and suggest additional actions via next_source_action. If payment fails, the PaymentIntent will transition to the requires_payment_method status. If payment succeeds, the PaymentIntent will transition to the succeeded status (or requires_capture, if capture_method is set to manual). Read the expanded documentation to learn more about server-side confirmation. See the Stripe docs.

Create a payment intent. See the Stripe docs.

Returns a list of PaymentIntents. See the Stripe docs.

Retrieves the details of a PaymentIntent that has previously been created. Client-side retrieval using a publishable key is allowed when the client_secret is provided in the query string. When retrieved with a publishable key, only a subset of properties will be returned. Please refer to the payment intent object reference for more details. See the Stripe docs.

Search PaymentIntents

Updates a PaymentIntent object. See the Stripe docs.

Link to this section Types

Specs

last_payment_error() :: %{
  type: String.t(),
  charge: String.t(),
  code: String.t(),
  decline_code: String.t(),
  doc_url: String.t(),
  message: String.t(),
  param: String.t(),
  payment_intent: t() | map(),
  source: Stripe.Card.t() | map()
}

Specs

next_action() :: %{
  redirect_to_url: redirect_to_url() | nil,
  type: String.t(),
  use_stripe_sdk: map() | nil
}

Specs

redirect_to_url() :: %{return_url: String.t(), url: String.t()}

Specs

t() :: %Stripe.PaymentIntent{
  amount: non_neg_integer(),
  amount_capturable: non_neg_integer(),
  amount_received: non_neg_integer(),
  application: Stripe.id() | nil,
  application_fee_amount: non_neg_integer() | nil,
  canceled_at: Stripe.timestamp() | nil,
  cancellation_reason: String.t() | nil,
  capture_method: String.t(),
  charges: Stripe.List.t(Stripe.Charge.t()),
  client_secret: String.t(),
  confirmation_method: String.t(),
  created: Stripe.timestamp(),
  currency: String.t(),
  customer: Stripe.id() | Stripe.Customer.t() | nil,
  description: String.t() | nil,
  id: Stripe.id(),
  invoice: Stripe.id() | Stripe.Invoice.t() | nil,
  last_payment_error: last_payment_error() | nil,
  livemode: boolean(),
  metadata: Stripe.Types.metadata(),
  next_action: next_action() | nil,
  object: String.t(),
  on_behalf_of: Stripe.id() | Stripe.Account.t() | nil,
  payment_method: Stripe.id() | Stripe.PaymentMethod.t() | nil,
  payment_method_options: map(),
  payment_method_types: [String.t()],
  receipt_email: String.t() | nil,
  review: Stripe.id() | Stripe.Review.t() | nil,
  setup_future_usage: String.t() | nil,
  shipping: Stripe.Types.shipping() | nil,
  source: Stripe.Card.t() | map(),
  statement_descriptor: String.t() | nil,
  statement_descriptor_suffix: String.t() | nil,
  status: String.t(),
  transfer_data: transfer_data() | nil,
  transfer_group: String.t() | nil
}

Specs

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

Link to this section Functions

Link to this function

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

View Source

Specs

cancel(Stripe.id() | t(), params, Stripe.options()) ::
  {:ok, t()} | {:error, Stripe.Error.t()}
when params: %{optional(:cancellation_reason) => String.t()} | %{}

A PaymentIntent object can be canceled when it is in one of these statuses: requires_payment_method, requires_capture, requires_confirmation, requires_action. Once canceled, no additional charges will be made by the PaymentIntent and any operations on the PaymentIntent will fail with an error. For PaymentIntents with status='requires_capture', the remaining amount_capturable will automatically be refunded. See the Stripe docs.

Link to this function

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

View Source

Specs

capture(Stripe.id() | t(), params, Stripe.options()) ::
  {:ok, t()} | {:error, Stripe.Error.t()}
when params:
       %{
         optional(:amount_to_capture) => non_neg_integer(),
         optional(:application_fee_amount) => non_neg_integer()
       }
       | %{}

Capture the funds of an existing uncaptured PaymentIntent where required_action="requires_capture". Uncaptured PaymentIntents will be canceled exactly seven days after they are created. See the Stripe docs.

Link to this function

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

View Source

Specs

confirm(Stripe.id() | t(), params, Stripe.options()) ::
  {:ok, t()} | {:error, Stripe.Error.t()}
when params:
       %{
         optional(:client_secret) => String.t(),
         optional(:receipt_email) => String.t(),
         optional(:return_url) => String.t(),
         optional(:save_payment_method) => boolean(),
         optional(:shipping) => Stripe.Types.shipping(),
         optional(:source) => Stripe.id() | Stripe.Card.t(),
         optional(:payment_method) => Stripe.id() | Stripe.PaymentMethod.t()
       }
       | %{}

Confirm that your customer intends to pay with current or provided source. Upon confirmation, the PaymentIntent will attempt to initiate a payment. If the selected source requires additional authentication steps, the PaymentIntent will transition to the requires_action status and suggest additional actions via next_source_action. If payment fails, the PaymentIntent will transition to the requires_payment_method status. If payment succeeds, the PaymentIntent will transition to the succeeded status (or requires_capture, if capture_method is set to manual). Read the expanded documentation to learn more about server-side confirmation. See the Stripe docs.

Link to this function

create(params, opts \\ [])

View Source

Specs

create(params, Stripe.options()) :: {:ok, t()} | {:error, Stripe.Error.t()}
when params:
       %{
         :amount => pos_integer(),
         :currency => String.t(),
         optional(:application_fee_amount) => non_neg_integer(),
         optional(:capture_method) => String.t(),
         optional(:confirm) => boolean(),
         optional(:customer) => Stripe.id() | Stripe.Customer.t(),
         optional(:description) => String.t(),
         optional(:metadata) => map(),
         optional(:off_session) => boolean(),
         optional(:on_behalf_of) => Stripe.id() | Stripe.Account.t(),
         optional(:payment_method) => String.t(),
         optional(:payment_method_options) => map(),
         optional(:payment_method_types) => [Stripe.id()],
         optional(:receipt_email) => String.t(),
         optional(:return_url) => String.t(),
         optional(:save_payment_method) => boolean(),
         optional(:setup_future_usage) => String.t(),
         optional(:shipping) => Stripe.Types.shipping(),
         optional(:source) => Stripe.id() | Stripe.Card.t(),
         optional(:statement_descriptor) => String.t(),
         optional(:statement_descriptor_suffix) => String.t(),
         optional(:transfer_data) => transfer_data(),
         optional(:transfer_group) => String.t()
       }
       | %{}

Create a payment intent. See the Stripe docs.

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(:created) => Stripe.date_query(),
       optional(:ending_before) => t() | Stripe.id(),
       optional(:limit) => 1..100,
       optional(:starting_after) => t() | Stripe.id()
     }

Returns a list of PaymentIntents. See the Stripe docs.

Link to this function

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

View Source

Specs

retrieve(Stripe.id() | t(), params, Stripe.options()) ::
  {:ok, t()} | {:error, Stripe.Error.t()}
when params: %{optional(:client_secret) => String.t()} | %{}

Retrieves the details of a PaymentIntent that has previously been created. Client-side retrieval using a publishable key is allowed when the client_secret is provided in the query string. When retrieved with a publishable key, only a subset of properties will be returned. Please refer to the payment intent object reference for more details. See the Stripe docs.

Link to this function

search(params, opts \\ [])

View Source

Specs

search(params, Stripe.options()) ::
  {:ok, Stripe.SearchResult.t(t())} | {:error, Stripe.Error.t()}
when params: %{
       :query => Stripe.search_query(),
       optional(:limit) => 1..100,
       optional(:page) => String.t()
     }

Search PaymentIntents

See the Stripe docs.

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(:amount) => non_neg_integer(),
         optional(:application_fee_amount) => non_neg_integer(),
         optional(:currency) => String.t(),
         optional(:customer) => Stripe.id() | Stripe.Customer.t(),
         optional(:description) => String.t(),
         optional(:metadata) => map(),
         optional(:payment_method) => String.t(),
         optional(:payment_method_types) => [Stripe.id()],
         optional(:receipt_email) => String.t(),
         optional(:save_payment_method) => boolean(),
         optional(:setup_future_usage) => String.t(),
         optional(:shipping) => Stripe.Types.shipping(),
         optional(:source) => Stripe.id() | Stripe.Card.t(),
         optional(:statement_descriptor_suffix) => String.t(),
         optional(:transfer_group) => String.t()
       }
       | %{}

Updates a PaymentIntent object. See the Stripe docs.