github.com/stripe/stripe-go/v76@v76.25.0/feerefund.go (about)

     1  //
     2  //
     3  // File generated from our OpenAPI spec
     4  //
     5  //
     6  
     7  package stripe
     8  
     9  import "encoding/json"
    10  
    11  // By default, you can see the 10 most recent refunds stored directly on the application fee object, but you can also retrieve details about a specific refund stored on the application fee.
    12  type FeeRefundParams struct {
    13  	Params `form:"*"`
    14  	ID     *string `form:"-"` // Included in URL
    15  	Fee    *string `form:"-"` // Included in URL
    16  	// A positive integer, in _cents (or local equivalent)_, representing how much of this fee to refund. Can refund only up to the remaining unrefunded amount of the fee.
    17  	Amount *int64 `form:"amount"`
    18  	// Specifies which fields in the response should be expanded.
    19  	Expand []*string `form:"expand"`
    20  	// Set of [key-value pairs](https://stripe.com/docs/api/metadata) that you can attach to an object. This can be useful for storing additional information about the object in a structured format. Individual keys can be unset by posting an empty value to them. All keys can be unset by posting an empty value to `metadata`.
    21  	Metadata map[string]string `form:"metadata"`
    22  }
    23  
    24  // AddExpand appends a new field to expand.
    25  func (p *FeeRefundParams) AddExpand(f string) {
    26  	p.Expand = append(p.Expand, &f)
    27  }
    28  
    29  // AddMetadata adds a new key-value pair to the Metadata.
    30  func (p *FeeRefundParams) AddMetadata(key string, value string) {
    31  	if p.Metadata == nil {
    32  		p.Metadata = make(map[string]string)
    33  	}
    34  
    35  	p.Metadata[key] = value
    36  }
    37  
    38  // You can see a list of the refunds belonging to a specific application fee. Note that the 10 most recent refunds are always available by default on the application fee object. If you need more than those 10, you can use this API method and the limit and starting_after parameters to page through additional refunds.
    39  type FeeRefundListParams struct {
    40  	ListParams `form:"*"`
    41  	ID         *string `form:"-"` // Included in URL
    42  	// Specifies which fields in the response should be expanded.
    43  	Expand []*string `form:"expand"`
    44  }
    45  
    46  // AddExpand appends a new field to expand.
    47  func (p *FeeRefundListParams) AddExpand(f string) {
    48  	p.Expand = append(p.Expand, &f)
    49  }
    50  
    51  // `Application Fee Refund` objects allow you to refund an application fee that
    52  // has previously been created but not yet refunded. Funds will be refunded to
    53  // the Stripe account from which the fee was originally collected.
    54  //
    55  // Related guide: [Refunding application fees](https://stripe.com/docs/connect/destination-charges#refunding-app-fee)
    56  type FeeRefund struct {
    57  	APIResource
    58  	// Amount, in cents (or local equivalent).
    59  	Amount int64 `json:"amount"`
    60  	// Balance transaction that describes the impact on your account balance.
    61  	BalanceTransaction *BalanceTransaction `json:"balance_transaction"`
    62  	// Time at which the object was created. Measured in seconds since the Unix epoch.
    63  	Created int64 `json:"created"`
    64  	// Three-letter [ISO currency code](https://www.iso.org/iso-4217-currency-codes.html), in lowercase. Must be a [supported currency](https://stripe.com/docs/currencies).
    65  	Currency Currency `json:"currency"`
    66  	// ID of the application fee that was refunded.
    67  	Fee *ApplicationFee `json:"fee"`
    68  	// Unique identifier for the object.
    69  	ID string `json:"id"`
    70  	// Set of [key-value pairs](https://stripe.com/docs/api/metadata) that you can attach to an object. This can be useful for storing additional information about the object in a structured format.
    71  	Metadata map[string]string `json:"metadata"`
    72  	// String representing the object's type. Objects of the same type share the same value.
    73  	Object string `json:"object"`
    74  }
    75  
    76  // FeeRefundList is a list of FeeRefunds as retrieved from a list endpoint.
    77  type FeeRefundList struct {
    78  	APIResource
    79  	ListMeta
    80  	Data []*FeeRefund `json:"data"`
    81  }
    82  
    83  // UnmarshalJSON handles deserialization of a FeeRefund.
    84  // This custom unmarshaling is needed because the resulting
    85  // property may be an id or the full struct if it was expanded.
    86  func (f *FeeRefund) UnmarshalJSON(data []byte) error {
    87  	if id, ok := ParseID(data); ok {
    88  		f.ID = id
    89  		return nil
    90  	}
    91  
    92  	type feeRefund FeeRefund
    93  	var v feeRefund
    94  	if err := json.Unmarshal(data, &v); err != nil {
    95  		return err
    96  	}
    97  
    98  	*f = FeeRefund(v)
    99  	return nil
   100  }