Skip to content

Commit 32be76c

Browse files
authored
Merge pull request #1118 from stripe/remi/codegen-3854362
Add support for the `SetupAttempt` resource and List API
2 parents 418f36e + 9e4eacf commit 32be76c

File tree

11 files changed

+667
-3
lines changed

11 files changed

+667
-3
lines changed

Diff for: .travis.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ before_install:
1818
env:
1919
global:
2020
# If changing this number, please also change it in `BaseStripeTest.java`.
21-
- STRIPE_MOCK_VERSION=0.98.0
21+
- STRIPE_MOCK_VERSION=0.99.0
2222

2323
matrix:
2424
include:

Diff for: src/main/java/com/stripe/model/EventDataClassLookup.java

+1
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ final class EventDataClassLookup {
6464
classLookup.put("refund", Refund.class);
6565
classLookup.put("reserve_transaction", ReserveTransaction.class);
6666
classLookup.put("review", Review.class);
67+
classLookup.put("setup_attempt", SetupAttempt.class);
6768
classLookup.put("setup_intent", SetupIntent.class);
6869
classLookup.put("sku", Sku.class);
6970
classLookup.put("source", Source.class);

Diff for: src/main/java/com/stripe/model/SetupAttempt.java

+247
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,247 @@
1+
// File generated from our OpenAPI spec
2+
package com.stripe.model;
3+
4+
import com.google.gson.annotations.SerializedName;
5+
import com.stripe.Stripe;
6+
import com.stripe.exception.StripeException;
7+
import com.stripe.net.ApiResource;
8+
import com.stripe.net.RequestOptions;
9+
import com.stripe.param.SetupAttemptListParams;
10+
import java.util.Map;
11+
import lombok.EqualsAndHashCode;
12+
import lombok.Getter;
13+
import lombok.Setter;
14+
15+
@Getter
16+
@Setter
17+
@EqualsAndHashCode(callSuper = false)
18+
public class SetupAttempt extends ApiResource implements HasId {
19+
/**
20+
* The value of <a
21+
* href="https://stripe.com/docs/api/setup_intents/object#setup_intent_object-application">application</a>
22+
* on the SetupIntent at the time of this confirmation.
23+
*/
24+
@SerializedName("application")
25+
@Getter(lombok.AccessLevel.NONE)
26+
@Setter(lombok.AccessLevel.NONE)
27+
ExpandableField<Application> application;
28+
29+
/** Time at which the object was created. Measured in seconds since the Unix epoch. */
30+
@SerializedName("created")
31+
Long created;
32+
33+
/**
34+
* The value of <a
35+
* href="https://stripe.com/docs/api/setup_intents/object#setup_intent_object-customer">customer</a>
36+
* on the SetupIntent at the time of this confirmation.
37+
*/
38+
@SerializedName("customer")
39+
@Getter(lombok.AccessLevel.NONE)
40+
@Setter(lombok.AccessLevel.NONE)
41+
ExpandableField<Customer> customer;
42+
43+
/** Unique identifier for the object. */
44+
@Getter(onMethod_ = {@Override})
45+
@SerializedName("id")
46+
String id;
47+
48+
/**
49+
* Has the value {@code true} if the object exists in live mode or the value {@code false} if the
50+
* object exists in test mode.
51+
*/
52+
@SerializedName("livemode")
53+
Boolean livemode;
54+
55+
/**
56+
* String representing the object's type. Objects of the same type share the same value.
57+
*
58+
* <p>Equal to {@code setup_attempt}.
59+
*/
60+
@SerializedName("object")
61+
String object;
62+
63+
/**
64+
* The value of <a
65+
* href="https://stripe.com/docs/api/setup_intents/object#setup_intent_object-on_behalf_of">on_behalf_of</a>
66+
* on the SetupIntent at the time of this confirmation.
67+
*/
68+
@SerializedName("on_behalf_of")
69+
@Getter(lombok.AccessLevel.NONE)
70+
@Setter(lombok.AccessLevel.NONE)
71+
ExpandableField<Account> onBehalfOf;
72+
73+
/** ID of the payment method used with this SetupAttempt. */
74+
@SerializedName("payment_method")
75+
@Getter(lombok.AccessLevel.NONE)
76+
@Setter(lombok.AccessLevel.NONE)
77+
ExpandableField<PaymentMethod> paymentMethod;
78+
79+
@SerializedName("payment_method_details")
80+
PaymentMethodDetails paymentMethodDetails;
81+
82+
/** The error encountered during this attempt to confirm the SetupIntent, if any. */
83+
@SerializedName("setup_error")
84+
StripeError setupError;
85+
86+
/** ID of the SetupIntent that this attempt belongs to. */
87+
@SerializedName("setup_intent")
88+
@Getter(lombok.AccessLevel.NONE)
89+
@Setter(lombok.AccessLevel.NONE)
90+
ExpandableField<SetupIntent> setupIntent;
91+
92+
/**
93+
* Status of this SetupAttempt, one of {@code requires_confirmation}, {@code requires_action},
94+
* {@code processing}, {@code succeeded}, {@code failed}, or {@code abandoned}.
95+
*/
96+
@SerializedName("status")
97+
String status;
98+
99+
/**
100+
* The value of <a
101+
* href="https://stripe.com/docs/api/setup_intents/object#setup_intent_object-usage">usage</a> on
102+
* the SetupIntent at the time of this confirmation, one of {@code off_session} or {@code
103+
* on_session}.
104+
*/
105+
@SerializedName("usage")
106+
String usage;
107+
108+
/** Get ID of expandable {@code application} object. */
109+
public String getApplication() {
110+
return (this.application != null) ? this.application.getId() : null;
111+
}
112+
113+
public void setApplication(String id) {
114+
this.application = ApiResource.setExpandableFieldId(id, this.application);
115+
}
116+
117+
/** Get expanded {@code application}. */
118+
public Application getApplicationObject() {
119+
return (this.application != null) ? this.application.getExpanded() : null;
120+
}
121+
122+
public void setApplicationObject(Application expandableObject) {
123+
this.application = new ExpandableField<Application>(expandableObject.getId(), expandableObject);
124+
}
125+
126+
/** Get ID of expandable {@code customer} object. */
127+
public String getCustomer() {
128+
return (this.customer != null) ? this.customer.getId() : null;
129+
}
130+
131+
public void setCustomer(String id) {
132+
this.customer = ApiResource.setExpandableFieldId(id, this.customer);
133+
}
134+
135+
/** Get expanded {@code customer}. */
136+
public Customer getCustomerObject() {
137+
return (this.customer != null) ? this.customer.getExpanded() : null;
138+
}
139+
140+
public void setCustomerObject(Customer expandableObject) {
141+
this.customer = new ExpandableField<Customer>(expandableObject.getId(), expandableObject);
142+
}
143+
144+
/** Get ID of expandable {@code onBehalfOf} object. */
145+
public String getOnBehalfOf() {
146+
return (this.onBehalfOf != null) ? this.onBehalfOf.getId() : null;
147+
}
148+
149+
public void setOnBehalfOf(String id) {
150+
this.onBehalfOf = ApiResource.setExpandableFieldId(id, this.onBehalfOf);
151+
}
152+
153+
/** Get expanded {@code onBehalfOf}. */
154+
public Account getOnBehalfOfObject() {
155+
return (this.onBehalfOf != null) ? this.onBehalfOf.getExpanded() : null;
156+
}
157+
158+
public void setOnBehalfOfObject(Account expandableObject) {
159+
this.onBehalfOf = new ExpandableField<Account>(expandableObject.getId(), expandableObject);
160+
}
161+
162+
/** Get ID of expandable {@code paymentMethod} object. */
163+
public String getPaymentMethod() {
164+
return (this.paymentMethod != null) ? this.paymentMethod.getId() : null;
165+
}
166+
167+
public void setPaymentMethod(String id) {
168+
this.paymentMethod = ApiResource.setExpandableFieldId(id, this.paymentMethod);
169+
}
170+
171+
/** Get expanded {@code paymentMethod}. */
172+
public PaymentMethod getPaymentMethodObject() {
173+
return (this.paymentMethod != null) ? this.paymentMethod.getExpanded() : null;
174+
}
175+
176+
public void setPaymentMethodObject(PaymentMethod expandableObject) {
177+
this.paymentMethod =
178+
new ExpandableField<PaymentMethod>(expandableObject.getId(), expandableObject);
179+
}
180+
181+
/** Get ID of expandable {@code setupIntent} object. */
182+
public String getSetupIntent() {
183+
return (this.setupIntent != null) ? this.setupIntent.getId() : null;
184+
}
185+
186+
public void setSetupIntent(String id) {
187+
this.setupIntent = ApiResource.setExpandableFieldId(id, this.setupIntent);
188+
}
189+
190+
/** Get expanded {@code setupIntent}. */
191+
public SetupIntent getSetupIntentObject() {
192+
return (this.setupIntent != null) ? this.setupIntent.getExpanded() : null;
193+
}
194+
195+
public void setSetupIntentObject(SetupIntent expandableObject) {
196+
this.setupIntent = new ExpandableField<SetupIntent>(expandableObject.getId(), expandableObject);
197+
}
198+
199+
/** Returns a list of SetupAttempts associated with a provided SetupIntent. */
200+
public static SetupAttemptCollection list(Map<String, Object> params) throws StripeException {
201+
return list(params, (RequestOptions) null);
202+
}
203+
204+
/** Returns a list of SetupAttempts associated with a provided SetupIntent. */
205+
public static SetupAttemptCollection list(Map<String, Object> params, RequestOptions options)
206+
throws StripeException {
207+
String url = String.format("%s%s", Stripe.getApiBase(), "/v1/setup_attempts");
208+
return ApiResource.requestCollection(url, params, SetupAttemptCollection.class, options);
209+
}
210+
211+
/** Returns a list of SetupAttempts associated with a provided SetupIntent. */
212+
public static SetupAttemptCollection list(SetupAttemptListParams params) throws StripeException {
213+
return list(params, (RequestOptions) null);
214+
}
215+
216+
/** Returns a list of SetupAttempts associated with a provided SetupIntent. */
217+
public static SetupAttemptCollection list(SetupAttemptListParams params, RequestOptions options)
218+
throws StripeException {
219+
String url = String.format("%s%s", Stripe.getApiBase(), "/v1/setup_attempts");
220+
return ApiResource.requestCollection(url, params, SetupAttemptCollection.class, options);
221+
}
222+
223+
@Getter
224+
@Setter
225+
@EqualsAndHashCode(callSuper = false)
226+
public static class PaymentMethodDetails extends StripeObject {
227+
@SerializedName("card")
228+
Card card;
229+
230+
/**
231+
* The type of the payment method used in the SetupIntent (e.g., {@code card}). An additional
232+
* hash is included on {@code payment_method_details} with a name matching this value. It
233+
* contains confirmation-specific information for the payment method.
234+
*/
235+
@SerializedName("type")
236+
String type;
237+
238+
@Getter
239+
@Setter
240+
@EqualsAndHashCode(callSuper = false)
241+
public static class Card extends StripeObject {
242+
/** Populated if this authorization used 3D Secure authentication. */
243+
@SerializedName("three_d_secure")
244+
Charge.PaymentMethodDetails.Card.ThreeDSecure threeDSecure;
245+
}
246+
}
247+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
// File generated from our OpenAPI spec
2+
package com.stripe.model;
3+
4+
public class SetupAttemptCollection extends StripeCollection<SetupAttempt> {}

Diff for: src/main/java/com/stripe/model/SetupIntent.java

+25
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,12 @@ public class SetupIntent extends ApiResource implements HasId, MetadataStore<Set
7373
@SerializedName("last_setup_error")
7474
StripeError lastSetupError;
7575

76+
/** The most recent SetupAttempt for this SetupIntent. */
77+
@SerializedName("latest_attempt")
78+
@Getter(lombok.AccessLevel.NONE)
79+
@Setter(lombok.AccessLevel.NONE)
80+
ExpandableField<SetupAttempt> latestAttempt;
81+
7682
/**
7783
* Has the value {@code true} if the object exists in live mode or the value {@code false} if the
7884
* object exists in test mode.
@@ -190,6 +196,25 @@ public void setCustomerObject(Customer expandableObject) {
190196
this.customer = new ExpandableField<Customer>(expandableObject.getId(), expandableObject);
191197
}
192198

199+
/** Get ID of expandable {@code latestAttempt} object. */
200+
public String getLatestAttempt() {
201+
return (this.latestAttempt != null) ? this.latestAttempt.getId() : null;
202+
}
203+
204+
public void setLatestAttempt(String id) {
205+
this.latestAttempt = ApiResource.setExpandableFieldId(id, this.latestAttempt);
206+
}
207+
208+
/** Get expanded {@code latestAttempt}. */
209+
public SetupAttempt getLatestAttemptObject() {
210+
return (this.latestAttempt != null) ? this.latestAttempt.getExpanded() : null;
211+
}
212+
213+
public void setLatestAttemptObject(SetupAttempt expandableObject) {
214+
this.latestAttempt =
215+
new ExpandableField<SetupAttempt>(expandableObject.getId(), expandableObject);
216+
}
217+
193218
/** Get ID of expandable {@code mandate} object. */
194219
public String getMandate() {
195220
return (this.mandate != null) ? this.mandate.getId() : null;

0 commit comments

Comments
 (0)