• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

stripe / stripe-ruby / #5867

18 Apr 2024 09:24PM UTC coverage: 92.724% (-4.8%) from 97.485%
#5867

push

github

ramya-stripe
Bump version to 11.2.0

10067 of 10857 relevant lines covered (92.72%)

258.85 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

90.63
/lib/stripe/resources/setup_intent.rb
1
# File generated from our OpenAPI spec
2
# frozen_string_literal: true
3

4
module Stripe
1✔
5
  # A SetupIntent guides you through the process of setting up and saving a customer's payment credentials for future payments.
6
  # For example, you can use a SetupIntent to set up and save your customer's card without immediately collecting a payment.
7
  # Later, you can use [PaymentIntents](https://stripe.com/docs/api#payment_intents) to drive the payment flow.
8
  #
9
  # Create a SetupIntent when you're ready to collect your customer's payment credentials.
10
  # Don't maintain long-lived, unconfirmed SetupIntents because they might not be valid.
11
  # The SetupIntent transitions through multiple [statuses](https://docs.stripe.com/payments/intents#intent-statuses) as it guides
12
  # you through the setup process.
13
  #
14
  # Successful SetupIntents result in payment credentials that are optimized for future payments.
15
  # For example, cardholders in [certain regions](https://stripe.com/guides/strong-customer-authentication) might need to be run through
16
  # [Strong Customer Authentication](https://docs.stripe.com/strong-customer-authentication) during payment method collection
17
  # to streamline later [off-session payments](https://docs.stripe.com/payments/setup-intents).
18
  # If you use the SetupIntent with a [Customer](https://stripe.com/docs/api#setup_intent_object-customer),
19
  # it automatically attaches the resulting payment method to that Customer after successful setup.
20
  # We recommend using SetupIntents or [setup_future_usage](https://stripe.com/docs/api#payment_intent_object-setup_future_usage) on
21
  # PaymentIntents to save payment methods to prevent saving invalid or unoptimized payment methods.
22
  #
23
  # By using SetupIntents, you can reduce friction for your customers, even as regulations change over time.
24
  #
25
  # Related guide: [Setup Intents API](https://docs.stripe.com/payments/setup-intents)
26
  class SetupIntent < APIResource
1✔
27
    extend Stripe::APIOperations::Create
1✔
28
    extend Stripe::APIOperations::List
1✔
29
    include Stripe::APIOperations::Save
1✔
30

31
    OBJECT_NAME = "setup_intent"
1✔
32
    def self.object_name
1✔
33
      "setup_intent"
28✔
34
    end
35

36
    # You can cancel a SetupIntent object when it's in one of these statuses: requires_payment_method, requires_confirmation, or requires_action.
37
    #
38
    # After you cancel it, setup is abandoned and any operations on the SetupIntent fail with an error.
39
    def cancel(params = {}, opts = {})
1✔
40
      request_stripe_object(
1✔
41
        method: :post,
42
        path: format("/v1/setup_intents/%<intent>s/cancel", { intent: CGI.escape(self["id"]) }),
×
43
        params: params,
44
        opts: opts
45
      )
46
    end
47

48
    # You can cancel a SetupIntent object when it's in one of these statuses: requires_payment_method, requires_confirmation, or requires_action.
49
    #
50
    # After you cancel it, setup is abandoned and any operations on the SetupIntent fail with an error.
51
    def self.cancel(intent, params = {}, opts = {})
1✔
52
      request_stripe_object(
2✔
53
        method: :post,
54
        path: format("/v1/setup_intents/%<intent>s/cancel", { intent: CGI.escape(intent) }),
1✔
55
        params: params,
56
        opts: opts
57
      )
58
    end
59

60
    # Confirm that your customer intends to set up the current or
61
    # provided payment method. For example, you would confirm a SetupIntent
62
    # when a customer hits the “Save” button on a payment method management
63
    # page on your website.
64
    #
65
    # If the selected payment method does not require any additional
66
    # steps from the customer, the SetupIntent will transition to the
67
    # succeeded status.
68
    #
69
    # Otherwise, it will transition to the requires_action status and
70
    # suggest additional actions via next_action. If setup fails,
71
    # the SetupIntent will transition to the
72
    # requires_payment_method status or the canceled status if the
73
    # confirmation limit is reached.
74
    def confirm(params = {}, opts = {})
1✔
75
      request_stripe_object(
1✔
76
        method: :post,
77
        path: format("/v1/setup_intents/%<intent>s/confirm", { intent: CGI.escape(self["id"]) }),
×
78
        params: params,
79
        opts: opts
80
      )
81
    end
82

83
    # Confirm that your customer intends to set up the current or
84
    # provided payment method. For example, you would confirm a SetupIntent
85
    # when a customer hits the “Save” button on a payment method management
86
    # page on your website.
87
    #
88
    # If the selected payment method does not require any additional
89
    # steps from the customer, the SetupIntent will transition to the
90
    # succeeded status.
91
    #
92
    # Otherwise, it will transition to the requires_action status and
93
    # suggest additional actions via next_action. If setup fails,
94
    # the SetupIntent will transition to the
95
    # requires_payment_method status or the canceled status if the
96
    # confirmation limit is reached.
97
    def self.confirm(intent, params = {}, opts = {})
1✔
98
      request_stripe_object(
2✔
99
        method: :post,
100
        path: format("/v1/setup_intents/%<intent>s/confirm", { intent: CGI.escape(intent) }),
1✔
101
        params: params,
102
        opts: opts
103
      )
104
    end
105

106
    # Creates a SetupIntent object.
107
    #
108
    # After you create the SetupIntent, attach a payment method and [confirm](https://stripe.com/docs/api/setup_intents/confirm)
109
    # it to collect any required permissions to charge the payment method later.
110
    def self.create(params = {}, opts = {})
1✔
111
      request_stripe_object(method: :post, path: "/v1/setup_intents", params: params, opts: opts)
2✔
112
    end
113

114
    # Returns a list of SetupIntents.
115
    def self.list(filters = {}, opts = {})
1✔
116
      request_stripe_object(method: :get, path: "/v1/setup_intents", params: filters, opts: opts)
2✔
117
    end
118

119
    # Updates a SetupIntent object.
120
    def self.update(id, params = {}, opts = {})
1✔
121
      request_stripe_object(
2✔
122
        method: :post,
123
        path: format("/v1/setup_intents/%<id>s", { id: CGI.escape(id) }),
1✔
124
        params: params,
125
        opts: opts
126
      )
127
    end
128

129
    # Verifies microdeposits on a SetupIntent object.
130
    def verify_microdeposits(params = {}, opts = {})
1✔
131
      request_stripe_object(
×
132
        method: :post,
133
        path: format("/v1/setup_intents/%<intent>s/verify_microdeposits", { intent: CGI.escape(self["id"]) }),
134
        params: params,
135
        opts: opts
136
      )
137
    end
138

139
    # Verifies microdeposits on a SetupIntent object.
140
    def self.verify_microdeposits(intent, params = {}, opts = {})
1✔
141
      request_stripe_object(
2✔
142
        method: :post,
143
        path: format("/v1/setup_intents/%<intent>s/verify_microdeposits", { intent: CGI.escape(intent) }),
1✔
144
        params: params,
145
        opts: opts
146
      )
147
    end
148
  end
149
end
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc