Class: Stripe::PaymentIntent

Inherits:
APIResource show all
Extended by:
APIOperations::Create, APIOperations::List, APIOperations::NestedResource, APIOperations::Search
Includes:
APIOperations::Save
Defined in:
lib/stripe/resources/payment_intent.rb

Overview

A PaymentIntent guides you through the process of collecting a payment from your customer. We recommend that you create exactly one PaymentIntent for each order or customer session in your system. You can reference the PaymentIntent later to see the history of payment attempts for a particular session.

A PaymentIntent transitions through multiple statuses throughout its lifetime as it interfaces with Stripe.js to perform authentication flows and ultimately creates at most one successful charge.

Related guide: Payment Intents API

Defined Under Namespace

Classes: AdvancedFeatureDetails, AgentDetails, AllocatedFunds, AmountDetails, AsyncWorkflows, AutomaticPaymentMethods, Hooks, LastPaymentError, ManagedPayments, NextAction, PaymentDetails, PaymentMethodConfigurationDetails, PaymentMethodOptions, PaymentsOrchestration, PresentmentDetails, Processing, Redaction, Shipping, TestHelpers, TransferData

Constant Summary collapse

OBJECT_NAME =
"payment_intent"

Constants inherited from StripeObject

StripeObject::RESERVED_FIELD_NAMES

Instance Attribute Summary collapse

Attributes inherited from APIResource

#save_with_parent

Attributes inherited from StripeObject

#last_response

Class Method Summary collapse

Instance Method Summary collapse

Methods included from APIOperations::Create

create

Methods included from APIOperations::List

list

Methods included from APIOperations::NestedResource

nested_resource_class_methods

Methods included from APIOperations::Search

_search

Methods included from APIOperations::Save

included, #save

Methods inherited from APIResource

class_name, custom_method, #refresh, #request_stripe_object, resource_url, #resource_url, retrieve, save_nested_resource

Methods included from APIOperations::Request

included

Methods inherited from StripeObject

#==, #[], #[]=, #_get_inner_class_type, additive_object_param, additive_object_param?, #as_json, construct_from, #deleted?, #dirty!, #each, #eql?, field_encodings, #hash, #initialize, #inspect, #keys, #marshal_dump, #marshal_load, protected_fields, #serialize_params, #to_hash, #to_json, #to_s, #update_attributes, #values

Constructor Details

This class inherits a constructor from Stripe::StripeObject

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Stripe::StripeObject

Instance Attribute Details

#advanced_feature_detailsObject (readonly)

Attribute for field advanced_feature_details



5438
5439
5440
# File 'lib/stripe/resources/payment_intent.rb', line 5438

def advanced_feature_details
  @advanced_feature_details
end

#agent_detailsObject (readonly)

Details about the agent that initiated the creation of this PaymentIntent.



5440
5441
5442
# File 'lib/stripe/resources/payment_intent.rb', line 5440

def agent_details
  @agent_details
end

#allocated_fundsObject (readonly)

Allocated Funds configuration for this PaymentIntent.



5442
5443
5444
# File 'lib/stripe/resources/payment_intent.rb', line 5442

def allocated_funds
  @allocated_funds
end

#allowed_payment_method_typesObject (readonly)

The list of payment method types allowed for use with this payment. Stripe automatically returns compatible payment methods from this list in the payment_method_types field of the response, based on the other PaymentIntent parameters, such as currency, amount, and customer.



5444
5445
5446
# File 'lib/stripe/resources/payment_intent.rb', line 5444

def allowed_payment_method_types
  @allowed_payment_method_types
end

#amountObject (readonly)

Amount intended to be collected by this PaymentIntent. 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).



5446
5447
5448
# File 'lib/stripe/resources/payment_intent.rb', line 5446

def amount
  @amount
end

#amount_capturableObject (readonly)

Amount that can be captured from this PaymentIntent.



5448
5449
5450
# File 'lib/stripe/resources/payment_intent.rb', line 5448

def amount_capturable
  @amount_capturable
end

#amount_detailsObject (readonly)

Attribute for field amount_details



5450
5451
5452
# File 'lib/stripe/resources/payment_intent.rb', line 5450

def amount_details
  @amount_details
end

#amount_receivedObject (readonly)

Amount that this PaymentIntent collects.



5452
5453
5454
# File 'lib/stripe/resources/payment_intent.rb', line 5452

def amount_received
  @amount_received
end

#applicationObject (readonly)

ID of the Connect application that created the PaymentIntent.



5454
5455
5456
# File 'lib/stripe/resources/payment_intent.rb', line 5454

def application
  @application
end

#application_fee_amountObject (readonly)

The amount of the application fee (if any) that will be requested to be applied to the payment and transferred to the application owner's Stripe account. The amount of the application fee collected will be capped at the total amount captured. For more information, see the PaymentIntents use case for connected accounts.



5456
5457
5458
# File 'lib/stripe/resources/payment_intent.rb', line 5456

def application_fee_amount
  @application_fee_amount
end

#async_workflowsObject (readonly)

Attribute for field async_workflows



5458
5459
5460
# File 'lib/stripe/resources/payment_intent.rb', line 5458

def async_workflows
  @async_workflows
end

#automatic_payment_methodsObject (readonly)

Settings to configure compatible payment methods from the Stripe Dashboard



5460
5461
5462
# File 'lib/stripe/resources/payment_intent.rb', line 5460

def automatic_payment_methods
  @automatic_payment_methods
end

#canceled_atObject (readonly)

Populated when status is canceled, this is the time at which the PaymentIntent was canceled. Measured in seconds since the Unix epoch.



5462
5463
5464
# File 'lib/stripe/resources/payment_intent.rb', line 5462

def canceled_at
  @canceled_at
end

#cancellation_reasonObject (readonly)

Reason for cancellation of this PaymentIntent, either user-provided (duplicate, fraudulent, requested_by_customer, or abandoned) or generated by Stripe internally (failed_invoice, void_invoice, automatic, or expired).



5464
5465
5466
# File 'lib/stripe/resources/payment_intent.rb', line 5464

def cancellation_reason
  @cancellation_reason
end

#capture_methodObject (readonly)

Controls when the funds will be captured from the customer's account.



5466
5467
5468
# File 'lib/stripe/resources/payment_intent.rb', line 5466

def capture_method
  @capture_method
end

#client_secretObject (readonly)

The client secret of this PaymentIntent. Used for client-side retrieval using a publishable key.

The client secret can be used to complete a payment from your frontend. It should not be stored, logged, or exposed to anyone other than the customer. Make sure that you have TLS enabled on any page that includes the client secret.

Refer to our docs to accept a payment and learn about how client_secret should be handled.



5472
5473
5474
# File 'lib/stripe/resources/payment_intent.rb', line 5472

def client_secret
  @client_secret
end

#confirmation_methodObject (readonly)

Describes whether we can confirm this PaymentIntent automatically, or if it requires customer action to confirm the payment.



5474
5475
5476
# File 'lib/stripe/resources/payment_intent.rb', line 5474

def confirmation_method
  @confirmation_method
end

#createdObject (readonly)

Time at which the object was created. Measured in seconds since the Unix epoch.



5476
5477
5478
# File 'lib/stripe/resources/payment_intent.rb', line 5476

def created
  @created
end

#currencyObject (readonly)

Three-letter ISO currency code, in lowercase. Must be a supported currency.



5478
5479
5480
# File 'lib/stripe/resources/payment_intent.rb', line 5478

def currency
  @currency
end

#customerObject (readonly)

ID of the Customer this PaymentIntent belongs to, if one exists.

Payment methods attached to other Customers cannot be used with this PaymentIntent.

If setup_future_usage is set and this PaymentIntent's payment method is not card_present, then the payment method attaches to the Customer after the PaymentIntent has been confirmed and any required actions from the user are complete. If the payment method is card_present and isn't a digital wallet, then a generated_card payment method representing the card is created and attached to the Customer instead.



5484
5485
5486
# File 'lib/stripe/resources/payment_intent.rb', line 5484

def customer
  @customer
end

#customer_accountObject (readonly)

ID of the Account representing the customer that this PaymentIntent belongs to, if one exists.

Payment methods attached to other Accounts cannot be used with this PaymentIntent.

If setup_future_usage is set and this PaymentIntent's payment method is not card_present, then the payment method attaches to the Account after the PaymentIntent has been confirmed and any required actions from the user are complete. If the payment method is card_present and isn't a digital wallet, then a generated_card payment method representing the card is created and attached to the Account instead.



5490
5491
5492
# File 'lib/stripe/resources/payment_intent.rb', line 5490

def 
  @customer_account
end

#descriptionObject (readonly)

An arbitrary string attached to the object. Often useful for displaying to users.



5492
5493
5494
# File 'lib/stripe/resources/payment_intent.rb', line 5492

def description
  @description
end

#excluded_payment_method_typesObject (readonly)

The list of payment method types to exclude from use with this payment.



5494
5495
5496
# File 'lib/stripe/resources/payment_intent.rb', line 5494

def excluded_payment_method_types
  @excluded_payment_method_types
end

#fx_quoteObject (readonly)

The FX Quote used for the PaymentIntent.



5496
5497
5498
# File 'lib/stripe/resources/payment_intent.rb', line 5496

def fx_quote
  @fx_quote
end

#hooksObject (readonly)

Attribute for field hooks



5498
5499
5500
# File 'lib/stripe/resources/payment_intent.rb', line 5498

def hooks
  @hooks
end

#idObject (readonly)

Unique identifier for the object.



5500
5501
5502
# File 'lib/stripe/resources/payment_intent.rb', line 5500

def id
  @id
end

#last_payment_errorObject (readonly)

The payment error encountered in the previous PaymentIntent confirmation. It will be cleared if the PaymentIntent is later updated for any reason.



5502
5503
5504
# File 'lib/stripe/resources/payment_intent.rb', line 5502

def last_payment_error
  @last_payment_error
end

#latest_chargeObject (readonly)

ID of the latest Charge object created by this PaymentIntent. This property is null until PaymentIntent confirmation is attempted.



5504
5505
5506
# File 'lib/stripe/resources/payment_intent.rb', line 5504

def latest_charge
  @latest_charge
end

#latest_payment_attempt_recordObject (readonly)

ID of the latest Payment Attempt Record object created by this PaymentIntent. This property is null until PaymentIntent confirmation is attempted.



5506
5507
5508
# File 'lib/stripe/resources/payment_intent.rb', line 5506

def latest_payment_attempt_record
  @latest_payment_attempt_record
end

#livemodeObject (readonly)

If the object exists in live mode, the value is true. If the object exists in test mode, the value is false.



5508
5509
5510
# File 'lib/stripe/resources/payment_intent.rb', line 5508

def livemode
  @livemode
end

#managed_paymentsObject (readonly)

Settings for Managed Payments.



5510
5511
5512
# File 'lib/stripe/resources/payment_intent.rb', line 5510

def managed_payments
  @managed_payments
end

#metadataObject (readonly)

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. Learn more about storing information in metadata.



5512
5513
5514
# File 'lib/stripe/resources/payment_intent.rb', line 5512

def 
  @metadata
end

#next_actionObject (readonly)

If present, this property tells you what actions you need to take in order for your customer to fulfill a payment using the provided source.



5514
5515
5516
# File 'lib/stripe/resources/payment_intent.rb', line 5514

def next_action
  @next_action
end

#objectObject (readonly)

String representing the object's type. Objects of the same type share the same value.



5516
5517
5518
# File 'lib/stripe/resources/payment_intent.rb', line 5516

def object
  @object
end

#on_behalf_ofObject (readonly)

You can specify the settlement merchant as the connected account using the on_behalf_of attribute on the charge. See the PaymentIntents use case for connected accounts for details.



5519
5520
5521
# File 'lib/stripe/resources/payment_intent.rb', line 5519

def on_behalf_of
  @on_behalf_of
end

#payment_detailsObject (readonly)

Attribute for field payment_details



5521
5522
5523
# File 'lib/stripe/resources/payment_intent.rb', line 5521

def payment_details
  @payment_details
end

#payment_methodObject (readonly)

ID of the payment method used in this PaymentIntent.



5523
5524
5525
# File 'lib/stripe/resources/payment_intent.rb', line 5523

def payment_method
  @payment_method
end

#payment_method_configuration_detailsObject (readonly)

Information about the payment method configuration used for this PaymentIntent.



5525
5526
5527
# File 'lib/stripe/resources/payment_intent.rb', line 5525

def payment_method_configuration_details
  @payment_method_configuration_details
end

#payment_method_optionsObject (readonly)

Payment-method-specific configuration for this PaymentIntent.



5527
5528
5529
# File 'lib/stripe/resources/payment_intent.rb', line 5527

def payment_method_options
  @payment_method_options
end

#payment_method_typesObject (readonly)

The list of payment method types (e.g. card) that this PaymentIntent is allowed to use. A comprehensive list of valid payment method types can be found here.



5529
5530
5531
# File 'lib/stripe/resources/payment_intent.rb', line 5529

def payment_method_types
  @payment_method_types
end

#payment_recordObject (readonly)

ID of the Payment Record object created by this PaymentIntent.



5531
5532
5533
# File 'lib/stripe/resources/payment_intent.rb', line 5531

def payment_record
  @payment_record
end

#payments_orchestrationObject (readonly)

When you enable this parameter, this PaymentIntent will route your payment to processors that you configure in the dashboard.



5533
5534
5535
# File 'lib/stripe/resources/payment_intent.rb', line 5533

def payments_orchestration
  @payments_orchestration
end

#presentment_detailsObject (readonly)

Attribute for field presentment_details



5535
5536
5537
# File 'lib/stripe/resources/payment_intent.rb', line 5535

def presentment_details
  @presentment_details
end

#processingObject (readonly)

If present, this property tells you about the processing state of the payment.



5537
5538
5539
# File 'lib/stripe/resources/payment_intent.rb', line 5537

def processing
  @processing
end

#receipt_emailObject (readonly)

Email address that the receipt for the resulting payment will be sent to. If receipt_email is specified for a payment in live mode, a receipt will be sent regardless of your email settings.



5539
5540
5541
# File 'lib/stripe/resources/payment_intent.rb', line 5539

def receipt_email
  @receipt_email
end

#redactionObject (readonly)

Redaction status of this PaymentIntent. If the PaymentIntent isn't redacted, this field is null.



5541
5542
5543
# File 'lib/stripe/resources/payment_intent.rb', line 5541

def redaction
  @redaction
end

#reviewObject (readonly)

ID of the review associated with this PaymentIntent, if any.



5543
5544
5545
# File 'lib/stripe/resources/payment_intent.rb', line 5543

def review
  @review
end

#secret_key_confirmationObject (readonly)

Indicates whether confirmation for this PaymentIntent using a secret key is required or optional.



5545
5546
5547
# File 'lib/stripe/resources/payment_intent.rb', line 5545

def secret_key_confirmation
  @secret_key_confirmation
end

#setup_future_usageObject (readonly)

Indicates that you intend to make future payments with this PaymentIntent's payment method.

If you provide a Customer with the PaymentIntent, you can use this parameter to attach the payment method to the Customer after the PaymentIntent is confirmed and the customer completes any required actions. If you don't provide a Customer, you can still attach the payment method to a Customer after the transaction completes.

If the payment method is card_present and isn't a digital wallet, Stripe creates and attaches a generated_card payment method representing the card to the Customer instead.

When processing card payments, Stripe uses setup_future_usage to help you comply with regional legislation and network rules, such as SCA.



5553
5554
5555
# File 'lib/stripe/resources/payment_intent.rb', line 5553

def setup_future_usage
  @setup_future_usage
end

#shippingObject (readonly)

Shipping information for this PaymentIntent.



5555
5556
5557
# File 'lib/stripe/resources/payment_intent.rb', line 5555

def shipping
  @shipping
end

#sourceObject (readonly)

This is a legacy field that will be removed in the future. It is the ID of the Source object that is associated with this PaymentIntent, if one was supplied.



5557
5558
5559
# File 'lib/stripe/resources/payment_intent.rb', line 5557

def source
  @source
end

#statement_descriptorObject (readonly)

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

Setting this value for a card charge returns an error. For card charges, set the statement_descriptor_suffix instead.



5561
5562
5563
# File 'lib/stripe/resources/payment_intent.rb', line 5561

def statement_descriptor
  @statement_descriptor
end

#statement_descriptor_suffixObject (readonly)

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.



5563
5564
5565
# File 'lib/stripe/resources/payment_intent.rb', line 5563

def statement_descriptor_suffix
  @statement_descriptor_suffix
end

#statusObject (readonly)

Status of this PaymentIntent, one of requires_payment_method, requires_confirmation, requires_action, processing, requires_capture, canceled, or succeeded. Read more about each PaymentIntent status.



5565
5566
5567
# File 'lib/stripe/resources/payment_intent.rb', line 5565

def status
  @status
end

#transfer_dataObject (readonly)

The data that automatically creates a Transfer after the payment finalizes. Learn more about the use case for connected accounts.



5567
5568
5569
# File 'lib/stripe/resources/payment_intent.rb', line 5567

def transfer_data
  @transfer_data
end

#transfer_groupObject (readonly)

A string that identifies the resulting payment as part of a group. Learn more about the use case for connected accounts.



5569
5570
5571
# File 'lib/stripe/resources/payment_intent.rb', line 5569

def transfer_group
  @transfer_group
end

Class Method Details

.apply_customer_balance(intent, params = {}, opts = {}) ⇒ Object

Manually reconcile the remaining amount for a customer_balance PaymentIntent.



5582
5583
5584
5585
5586
5587
5588
5589
# File 'lib/stripe/resources/payment_intent.rb', line 5582

def self.apply_customer_balance(intent, params = {}, opts = {})
  request_stripe_object(
    method: :post,
    path: format("/v1/payment_intents/%<intent>s/apply_customer_balance", { intent: CGI.escape(intent) }),
    params: params,
    opts: opts
  )
end

.cancel(intent, params = {}, opts = {}) ⇒ Object

You can cancel a PaymentIntent object when it's in one of these statuses: requires_payment_method, requires_capture, requires_confirmation, requires_action or, in rare cases, processing.

After it's canceled, no additional charges are made by the PaymentIntent and any operations on the PaymentIntent fail with an error. For PaymentIntents with a status of requires_capture, the remaining amount_capturable is automatically refunded.

You can directly cancel the PaymentIntent for a Checkout Session only when the PaymentIntent has a status of requires_capture. Otherwise, you must expire the Checkout Session.



5610
5611
5612
5613
5614
5615
5616
5617
# File 'lib/stripe/resources/payment_intent.rb', line 5610

def self.cancel(intent, params = {}, opts = {})
  request_stripe_object(
    method: :post,
    path: format("/v1/payment_intents/%<intent>s/cancel", { intent: CGI.escape(intent) }),
    params: params,
    opts: opts
  )
end

.capture(intent, params = {}, opts = {}) ⇒ Object

Capture the funds of an existing uncaptured PaymentIntent when its status is requires_capture.

Uncaptured PaymentIntents are cancelled a set number of days (7 by default) after their creation.

Learn more about separate authorization and capture.



5638
5639
5640
5641
5642
5643
5644
5645
# File 'lib/stripe/resources/payment_intent.rb', line 5638

def self.capture(intent, params = {}, opts = {})
  request_stripe_object(
    method: :post,
    path: format("/v1/payment_intents/%<intent>s/capture", { intent: CGI.escape(intent) }),
    params: params,
    opts: opts
  )
end

.confirm(intent, params = {}, opts = {}) ⇒ Object

Confirm that your customer intends to pay with current or provided payment method. Upon confirmation, the PaymentIntent will attempt to initiate a payment.

If the selected payment method requires additional authentication steps, the PaymentIntent will transition to the requires_action status and suggest additional actions via next_action. If payment fails, the PaymentIntent transitions to the requires_payment_method status or the canceled status if the confirmation limit is reached. If payment succeeds, the PaymentIntent will transition to the succeeded status (or requires_capture, if capture_method is set to manual).

If the confirmation_method is automatic, payment may be attempted using our client SDKs and the PaymentIntent's client_secret. After next_actions are handled by the client, no additional confirmation is required to complete the payment.

If the confirmation_method is manual, all payment attempts must be initiated using a secret key.

If any actions are required for the payment, the PaymentIntent will return to the requires_confirmation state after those actions are completed. Your server needs to then explicitly re-confirm the PaymentIntent to initiate the next payment attempt.

There is a variable upper limit on how many times a PaymentIntent can be confirmed. After this limit is reached, any further calls to this endpoint will transition the PaymentIntent to the canceled state.



5716
5717
5718
5719
5720
5721
5722
5723
# File 'lib/stripe/resources/payment_intent.rb', line 5716

def self.confirm(intent, params = {}, opts = {})
  request_stripe_object(
    method: :post,
    path: format("/v1/payment_intents/%<intent>s/confirm", { intent: CGI.escape(intent) }),
    params: params,
    opts: opts
  )
end

.create(params = {}, opts = {}) ⇒ Object

Creates a PaymentIntent object.

After the PaymentIntent is created, attach a payment method and confirm to continue the payment. Learn more about the available payment flows with the Payment Intents API.

When you use confirm=true during creation, it's equivalent to creating and confirming the PaymentIntent in the same call. You can use any parameters available in the confirm API when you supply confirm=true.



5735
5736
5737
# File 'lib/stripe/resources/payment_intent.rb', line 5735

def self.create(params = {}, opts = {})
  request_stripe_object(method: :post, path: "/v1/payment_intents", params: params, opts: opts)
end

.decrement_authorization(intent, params = {}, opts = {}) ⇒ Object

Perform a decremental authorization on an eligible PaymentIntent. To be eligible, the PaymentIntent's status must be requires_capture and decremental_authorization.status must be available.

Decremental authorizations decrease the authorized amount on your customer's card to the new, lower amount provided. A single PaymentIntent can call this endpoint multiple times to further decrease the authorized amount.

After decrement, the PaymentIntent object returns with the updated amount. The PaymentIntent will now be capturable up to the new authorized amount.

Each PaymentIntent can have a maximum of 10 decremental or incremental authorization attempts, including declines. After it's fully captured, a PaymentIntent can no longer be decremented.



5780
5781
5782
5783
5784
5785
5786
5787
# File 'lib/stripe/resources/payment_intent.rb', line 5780

def self.decrement_authorization(intent, params = {}, opts = {})
  request_stripe_object(
    method: :post,
    path: format("/v1/payment_intents/%<intent>s/decrement_authorization", { intent: CGI.escape(intent) }),
    params: params,
    opts: opts
  )
end

.field_remappingsObject



6042
6043
6044
# File 'lib/stripe/resources/payment_intent.rb', line 6042

def self.field_remappings
  @field_remappings = {}
end

.increment_authorization(intent, params = {}, opts = {}) ⇒ Object

Perform an incremental authorization on an eligible PaymentIntent. To be eligible, the PaymentIntent's status must be requires_capture and incremental_authorization_supported must be true.

Incremental authorizations attempt to increase the authorized amount on your customer's card to the new, higher amount provided. Similar to the initial authorization, incremental authorizations can be declined. A single PaymentIntent can call this endpoint multiple times to further increase the authorized amount.

If the incremental authorization succeeds, the PaymentIntent object returns with the updated amount. If the incremental authorization fails, a card_declined error returns, and no other fields on the PaymentIntent or Charge update. The PaymentIntent object remains capturable for the previously authorized amount.

Each PaymentIntent can have a maximum of 10 incremental authorization attempts, including declines. After it's captured, a PaymentIntent can no longer be incremented.

Learn more about incremental authorizations with in-person payments and online payments.



5850
5851
5852
5853
5854
5855
5856
5857
# File 'lib/stripe/resources/payment_intent.rb', line 5850

def self.increment_authorization(intent, params = {}, opts = {})
  request_stripe_object(
    method: :post,
    path: format("/v1/payment_intents/%<intent>s/increment_authorization", { intent: CGI.escape(intent) }),
    params: params,
    opts: opts
  )
end

.inner_class_typesObject



6018
6019
6020
6021
6022
6023
6024
6025
6026
6027
6028
6029
6030
6031
6032
6033
6034
6035
6036
6037
6038
6039
6040
# File 'lib/stripe/resources/payment_intent.rb', line 6018

def self.inner_class_types
  @inner_class_types = {
    advanced_feature_details: AdvancedFeatureDetails,
    agent_details: AgentDetails,
    allocated_funds: AllocatedFunds,
    amount_details: AmountDetails,
    async_workflows: AsyncWorkflows,
    automatic_payment_methods: AutomaticPaymentMethods,
    hooks: Hooks,
    last_payment_error: LastPaymentError,
    managed_payments: ManagedPayments,
    next_action: NextAction,
    payment_details: PaymentDetails,
    payment_method_configuration_details: PaymentMethodConfigurationDetails,
    payment_method_options: PaymentMethodOptions,
    payments_orchestration: PaymentsOrchestration,
    presentment_details: PresentmentDetails,
    processing: Processing,
    redaction: Redaction,
    shipping: Shipping,
    transfer_data: TransferData,
  }
end

.list(params = {}, opts = {}) ⇒ Object

Returns a list of PaymentIntents.



5860
5861
5862
# File 'lib/stripe/resources/payment_intent.rb', line 5860

def self.list(params = {}, opts = {})
  request_stripe_object(method: :get, path: "/v1/payment_intents", params: params, opts: opts)
end

.object_nameObject



24
25
26
# File 'lib/stripe/resources/payment_intent.rb', line 24

def self.object_name
  "payment_intent"
end

.reauthorize(intent, params = {}, opts = {}) ⇒ Object

Reauthorize a PaymentIntent to obtain a new valid authorization after the initial authorization has expired.

When a PaymentIntent's authorization expires and the capture window elapses, the PaymentIntent transitions to requires_reauthorization status with amount_capturable set to 0. This endpoint brings the PaymentIntent back to requires_capture status, allowing you to capture payment.

This is useful for retail and ecommerce scenarios with delayed shipments where authorization validity periods (typically 7 days) expire before the merchant is ready to capture payment.



5889
5890
5891
5892
5893
5894
5895
5896
# File 'lib/stripe/resources/payment_intent.rb', line 5889

def self.reauthorize(intent, params = {}, opts = {})
  request_stripe_object(
    method: :post,
    path: format("/v1/payment_intents/%<intent>s/reauthorize", { intent: CGI.escape(intent) }),
    params: params,
    opts: opts
  )
end

.search(params = {}, opts = {}) ⇒ Object



5898
5899
5900
5901
5902
5903
5904
5905
# File 'lib/stripe/resources/payment_intent.rb', line 5898

def self.search(params = {}, opts = {})
  request_stripe_object(
    method: :get,
    path: "/v1/payment_intents/search",
    params: params,
    opts: opts
  )
end

.search_auto_paging_each(params = {}, opts = {}, &blk) ⇒ Object



5907
5908
5909
# File 'lib/stripe/resources/payment_intent.rb', line 5907

def self.search_auto_paging_each(params = {}, opts = {}, &blk)
  search(params, opts).auto_paging_each(&blk)
end

.trigger_action(intent, params = {}, opts = {}) ⇒ Object

Trigger an external action on a PaymentIntent.



5922
5923
5924
5925
5926
5927
5928
5929
# File 'lib/stripe/resources/payment_intent.rb', line 5922

def self.trigger_action(intent, params = {}, opts = {})
  request_stripe_object(
    method: :post,
    path: format("/v1/test/payment_intents/%<intent>s/trigger_action", { intent: CGI.escape(intent) }),
    params: params,
    opts: opts
  )
end

.update(intent, params = {}, opts = {}) ⇒ Object

Updates properties on a PaymentIntent object without confirming.

Depending on which properties you update, you might need to confirm the PaymentIntent again. For example, updating the payment_method always requires you to confirm the PaymentIntent again. If you prefer to update and confirm at the same time, we recommend updating properties through the confirm API instead.



5938
5939
5940
5941
5942
5943
5944
5945
# File 'lib/stripe/resources/payment_intent.rb', line 5938

def self.update(intent, params = {}, opts = {})
  request_stripe_object(
    method: :post,
    path: format("/v1/payment_intents/%<intent>s", { intent: CGI.escape(intent) }),
    params: params,
    opts: opts
  )
end

.update_crypto_refund_address(intent, params = {}, opts = {}) ⇒ Object

Updates the refund address for a static crypto deposit PaymentIntent on the specified network.



5958
5959
5960
5961
5962
5963
5964
5965
# File 'lib/stripe/resources/payment_intent.rb', line 5958

def self.update_crypto_refund_address(intent, params = {}, opts = {})
  request_stripe_object(
    method: :post,
    path: format("/v1/payment_intents/%<intent>s/update_crypto_refund_address", { intent: CGI.escape(intent) }),
    params: params,
    opts: opts
  )
end

.verify_microdeposits(intent, params = {}, opts = {}) ⇒ Object

Verifies microdeposits on a PaymentIntent object.



5978
5979
5980
5981
5982
5983
5984
5985
# File 'lib/stripe/resources/payment_intent.rb', line 5978

def self.verify_microdeposits(intent, params = {}, opts = {})
  request_stripe_object(
    method: :post,
    path: format("/v1/payment_intents/%<intent>s/verify_microdeposits", { intent: CGI.escape(intent) }),
    params: params,
    opts: opts
  )
end

Instance Method Details

#apply_customer_balance(params = {}, opts = {}) ⇒ Object

Manually reconcile the remaining amount for a customer_balance PaymentIntent.



5572
5573
5574
5575
5576
5577
5578
5579
# File 'lib/stripe/resources/payment_intent.rb', line 5572

def apply_customer_balance(params = {}, opts = {})
  request_stripe_object(
    method: :post,
    path: format("/v1/payment_intents/%<intent>s/apply_customer_balance", { intent: CGI.escape(self["id"]) }),
    params: params,
    opts: opts
  )
end

#cancel(params = {}, opts = {}) ⇒ Object

You can cancel a PaymentIntent object when it's in one of these statuses: requires_payment_method, requires_capture, requires_confirmation, requires_action or, in rare cases, processing.

After it's canceled, no additional charges are made by the PaymentIntent and any operations on the PaymentIntent fail with an error. For PaymentIntents with a status of requires_capture, the remaining amount_capturable is automatically refunded.

You can directly cancel the PaymentIntent for a Checkout Session only when the PaymentIntent has a status of requires_capture. Otherwise, you must expire the Checkout Session.



5596
5597
5598
5599
5600
5601
5602
5603
# File 'lib/stripe/resources/payment_intent.rb', line 5596

def cancel(params = {}, opts = {})
  request_stripe_object(
    method: :post,
    path: format("/v1/payment_intents/%<intent>s/cancel", { intent: CGI.escape(self["id"]) }),
    params: params,
    opts: opts
  )
end

#capture(params = {}, opts = {}) ⇒ Object

Capture the funds of an existing uncaptured PaymentIntent when its status is requires_capture.

Uncaptured PaymentIntents are cancelled a set number of days (7 by default) after their creation.

Learn more about separate authorization and capture.



5624
5625
5626
5627
5628
5629
5630
5631
# File 'lib/stripe/resources/payment_intent.rb', line 5624

def capture(params = {}, opts = {})
  request_stripe_object(
    method: :post,
    path: format("/v1/payment_intents/%<intent>s/capture", { intent: CGI.escape(self["id"]) }),
    params: params,
    opts: opts
  )
end

#confirm(params = {}, opts = {}) ⇒ Object

Confirm that your customer intends to pay with current or provided payment method. Upon confirmation, the PaymentIntent will attempt to initiate a payment.

If the selected payment method requires additional authentication steps, the PaymentIntent will transition to the requires_action status and suggest additional actions via next_action. If payment fails, the PaymentIntent transitions to the requires_payment_method status or the canceled status if the confirmation limit is reached. If payment succeeds, the PaymentIntent will transition to the succeeded status (or requires_capture, if capture_method is set to manual).

If the confirmation_method is automatic, payment may be attempted using our client SDKs and the PaymentIntent's client_secret. After next_actions are handled by the client, no additional confirmation is required to complete the payment.

If the confirmation_method is manual, all payment attempts must be initiated using a secret key.

If any actions are required for the payment, the PaymentIntent will return to the requires_confirmation state after those actions are completed. Your server needs to then explicitly re-confirm the PaymentIntent to initiate the next payment attempt.

There is a variable upper limit on how many times a PaymentIntent can be confirmed. After this limit is reached, any further calls to this endpoint will transition the PaymentIntent to the canceled state.



5677
5678
5679
5680
5681
5682
5683
5684
# File 'lib/stripe/resources/payment_intent.rb', line 5677

def confirm(params = {}, opts = {})
  request_stripe_object(
    method: :post,
    path: format("/v1/payment_intents/%<intent>s/confirm", { intent: CGI.escape(self["id"]) }),
    params: params,
    opts: opts
  )
end

#decrement_authorization(params = {}, opts = {}) ⇒ Object

Perform a decremental authorization on an eligible PaymentIntent. To be eligible, the PaymentIntent's status must be requires_capture and decremental_authorization.status must be available.

Decremental authorizations decrease the authorized amount on your customer's card to the new, lower amount provided. A single PaymentIntent can call this endpoint multiple times to further decrease the authorized amount.

After decrement, the PaymentIntent object returns with the updated amount. The PaymentIntent will now be capturable up to the new authorized amount.

Each PaymentIntent can have a maximum of 10 decremental or incremental authorization attempts, including declines. After it's fully captured, a PaymentIntent can no longer be decremented.



5755
5756
5757
5758
5759
5760
5761
5762
# File 'lib/stripe/resources/payment_intent.rb', line 5755

def decrement_authorization(params = {}, opts = {})
  request_stripe_object(
    method: :post,
    path: format("/v1/payment_intents/%<intent>s/decrement_authorization", { intent: CGI.escape(self["id"]) }),
    params: params,
    opts: opts
  )
end

#increment_authorization(params = {}, opts = {}) ⇒ Object

Perform an incremental authorization on an eligible PaymentIntent. To be eligible, the PaymentIntent's status must be requires_capture and incremental_authorization_supported must be true.

Incremental authorizations attempt to increase the authorized amount on your customer's card to the new, higher amount provided. Similar to the initial authorization, incremental authorizations can be declined. A single PaymentIntent can call this endpoint multiple times to further increase the authorized amount.

If the incremental authorization succeeds, the PaymentIntent object returns with the updated amount. If the incremental authorization fails, a card_declined error returns, and no other fields on the PaymentIntent or Charge update. The PaymentIntent object remains capturable for the previously authorized amount.

Each PaymentIntent can have a maximum of 10 incremental authorization attempts, including declines. After it's captured, a PaymentIntent can no longer be incremented.

Learn more about incremental authorizations with in-person payments and online payments.



5815
5816
5817
5818
5819
5820
5821
5822
# File 'lib/stripe/resources/payment_intent.rb', line 5815

def increment_authorization(params = {}, opts = {})
  request_stripe_object(
    method: :post,
    path: format("/v1/payment_intents/%<intent>s/increment_authorization", { intent: CGI.escape(self["id"]) }),
    params: params,
    opts: opts
  )
end

#reauthorize(params = {}, opts = {}) ⇒ Object

Reauthorize a PaymentIntent to obtain a new valid authorization after the initial authorization has expired.

When a PaymentIntent's authorization expires and the capture window elapses, the PaymentIntent transitions to requires_reauthorization status with amount_capturable set to 0. This endpoint brings the PaymentIntent back to requires_capture status, allowing you to capture payment.

This is useful for retail and ecommerce scenarios with delayed shipments where authorization validity periods (typically 7 days) expire before the merchant is ready to capture payment.



5872
5873
5874
5875
5876
5877
5878
5879
# File 'lib/stripe/resources/payment_intent.rb', line 5872

def reauthorize(params = {}, opts = {})
  request_stripe_object(
    method: :post,
    path: format("/v1/payment_intents/%<intent>s/reauthorize", { intent: CGI.escape(self["id"]) }),
    params: params,
    opts: opts
  )
end

#test_helpersObject



5987
5988
5989
# File 'lib/stripe/resources/payment_intent.rb', line 5987

def test_helpers
  TestHelpers.new(self)
end

#trigger_action(params = {}, opts = {}) ⇒ Object

Trigger an external action on a PaymentIntent.



5912
5913
5914
5915
5916
5917
5918
5919
# File 'lib/stripe/resources/payment_intent.rb', line 5912

def trigger_action(params = {}, opts = {})
  request_stripe_object(
    method: :post,
    path: format("/v1/test/payment_intents/%<intent>s/trigger_action", { intent: CGI.escape(self["id"]) }),
    params: params,
    opts: opts
  )
end

#update_crypto_refund_address(params = {}, opts = {}) ⇒ Object

Updates the refund address for a static crypto deposit PaymentIntent on the specified network.



5948
5949
5950
5951
5952
5953
5954
5955
# File 'lib/stripe/resources/payment_intent.rb', line 5948

def update_crypto_refund_address(params = {}, opts = {})
  request_stripe_object(
    method: :post,
    path: format("/v1/payment_intents/%<intent>s/update_crypto_refund_address", { intent: CGI.escape(self["id"]) }),
    params: params,
    opts: opts
  )
end

#verify_microdeposits(params = {}, opts = {}) ⇒ Object

Verifies microdeposits on a PaymentIntent object.



5968
5969
5970
5971
5972
5973
5974
5975
# File 'lib/stripe/resources/payment_intent.rb', line 5968

def verify_microdeposits(params = {}, opts = {})
  request_stripe_object(
    method: :post,
    path: format("/v1/payment_intents/%<intent>s/verify_microdeposits", { intent: CGI.escape(self["id"]) }),
    params: params,
    opts: opts
  )
end