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

     1  //
     2  //
     3  // File generated from our OpenAPI spec
     4  //
     5  //
     6  
     7  package stripe
     8  
     9  import "encoding/json"
    10  
    11  // The funding method type used to fund the customer balance. Permitted values include: `eu_bank_transfer`, `gb_bank_transfer`, `jp_bank_transfer`, `mx_bank_transfer`, or `us_bank_transfer`.
    12  type CustomerCashBalanceTransactionFundedBankTransferType string
    13  
    14  // List of values that CustomerCashBalanceTransactionFundedBankTransferType can take
    15  const (
    16  	CustomerCashBalanceTransactionFundedBankTransferTypeEUBankTransfer CustomerCashBalanceTransactionFundedBankTransferType = "eu_bank_transfer"
    17  	CustomerCashBalanceTransactionFundedBankTransferTypeGBBankTransfer CustomerCashBalanceTransactionFundedBankTransferType = "gb_bank_transfer"
    18  	CustomerCashBalanceTransactionFundedBankTransferTypeJPBankTransfer CustomerCashBalanceTransactionFundedBankTransferType = "jp_bank_transfer"
    19  	CustomerCashBalanceTransactionFundedBankTransferTypeMXBankTransfer CustomerCashBalanceTransactionFundedBankTransferType = "mx_bank_transfer"
    20  	CustomerCashBalanceTransactionFundedBankTransferTypeUSBankTransfer CustomerCashBalanceTransactionFundedBankTransferType = "us_bank_transfer"
    21  )
    22  
    23  // The banking network used for this funding.
    24  type CustomerCashBalanceTransactionFundedBankTransferUSBankTransferNetwork string
    25  
    26  // List of values that CustomerCashBalanceTransactionFundedBankTransferUSBankTransferNetwork can take
    27  const (
    28  	CustomerCashBalanceTransactionFundedBankTransferUSBankTransferNetworkACH            CustomerCashBalanceTransactionFundedBankTransferUSBankTransferNetwork = "ach"
    29  	CustomerCashBalanceTransactionFundedBankTransferUSBankTransferNetworkDomesticWireUS CustomerCashBalanceTransactionFundedBankTransferUSBankTransferNetwork = "domestic_wire_us"
    30  	CustomerCashBalanceTransactionFundedBankTransferUSBankTransferNetworkSwift          CustomerCashBalanceTransactionFundedBankTransferUSBankTransferNetwork = "swift"
    31  )
    32  
    33  // The type of the cash balance transaction. New types may be added in future. See [Customer Balance](https://stripe.com/docs/payments/customer-balance#types) to learn more about these types.
    34  type CustomerCashBalanceTransactionType string
    35  
    36  // List of values that CustomerCashBalanceTransactionType can take
    37  const (
    38  	CustomerCashBalanceTransactionTypeAdjustedForOverdraft CustomerCashBalanceTransactionType = "adjusted_for_overdraft"
    39  	CustomerCashBalanceTransactionTypeAppliedToPayment     CustomerCashBalanceTransactionType = "applied_to_payment"
    40  	CustomerCashBalanceTransactionTypeFunded               CustomerCashBalanceTransactionType = "funded"
    41  	CustomerCashBalanceTransactionTypeFundingReversed      CustomerCashBalanceTransactionType = "funding_reversed"
    42  	CustomerCashBalanceTransactionTypeRefundedFromPayment  CustomerCashBalanceTransactionType = "refunded_from_payment"
    43  	CustomerCashBalanceTransactionTypeReturnCanceled       CustomerCashBalanceTransactionType = "return_canceled"
    44  	CustomerCashBalanceTransactionTypeReturnInitiated      CustomerCashBalanceTransactionType = "return_initiated"
    45  	CustomerCashBalanceTransactionTypeTransferredToBalance CustomerCashBalanceTransactionType = "transferred_to_balance"
    46  	CustomerCashBalanceTransactionTypeUnappliedFromPayment CustomerCashBalanceTransactionType = "unapplied_from_payment"
    47  )
    48  
    49  // Returns a list of transactions that modified the customer's [cash balance](https://stripe.com/docs/payments/customer-balance).
    50  type CustomerCashBalanceTransactionListParams struct {
    51  	ListParams `form:"*"`
    52  	Customer   *string `form:"-"` // Included in URL
    53  	// Specifies which fields in the response should be expanded.
    54  	Expand []*string `form:"expand"`
    55  }
    56  
    57  // AddExpand appends a new field to expand.
    58  func (p *CustomerCashBalanceTransactionListParams) AddExpand(f string) {
    59  	p.Expand = append(p.Expand, &f)
    60  }
    61  
    62  // Retrieves a specific cash balance transaction, which updated the customer's [cash balance](https://stripe.com/docs/payments/customer-balance).
    63  type CustomerCashBalanceTransactionParams struct {
    64  	Params   `form:"*"`
    65  	Customer *string `form:"-"` // Included in URL
    66  	// Specifies which fields in the response should be expanded.
    67  	Expand []*string `form:"expand"`
    68  }
    69  
    70  // AddExpand appends a new field to expand.
    71  func (p *CustomerCashBalanceTransactionParams) AddExpand(f string) {
    72  	p.Expand = append(p.Expand, &f)
    73  }
    74  
    75  type CustomerCashBalanceTransactionAdjustedForOverdraft struct {
    76  	// The [Balance Transaction](https://stripe.com/docs/api/balance_transactions/object) that corresponds to funds taken out of your Stripe balance.
    77  	BalanceTransaction *BalanceTransaction `json:"balance_transaction"`
    78  	// The [Cash Balance Transaction](https://stripe.com/docs/api/cash_balance_transactions/object) that brought the customer balance negative, triggering the clawback of funds.
    79  	LinkedTransaction *CustomerCashBalanceTransaction `json:"linked_transaction"`
    80  }
    81  type CustomerCashBalanceTransactionAppliedToPayment struct {
    82  	// The [Payment Intent](https://stripe.com/docs/api/payment_intents/object) that funds were applied to.
    83  	PaymentIntent *PaymentIntent `json:"payment_intent"`
    84  }
    85  type CustomerCashBalanceTransactionFundedBankTransferEUBankTransfer struct {
    86  	// The BIC of the bank of the sender of the funding.
    87  	BIC string `json:"bic"`
    88  	// The last 4 digits of the IBAN of the sender of the funding.
    89  	IBANLast4 string `json:"iban_last4"`
    90  	// The full name of the sender, as supplied by the sending bank.
    91  	SenderName string `json:"sender_name"`
    92  }
    93  type CustomerCashBalanceTransactionFundedBankTransferGBBankTransfer struct {
    94  	// The last 4 digits of the account number of the sender of the funding.
    95  	AccountNumberLast4 string `json:"account_number_last4"`
    96  	// The full name of the sender, as supplied by the sending bank.
    97  	SenderName string `json:"sender_name"`
    98  	// The sort code of the bank of the sender of the funding
    99  	SortCode string `json:"sort_code"`
   100  }
   101  type CustomerCashBalanceTransactionFundedBankTransferJPBankTransfer struct {
   102  	// The name of the bank of the sender of the funding.
   103  	SenderBank string `json:"sender_bank"`
   104  	// The name of the bank branch of the sender of the funding.
   105  	SenderBranch string `json:"sender_branch"`
   106  	// The full name of the sender, as supplied by the sending bank.
   107  	SenderName string `json:"sender_name"`
   108  }
   109  type CustomerCashBalanceTransactionFundedBankTransferUSBankTransfer struct {
   110  	// The banking network used for this funding.
   111  	Network CustomerCashBalanceTransactionFundedBankTransferUSBankTransferNetwork `json:"network"`
   112  	// The full name of the sender, as supplied by the sending bank.
   113  	SenderName string `json:"sender_name"`
   114  }
   115  type CustomerCashBalanceTransactionFundedBankTransfer struct {
   116  	EUBankTransfer *CustomerCashBalanceTransactionFundedBankTransferEUBankTransfer `json:"eu_bank_transfer"`
   117  	GBBankTransfer *CustomerCashBalanceTransactionFundedBankTransferGBBankTransfer `json:"gb_bank_transfer"`
   118  	JPBankTransfer *CustomerCashBalanceTransactionFundedBankTransferJPBankTransfer `json:"jp_bank_transfer"`
   119  	// The user-supplied reference field on the bank transfer.
   120  	Reference string `json:"reference"`
   121  	// The funding method type used to fund the customer balance. Permitted values include: `eu_bank_transfer`, `gb_bank_transfer`, `jp_bank_transfer`, `mx_bank_transfer`, or `us_bank_transfer`.
   122  	Type           CustomerCashBalanceTransactionFundedBankTransferType            `json:"type"`
   123  	USBankTransfer *CustomerCashBalanceTransactionFundedBankTransferUSBankTransfer `json:"us_bank_transfer"`
   124  }
   125  type CustomerCashBalanceTransactionFunded struct {
   126  	BankTransfer *CustomerCashBalanceTransactionFundedBankTransfer `json:"bank_transfer"`
   127  }
   128  type CustomerCashBalanceTransactionRefundedFromPayment struct {
   129  	// The [Refund](https://stripe.com/docs/api/refunds/object) that moved these funds into the customer's cash balance.
   130  	Refund *Refund `json:"refund"`
   131  }
   132  type CustomerCashBalanceTransactionTransferredToBalance struct {
   133  	// The [Balance Transaction](https://stripe.com/docs/api/balance_transactions/object) that corresponds to funds transferred to your Stripe balance.
   134  	BalanceTransaction *BalanceTransaction `json:"balance_transaction"`
   135  }
   136  type CustomerCashBalanceTransactionUnappliedFromPayment struct {
   137  	// The [Payment Intent](https://stripe.com/docs/api/payment_intents/object) that funds were unapplied from.
   138  	PaymentIntent *PaymentIntent `json:"payment_intent"`
   139  }
   140  
   141  // Customers with certain payments enabled have a cash balance, representing funds that were paid
   142  // by the customer to a merchant, but have not yet been allocated to a payment. Cash Balance Transactions
   143  // represent when funds are moved into or out of this balance. This includes funding by the customer, allocation
   144  // to payments, and refunds to the customer.
   145  type CustomerCashBalanceTransaction struct {
   146  	APIResource
   147  	AdjustedForOverdraft *CustomerCashBalanceTransactionAdjustedForOverdraft `json:"adjusted_for_overdraft"`
   148  	AppliedToPayment     *CustomerCashBalanceTransactionAppliedToPayment     `json:"applied_to_payment"`
   149  	// Time at which the object was created. Measured in seconds since the Unix epoch.
   150  	Created int64 `json:"created"`
   151  	// 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).
   152  	Currency Currency `json:"currency"`
   153  	// The customer whose available cash balance changed as a result of this transaction.
   154  	Customer *Customer `json:"customer"`
   155  	// The total available cash balance for the specified currency after this transaction was applied. Represented in the [smallest currency unit](https://stripe.com/docs/currencies#zero-decimal).
   156  	EndingBalance int64                                 `json:"ending_balance"`
   157  	Funded        *CustomerCashBalanceTransactionFunded `json:"funded"`
   158  	// Unique identifier for the object.
   159  	ID string `json:"id"`
   160  	// Has the value `true` if the object exists in live mode or the value `false` if the object exists in test mode.
   161  	Livemode bool `json:"livemode"`
   162  	// The amount by which the cash balance changed, represented in the [smallest currency unit](https://stripe.com/docs/currencies#zero-decimal). A positive value represents funds being added to the cash balance, a negative value represents funds being removed from the cash balance.
   163  	NetAmount int64 `json:"net_amount"`
   164  	// String representing the object's type. Objects of the same type share the same value.
   165  	Object               string                                              `json:"object"`
   166  	RefundedFromPayment  *CustomerCashBalanceTransactionRefundedFromPayment  `json:"refunded_from_payment"`
   167  	TransferredToBalance *CustomerCashBalanceTransactionTransferredToBalance `json:"transferred_to_balance"`
   168  	// The type of the cash balance transaction. New types may be added in future. See [Customer Balance](https://stripe.com/docs/payments/customer-balance#types) to learn more about these types.
   169  	Type                 CustomerCashBalanceTransactionType                  `json:"type"`
   170  	UnappliedFromPayment *CustomerCashBalanceTransactionUnappliedFromPayment `json:"unapplied_from_payment"`
   171  }
   172  
   173  // CustomerCashBalanceTransactionList is a list of CustomerCashBalanceTransactions as retrieved from a list endpoint.
   174  type CustomerCashBalanceTransactionList struct {
   175  	APIResource
   176  	ListMeta
   177  	Data []*CustomerCashBalanceTransaction `json:"data"`
   178  }
   179  
   180  // UnmarshalJSON handles deserialization of a CustomerCashBalanceTransaction.
   181  // This custom unmarshaling is needed because the resulting
   182  // property may be an id or the full struct if it was expanded.
   183  func (c *CustomerCashBalanceTransaction) UnmarshalJSON(data []byte) error {
   184  	if id, ok := ParseID(data); ok {
   185  		c.ID = id
   186  		return nil
   187  	}
   188  
   189  	type customerCashBalanceTransaction CustomerCashBalanceTransaction
   190  	var v customerCashBalanceTransaction
   191  	if err := json.Unmarshal(data, &v); err != nil {
   192  		return err
   193  	}
   194  
   195  	*c = CustomerCashBalanceTransaction(v)
   196  	return nil
   197  }