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.
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 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_urlThis 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_methodID of the payment method used in this charge.livemodeHas the valuetrueif the object exists in live mode or the valuefalseif the object exists in test mode.calculated_statement_descriptorThe 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_optionsmetadataSet 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.descriptionAn arbitrary string attached to the object. Often useful for displaying to users.paidtrueif the charge succeeded, or was successfully authorized for later capture.application_feeThe application fee (if any) for the charge. See the Connect documentation for details.failure_messageMessage to user further explaining reason for charge failure if available.reviewID of the review associated with this charge if one exists.payment_intentID of the PaymentIntent associated with this charge, if one exists.refundsA list of refunds that have been applied to the charge.alternate_statement_descriptorson_behalf_ofThe account (if any) the charge was made on behalf of without triggering an automatic transfer. See the Connect documentation for details.customerID of the customer this charge is for if one exists.fraud_detailsInformation on fraud assessments for the charge.amountAmount 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).outcomeDetails about whether the payment was accepted, and why. See understanding declines for details.invoiceID of the invoice this charge is for if one exists.payment_method_detailsDetails about the payment method at the time of the transaction.statement_descriptorFor card charges, usestatement_descriptor_suffixinstead. 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_transactionID of the balance transaction that describes the impact of this charge on your account balance (not including refunds or disputes).applicationID of the Connect application that created the charge.receipt_emailThis is the email address that the receipt for this charge was sent to.failure_balance_transactionID of the balance transaction that describes the reversal of the balance on your account due to payment failure.receipt_numberThis is the transaction number that appears on email receipts sent for this charge. This attribute will benulluntil a receipt has been sent.failure_codeError code explaining reason for charge failure if available (see the errors section for a list of codes).objectString representing the object's type. Objects of the same type share the same value.amount_capturedAmount in %s captured (can be less than the amount attribute on the charge if a partial capture was made).billing_detailslevel3authorization_codeAuthorization code on the charge.sourceThis 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_methodorpayment_method_detailsinstead.capturedIf the charge was created without capturing, this Boolean represents whether it is still uncaptured or has since been captured.amount_refundedAmount in %s refunded (can be less than the amount attribute on the charge if a partial refund was issued).refundedWhether the charge has been fully refunded. If the charge is only partially refunded, this attribute will still be false.currencyThree-letter ISO currency code, in lowercase. Must be a supported currency.createdTime at which the object was created. Measured in seconds since the Unix epoch.transferID of the transfer to thedestinationaccount (only applicable if the charge was created using thedestinationparameter).disputeDetails about the dispute if the charge has been disputed.destinationID of an existing, connected Stripe account to transfer funds to iftransfer_datawas specified in the charge request.source_transferThe transfer ID which created this charge. Only present if the charge came from another Stripe account. See the Connect documentation for details.statusThe status of the payment is eithersucceeded,pending, orfailed.transfer_groupA string that identifies this transaction as part of a group. See the Connect documentation for details.disputedWhether the charge has been disputed.application_fee_amountThe amount of the application fee (if any) requested for the charge. See the Connect documentation for details.statement_descriptor_suffixProvides 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_dataAn optional dictionary including the account to automatically transfer to as part of a destination charge. See the Connect documentation for details.idUnique identifier for the object.shippingShipping information for the charge.
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
@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
@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
@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
@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}
@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
@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}