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

     1  //
     2  //
     3  // File generated from our OpenAPI spec
     4  //
     5  //
     6  
     7  package stripe
     8  
     9  import "encoding/json"
    10  
    11  // Returns a list of application fees you've previously collected. The application fees are returned in sorted order, with the most recent fees appearing first.
    12  type ApplicationFeeListParams struct {
    13  	ListParams `form:"*"`
    14  	// Only return application fees for the charge specified by this charge ID.
    15  	Charge *string `form:"charge"`
    16  	// Only return applications fees that were created during the given date interval.
    17  	Created *int64 `form:"created"`
    18  	// Only return applications fees that were created during the given date interval.
    19  	CreatedRange *RangeQueryParams `form:"created"`
    20  	// Specifies which fields in the response should be expanded.
    21  	Expand []*string `form:"expand"`
    22  }
    23  
    24  // AddExpand appends a new field to expand.
    25  func (p *ApplicationFeeListParams) AddExpand(f string) {
    26  	p.Expand = append(p.Expand, &f)
    27  }
    28  
    29  // Retrieves the details of an application fee that your account has collected. The same information is returned when refunding the application fee.
    30  type ApplicationFeeParams struct {
    31  	Params `form:"*"`
    32  	// Specifies which fields in the response should be expanded.
    33  	Expand []*string `form:"expand"`
    34  }
    35  
    36  // AddExpand appends a new field to expand.
    37  func (p *ApplicationFeeParams) AddExpand(f string) {
    38  	p.Expand = append(p.Expand, &f)
    39  }
    40  
    41  type ApplicationFee struct {
    42  	APIResource
    43  	// ID of the Stripe account this fee was taken from.
    44  	Account *Account `json:"account"`
    45  	// Amount earned, in cents (or local equivalent).
    46  	Amount int64 `json:"amount"`
    47  	// Amount in cents (or local equivalent) refunded (can be less than the amount attribute on the fee if a partial refund was issued)
    48  	AmountRefunded int64 `json:"amount_refunded"`
    49  	// ID of the Connect application that earned the fee.
    50  	Application *Application `json:"application"`
    51  	// Balance transaction that describes the impact of this collected application fee on your account balance (not including refunds).
    52  	BalanceTransaction *BalanceTransaction `json:"balance_transaction"`
    53  	// ID of the charge that the application fee was taken from.
    54  	Charge *Charge `json:"charge"`
    55  	// Time at which the object was created. Measured in seconds since the Unix epoch.
    56  	Created int64 `json:"created"`
    57  	// 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).
    58  	Currency Currency `json:"currency"`
    59  	// Unique identifier for the object.
    60  	ID string `json:"id"`
    61  	// Has the value `true` if the object exists in live mode or the value `false` if the object exists in test mode.
    62  	Livemode bool `json:"livemode"`
    63  	// String representing the object's type. Objects of the same type share the same value.
    64  	Object string `json:"object"`
    65  	// ID of the corresponding charge on the platform account, if this fee was the result of a charge using the `destination` parameter.
    66  	OriginatingTransaction *Charge `json:"originating_transaction"`
    67  	// Whether the fee has been fully refunded. If the fee is only partially refunded, this attribute will still be false.
    68  	Refunded bool `json:"refunded"`
    69  	// A list of refunds that have been applied to the fee.
    70  	Refunds *FeeRefundList `json:"refunds"`
    71  }
    72  
    73  // ApplicationFeeList is a list of ApplicationFees as retrieved from a list endpoint.
    74  type ApplicationFeeList struct {
    75  	APIResource
    76  	ListMeta
    77  	Data []*ApplicationFee `json:"data"`
    78  }
    79  
    80  // UnmarshalJSON handles deserialization of an ApplicationFee.
    81  // This custom unmarshaling is needed because the resulting
    82  // property may be an id or the full struct if it was expanded.
    83  func (a *ApplicationFee) UnmarshalJSON(data []byte) error {
    84  	if id, ok := ParseID(data); ok {
    85  		a.ID = id
    86  		return nil
    87  	}
    88  
    89  	type applicationFee ApplicationFee
    90  	var v applicationFee
    91  	if err := json.Unmarshal(data, &v); err != nil {
    92  		return err
    93  	}
    94  
    95  	*a = ApplicationFee(v)
    96  	return nil
    97  }