Skip to content

Add support for the SetupAttempt resource and List API #1118

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Sep 30, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ before_install:
env:
global:
# If changing this number, please also change it in `BaseStripeTest.java`.
- STRIPE_MOCK_VERSION=0.98.0
- STRIPE_MOCK_VERSION=0.99.0

matrix:
include:
Expand Down
1 change: 1 addition & 0 deletions src/main/java/com/stripe/model/EventDataClassLookup.java
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ final class EventDataClassLookup {
classLookup.put("refund", Refund.class);
classLookup.put("reserve_transaction", ReserveTransaction.class);
classLookup.put("review", Review.class);
classLookup.put("setup_attempt", SetupAttempt.class);
classLookup.put("setup_intent", SetupIntent.class);
classLookup.put("sku", Sku.class);
classLookup.put("source", Source.class);
Expand Down
247 changes: 247 additions & 0 deletions src/main/java/com/stripe/model/SetupAttempt.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,247 @@
// File generated from our OpenAPI spec
package com.stripe.model;

import com.google.gson.annotations.SerializedName;
import com.stripe.Stripe;
import com.stripe.exception.StripeException;
import com.stripe.net.ApiResource;
import com.stripe.net.RequestOptions;
import com.stripe.param.SetupAttemptListParams;
import java.util.Map;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.Setter;

@Getter
@Setter
@EqualsAndHashCode(callSuper = false)
public class SetupAttempt extends ApiResource implements HasId {
/**
* The value of <a
* href="https://stripe.com/docs/api/setup_intents/object#setup_intent_object-application">application</a>
* on the SetupIntent at the time of this confirmation.
*/
@SerializedName("application")
@Getter(lombok.AccessLevel.NONE)
@Setter(lombok.AccessLevel.NONE)
ExpandableField<Application> application;

/** Time at which the object was created. Measured in seconds since the Unix epoch. */
@SerializedName("created")
Long created;

/**
* The value of <a
* href="https://stripe.com/docs/api/setup_intents/object#setup_intent_object-customer">customer</a>
* on the SetupIntent at the time of this confirmation.
*/
@SerializedName("customer")
@Getter(lombok.AccessLevel.NONE)
@Setter(lombok.AccessLevel.NONE)
ExpandableField<Customer> customer;

/** Unique identifier for the object. */
@Getter(onMethod_ = {@Override})
@SerializedName("id")
String id;

/**
* Has the value {@code true} if the object exists in live mode or the value {@code false} if the
* object exists in test mode.
*/
@SerializedName("livemode")
Boolean livemode;

/**
* String representing the object's type. Objects of the same type share the same value.
*
* <p>Equal to {@code setup_attempt}.
*/
@SerializedName("object")
String object;

/**
* The value of <a
* href="https://stripe.com/docs/api/setup_intents/object#setup_intent_object-on_behalf_of">on_behalf_of</a>
* on the SetupIntent at the time of this confirmation.
*/
@SerializedName("on_behalf_of")
@Getter(lombok.AccessLevel.NONE)
@Setter(lombok.AccessLevel.NONE)
ExpandableField<Account> onBehalfOf;

/** ID of the payment method used with this SetupAttempt. */
@SerializedName("payment_method")
@Getter(lombok.AccessLevel.NONE)
@Setter(lombok.AccessLevel.NONE)
ExpandableField<PaymentMethod> paymentMethod;

@SerializedName("payment_method_details")
PaymentMethodDetails paymentMethodDetails;

/** The error encountered during this attempt to confirm the SetupIntent, if any. */
@SerializedName("setup_error")
StripeError setupError;

/** ID of the SetupIntent that this attempt belongs to. */
@SerializedName("setup_intent")
@Getter(lombok.AccessLevel.NONE)
@Setter(lombok.AccessLevel.NONE)
ExpandableField<SetupIntent> setupIntent;

/**
* Status of this SetupAttempt, one of {@code requires_confirmation}, {@code requires_action},
* {@code processing}, {@code succeeded}, {@code failed}, or {@code abandoned}.
*/
@SerializedName("status")
String status;

/**
* The value of <a
* href="https://stripe.com/docs/api/setup_intents/object#setup_intent_object-usage">usage</a> on
* the SetupIntent at the time of this confirmation, one of {@code off_session} or {@code
* on_session}.
*/
@SerializedName("usage")
String usage;

/** Get ID of expandable {@code application} object. */
public String getApplication() {
return (this.application != null) ? this.application.getId() : null;
}

public void setApplication(String id) {
this.application = ApiResource.setExpandableFieldId(id, this.application);
}

/** Get expanded {@code application}. */
public Application getApplicationObject() {
return (this.application != null) ? this.application.getExpanded() : null;
}

public void setApplicationObject(Application expandableObject) {
this.application = new ExpandableField<Application>(expandableObject.getId(), expandableObject);
}

/** Get ID of expandable {@code customer} object. */
public String getCustomer() {
return (this.customer != null) ? this.customer.getId() : null;
}

public void setCustomer(String id) {
this.customer = ApiResource.setExpandableFieldId(id, this.customer);
}

/** Get expanded {@code customer}. */
public Customer getCustomerObject() {
return (this.customer != null) ? this.customer.getExpanded() : null;
}

public void setCustomerObject(Customer expandableObject) {
this.customer = new ExpandableField<Customer>(expandableObject.getId(), expandableObject);
}

/** Get ID of expandable {@code onBehalfOf} object. */
public String getOnBehalfOf() {
return (this.onBehalfOf != null) ? this.onBehalfOf.getId() : null;
}

public void setOnBehalfOf(String id) {
this.onBehalfOf = ApiResource.setExpandableFieldId(id, this.onBehalfOf);
}

/** Get expanded {@code onBehalfOf}. */
public Account getOnBehalfOfObject() {
return (this.onBehalfOf != null) ? this.onBehalfOf.getExpanded() : null;
}

public void setOnBehalfOfObject(Account expandableObject) {
this.onBehalfOf = new ExpandableField<Account>(expandableObject.getId(), expandableObject);
}

/** Get ID of expandable {@code paymentMethod} object. */
public String getPaymentMethod() {
return (this.paymentMethod != null) ? this.paymentMethod.getId() : null;
}

public void setPaymentMethod(String id) {
this.paymentMethod = ApiResource.setExpandableFieldId(id, this.paymentMethod);
}

/** Get expanded {@code paymentMethod}. */
public PaymentMethod getPaymentMethodObject() {
return (this.paymentMethod != null) ? this.paymentMethod.getExpanded() : null;
}

public void setPaymentMethodObject(PaymentMethod expandableObject) {
this.paymentMethod =
new ExpandableField<PaymentMethod>(expandableObject.getId(), expandableObject);
}

/** Get ID of expandable {@code setupIntent} object. */
public String getSetupIntent() {
return (this.setupIntent != null) ? this.setupIntent.getId() : null;
}

public void setSetupIntent(String id) {
this.setupIntent = ApiResource.setExpandableFieldId(id, this.setupIntent);
}

/** Get expanded {@code setupIntent}. */
public SetupIntent getSetupIntentObject() {
return (this.setupIntent != null) ? this.setupIntent.getExpanded() : null;
}

public void setSetupIntentObject(SetupIntent expandableObject) {
this.setupIntent = new ExpandableField<SetupIntent>(expandableObject.getId(), expandableObject);
}

/** Returns a list of SetupAttempts associated with a provided SetupIntent. */
public static SetupAttemptCollection list(Map<String, Object> params) throws StripeException {
return list(params, (RequestOptions) null);
}

/** Returns a list of SetupAttempts associated with a provided SetupIntent. */
public static SetupAttemptCollection list(Map<String, Object> params, RequestOptions options)
throws StripeException {
String url = String.format("%s%s", Stripe.getApiBase(), "/v1/setup_attempts");
return ApiResource.requestCollection(url, params, SetupAttemptCollection.class, options);
}

/** Returns a list of SetupAttempts associated with a provided SetupIntent. */
public static SetupAttemptCollection list(SetupAttemptListParams params) throws StripeException {
return list(params, (RequestOptions) null);
}

/** Returns a list of SetupAttempts associated with a provided SetupIntent. */
public static SetupAttemptCollection list(SetupAttemptListParams params, RequestOptions options)
throws StripeException {
String url = String.format("%s%s", Stripe.getApiBase(), "/v1/setup_attempts");
return ApiResource.requestCollection(url, params, SetupAttemptCollection.class, options);
}

@Getter
@Setter
@EqualsAndHashCode(callSuper = false)
public static class PaymentMethodDetails extends StripeObject {
@SerializedName("card")
Card card;

/**
* The type of the payment method used in the SetupIntent (e.g., {@code card}). An additional
* hash is included on {@code payment_method_details} with a name matching this value. It
* contains confirmation-specific information for the payment method.
*/
@SerializedName("type")
String type;

@Getter
@Setter
@EqualsAndHashCode(callSuper = false)
public static class Card extends StripeObject {
/** Populated if this authorization used 3D Secure authentication. */
@SerializedName("three_d_secure")
Charge.PaymentMethodDetails.Card.ThreeDSecure threeDSecure;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Flagging this should not be shared but for now Java does still share so deferring to a future major

}
}
}
4 changes: 4 additions & 0 deletions src/main/java/com/stripe/model/SetupAttemptCollection.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// File generated from our OpenAPI spec
package com.stripe.model;

public class SetupAttemptCollection extends StripeCollection<SetupAttempt> {}
25 changes: 25 additions & 0 deletions src/main/java/com/stripe/model/SetupIntent.java
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,12 @@ public class SetupIntent extends ApiResource implements HasId, MetadataStore<Set
@SerializedName("last_setup_error")
StripeError lastSetupError;

/** The most recent SetupAttempt for this SetupIntent. */
@SerializedName("latest_attempt")
@Getter(lombok.AccessLevel.NONE)
@Setter(lombok.AccessLevel.NONE)
ExpandableField<SetupAttempt> latestAttempt;

/**
* Has the value {@code true} if the object exists in live mode or the value {@code false} if the
* object exists in test mode.
Expand Down Expand Up @@ -190,6 +196,25 @@ public void setCustomerObject(Customer expandableObject) {
this.customer = new ExpandableField<Customer>(expandableObject.getId(), expandableObject);
}

/** Get ID of expandable {@code latestAttempt} object. */
public String getLatestAttempt() {
return (this.latestAttempt != null) ? this.latestAttempt.getId() : null;
}

public void setLatestAttempt(String id) {
this.latestAttempt = ApiResource.setExpandableFieldId(id, this.latestAttempt);
}

/** Get expanded {@code latestAttempt}. */
public SetupAttempt getLatestAttemptObject() {
return (this.latestAttempt != null) ? this.latestAttempt.getExpanded() : null;
}

public void setLatestAttemptObject(SetupAttempt expandableObject) {
this.latestAttempt =
new ExpandableField<SetupAttempt>(expandableObject.getId(), expandableObject);
}

/** Get ID of expandable {@code mandate} object. */
public String getMandate() {
return (this.mandate != null) ? this.mandate.getId() : null;
Expand Down
Loading