1 | import {PaymentMethod} from './payment-methods';
|
2 |
|
3 | /**
|
4 | * The SetupIntent object.
|
5 | */
|
6 | export interface SetupIntent {
|
7 | /**
|
8 | * Unique identifier for the object.
|
9 | */
|
10 | id: string;
|
11 |
|
12 | /**
|
13 | * String representing the object's type. Objects of the same type share the same value.
|
14 | */
|
15 | object: 'setup_intent';
|
16 |
|
17 | /**
|
18 | * Reason for cancellation of this SetupIntent, one of `abandoned`, `requested_by_customer`, or `duplicate`.
|
19 | */
|
20 | cancellation_reason: SetupIntent.CancellationReason | null;
|
21 |
|
22 | /**
|
23 | * The client secret of this SetupIntent. Used for client-side retrieval using a publishable key.
|
24 | *
|
25 | * The client secret can be used to complete payment setup from your frontend. It should not be stored, logged, embedded in URLs, or exposed to anyone other than the customer. Make sure that you have TLS enabled on any page that includes the client secret.
|
26 | */
|
27 | client_secret: string | null;
|
28 |
|
29 | /**
|
30 | * Time at which the object was created. Measured in seconds since the Unix epoch.
|
31 | */
|
32 | created: number;
|
33 |
|
34 | /**
|
35 | * An arbitrary string attached to the object. Often useful for displaying to users.
|
36 | */
|
37 | description: string | null;
|
38 |
|
39 | /**
|
40 | * The error encountered in the previous SetupIntent confirmation.
|
41 | */
|
42 | last_setup_error: SetupIntent.LastSetupError | null;
|
43 |
|
44 | /**
|
45 | * Has the value `true` if the object exists in live mode or the value `false` if the object exists in test mode.
|
46 | */
|
47 | livemode: boolean;
|
48 |
|
49 | /**
|
50 | * If present, this property tells you what actions you need to take in order for your customer to continue payment setup.
|
51 | */
|
52 | next_action: SetupIntent.NextAction | null;
|
53 |
|
54 | /**
|
55 | * ID of the payment method used with this SetupIntent, or the PaymentMethod itself if this field is expanded.
|
56 | */
|
57 | payment_method: string | null | PaymentMethod;
|
58 |
|
59 | /**
|
60 | * The list of payment method types (e.g. card) that this SetupIntent is allowed to set up.
|
61 | */
|
62 | payment_method_types: Array<string>;
|
63 |
|
64 | /**
|
65 | * [Status](https://stripe.com/docs/payments/intents#intent-statuses) of this SetupIntent, one of `requires_payment_method`, `requires_confirmation`, `requires_action`, `processing`, `canceled`, or `succeeded`.
|
66 | */
|
67 | status: SetupIntent.Status;
|
68 |
|
69 | /**
|
70 | * Indicates how the payment method is intended to be used in the future.
|
71 | *
|
72 | * Use `on_session` if you intend to only reuse the payment method when the customer is in your checkout flow. Use `off_session` if your customer may or may not be in your checkout flow. If not provided, this value defaults to `off_session`.
|
73 | */
|
74 | usage: string;
|
75 | }
|
76 |
|
77 | export namespace SetupIntent {
|
78 | export type CancellationReason =
|
79 | | 'abandoned'
|
80 | | 'duplicate'
|
81 | | 'requested_by_customer';
|
82 |
|
83 | export interface LastSetupError {
|
84 | /**
|
85 | * For card errors, the ID of the failed charge.
|
86 | */
|
87 | charge?: string;
|
88 |
|
89 | /**
|
90 | * For some errors that could be handled programmatically, a short string indicating the [error code](https://stripe.com/docs/error-codes) reported.
|
91 | */
|
92 | code?: string;
|
93 |
|
94 | /**
|
95 | * For card errors resulting from a card issuer decline, a short string indicating the [card issuer's reason for the decline](https://stripe.com/docs/declines#issuer-declines) if they provide one.
|
96 | */
|
97 | decline_code?: string;
|
98 |
|
99 | /**
|
100 | * A URL to more information about the [error code](https://stripe.com/docs/error-codes) reported.
|
101 | */
|
102 | doc_url?: string;
|
103 |
|
104 | /**
|
105 | * A human-readable message providing more details about the error. For card errors, these messages can be shown to your users.
|
106 | */
|
107 | message?: string;
|
108 |
|
109 | /**
|
110 | * If the error is parameter-specific, the parameter related to the error. For example, you can use this to display a message near the correct form field.
|
111 | */
|
112 | param?: string;
|
113 |
|
114 | payment_method?: PaymentMethod;
|
115 |
|
116 | /**
|
117 | * The type of error returned. One of `api_connection_error`, `api_error`, `authentication_error`, `card_error`, `idempotency_error`, `invalid_request_error`, or `rate_limit_error`
|
118 | */
|
119 | type: LastSetupError.Type;
|
120 | }
|
121 |
|
122 | export namespace LastSetupError {
|
123 | export type Type =
|
124 | | 'api_connection_error'
|
125 | | 'api_error'
|
126 | | 'authentication_error'
|
127 | | 'card_error'
|
128 | | 'idempotency_error'
|
129 | | 'invalid_request_error'
|
130 | | 'rate_limit_error';
|
131 | }
|
132 |
|
133 | export interface NextAction {
|
134 | redirect_to_url?: NextAction.RedirectToUrl;
|
135 |
|
136 | /**
|
137 | * Type of the next action to perform, one of `redirect_to_url` or `use_stripe_sdk`.
|
138 | */
|
139 | type: string;
|
140 |
|
141 | /**
|
142 | * When confirming a SetupIntent with Stripe.js, Stripe.js depends on the contents of this dictionary to invoke authentication flows. The shape of the contents is subject to change and is only intended to be used by Stripe.js.
|
143 | */
|
144 | use_stripe_sdk?: NextAction.UseStripeSdk;
|
145 | }
|
146 |
|
147 | export namespace NextAction {
|
148 | export interface RedirectToUrl {
|
149 | /**
|
150 | * If the customer does not exit their browser while authenticating, they will be redirected to this specified URL after completion.
|
151 | */
|
152 | return_url: string | null;
|
153 |
|
154 | /**
|
155 | * The URL you must redirect your customer to in order to authenticate.
|
156 | */
|
157 | url: string | null;
|
158 | }
|
159 |
|
160 | export interface UseStripeSdk {}
|
161 | }
|
162 |
|
163 | export type Status =
|
164 | | 'canceled'
|
165 | | 'processing'
|
166 | | 'requires_action'
|
167 | | 'requires_confirmation'
|
168 | | 'requires_payment_method'
|
169 | | 'succeeded';
|
170 | }
|
171 |
|
172 | export interface SetupIntentConfirmParams {
|
173 | /**
|
174 | * This hash contains details about the Mandate to create
|
175 | */
|
176 | mandate_data?: {[k: string]: any};
|
177 |
|
178 | /**
|
179 | * The URL to redirect your customer back to after they authenticate on the payment method's app or site.
|
180 | * If you'd prefer to redirect to a mobile application, you can alternatively supply an application URI scheme.
|
181 | * This parameter is only used for cards and other redirect-based payment methods.
|
182 | */
|
183 | return_url?: string;
|
184 | }
|