com.stripe.model.treasury.Transaction Maven / Gradle / Ivy
// File generated from our OpenAPI spec
package com.stripe.model.treasury;
import com.google.gson.annotations.SerializedName;
import com.stripe.exception.StripeException;
import com.stripe.model.HasId;
import com.stripe.model.StripeObject;
import com.stripe.model.issuing.Authorization;
import com.stripe.net.ApiRequest;
import com.stripe.net.ApiRequestParams;
import com.stripe.net.ApiResource;
import com.stripe.net.BaseAddress;
import com.stripe.net.RequestOptions;
import com.stripe.net.StripeResponseGetter;
import com.stripe.param.treasury.TransactionListParams;
import com.stripe.param.treasury.TransactionRetrieveParams;
import java.util.Map;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.Setter;
/**
* Transactions represent changes to a FinancialAccount's balance.
*/
@Getter
@Setter
@EqualsAndHashCode(callSuper = false)
public class Transaction extends ApiResource implements HasId {
/** Amount (in cents) transferred. */
@SerializedName("amount")
Long amount;
/** Change to a FinancialAccount's balance. */
@SerializedName("balance_impact")
BalanceImpact balanceImpact;
/** Time at which the object was created. Measured in seconds since the Unix epoch. */
@SerializedName("created")
Long created;
/**
* Three-letter ISO currency code,
* in lowercase. Must be a supported currency.
*/
@SerializedName("currency")
String currency;
/** An arbitrary string attached to the object. Often useful for displaying to users. */
@SerializedName("description")
String description;
/**
* A list of TransactionEntries that are part of this Transaction. This cannot be expanded in any
* list endpoints.
*/
@SerializedName("entries")
TransactionEntryCollection entries;
/** The FinancialAccount associated with this object. */
@SerializedName("financial_account")
String financialAccount;
/** ID of the flow that created the Transaction. */
@SerializedName("flow")
String flow;
/** Details of the flow that created the Transaction. */
@SerializedName("flow_details")
FlowDetails flowDetails;
/**
* Type of the flow that created the Transaction.
*
* One of {@code credit_reversal}, {@code debit_reversal}, {@code inbound_transfer}, {@code
* issuing_authorization}, {@code other}, {@code outbound_payment}, {@code outbound_transfer},
* {@code received_credit}, or {@code received_debit}.
*/
@SerializedName("flow_type")
String flowType;
/** 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.
*
*
Equal to {@code treasury.transaction}.
*/
@SerializedName("object")
String object;
/**
* Status of the Transaction.
*
*
One of {@code open}, {@code posted}, or {@code void}.
*/
@SerializedName("status")
String status;
@SerializedName("status_transitions")
StatusTransitions statusTransitions;
/** Retrieves a list of Transaction objects. */
public static TransactionCollection list(Map params) throws StripeException {
return list(params, (RequestOptions) null);
}
/** Retrieves a list of Transaction objects. */
public static TransactionCollection list(Map params, RequestOptions options)
throws StripeException {
String path = "/v1/treasury/transactions";
ApiRequest request =
new ApiRequest(BaseAddress.API, ApiResource.RequestMethod.GET, path, params, options);
return getGlobalResponseGetter().request(request, TransactionCollection.class);
}
/** Retrieves a list of Transaction objects. */
public static TransactionCollection list(TransactionListParams params) throws StripeException {
return list(params, (RequestOptions) null);
}
/** Retrieves a list of Transaction objects. */
public static TransactionCollection list(TransactionListParams params, RequestOptions options)
throws StripeException {
String path = "/v1/treasury/transactions";
ApiResource.checkNullTypedParams(path, params);
ApiRequest request =
new ApiRequest(
BaseAddress.API,
ApiResource.RequestMethod.GET,
path,
ApiRequestParams.paramsToMap(params),
options);
return getGlobalResponseGetter().request(request, TransactionCollection.class);
}
/** Retrieves the details of an existing Transaction. */
public static Transaction retrieve(String id) throws StripeException {
return retrieve(id, (Map) null, (RequestOptions) null);
}
/** Retrieves the details of an existing Transaction. */
public static Transaction retrieve(String id, RequestOptions options) throws StripeException {
return retrieve(id, (Map) null, options);
}
/** Retrieves the details of an existing Transaction. */
public static Transaction retrieve(String id, Map params, RequestOptions options)
throws StripeException {
String path = String.format("/v1/treasury/transactions/%s", ApiResource.urlEncodeId(id));
ApiRequest request =
new ApiRequest(BaseAddress.API, ApiResource.RequestMethod.GET, path, params, options);
return getGlobalResponseGetter().request(request, Transaction.class);
}
/** Retrieves the details of an existing Transaction. */
public static Transaction retrieve(
String id, TransactionRetrieveParams params, RequestOptions options) throws StripeException {
String path = String.format("/v1/treasury/transactions/%s", ApiResource.urlEncodeId(id));
ApiResource.checkNullTypedParams(path, params);
ApiRequest request =
new ApiRequest(
BaseAddress.API,
ApiResource.RequestMethod.GET,
path,
ApiRequestParams.paramsToMap(params),
options);
return getGlobalResponseGetter().request(request, Transaction.class);
}
/** Change to a FinancialAccount's balance. */
@Getter
@Setter
@EqualsAndHashCode(callSuper = false)
public static class BalanceImpact extends StripeObject {
/** The change made to funds the user can spend right now. */
@SerializedName("cash")
Long cash;
/**
* The change made to funds that are not spendable yet, but will become available at a later
* time.
*/
@SerializedName("inbound_pending")
Long inboundPending;
/**
* The change made to funds in the account, but not spendable because they are being held for
* pending outbound flows.
*/
@SerializedName("outbound_pending")
Long outboundPending;
}
@Getter
@Setter
@EqualsAndHashCode(callSuper = false)
public static class FlowDetails extends StripeObject {
/**
* You can reverse some ReceivedCredits depending on their
* network and source flow. Reversing a ReceivedCredit leads to the creation of a new object
* known as a CreditReversal.
*/
@SerializedName("credit_reversal")
CreditReversal creditReversal;
/**
* You can reverse some ReceivedDebits
* depending on their network and source flow. Reversing a ReceivedDebit leads to the creation
* of a new object known as a DebitReversal.
*/
@SerializedName("debit_reversal")
DebitReversal debitReversal;
/**
* Use InboundTransfers
* to add funds to your FinancialAccount via a
* PaymentMethod that is owned by you. The funds will be transferred via an ACH debit.
*
* Related guide: Moving
* money with Treasury using InboundTransfer objects
*/
@SerializedName("inbound_transfer")
InboundTransfer inboundTransfer;
/**
* When an issued card is used to make a purchase,
* an Issuing {@code Authorization} object is created. Authorizations must be
* approved for the purchase to be completed successfully.
*
*
Related guide: Issued
* card authorizations
*/
@SerializedName("issuing_authorization")
Authorization issuingAuthorization;
/**
* Use OutboundPayments
* to send funds to another party's external bank account or FinancialAccount. To send money to
* an account belonging to the same user, use an OutboundTransfer.
*
*
Simulate OutboundPayment state changes with the {@code
* /v1/test_helpers/treasury/outbound_payments} endpoints. These methods can only be called on
* test mode objects.
*
*
Related guide: Moving
* money with Treasury using OutboundPayment objects
*/
@SerializedName("outbound_payment")
OutboundPayment outboundPayment;
/**
* Use OutboundTransfers
* to transfer funds from a FinancialAccount to a PaymentMethod
* belonging to the same entity. To send funds to a different party, use OutboundPayments instead. You can
* send funds over ACH rails or through a domestic wire transfer to a user's own external bank
* account.
*
*
Simulate OutboundTransfer state changes with the {@code
* /v1/test_helpers/treasury/outbound_transfers} endpoints. These methods can only be called on
* test mode objects.
*
*
Related guide: Moving
* money with Treasury using OutboundTransfer objects
*/
@SerializedName("outbound_transfer")
OutboundTransfer outboundTransfer;
/**
* ReceivedCredits represent funds sent to a FinancialAccount (for example, via
* ACH or wire). These money movements are not initiated from the FinancialAccount.
*/
@SerializedName("received_credit")
ReceivedCredit receivedCredit;
/**
* ReceivedDebits represent funds pulled from a FinancialAccount. These are not
* initiated from the FinancialAccount.
*/
@SerializedName("received_debit")
ReceivedDebit receivedDebit;
/**
* Type of the flow that created the Transaction. Set to the same value as {@code flow_type}.
*
*
One of {@code credit_reversal}, {@code debit_reversal}, {@code inbound_transfer}, {@code
* issuing_authorization}, {@code other}, {@code outbound_payment}, {@code outbound_transfer},
* {@code received_credit}, or {@code received_debit}.
*/
@SerializedName("type")
String type;
}
@Getter
@Setter
@EqualsAndHashCode(callSuper = false)
public static class StatusTransitions extends StripeObject {
/** Timestamp describing when the Transaction changed status to {@code posted}. */
@SerializedName("posted_at")
Long postedAt;
/** Timestamp describing when the Transaction changed status to {@code void}. */
@SerializedName("void_at")
Long voidAt;
}
@Override
public void setResponseGetter(StripeResponseGetter responseGetter) {
super.setResponseGetter(responseGetter);
trySetResponseGetter(balanceImpact, responseGetter);
trySetResponseGetter(entries, responseGetter);
trySetResponseGetter(flowDetails, responseGetter);
trySetResponseGetter(statusTransitions, responseGetter);
}
}