View Source Stripe.Charge (Striped v0.5.0) (generated)

To charge a credit or a debit card, you create a Charge object. You can retrieve and refund individual charges as well as list all charges. Charges are identified by a unique, random ID.

Related guide: Accept a payment with the Charges API.

Link to this section Summary

Types

Shipping address.

A set of key-value pairs you can attach to a charge giving information about its riskiness. If you believe a charge is fraudulent, include a user_report key with a value of fraudulent. If you believe a charge is safe, include a user_report key with a value of safe. Stripe will use the information you send to improve our fraud detection algorithms.

Options to configure Radar. See Radar Session for more information.

Shipping information for the charge. Helps prevent fraud on charges for physical goods.

t()

The charge type.

An optional dictionary including the account to automatically transfer to as part of a destination charge. See the Connect documentation for details.

Functions

Capture the payment of an existing, uncaptured, charge. This is the second half of the two-step payment flow, where first you created a charge with the capture option set to false.

To charge a credit card or other payment source, you create a Charge object. If your API key is in test mode, the supplied payment source (e.g., card) won’t actually be charged, although everything else will occur as if in live mode. (Stripe assumes that the charge would have completed successfully).

Returns a list of charges you’ve previously created. The charges are returned in sorted order, with the most recent charges appearing first.

Retrieves the details of a charge that has previously been created. Supply the unique charge ID that was returned from your previous request, and Stripe will return the corresponding charge information. The same information is returned when creating or refunding the charge.

Search for charges you’ve previously created using Stripe’s Search Query Language.Don’t use search in read-after-write flows where strict consistency is necessary. Under normal operating conditions, data is searchable in less than a minute. Occasionally, propagation of new or updated data can be up to an hour behind during outages. Search functionality is not available to merchants in India.

Updates the specified charge by setting the values of the parameters passed. Any parameters not provided will be left unchanged.

Link to this section Types

@type address() :: %{
  optional(:city) => binary(),
  optional(:country) => binary(),
  optional(:line1) => binary(),
  optional(:line2) => binary(),
  optional(:postal_code) => binary(),
  optional(:state) => binary()
}

Shipping address.

@type created() :: %{
  optional(:gt) => integer(),
  optional(:gte) => integer(),
  optional(:lt) => integer(),
  optional(:lte) => integer()
}
@type destination() :: %{
  optional(:account) => binary(),
  optional(:amount) => integer()
}
@type fraud_details() :: %{optional(:user_report) => :fraudulent | :safe}

A set of key-value pairs you can attach to a charge giving information about its riskiness. If you believe a charge is fraudulent, include a user_report key with a value of fraudulent. If you believe a charge is safe, include a user_report key with a value of safe. Stripe will use the information you send to improve our fraud detection algorithms.

@type radar_options() :: %{optional(:session) => binary()}

Options to configure Radar. See Radar Session for more information.

@type shipping() :: %{
  optional(:address) => address(),
  optional(:carrier) => binary(),
  optional(:name) => binary(),
  optional(:phone) => binary(),
  optional(:tracking_number) => binary()
}

Shipping information for the charge. Helps prevent fraud on charges for physical goods.

@type t() :: %Stripe.Charge{
  alternate_statement_descriptors: term(),
  amount: integer(),
  amount_captured: integer(),
  amount_refunded: integer(),
  application: (binary() | term()) | nil,
  application_fee: (binary() | Stripe.ApplicationFee.t()) | nil,
  application_fee_amount: integer() | nil,
  authorization_code: binary(),
  balance_transaction: (binary() | Stripe.BalanceTransaction.t()) | nil,
  billing_details: term(),
  calculated_statement_descriptor: binary() | nil,
  captured: boolean(),
  created: integer(),
  currency: binary(),
  customer: (binary() | Stripe.Customer.t() | Stripe.DeletedCustomer.t()) | nil,
  description: binary() | nil,
  destination: (binary() | Stripe.Account.t()) | nil,
  dispute: (binary() | Stripe.Dispute.t()) | nil,
  disputed: boolean(),
  failure_balance_transaction: (binary() | Stripe.BalanceTransaction.t()) | nil,
  failure_code: binary() | nil,
  failure_message: binary() | nil,
  fraud_details: term() | nil,
  id: binary(),
  invoice: (binary() | Stripe.Invoice.t()) | nil,
  level3: term(),
  livemode: boolean(),
  metadata: term(),
  object: binary(),
  on_behalf_of: (binary() | Stripe.Account.t()) | nil,
  outcome: term() | nil,
  paid: boolean(),
  payment_intent: (binary() | Stripe.PaymentIntent.t()) | nil,
  payment_method: binary() | nil,
  payment_method_details: term() | nil,
  radar_options: term(),
  receipt_email: binary() | nil,
  receipt_number: binary() | nil,
  receipt_url: binary() | nil,
  refunded: boolean(),
  refunds: term() | nil,
  review: (binary() | Stripe.Review.t()) | nil,
  shipping: term() | nil,
  source: Stripe.PaymentSource.t() | nil,
  source_transfer: (binary() | Stripe.Transfer.t()) | nil,
  statement_descriptor: binary() | nil,
  statement_descriptor_suffix: binary() | nil,
  status: binary(),
  transfer: binary() | Stripe.Transfer.t(),
  transfer_data: term() | nil,
  transfer_group: binary() | nil
}

The charge type.

  • receipt_url This is the URL to view the receipt for this charge. The receipt is kept up-to-date to the latest state of the charge, including any refunds. If the charge is for an Invoice, the receipt will be stylized as an Invoice receipt.
  • payment_method ID of the payment method used in this charge.
  • livemode Has the value true if the object exists in live mode or the value false if the object exists in test mode.
  • calculated_statement_descriptor The full statement descriptor that is passed to card networks, and that is displayed on your customers' credit card and bank statements. Allows you to see what the statement descriptor looks like after the static and dynamic portions are combined.
  • radar_options
  • metadata Set of key-value pairs that you can attach to an object. This can be useful for storing additional information about the object in a structured format.
  • description An arbitrary string attached to the object. Often useful for displaying to users.
  • paid true if the charge succeeded, or was successfully authorized for later capture.
  • application_fee The application fee (if any) for the charge. See the Connect documentation for details.
  • failure_message Message to user further explaining reason for charge failure if available.
  • review ID of the review associated with this charge if one exists.
  • payment_intent ID of the PaymentIntent associated with this charge, if one exists.
  • refunds A list of refunds that have been applied to the charge.
  • alternate_statement_descriptors
  • on_behalf_of The account (if any) the charge was made on behalf of without triggering an automatic transfer. See the Connect documentation for details.
  • customer ID of the customer this charge is for if one exists.
  • fraud_details Information on fraud assessments for the charge.
  • amount Amount intended to be collected by this payment. A positive integer representing how much to charge in the smallest currency unit (e.g., 100 cents to charge $1.00 or 100 to charge ¥100, a zero-decimal currency). The minimum amount is $0.50 US or equivalent in charge currency. The amount value supports up to eight digits (e.g., a value of 99999999 for a USD charge of $999,999.99).
  • outcome Details about whether the payment was accepted, and why. See understanding declines for details.
  • invoice ID of the invoice this charge is for if one exists.
  • payment_method_details Details about the payment method at the time of the transaction.
  • statement_descriptor For card charges, use statement_descriptor_suffix instead. Otherwise, you can use this value as the complete description of a charge on your customers’ statements. Must contain at least one letter, maximum 22 characters.
  • balance_transaction ID of the balance transaction that describes the impact of this charge on your account balance (not including refunds or disputes).
  • application ID of the Connect application that created the charge.
  • receipt_email This is the email address that the receipt for this charge was sent to.
  • failure_balance_transaction ID of the balance transaction that describes the reversal of the balance on your account due to payment failure.
  • receipt_number This is the transaction number that appears on email receipts sent for this charge. This attribute will be null until a receipt has been sent.
  • failure_code Error code explaining reason for charge failure if available (see the errors section for a list of codes).
  • object String representing the object's type. Objects of the same type share the same value.
  • amount_captured Amount in %s captured (can be less than the amount attribute on the charge if a partial capture was made).
  • billing_details
  • level3
  • authorization_code Authorization code on the charge.
  • source This is a legacy field that will be removed in the future. It contains the Source, Card, or BankAccount object used for the charge. For details about the payment method used for this charge, refer to payment_method or payment_method_details instead.
  • captured If the charge was created without capturing, this Boolean represents whether it is still uncaptured or has since been captured.
  • amount_refunded Amount in %s refunded (can be less than the amount attribute on the charge if a partial refund was issued).
  • refunded Whether the charge has been fully refunded. If the charge is only partially refunded, this attribute will still be false.
  • currency Three-letter ISO currency code, in lowercase. Must be a supported currency.
  • created Time at which the object was created. Measured in seconds since the Unix epoch.
  • transfer ID of the transfer to the destination account (only applicable if the charge was created using the destination parameter).
  • dispute Details about the dispute if the charge has been disputed.
  • destination ID of an existing, connected Stripe account to transfer funds to if transfer_data was specified in the charge request.
  • source_transfer The transfer ID which created this charge. Only present if the charge came from another Stripe account. See the Connect documentation for details.
  • status The status of the payment is either succeeded, pending, or failed.
  • transfer_group A string that identifies this transaction as part of a group. See the Connect documentation for details.
  • disputed Whether the charge has been disputed.
  • application_fee_amount The amount of the application fee (if any) requested for the charge. See the Connect documentation for details.
  • statement_descriptor_suffix Provides information about the charge that customers see on their statements. Concatenated with the prefix (shortened descriptor) or statement descriptor that’s set on the account to form the complete statement descriptor. Maximum 22 characters for the concatenated descriptor.
  • transfer_data An optional dictionary including the account to automatically transfer to as part of a destination charge. See the Connect documentation for details.
  • id Unique identifier for the object.
  • shipping Shipping information for the charge.
@type transfer_data() :: %{
  optional(:amount) => integer(),
  optional(:destination) => binary()
}

An optional dictionary including the account to automatically transfer to as part of a destination charge. See the Connect documentation for details.

Link to this section Functions

Link to this function

capture(client, charge, params \\ %{}, opts \\ [])

View Source
@spec capture(
  client :: Stripe.t(),
  charge :: binary(),
  params :: %{
    optional(:amount) => integer(),
    optional(:application_fee) => integer(),
    optional(:application_fee_amount) => integer(),
    optional(:expand) => [binary()],
    optional(:receipt_email) => binary(),
    optional(:statement_descriptor) => binary(),
    optional(:statement_descriptor_suffix) => binary(),
    optional(:transfer_data) => transfer_data(),
    optional(:transfer_group) => binary()
  },
  opts :: Keyword.t()
) :: {:ok, t()} | {:error, Stripe.ApiErrors.t()} | {:error, term()}

Capture the payment of an existing, uncaptured, charge. This is the second half of the two-step payment flow, where first you created a charge with the capture option set to false.

Uncaptured payments expire a set number of days after they are created (7 by default). If they are not captured by that point in time, they will be marked as refunded and will no longer be capturable.

Details

  • Method: post
  • Path: /v1/charges/{charge}/capture
Link to this function

create(client, params \\ %{}, opts \\ [])

View Source
@spec create(
  client :: Stripe.t(),
  params :: %{
    optional(:amount) => integer(),
    optional(:application_fee) => integer(),
    optional(:application_fee_amount) => integer(),
    optional(:capture) => boolean(),
    optional(:currency) => binary(),
    optional(:customer) => binary(),
    optional(:description) => binary(),
    optional(:destination) => destination(),
    optional(:expand) => [binary()],
    optional(:metadata) => %{optional(binary()) => binary()} | binary(),
    optional(:on_behalf_of) => binary(),
    optional(:radar_options) => radar_options(),
    optional(:receipt_email) => binary(),
    optional(:shipping) => shipping(),
    optional(:source) => binary(),
    optional(:statement_descriptor) => binary(),
    optional(:statement_descriptor_suffix) => binary(),
    optional(:transfer_data) => transfer_data(),
    optional(:transfer_group) => binary()
  },
  opts :: Keyword.t()
) :: {:ok, t()} | {:error, Stripe.ApiErrors.t()} | {:error, term()}

To charge a credit card or other payment source, you create a Charge object. If your API key is in test mode, the supplied payment source (e.g., card) won’t actually be charged, although everything else will occur as if in live mode. (Stripe assumes that the charge would have completed successfully).

Details

  • Method: post
  • Path: /v1/charges
Link to this function

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

View Source
@spec list(
  client :: Stripe.t(),
  params :: %{
    optional(:created) => created() | integer(),
    optional(:customer) => binary(),
    optional(:ending_before) => binary(),
    optional(:expand) => [binary()],
    optional(:limit) => integer(),
    optional(:payment_intent) => binary(),
    optional(:starting_after) => binary(),
    optional(:transfer_group) => binary()
  },
  opts :: Keyword.t()
) ::
  {:ok, Stripe.List.t(t())} | {:error, Stripe.ApiErrors.t()} | {:error, term()}

Returns a list of charges you’ve previously created. The charges are returned in sorted order, with the most recent charges appearing first.

Details

  • Method: get
  • Path: /v1/charges
Link to this function

retrieve(client, charge, params \\ %{}, opts \\ [])

View Source
@spec retrieve(
  client :: Stripe.t(),
  charge :: binary(),
  params :: %{optional(:expand) => [binary()]},
  opts :: Keyword.t()
) :: {:ok, t()} | {:error, Stripe.ApiErrors.t()} | {:error, term()}

Retrieves the details of a charge that has previously been created. Supply the unique charge ID that was returned from your previous request, and Stripe will return the corresponding charge information. The same information is returned when creating or refunding the charge.

Details

  • Method: get
  • Path: /v1/charges/{charge}
Link to this function

search(client, params \\ %{}, opts \\ [])

View Source
@spec search(
  client :: Stripe.t(),
  params :: %{
    optional(:expand) => [binary()],
    optional(:limit) => integer(),
    optional(:page) => binary(),
    optional(:query) => binary()
  },
  opts :: Keyword.t()
) ::
  {:ok, Stripe.SearchResult.t(t())}
  | {:error, Stripe.ApiErrors.t()}
  | {:error, term()}

Search for charges you’ve previously created using Stripe’s Search Query Language.Don’t use search in read-after-write flows where strict consistency is necessary. Under normal operating conditions, data is searchable in less than a minute. Occasionally, propagation of new or updated data can be up to an hour behind during outages. Search functionality is not available to merchants in India.

Details

  • Method: get
  • Path: /v1/charges/search
Link to this function

update(client, charge, params \\ %{}, opts \\ [])

View Source
@spec update(
  client :: Stripe.t(),
  charge :: binary(),
  params :: %{
    optional(:customer) => binary(),
    optional(:description) => binary(),
    optional(:expand) => [binary()],
    optional(:fraud_details) => fraud_details(),
    optional(:metadata) => %{optional(binary()) => binary()} | binary(),
    optional(:receipt_email) => binary(),
    optional(:shipping) => shipping(),
    optional(:transfer_group) => binary()
  },
  opts :: Keyword.t()
) :: {:ok, t()} | {:error, Stripe.ApiErrors.t()} | {:error, term()}

Updates the specified charge by setting the values of the parameters passed. Any parameters not provided will be left unchanged.

Details

  • Method: post
  • Path: /v1/charges/{charge}