com.stripe.model.FeeRefund Maven / Gradle / Ivy
// File generated from our OpenAPI spec
package com.stripe.model;
import com.google.gson.annotations.SerializedName;
import com.stripe.exception.StripeException;
import com.stripe.net.ApiMode;
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.FeeRefundUpdateParams;
import java.util.Map;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.Setter;
/**
* {@code Application Fee Refund} objects allow you to refund an application fee that has previously
* been created but not yet refunded. Funds will be refunded to the Stripe account from which the
* fee was originally collected.
*
* Related guide: Refunding
* application fees
*/
@Getter
@Setter
@EqualsAndHashCode(callSuper = false)
public class FeeRefund extends ApiResource
implements MetadataStore, BalanceTransactionSource {
/** Amount, in cents (or local equivalent). */
@SerializedName("amount")
Long amount;
/** Balance transaction that describes the impact on your account balance. */
@SerializedName("balance_transaction")
@Getter(lombok.AccessLevel.NONE)
@Setter(lombok.AccessLevel.NONE)
ExpandableField balanceTransaction;
/** 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;
/** ID of the application fee that was refunded. */
@SerializedName("fee")
@Getter(lombok.AccessLevel.NONE)
@Setter(lombok.AccessLevel.NONE)
ExpandableField fee;
/** Unique identifier for the object. */
@Getter(onMethod_ = {@Override})
@SerializedName("id")
String id;
/**
* Set of key-value pairs that you can attach
* to an object. This can be useful for storing additional information about the object in a
* structured format.
*/
@Getter(onMethod_ = {@Override})
@SerializedName("metadata")
Map metadata;
/**
* String representing the object's type. Objects of the same type share the same value.
*
* Equal to {@code fee_refund}.
*/
@SerializedName("object")
String object;
/** Get ID of expandable {@code balanceTransaction} object. */
public String getBalanceTransaction() {
return (this.balanceTransaction != null) ? this.balanceTransaction.getId() : null;
}
public void setBalanceTransaction(String id) {
this.balanceTransaction = ApiResource.setExpandableFieldId(id, this.balanceTransaction);
}
/** Get expanded {@code balanceTransaction}. */
public BalanceTransaction getBalanceTransactionObject() {
return (this.balanceTransaction != null) ? this.balanceTransaction.getExpanded() : null;
}
public void setBalanceTransactionObject(BalanceTransaction expandableObject) {
this.balanceTransaction =
new ExpandableField(expandableObject.getId(), expandableObject);
}
/** Get ID of expandable {@code fee} object. */
public String getFee() {
return (this.fee != null) ? this.fee.getId() : null;
}
public void setFee(String id) {
this.fee = ApiResource.setExpandableFieldId(id, this.fee);
}
/** Get expanded {@code fee}. */
public ApplicationFee getFeeObject() {
return (this.fee != null) ? this.fee.getExpanded() : null;
}
public void setFeeObject(ApplicationFee expandableObject) {
this.fee = new ExpandableField(expandableObject.getId(), expandableObject);
}
/**
* Updates the specified application fee refund by setting the values of the parameters passed.
* Any parameters not provided will be left unchanged.
*
* This request only accepts metadata as an argument.
*/
@Override
public FeeRefund update(Map params) throws StripeException {
return update(params, (RequestOptions) null);
}
/**
* Updates the specified application fee refund by setting the values of the parameters passed.
* Any parameters not provided will be left unchanged.
*
* This request only accepts metadata as an argument.
*/
@Override
public FeeRefund update(Map params, RequestOptions options)
throws StripeException {
String path =
String.format(
"/v1/application_fees/%s/refunds/%s",
ApiResource.urlEncodeId(this.getFee()), ApiResource.urlEncodeId(this.getId()));
ApiRequest request =
new ApiRequest(
BaseAddress.API, ApiResource.RequestMethod.POST, path, params, options, ApiMode.V1);
return getResponseGetter().request(request, FeeRefund.class);
}
/**
* Updates the specified application fee refund by setting the values of the parameters passed.
* Any parameters not provided will be left unchanged.
*
* This request only accepts metadata as an argument.
*/
public FeeRefund update(FeeRefundUpdateParams params) throws StripeException {
return update(params, (RequestOptions) null);
}
/**
* Updates the specified application fee refund by setting the values of the parameters passed.
* Any parameters not provided will be left unchanged.
*
*
This request only accepts metadata as an argument.
*/
public FeeRefund update(FeeRefundUpdateParams params, RequestOptions options)
throws StripeException {
String path =
String.format(
"/v1/application_fees/%s/refunds/%s",
ApiResource.urlEncodeId(this.getFee()), ApiResource.urlEncodeId(this.getId()));
ApiResource.checkNullTypedParams(path, params);
ApiRequest request =
new ApiRequest(
BaseAddress.API,
ApiResource.RequestMethod.POST,
path,
ApiRequestParams.paramsToMap(params),
options,
ApiMode.V1);
return getResponseGetter().request(request, FeeRefund.class);
}
@Override
public void setResponseGetter(StripeResponseGetter responseGetter) {
super.setResponseGetter(responseGetter);
trySetResponseGetter(balanceTransaction, responseGetter);
trySetResponseGetter(fee, responseGetter);
}
}