stripe-ruby/lib/stripe/resources/setup_intent.rb
stripe-openapi[bot] 8875698b96
Update generated code for v742 (#1306)
Co-authored-by: Stripe OpenAPI <105521251+stripe-openapi[bot]@users.noreply.github.com>
2024-01-04 11:40:30 -08:00

124 lines
5.6 KiB
Ruby

# File generated from our OpenAPI spec
# frozen_string_literal: true
module Stripe
# A SetupIntent guides you through the process of setting up and saving a customer's payment credentials for future payments.
# For example, you can use a SetupIntent to set up and save your customer's card without immediately collecting a payment.
# Later, you can use [PaymentIntents](https://stripe.com/docs/api#payment_intents) to drive the payment flow.
#
# Create a SetupIntent when you're ready to collect your customer's payment credentials.
# Don't maintain long-lived, unconfirmed SetupIntents because they might not be valid.
# The SetupIntent transitions through multiple [statuses](https://stripe.com/docs/payments/intents#intent-statuses) as it guides
# you through the setup process.
#
# Successful SetupIntents result in payment credentials that are optimized for future payments.
# For example, cardholders in [certain regions](https://stripe.com/guides/strong-customer-authentication) might need to be run through
# [Strong Customer Authentication](https://stripe.com/docs/strong-customer-authentication) during payment method collection
# to streamline later [off-session payments](https://stripe.com/docs/payments/setup-intents).
# If you use the SetupIntent with a [Customer](https://stripe.com/docs/api#setup_intent_object-customer),
# it automatically attaches the resulting payment method to that Customer after successful setup.
# We recommend using SetupIntents or [setup_future_usage](https://stripe.com/docs/api#payment_intent_object-setup_future_usage) on
# PaymentIntents to save payment methods to prevent saving invalid or unoptimized payment methods.
#
# By using SetupIntents, you can reduce friction for your customers, even as regulations change over time.
#
# Related guide: [Setup Intents API](https://stripe.com/docs/payments/setup-intents)
class SetupIntent < APIResource
extend Stripe::APIOperations::Create
extend Stripe::APIOperations::List
include Stripe::APIOperations::Save
OBJECT_NAME = "setup_intent"
# You can cancel a SetupIntent object when it's in one of these statuses: requires_payment_method, requires_confirmation, or requires_action.
#
# After you cancel it, setup is abandoned and any operations on the SetupIntent fail with an error.
def cancel(params = {}, opts = {})
request_stripe_object(
method: :post,
path: format("/v1/setup_intents/%<intent>s/cancel", { intent: CGI.escape(self["id"]) }),
params: params,
opts: opts
)
end
# Confirm that your customer intends to set up the current or
# provided payment method. For example, you would confirm a SetupIntent
# when a customer hits the “Save” button on a payment method management
# page on your website.
#
# If the selected payment method does not require any additional
# steps from the customer, the SetupIntent will transition to the
# succeeded status.
#
# Otherwise, it will transition to the requires_action status and
# suggest additional actions via next_action. If setup fails,
# the SetupIntent will transition to the
# requires_payment_method status or the canceled status if the
# confirmation limit is reached.
def confirm(params = {}, opts = {})
request_stripe_object(
method: :post,
path: format("/v1/setup_intents/%<intent>s/confirm", { intent: CGI.escape(self["id"]) }),
params: params,
opts: opts
)
end
# Verifies microdeposits on a SetupIntent object.
def verify_microdeposits(params = {}, opts = {})
request_stripe_object(
method: :post,
path: format("/v1/setup_intents/%<intent>s/verify_microdeposits", { intent: CGI.escape(self["id"]) }),
params: params,
opts: opts
)
end
# You can cancel a SetupIntent object when it's in one of these statuses: requires_payment_method, requires_confirmation, or requires_action.
#
# After you cancel it, setup is abandoned and any operations on the SetupIntent fail with an error.
def self.cancel(intent, params = {}, opts = {})
request_stripe_object(
method: :post,
path: format("/v1/setup_intents/%<intent>s/cancel", { intent: CGI.escape(intent) }),
params: params,
opts: opts
)
end
# Confirm that your customer intends to set up the current or
# provided payment method. For example, you would confirm a SetupIntent
# when a customer hits the “Save” button on a payment method management
# page on your website.
#
# If the selected payment method does not require any additional
# steps from the customer, the SetupIntent will transition to the
# succeeded status.
#
# Otherwise, it will transition to the requires_action status and
# suggest additional actions via next_action. If setup fails,
# the SetupIntent will transition to the
# requires_payment_method status or the canceled status if the
# confirmation limit is reached.
def self.confirm(intent, params = {}, opts = {})
request_stripe_object(
method: :post,
path: format("/v1/setup_intents/%<intent>s/confirm", { intent: CGI.escape(intent) }),
params: params,
opts: opts
)
end
# Verifies microdeposits on a SetupIntent object.
def self.verify_microdeposits(intent, params = {}, opts = {})
request_stripe_object(
method: :post,
path: format("/v1/setup_intents/%<intent>s/verify_microdeposits", { intent: CGI.escape(intent) }),
params: params,
opts: opts
)
end
end
end