Class Charge

All Implemented Interfaces:
BalanceTransactionSource, HasId, MetadataStore<Charge>, StripeActiveObject, StripeObjectInterface

public class Charge extends ApiResource implements MetadataStore<Charge>, BalanceTransactionSource
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.
  • Constructor Details

    • Charge

      public Charge()
  • Method Details

    • getApplication

      public String getApplication()
      Get ID of expandable application object.
    • setApplication

      public void setApplication(String id)
    • getApplicationObject

      public Application getApplicationObject()
      Get expanded application.
    • setApplicationObject

      public void setApplicationObject(Application expandableObject)
    • getApplicationFee

      public String getApplicationFee()
      Get ID of expandable applicationFee object.
    • setApplicationFee

      public void setApplicationFee(String id)
    • getApplicationFeeObject

      public ApplicationFee getApplicationFeeObject()
      Get expanded applicationFee.
    • setApplicationFeeObject

      public void setApplicationFeeObject(ApplicationFee expandableObject)
    • getBalanceTransaction

      public String getBalanceTransaction()
      Get ID of expandable balanceTransaction object.
    • setBalanceTransaction

      public void setBalanceTransaction(String id)
    • getBalanceTransactionObject

      public BalanceTransaction getBalanceTransactionObject()
      Get expanded balanceTransaction.
    • setBalanceTransactionObject

      public void setBalanceTransactionObject(BalanceTransaction expandableObject)
    • getCustomer

      public String getCustomer()
      Get ID of expandable customer object.
    • setCustomer

      public void setCustomer(String id)
    • getCustomerObject

      public Customer getCustomerObject()
      Get expanded customer.
    • setCustomerObject

      public void setCustomerObject(Customer expandableObject)
    • getFailureBalanceTransaction

      public String getFailureBalanceTransaction()
      Get ID of expandable failureBalanceTransaction object.
    • setFailureBalanceTransaction

      public void setFailureBalanceTransaction(String id)
    • getFailureBalanceTransactionObject

      public BalanceTransaction getFailureBalanceTransactionObject()
      Get expanded failureBalanceTransaction.
    • setFailureBalanceTransactionObject

      public void setFailureBalanceTransactionObject(BalanceTransaction expandableObject)
    • getInvoice

      public String getInvoice()
      Get ID of expandable invoice object.
    • setInvoice

      public void setInvoice(String id)
    • getInvoiceObject

      public Invoice getInvoiceObject()
      Get expanded invoice.
    • setInvoiceObject

      public void setInvoiceObject(Invoice expandableObject)
    • getOnBehalfOf

      public String getOnBehalfOf()
      Get ID of expandable onBehalfOf object.
    • setOnBehalfOf

      public void setOnBehalfOf(String id)
    • getOnBehalfOfObject

      public Account getOnBehalfOfObject()
      Get expanded onBehalfOf.
    • setOnBehalfOfObject

      public void setOnBehalfOfObject(Account expandableObject)
    • getPaymentIntent

      public String getPaymentIntent()
      Get ID of expandable paymentIntent object.
    • setPaymentIntent

      public void setPaymentIntent(String id)
    • getPaymentIntentObject

      public PaymentIntent getPaymentIntentObject()
      Get expanded paymentIntent.
    • setPaymentIntentObject

      public void setPaymentIntentObject(PaymentIntent expandableObject)
    • getReview

      public String getReview()
      Get ID of expandable review object.
    • setReview

      public void setReview(String id)
    • getReviewObject

      public Review getReviewObject()
      Get expanded review.
    • setReviewObject

      public void setReviewObject(Review expandableObject)
    • getSourceTransfer

      public String getSourceTransfer()
      Get ID of expandable sourceTransfer object.
    • setSourceTransfer

      public void setSourceTransfer(String id)
    • getSourceTransferObject

      public Transfer getSourceTransferObject()
      Get expanded sourceTransfer.
    • setSourceTransferObject

      public void setSourceTransferObject(Transfer expandableObject)
    • getTransfer

      public String getTransfer()
      Get ID of expandable transfer object.
    • setTransfer

      public void setTransfer(String id)
    • getTransferObject

      public Transfer getTransferObject()
      Get expanded transfer.
    • setTransferObject

      public void setTransferObject(Transfer expandableObject)
    • capture

      public Charge capture() throws StripeException
      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.

      Throws:
      StripeException
    • capture

      public Charge capture(RequestOptions options) throws StripeException
      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.

      Throws:
      StripeException
    • capture

      public Charge capture(Map<String,Object> params) throws StripeException
      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.

      Throws:
      StripeException
    • capture

      public Charge capture(Map<String,Object> params, RequestOptions options) throws StripeException
      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.

      Throws:
      StripeException
    • capture

      public Charge capture(ChargeCaptureParams params) throws StripeException
      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.

      Throws:
      StripeException
    • capture

      public Charge capture(ChargeCaptureParams params, RequestOptions options) throws StripeException
      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.

      Throws:
      StripeException
    • create

      public static Charge create(Map<String,Object> params) throws StripeException
      This method is no longer recommended—use the Payment Intents API to initiate a new payment instead. Confirmation of the PaymentIntent creates the Charge object used to request payment.
      Throws:
      StripeException
    • create

      public static Charge create(Map<String,Object> params, RequestOptions options) throws StripeException
      This method is no longer recommended—use the Payment Intents API to initiate a new payment instead. Confirmation of the PaymentIntent creates the Charge object used to request payment.
      Throws:
      StripeException
    • create

      public static Charge create(ChargeCreateParams params) throws StripeException
      This method is no longer recommended—use the Payment Intents API to initiate a new payment instead. Confirmation of the PaymentIntent creates the Charge object used to request payment.
      Throws:
      StripeException
    • create

      public static Charge create(ChargeCreateParams params, RequestOptions options) throws StripeException
      This method is no longer recommended—use the Payment Intents API to initiate a new payment instead. Confirmation of the PaymentIntent creates the Charge object used to request payment.
      Throws:
      StripeException
    • list

      public static ChargeCollection list(Map<String,Object> params) throws StripeException
      Returns a list of charges you’ve previously created. The charges are returned in sorted order, with the most recent charges appearing first.
      Throws:
      StripeException
    • list

      public static ChargeCollection list(Map<String,Object> params, RequestOptions options) throws StripeException
      Returns a list of charges you’ve previously created. The charges are returned in sorted order, with the most recent charges appearing first.
      Throws:
      StripeException
    • list

      public static ChargeCollection list(ChargeListParams params) throws StripeException
      Returns a list of charges you’ve previously created. The charges are returned in sorted order, with the most recent charges appearing first.
      Throws:
      StripeException
    • list

      public static ChargeCollection list(ChargeListParams params, RequestOptions options) throws StripeException
      Returns a list of charges you’ve previously created. The charges are returned in sorted order, with the most recent charges appearing first.
      Throws:
      StripeException
    • retrieve

      public static Charge retrieve(String charge) throws StripeException
      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.
      Throws:
      StripeException
    • retrieve

      public static Charge retrieve(String charge, RequestOptions options) throws StripeException
      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.
      Throws:
      StripeException
    • retrieve

      public static Charge retrieve(String charge, Map<String,Object> params, RequestOptions options) throws StripeException
      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.
      Throws:
      StripeException
    • retrieve

      public static Charge retrieve(String charge, ChargeRetrieveParams params, RequestOptions options) throws StripeException
      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.
      Throws:
      StripeException
    • search

      public static ChargeSearchResult search(Map<String,Object> params) throws StripeException
      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.
      Throws:
      StripeException
    • search

      public static ChargeSearchResult search(Map<String,Object> params, RequestOptions options) throws StripeException
      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.
      Throws:
      StripeException
    • search

      public static ChargeSearchResult search(ChargeSearchParams params) throws StripeException
      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.
      Throws:
      StripeException
    • search

      public static ChargeSearchResult search(ChargeSearchParams params, RequestOptions options) throws StripeException
      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.
      Throws:
      StripeException
    • update

      public Charge update(Map<String,Object> params) throws StripeException
      Updates the specified charge by setting the values of the parameters passed. Any parameters not provided will be left unchanged.
      Specified by:
      update in interface MetadataStore<Charge>
      Throws:
      StripeException
    • update

      public Charge update(Map<String,Object> params, RequestOptions options) throws StripeException
      Updates the specified charge by setting the values of the parameters passed. Any parameters not provided will be left unchanged.
      Specified by:
      update in interface MetadataStore<Charge>
      Throws:
      StripeException
    • update

      public Charge update(ChargeUpdateParams params) throws StripeException
      Updates the specified charge by setting the values of the parameters passed. Any parameters not provided will be left unchanged.
      Throws:
      StripeException
    • update

      public Charge update(ChargeUpdateParams params, RequestOptions options) throws StripeException
      Updates the specified charge by setting the values of the parameters passed. Any parameters not provided will be left unchanged.
      Throws:
      StripeException
    • setResponseGetter

      public void setResponseGetter(StripeResponseGetter responseGetter)
      Description copied from interface: StripeActiveObject
      Method is used by the containing object or StripeResponseGetter implementations to set the StripeResponseGetter instance used to make further requests.
      Specified by:
      setResponseGetter in interface StripeActiveObject
      Overrides:
      setResponseGetter in class ApiResource
      Parameters:
      responseGetter - the StripeResponseGetter instance to use for making further requests.
    • getAmount

      public Long getAmount()
      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).
    • getAmountCaptured

      public Long getAmountCaptured()
      Amount in cents (or local equivalent) captured (can be less than the amount attribute on the charge if a partial capture was made).
    • getAmountRefunded

      public Long getAmountRefunded()
      Amount in cents (or local equivalent) refunded (can be less than the amount attribute on the charge if a partial refund was issued).
    • getApplicationFeeAmount

      public Long getApplicationFeeAmount()
      The amount of the application fee (if any) requested for the charge. See the Connect documentation for details.
    • getAuthorizationCode

      public String getAuthorizationCode()
      Authorization code on the charge.
    • getBillingDetails

      public Charge.BillingDetails getBillingDetails()
    • getCalculatedStatementDescriptor

      public String getCalculatedStatementDescriptor()
      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. This value only exists for card payments.
    • getCaptured

      public Boolean getCaptured()
      If the charge was created without capturing, this Boolean represents whether it is still uncaptured or has since been captured.
    • getCreated

      public Long getCreated()
      Time at which the object was created. Measured in seconds since the Unix epoch.
    • getCurrency

      public String getCurrency()
      Three-letter ISO currency code, in lowercase. Must be a supported currency.
    • getDescription

      public String getDescription()
      An arbitrary string attached to the object. Often useful for displaying to users.
    • getDisputed

      public Boolean getDisputed()
      Whether the charge has been disputed.
    • getFailureCode

      public String getFailureCode()
      Error code explaining reason for charge failure if available (see the errors section for a list of codes).
    • getFailureMessage

      public String getFailureMessage()
      Message to user further explaining reason for charge failure if available.
    • getFraudDetails

      public Charge.FraudDetails getFraudDetails()
      Information on fraud assessments for the charge.
    • getLevel3

      public Charge.Level3 getLevel3()
    • getLivemode

      public Boolean getLivemode()
      Has the value true if the object exists in live mode or the value false if the object exists in test mode.
    • getObject

      public String getObject()
      String representing the object's type. Objects of the same type share the same value.

      Equal to charge.

    • getOutcome

      public Charge.Outcome getOutcome()
      Details about whether the payment was accepted, and why. See understanding declines for details.
    • getPaid

      public Boolean getPaid()
      true if the charge succeeded, or was successfully authorized for later capture.
    • getPaymentMethod

      public String getPaymentMethod()
      ID of the payment method used in this charge.
    • getPaymentMethodDetails

      public Charge.PaymentMethodDetails getPaymentMethodDetails()
      Details about the payment method at the time of the transaction.
    • getRadarOptions

      public Charge.RadarOptions getRadarOptions()
      Options to configure Radar. See Radar Session for more information.
    • getReceiptEmail

      public String getReceiptEmail()
      This is the email address that the receipt for this charge was sent to.
    • getReceiptNumber

      public String getReceiptNumber()
      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.
    • getReceiptUrl

      public String getReceiptUrl()
      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.
    • getRefunded

      public Boolean getRefunded()
      Whether the charge has been fully refunded. If the charge is only partially refunded, this attribute will still be false.
    • getRefunds

      public RefundCollection getRefunds()
      A list of refunds that have been applied to the charge.
    • getShipping

      public ShippingDetails getShipping()
      Shipping information for the charge.
    • getSource

      public PaymentSource getSource()
      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.
    • getStatementDescriptor

      public String getStatementDescriptor()
      For a non-card charge, text that appears on the customer's statement as the statement descriptor. This value overrides the account's default statement descriptor. For information about requirements, including the 22-character limit, see the Statement Descriptor docs.

      For a card charge, this value is ignored unless you don't specify a statement_descriptor_suffix, in which case this value is used as the suffix.

    • getStatementDescriptorSuffix

      public String getStatementDescriptorSuffix()
      Provides information about a card charge. Concatenated to the account's statement descriptor prefix to form the complete statement descriptor that appears on the customer's statement. If the account has no prefix value, the suffix is concatenated to the account's statement descriptor.
    • getStatus

      public String getStatus()
      The status of the payment is either succeeded, pending, or failed.

      One of failed, pending, or succeeded.

    • getTransferData

      public Charge.TransferData getTransferData()
      An optional dictionary including the account to automatically transfer to as part of a destination charge. See the Connect documentation for details.
    • getTransferGroup

      public String getTransferGroup()
      A string that identifies this transaction as part of a group. See the Connect documentation for details.
    • setAmount

      public void setAmount(Long 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).
    • setAmountCaptured

      public void setAmountCaptured(Long amountCaptured)
      Amount in cents (or local equivalent) captured (can be less than the amount attribute on the charge if a partial capture was made).
    • setAmountRefunded

      public void setAmountRefunded(Long amountRefunded)
      Amount in cents (or local equivalent) refunded (can be less than the amount attribute on the charge if a partial refund was issued).
    • setApplicationFeeAmount

      public void setApplicationFeeAmount(Long applicationFeeAmount)
      The amount of the application fee (if any) requested for the charge. See the Connect documentation for details.
    • setAuthorizationCode

      public void setAuthorizationCode(String authorizationCode)
      Authorization code on the charge.
    • setBillingDetails

      public void setBillingDetails(Charge.BillingDetails billingDetails)
    • setCalculatedStatementDescriptor

      public void setCalculatedStatementDescriptor(String calculatedStatementDescriptor)
      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. This value only exists for card payments.
    • setCaptured

      public void setCaptured(Boolean captured)
      If the charge was created without capturing, this Boolean represents whether it is still uncaptured or has since been captured.
    • setCreated

      public void setCreated(Long created)
      Time at which the object was created. Measured in seconds since the Unix epoch.
    • setCurrency

      public void setCurrency(String currency)
      Three-letter ISO currency code, in lowercase. Must be a supported currency.
    • setDescription

      public void setDescription(String description)
      An arbitrary string attached to the object. Often useful for displaying to users.
    • setDisputed

      public void setDisputed(Boolean disputed)
      Whether the charge has been disputed.
    • setFailureCode

      public void setFailureCode(String failureCode)
      Error code explaining reason for charge failure if available (see the errors section for a list of codes).
    • setFailureMessage

      public void setFailureMessage(String failureMessage)
      Message to user further explaining reason for charge failure if available.
    • setFraudDetails

      public void setFraudDetails(Charge.FraudDetails fraudDetails)
      Information on fraud assessments for the charge.
    • setId

      public void setId(String id)
      Unique identifier for the object.
    • setLevel3

      public void setLevel3(Charge.Level3 level3)
    • setLivemode

      public void setLivemode(Boolean livemode)
      Has the value true if the object exists in live mode or the value false if the object exists in test mode.
    • setMetadata

      public void setMetadata(Map<String,String> 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.
    • setObject

      public void setObject(String object)
      String representing the object's type. Objects of the same type share the same value.

      Equal to charge.

    • setOutcome

      public void setOutcome(Charge.Outcome outcome)
      Details about whether the payment was accepted, and why. See understanding declines for details.
    • setPaid

      public void setPaid(Boolean paid)
      true if the charge succeeded, or was successfully authorized for later capture.
    • setPaymentMethod

      public void setPaymentMethod(String paymentMethod)
      ID of the payment method used in this charge.
    • setPaymentMethodDetails

      public void setPaymentMethodDetails(Charge.PaymentMethodDetails paymentMethodDetails)
      Details about the payment method at the time of the transaction.
    • setRadarOptions

      public void setRadarOptions(Charge.RadarOptions radarOptions)
      Options to configure Radar. See Radar Session for more information.
    • setReceiptEmail

      public void setReceiptEmail(String receiptEmail)
      This is the email address that the receipt for this charge was sent to.
    • setReceiptNumber

      public void setReceiptNumber(String receiptNumber)
      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.
    • setReceiptUrl

      public void setReceiptUrl(String receiptUrl)
      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.
    • setRefunded

      public void setRefunded(Boolean refunded)
      Whether the charge has been fully refunded. If the charge is only partially refunded, this attribute will still be false.
    • setRefunds

      public void setRefunds(RefundCollection refunds)
      A list of refunds that have been applied to the charge.
    • setShipping

      public void setShipping(ShippingDetails shipping)
      Shipping information for the charge.
    • setSource

      public void setSource(PaymentSource 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.
    • setStatementDescriptor

      public void setStatementDescriptor(String statementDescriptor)
      For a non-card charge, text that appears on the customer's statement as the statement descriptor. This value overrides the account's default statement descriptor. For information about requirements, including the 22-character limit, see the Statement Descriptor docs.

      For a card charge, this value is ignored unless you don't specify a statement_descriptor_suffix, in which case this value is used as the suffix.

    • setStatementDescriptorSuffix

      public void setStatementDescriptorSuffix(String statementDescriptorSuffix)
      Provides information about a card charge. Concatenated to the account's statement descriptor prefix to form the complete statement descriptor that appears on the customer's statement. If the account has no prefix value, the suffix is concatenated to the account's statement descriptor.
    • setStatus

      public void setStatus(String status)
      The status of the payment is either succeeded, pending, or failed.

      One of failed, pending, or succeeded.

    • setTransferData

      public void setTransferData(Charge.TransferData transferData)
      An optional dictionary including the account to automatically transfer to as part of a destination charge. See the Connect documentation for details.
    • setTransferGroup

      public void setTransferGroup(String transferGroup)
      A string that identifies this transaction as part of a group. See the Connect documentation for details.
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • canEqual

      protected boolean canEqual(Object other)
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • getId

      public String getId()
      Unique identifier for the object.
      Specified by:
      getId in interface HasId
    • getMetadata

      public Map<String,String> getMetadata()
      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.
      Specified by:
      getMetadata in interface MetadataStore<Charge>