View Source Stripe.Charge (stripity_stripe v3.2.0)
The Charge
object represents a single attempt to move money into your Stripe account.
PaymentIntent confirmation is the most common way to create Charges, but transferring
money to a different Stripe account through Connect also creates Charges.
Some legacy payment flows create Charges directly, which is not recommended for new integrations.
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.
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 that was created with the capture
option set to false.
Use the Payment Intents API to initiate a new payment insteadof using this method. Confirmation of the PaymentIntent creates the Charge
object used to request payment, so this method is limited to legacy integrations.
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.
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 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{ 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, 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.
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).amount_captured
Amount in cents (or local equivalent) captured (can be less than the amount attribute on the charge if a partial capture was made).amount_refunded
Amount in cents (or local equivalent) refunded (can be less than the amount attribute on the charge if a partial refund was issued).application
ID of the Connect application that created the charge.application_fee
The application fee (if any) for the charge. See the Connect documentation for details.application_fee_amount
The amount of the application fee (if any) requested for the charge. See the Connect documentation for details.authorization_code
Authorization code on the charge.balance_transaction
ID of the balance transaction that describes the impact of this charge on your account balance (not including refunds or disputes).billing_details
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.captured
If the charge was created without capturing, this Boolean represents whether it is still uncaptured or has since been captured.created
Time at which the object was created. Measured in seconds since the Unix epoch.currency
Three-letter ISO currency code, in lowercase. Must be a supported currency.customer
ID of the customer this charge is for if one exists.description
An arbitrary string attached to the object. Often useful for displaying to users.disputed
Whether the charge has been disputed.failure_balance_transaction
ID of the balance transaction that describes the reversal of the balance on your account due to payment failure.failure_code
Error code explaining reason for charge failure if available (see the errors section for a list of codes).failure_message
Message to user further explaining reason for charge failure if available.fraud_details
Information on fraud assessments for the charge.id
Unique identifier for the object.invoice
ID of the invoice this charge is for if one exists.level3
livemode
Has the valuetrue
if the object exists in live mode or the valuefalse
if the object exists in test mode.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.object
String representing the object's type. Objects of the same type share the same value.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.outcome
Details about whether the payment was accepted, and why. See understanding declines for details.paid
true
if the charge succeeded, or was successfully authorized for later capture.payment_intent
ID of the PaymentIntent associated with this charge, if one exists.payment_method
ID of the payment method used in this charge.payment_method_details
Details about the payment method at the time of the transaction.radar_options
receipt_email
This is the email address that the receipt for this charge was sent to.receipt_number
This is the transaction number that appears on email receipts sent for this charge. This attribute will benull
until a receipt has been sent.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.refunded
Whether the charge has been fully refunded. If the charge is only partially refunded, this attribute will still be false.refunds
A list of refunds that have been applied to the charge.review
ID of the review associated with this charge if one exists.shipping
Shipping information for 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 topayment_method
orpayment_method_details
instead.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.statement_descriptor
For card charges, usestatement_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.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.status
The status of the payment is eithersucceeded
,pending
, orfailed
.transfer
ID of the transfer to thedestination
account (only applicable if the charge was created using thedestination
parameter).transfer_data
An optional dictionary including the account to automatically transfer to as part of a destination charge. See the Connect documentation for details.transfer_group
A string that identifies this transaction as part of a group. See the Connect documentation for details.
An optional dictionary including the account to automatically transfer to as part of a destination charge. See the Connect documentation for details.
Functions
@spec capture( 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 that was created with the capture
option set to false.
Uncaptured payments expire a set number of days after they are created (7 by default), after which they are marked as refunded and capture attempts will fail.
Don’t use this method to capture a PaymentIntent-initiated charge. Use Capture a PaymentIntent.
Details
- Method:
post
- Path:
/v1/charges/{charge}/capture
@spec create( 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()}
Use the Payment Intents API to initiate a new payment insteadof using this method. Confirmation of the PaymentIntent creates the Charge
object used to request payment, so this method is limited to legacy integrations.
@spec list( 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
@spec retrieve( 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}
@spec search( 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`@spec update( 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}