
com.stripe.model.Invoice Maven / Gradle / Ivy
package com.stripe.model;
import com.google.gson.annotations.SerializedName;
import com.stripe.exception.APIConnectionException;
import com.stripe.exception.APIException;
import com.stripe.exception.AuthenticationException;
import com.stripe.exception.CardException;
import com.stripe.exception.InvalidRequestException;
import com.stripe.net.APIResource;
import com.stripe.net.RequestOptions;
import java.util.Map;
import lombok.AccessLevel;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.Setter;
@Getter
@Setter
@EqualsAndHashCode(callSuper = false)
public class Invoice extends APIResource implements MetadataStore, HasId {
@Getter(onMethod = @__({@Override})) String id;
String object;
Long amountDue;
Long amountPaid;
Long amountRemaining;
Long applicationFee;
Integer attemptCount;
Boolean attempted;
String billing;
String billingReason;
@Getter(AccessLevel.NONE) @Setter(AccessLevel.NONE) ExpandableField charge;
Boolean closed;
Long created;
String currency;
String customer;
Long date;
String description;
Discount discount;
Long dueDate;
Long endingBalance;
Boolean forgiven;
@SerializedName("hosted_invoice_url") String hostedInvoiceURL;
@SerializedName("invoice_pdf") String invoicePDF;
InvoiceLineItemCollection lines;
Boolean livemode;
@Getter(onMethod = @__({@Override})) Map metadata;
Long nextPaymentAttempt;
String number;
Boolean paid;
Long periodEnd;
Long periodStart;
String receiptNumber;
Long startingBalance;
String statementDescriptor;
@Getter(AccessLevel.NONE) @Setter(AccessLevel.NONE) ExpandableField subscription;
Long subscriptionProrationDate;
Long subtotal;
Long tax;
Double taxPercent;
Long total;
Long webhooksDeliveredAt;
//
public String getCharge() {
return (this.charge != null) ? this.charge.getId() : null;
}
public void setCharge(String chargeID) {
this.charge = setExpandableFieldID(chargeID, this.charge);
}
public Charge getChargeObject() {
return (this.charge != null) ? this.charge.getExpanded() : null;
}
public void setChargeObject(Charge charge) {
this.charge = new ExpandableField(charge.getId(), charge);
}
//
//
public String getSubscription() {
return (this.subscription != null) ? this.subscription.getId() : null;
}
public void setSubscription(String subscriptionID) {
this.subscription = setExpandableFieldID(subscriptionID, this.subscription);
}
public Subscription getSubscriptionObject() {
return (this.subscription != null) ? this.subscription.getExpanded() : null;
}
public void setSubscriptionObject(Subscription subscription) {
this.subscription = new ExpandableField(subscription.getId(), subscription);
}
//
//
/**
* List all invoices.
*
* @deprecated Use the {@link #list(Map)} method instead.
* This method will be removed in the next major version.
*/
@Deprecated
public static InvoiceCollection all(Map params)
throws AuthenticationException, InvalidRequestException,
APIConnectionException, CardException, APIException {
return list(params, null);
}
/**
* List all invoices.
*
* @deprecated Use the {@link #list(Map, RequestOptions)} method instead.
* This method will be removed in the next major version.
*/
@Deprecated
public static InvoiceCollection all(Map params,
RequestOptions options) throws AuthenticationException,
InvalidRequestException, APIConnectionException, CardException,
APIException {
return list(params, options);
}
/**
* List all invoices.
*
* @deprecated Use the {@link #list(Map, RequestOptions)} method instead.
* This method will be removed in the next major version.
*/
@Deprecated
public static InvoiceCollection all(Map params,
String apiKey) throws AuthenticationException,
InvalidRequestException, APIConnectionException, CardException,
APIException {
return list(params, RequestOptions.builder().setApiKey(apiKey).build());
}
//
//
/**
* Create an invoice.
*/
public static Invoice create(Map params)
throws AuthenticationException, InvalidRequestException,
APIConnectionException, CardException, APIException {
return create(params, (RequestOptions) null);
}
/**
* Create an invoice.
*/
public static Invoice create(Map params, RequestOptions options)
throws AuthenticationException, InvalidRequestException,
APIConnectionException, CardException, APIException {
return request(RequestMethod.POST, classURL(Invoice.class), params, Invoice.class, options);
}
/**
* Create an invoice.
*
* @deprecated Use the {@link #create(Map, RequestOptions)} method instead.
* This method will be removed in the next major version.
*/
@Deprecated
public static Invoice create(Map params, String apiKey)
throws AuthenticationException, InvalidRequestException,
APIConnectionException, CardException, APIException {
return create(params, RequestOptions.builder().setApiKey(apiKey).build());
}
//
//
/**
* List all invoices.
*/
public static InvoiceCollection list(Map params)
throws AuthenticationException, InvalidRequestException,
APIConnectionException, CardException, APIException {
return list(params, null);
}
/**
* List all invoices.
*/
public static InvoiceCollection list(Map params,
RequestOptions options) throws AuthenticationException,
InvalidRequestException, APIConnectionException, CardException,
APIException {
return requestCollection(classURL(Invoice.class), params, InvoiceCollection.class, options);
}
//
//
/**
* Pay an invoice.
*/
public Invoice pay() throws AuthenticationException,
InvalidRequestException, APIConnectionException, CardException,
APIException {
return this.pay((RequestOptions) null);
}
/**
* Pay an invoice.
*/
public Invoice pay(RequestOptions options) throws AuthenticationException,
InvalidRequestException, APIConnectionException, CardException,
APIException {
return pay(null, options);
}
/**
* Pay an invoice.
*
* @deprecated Use the {@link #pay(RequestOptions)} method instead.
* This method will be removed in the next major version.
*/
@Deprecated
public Invoice pay(String apiKey) throws AuthenticationException,
InvalidRequestException, APIConnectionException, CardException,
APIException {
return pay(RequestOptions.builder().setApiKey(apiKey).build());
}
/**
* Pay an invoice.
*/
public Invoice pay(Map params) throws AuthenticationException,
InvalidRequestException, APIConnectionException, CardException,
APIException {
return this.pay(params, null);
}
/**
* Pay an invoice.
*/
public Invoice pay(Map params, RequestOptions options)
throws AuthenticationException, InvalidRequestException, APIConnectionException,
CardException, APIException {
return request(RequestMethod.POST, String.format("%s/pay",
instanceURL(Invoice.class, this.getId())), params, Invoice.class, options);
}
//
//
/**
* Retrieve an invoice.
*/
public static Invoice retrieve(String id) throws AuthenticationException,
InvalidRequestException, APIConnectionException, CardException,
APIException {
return retrieve(id, (RequestOptions) null);
}
/**
* Retrieve an invoice.
*/
public static Invoice retrieve(String id, RequestOptions options)
throws AuthenticationException, InvalidRequestException,
APIConnectionException, CardException, APIException {
return request(RequestMethod.GET, instanceURL(Invoice.class, id), null, Invoice.class, options);
}
/**
* Retrieve an invoice.
*
* @deprecated Use the {@link #retrieve(String, RequestOptions)} method instead.
* This method will be removed in the next major version.
*/
@Deprecated
public static Invoice retrieve(String id, String apiKey)
throws AuthenticationException, InvalidRequestException,
APIConnectionException, CardException, APIException {
return retrieve(id, RequestOptions.builder().setApiKey(apiKey).build());
}
/**
* Retrieve an invoice.
*/
public static Invoice retrieve(String id, Map params, RequestOptions options)
throws AuthenticationException, InvalidRequestException,
APIConnectionException, CardException, APIException {
return request(RequestMethod.GET, instanceURL(Invoice.class, id), params, Invoice.class,
options);
}
//
//
/**
* Retrieve an upcoming invoice.
*/
public static Invoice upcoming(Map params)
throws AuthenticationException, InvalidRequestException,
APIConnectionException, CardException, APIException {
return upcoming(params, (RequestOptions) null);
}
/**
* Retrieve an upcoming invoice.
*/
public static Invoice upcoming(Map params, RequestOptions options)
throws AuthenticationException, InvalidRequestException,
APIConnectionException, CardException, APIException {
return request(RequestMethod.GET, String.format("%s/upcoming", classURL(Invoice.class)), params,
Invoice.class, options);
}
/**
* Retrieve an upcoming invoice.
*
* @deprecated Use the {@link #upcoming(Map, RequestOptions)} method instead.
* This method will be removed in the next major version.
*/
@Deprecated
public static Invoice upcoming(Map params, String apiKey)
throws AuthenticationException, InvalidRequestException,
APIConnectionException, CardException, APIException {
return upcoming(params, RequestOptions.builder().setApiKey(apiKey).build());
}
//
//
/**
* Update an invoice.
*/
@Override
public Invoice update(Map params)
throws AuthenticationException, InvalidRequestException,
APIConnectionException, CardException, APIException {
return update(params, (RequestOptions) null);
}
/**
* Update an invoice.
*/
@Override
public Invoice update(Map params, RequestOptions options)
throws AuthenticationException, InvalidRequestException,
APIConnectionException, CardException, APIException {
return request(RequestMethod.POST, instanceURL(Invoice.class, this.id), params, Invoice.class,
options);
}
/**
* Update an invoice.
*
* @deprecated Use the {@link #update(Map, RequestOptions)} method instead.
* This method will be removed in the next major version.
*/
@Deprecated
public Invoice update(Map params, String apiKey)
throws AuthenticationException, InvalidRequestException,
APIConnectionException, CardException, APIException {
return update(params, RequestOptions.builder().setApiKey(apiKey).build());
}
//
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy