github.com/stripe/stripe-go/v76@v76.25.0/payout.go (about) 1 // 2 // 3 // File generated from our OpenAPI spec 4 // 5 // 6 7 package stripe 8 9 import "encoding/json" 10 11 type PayoutDestinationType string 12 13 // List of values that PayoutDestinationType can take 14 const ( 15 PayoutDestinationTypeBankAccount PayoutDestinationType = "bank_account" 16 PayoutDestinationTypeCard PayoutDestinationType = "card" 17 ) 18 19 // Error code that provides a reason for a payout failure, if available. View our [list of failure codes](https://stripe.com/docs/api#payout_failures). 20 type PayoutFailureCode string 21 22 // List of values that PayoutFailureCode can take 23 const ( 24 PayoutFailureCodeAccountClosed PayoutFailureCode = "account_closed" 25 PayoutFailureCodeAccountFrozen PayoutFailureCode = "account_frozen" 26 PayoutFailureCodeBankAccountRestricted PayoutFailureCode = "bank_account_restricted" 27 PayoutFailureCodeBankOwnershipChanged PayoutFailureCode = "bank_ownership_changed" 28 PayoutFailureCodeCouldNotProcess PayoutFailureCode = "could_not_process" 29 PayoutFailureCodeDebitNotAuthorized PayoutFailureCode = "debit_not_authorized" 30 PayoutFailureCodeDeclined PayoutFailureCode = "declined" 31 PayoutFailureCodeInsufficientFunds PayoutFailureCode = "insufficient_funds" 32 PayoutFailureCodeInvalidAccountNumber PayoutFailureCode = "invalid_account_number" 33 PayoutFailureCodeIncorrectAccountHolderName PayoutFailureCode = "incorrect_account_holder_name" 34 PayoutFailureCodeIncorrectAccountHolderAddress PayoutFailureCode = "incorrect_account_holder_address" 35 PayoutFailureCodeIncorrectAccountHolderTaxID PayoutFailureCode = "incorrect_account_holder_tax_id" 36 PayoutFailureCodeInvalidCurrency PayoutFailureCode = "invalid_currency" 37 PayoutFailureCodeNoAccount PayoutFailureCode = "no_account" 38 PayoutFailureCodeUnsupportedCard PayoutFailureCode = "unsupported_card" 39 ) 40 41 // The method used to send this payout, which can be `standard` or `instant`. `instant` is supported for payouts to debit cards and bank accounts in certain countries. Learn more about [bank support for Instant Payouts](https://stripe.com/docs/payouts/instant-payouts-banks). 42 type PayoutMethodType string 43 44 // List of values that PayoutMethodType can take 45 const ( 46 PayoutMethodInstant PayoutMethodType = "instant" 47 PayoutMethodStandard PayoutMethodType = "standard" 48 ) 49 50 // If `completed`, you can use the [Balance Transactions API](https://stripe.com/docs/api/balance_transactions/list#balance_transaction_list-payout) to list all balance transactions that are paid out in this payout. 51 type PayoutReconciliationStatus string 52 53 // List of values that PayoutReconciliationStatus can take 54 const ( 55 PayoutReconciliationStatusCompleted PayoutReconciliationStatus = "completed" 56 PayoutReconciliationStatusInProgress PayoutReconciliationStatus = "in_progress" 57 PayoutReconciliationStatusNotApplicable PayoutReconciliationStatus = "not_applicable" 58 ) 59 60 // The source balance this payout came from, which can be one of the following: `card`, `fpx`, or `bank_account`. 61 type PayoutSourceType string 62 63 // List of values that PayoutSourceType can take 64 const ( 65 PayoutSourceTypeBankAccount PayoutSourceType = "bank_account" 66 PayoutSourceTypeCard PayoutSourceType = "card" 67 PayoutSourceTypeFPX PayoutSourceType = "fpx" 68 ) 69 70 // Current status of the payout: `paid`, `pending`, `in_transit`, `canceled` or `failed`. A payout is `pending` until it's submitted to the bank, when it becomes `in_transit`. The status changes to `paid` if the transaction succeeds, or to `failed` or `canceled` (within 5 business days). Some payouts that fail might initially show as `paid`, then change to `failed`. 71 type PayoutStatus string 72 73 // List of values that PayoutStatus can take 74 const ( 75 PayoutStatusCanceled PayoutStatus = "canceled" 76 PayoutStatusFailed PayoutStatus = "failed" 77 PayoutStatusInTransit PayoutStatus = "in_transit" 78 PayoutStatusPaid PayoutStatus = "paid" 79 PayoutStatusPending PayoutStatus = "pending" 80 ) 81 82 // Can be `bank_account` or `card`. 83 type PayoutType string 84 85 // List of values that PayoutType can take 86 const ( 87 PayoutTypeBank PayoutType = "bank_account" 88 PayoutTypeCard PayoutType = "card" 89 ) 90 91 // Returns a list of existing payouts sent to third-party bank accounts or payouts that Stripe sent to you. The payouts return in sorted order, with the most recently created payouts appearing first. 92 type PayoutListParams struct { 93 ListParams `form:"*"` 94 // Only return payouts that are expected to arrive during the given date interval. 95 ArrivalDate *int64 `form:"arrival_date"` 96 // Only return payouts that are expected to arrive during the given date interval. 97 ArrivalDateRange *RangeQueryParams `form:"arrival_date"` 98 // Only return payouts that were created during the given date interval. 99 Created *int64 `form:"created"` 100 // Only return payouts that were created during the given date interval. 101 CreatedRange *RangeQueryParams `form:"created"` 102 // The ID of an external account - only return payouts sent to this external account. 103 Destination *string `form:"destination"` 104 // Specifies which fields in the response should be expanded. 105 Expand []*string `form:"expand"` 106 // Only return payouts that have the given status: `pending`, `paid`, `failed`, or `canceled`. 107 Status *string `form:"status"` 108 } 109 110 // AddExpand appends a new field to expand. 111 func (p *PayoutListParams) AddExpand(f string) { 112 p.Expand = append(p.Expand, &f) 113 } 114 115 // To send funds to your own bank account, create a new payout object. Your [Stripe balance](https://stripe.com/docs/api#balance) must cover the payout amount. If it doesn't, you receive an “Insufficient Funds” error. 116 // 117 // If your API key is in test mode, money won't actually be sent, though every other action occurs as if you're in live mode. 118 // 119 // If you create a manual payout on a Stripe account that uses multiple payment source types, you need to specify the source type balance that the payout draws from. The [balance object](https://stripe.com/docs/api#balance_object) details available and pending amounts by source type. 120 type PayoutParams struct { 121 Params `form:"*"` 122 // A positive integer in cents representing how much to payout. 123 Amount *int64 `form:"amount"` 124 // 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). 125 Currency *string `form:"currency"` 126 // An arbitrary string attached to the object. Often useful for displaying to users. 127 Description *string `form:"description"` 128 // The ID of a bank account or a card to send the payout to. If you don't provide a destination, we use the default external account for the specified currency. 129 Destination *string `form:"destination"` 130 // Specifies which fields in the response should be expanded. 131 Expand []*string `form:"expand"` 132 // 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`. 133 Metadata map[string]string `form:"metadata"` 134 // The method used to send this payout, which is `standard` or `instant`. We support `instant` for payouts to debit cards and bank accounts in certain countries. Learn more about [bank support for Instant Payouts](https://stripe.com/docs/payouts/instant-payouts-banks). 135 Method *string `form:"method"` 136 // The balance type of your Stripe balance to draw this payout from. Balances for different payment sources are kept separately. You can find the amounts with the Balances API. One of `bank_account`, `card`, or `fpx`. 137 SourceType *string `form:"source_type"` 138 // A string that displays on the recipient's bank or card statement (up to 22 characters). A `statement_descriptor` that's longer than 22 characters return an error. Most banks truncate this information and display it inconsistently. Some banks might not display it at all. 139 StatementDescriptor *string `form:"statement_descriptor"` 140 } 141 142 // AddExpand appends a new field to expand. 143 func (p *PayoutParams) AddExpand(f string) { 144 p.Expand = append(p.Expand, &f) 145 } 146 147 // AddMetadata adds a new key-value pair to the Metadata. 148 func (p *PayoutParams) AddMetadata(key string, value string) { 149 if p.Metadata == nil { 150 p.Metadata = make(map[string]string) 151 } 152 153 p.Metadata[key] = value 154 } 155 156 // Reverses a payout by debiting the destination bank account. At this time, you can only reverse payouts for connected accounts to US bank accounts. If the payout is manual and in the pending status, use /v1/payouts/:id/cancel instead. 157 // 158 // By requesting a reversal through /v1/payouts/:id/reverse, you confirm that the authorized signatory of the selected bank account authorizes the debit on the bank account and that no other authorization is required. 159 type PayoutReverseParams struct { 160 Params `form:"*"` 161 // Specifies which fields in the response should be expanded. 162 Expand []*string `form:"expand"` 163 // 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`. 164 Metadata map[string]string `form:"metadata"` 165 } 166 167 // AddExpand appends a new field to expand. 168 func (p *PayoutReverseParams) AddExpand(f string) { 169 p.Expand = append(p.Expand, &f) 170 } 171 172 // AddMetadata adds a new key-value pair to the Metadata. 173 func (p *PayoutReverseParams) AddMetadata(key string, value string) { 174 if p.Metadata == nil { 175 p.Metadata = make(map[string]string) 176 } 177 178 p.Metadata[key] = value 179 } 180 181 // A `Payout` object is created when you receive funds from Stripe, or when you 182 // initiate a payout to either a bank account or debit card of a [connected 183 // Stripe account](https://stripe.com/docs/connect/bank-debit-card-payouts). You can retrieve individual payouts, 184 // and list all payouts. Payouts are made on [varying 185 // schedules](https://stripe.com/docs/connect/manage-payout-schedule), depending on your country and 186 // industry. 187 // 188 // Related guide: [Receiving payouts](https://stripe.com/docs/payouts) 189 type Payout struct { 190 APIResource 191 // The amount (in cents (or local equivalent)) that transfers to your bank account or debit card. 192 Amount int64 `json:"amount"` 193 // Date that you can expect the payout to arrive in the bank. This factors in delays to account for weekends or bank holidays. 194 ArrivalDate int64 `json:"arrival_date"` 195 // Returns `true` if the payout is created by an [automated payout schedule](https://stripe.com/docs/payouts#payout-schedule) and `false` if it's [requested manually](https://stripe.com/docs/payouts#manual-payouts). 196 Automatic bool `json:"automatic"` 197 // ID of the balance transaction that describes the impact of this payout on your account balance. 198 BalanceTransaction *BalanceTransaction `json:"balance_transaction"` 199 // Time at which the object was created. Measured in seconds since the Unix epoch. 200 Created int64 `json:"created"` 201 // 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). 202 Currency Currency `json:"currency"` 203 // An arbitrary string attached to the object. Often useful for displaying to users. 204 Description string `json:"description"` 205 // ID of the bank account or card the payout is sent to. 206 Destination *PayoutDestination `json:"destination"` 207 // If the payout fails or cancels, this is the ID of the balance transaction that reverses the initial balance transaction and returns the funds from the failed payout back in your balance. 208 FailureBalanceTransaction *BalanceTransaction `json:"failure_balance_transaction"` 209 // Error code that provides a reason for a payout failure, if available. View our [list of failure codes](https://stripe.com/docs/api#payout_failures). 210 FailureCode PayoutFailureCode `json:"failure_code"` 211 // Message that provides the reason for a payout failure, if available. 212 FailureMessage string `json:"failure_message"` 213 // Unique identifier for the object. 214 ID string `json:"id"` 215 // Has the value `true` if the object exists in live mode or the value `false` if the object exists in test mode. 216 Livemode bool `json:"livemode"` 217 // 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. 218 Metadata map[string]string `json:"metadata"` 219 // The method used to send this payout, which can be `standard` or `instant`. `instant` is supported for payouts to debit cards and bank accounts in certain countries. Learn more about [bank support for Instant Payouts](https://stripe.com/docs/payouts/instant-payouts-banks). 220 Method PayoutMethodType `json:"method"` 221 // String representing the object's type. Objects of the same type share the same value. 222 Object string `json:"object"` 223 // If the payout reverses another, this is the ID of the original payout. 224 OriginalPayout *Payout `json:"original_payout"` 225 // If `completed`, you can use the [Balance Transactions API](https://stripe.com/docs/api/balance_transactions/list#balance_transaction_list-payout) to list all balance transactions that are paid out in this payout. 226 ReconciliationStatus PayoutReconciliationStatus `json:"reconciliation_status"` 227 // If the payout reverses, this is the ID of the payout that reverses this payout. 228 ReversedBy *Payout `json:"reversed_by"` 229 // The source balance this payout came from, which can be one of the following: `card`, `fpx`, or `bank_account`. 230 SourceType PayoutSourceType `json:"source_type"` 231 // Extra information about a payout that displays on the user's bank statement. 232 StatementDescriptor string `json:"statement_descriptor"` 233 // Current status of the payout: `paid`, `pending`, `in_transit`, `canceled` or `failed`. A payout is `pending` until it's submitted to the bank, when it becomes `in_transit`. The status changes to `paid` if the transaction succeeds, or to `failed` or `canceled` (within 5 business days). Some payouts that fail might initially show as `paid`, then change to `failed`. 234 Status PayoutStatus `json:"status"` 235 // Can be `bank_account` or `card`. 236 Type PayoutType `json:"type"` 237 } 238 type PayoutDestination struct { 239 ID string `json:"id"` 240 Type PayoutDestinationType `json:"object"` 241 242 BankAccount *BankAccount `json:"-"` 243 Card *Card `json:"-"` 244 } 245 246 // PayoutList is a list of Payouts as retrieved from a list endpoint. 247 type PayoutList struct { 248 APIResource 249 ListMeta 250 Data []*Payout `json:"data"` 251 } 252 253 // UnmarshalJSON handles deserialization of a Payout. 254 // This custom unmarshaling is needed because the resulting 255 // property may be an id or the full struct if it was expanded. 256 func (p *Payout) UnmarshalJSON(data []byte) error { 257 if id, ok := ParseID(data); ok { 258 p.ID = id 259 return nil 260 } 261 262 type payout Payout 263 var v payout 264 if err := json.Unmarshal(data, &v); err != nil { 265 return err 266 } 267 268 *p = Payout(v) 269 return nil 270 } 271 272 // UnmarshalJSON handles deserialization of a PayoutDestination. 273 // This custom unmarshaling is needed because the specific type of 274 // PayoutDestination it refers to is specified in the JSON 275 func (p *PayoutDestination) UnmarshalJSON(data []byte) error { 276 if id, ok := ParseID(data); ok { 277 p.ID = id 278 return nil 279 } 280 281 type payoutDestination PayoutDestination 282 var v payoutDestination 283 if err := json.Unmarshal(data, &v); err != nil { 284 return err 285 } 286 287 *p = PayoutDestination(v) 288 var err error 289 290 switch p.Type { 291 case PayoutDestinationTypeBankAccount: 292 err = json.Unmarshal(data, &p.BankAccount) 293 case PayoutDestinationTypeCard: 294 err = json.Unmarshal(data, &p.Card) 295 } 296 return err 297 }