github.com/stripe/stripe-go/v76@v76.25.0/transfer.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 source balance this transfer came from. One of `card`, `fpx`, or `bank_account`. 12 type TransferSourceType string 13 14 // List of values that TransferSourceType can take 15 const ( 16 TransferSourceTypeBankAccount TransferSourceType = "bank_account" 17 TransferSourceTypeCard TransferSourceType = "card" 18 TransferSourceTypeFPX TransferSourceType = "fpx" 19 ) 20 21 // Returns a list of existing transfers sent to connected accounts. The transfers are returned in sorted order, with the most recently created transfers appearing first. 22 type TransferListParams struct { 23 ListParams `form:"*"` 24 // Only return transfers that were created during the given date interval. 25 Created *int64 `form:"created"` 26 // Only return transfers that were created during the given date interval. 27 CreatedRange *RangeQueryParams `form:"created"` 28 // Only return transfers for the destination specified by this account ID. 29 Destination *string `form:"destination"` 30 // Specifies which fields in the response should be expanded. 31 Expand []*string `form:"expand"` 32 // Only return transfers with the specified transfer group. 33 TransferGroup *string `form:"transfer_group"` 34 } 35 36 // AddExpand appends a new field to expand. 37 func (p *TransferListParams) AddExpand(f string) { 38 p.Expand = append(p.Expand, &f) 39 } 40 41 // To send funds from your Stripe account to a connected account, you create a new transfer object. Your [Stripe balance](https://stripe.com/docs/api#balance) must be able to cover the transfer amount, or you'll receive an “Insufficient Funds” error. 42 type TransferParams struct { 43 Params `form:"*"` 44 // A positive integer in cents (or local equivalent) representing how much to transfer. 45 Amount *int64 `form:"amount"` 46 // 3-letter [ISO code for currency](https://stripe.com/docs/payouts). 47 Currency *string `form:"currency"` 48 // An arbitrary string attached to the object. Often useful for displaying to users. 49 Description *string `form:"description"` 50 // The ID of a connected Stripe account. [See the Connect documentation](https://stripe.com/docs/connect/separate-charges-and-transfers) for details. 51 Destination *string `form:"destination"` 52 // Specifies which fields in the response should be expanded. 53 Expand []*string `form:"expand"` 54 // 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`. 55 Metadata map[string]string `form:"metadata"` 56 // You can use this parameter to transfer funds from a charge before they are added to your available balance. A pending balance will transfer immediately but the funds will not become available until the original charge becomes available. [See the Connect documentation](https://stripe.com/docs/connect/separate-charges-and-transfers#transfer-availability) for details. 57 SourceTransaction *string `form:"source_transaction"` 58 // The source balance to use for this transfer. One of `bank_account`, `card`, or `fpx`. For most users, this will default to `card`. 59 SourceType *string `form:"source_type"` 60 // A string that identifies this transaction as part of a group. See the [Connect documentation](https://stripe.com/docs/connect/separate-charges-and-transfers#transfer-options) for details. 61 TransferGroup *string `form:"transfer_group"` 62 } 63 64 // AddExpand appends a new field to expand. 65 func (p *TransferParams) AddExpand(f string) { 66 p.Expand = append(p.Expand, &f) 67 } 68 69 // AddMetadata adds a new key-value pair to the Metadata. 70 func (p *TransferParams) AddMetadata(key string, value string) { 71 if p.Metadata == nil { 72 p.Metadata = make(map[string]string) 73 } 74 75 p.Metadata[key] = value 76 } 77 78 // A `Transfer` object is created when you move funds between Stripe accounts as 79 // part of Connect. 80 // 81 // Before April 6, 2017, transfers also represented movement of funds from a 82 // Stripe account to a card or bank account. This behavior has since been split 83 // out into a [Payout](https://stripe.com/docs/api#payout_object) object, with corresponding payout endpoints. For more 84 // information, read about the 85 // [transfer/payout split](https://stripe.com/docs/transfer-payout-split). 86 // 87 // Related guide: [Creating separate charges and transfers](https://stripe.com/docs/connect/separate-charges-and-transfers) 88 type Transfer struct { 89 APIResource 90 // Amount in cents (or local equivalent) to be transferred. 91 Amount int64 `json:"amount"` 92 // Amount in cents (or local equivalent) reversed (can be less than the amount attribute on the transfer if a partial reversal was issued). 93 AmountReversed int64 `json:"amount_reversed"` 94 // Balance transaction that describes the impact of this transfer on your account balance. 95 BalanceTransaction *BalanceTransaction `json:"balance_transaction"` 96 // Time that this record of the transfer was first created. 97 Created int64 `json:"created"` 98 // 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). 99 Currency Currency `json:"currency"` 100 // An arbitrary string attached to the object. Often useful for displaying to users. 101 Description string `json:"description"` 102 // ID of the Stripe account the transfer was sent to. 103 Destination *Account `json:"destination"` 104 // If the destination is a Stripe account, this will be the ID of the payment that the destination account received for the transfer. 105 DestinationPayment *Charge `json:"destination_payment"` 106 // Unique identifier for the object. 107 ID string `json:"id"` 108 // Has the value `true` if the object exists in live mode or the value `false` if the object exists in test mode. 109 Livemode bool `json:"livemode"` 110 // 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. 111 Metadata map[string]string `json:"metadata"` 112 // String representing the object's type. Objects of the same type share the same value. 113 Object string `json:"object"` 114 // A list of reversals that have been applied to the transfer. 115 Reversals *TransferReversalList `json:"reversals"` 116 // Whether the transfer has been fully reversed. If the transfer is only partially reversed, this attribute will still be false. 117 Reversed bool `json:"reversed"` 118 // ID of the charge or payment that was used to fund the transfer. If null, the transfer was funded from the available balance. 119 SourceTransaction *Charge `json:"source_transaction"` 120 // The source balance this transfer came from. One of `card`, `fpx`, or `bank_account`. 121 SourceType TransferSourceType `json:"source_type"` 122 // A string that identifies this transaction as part of a group. See the [Connect documentation](https://stripe.com/docs/connect/separate-charges-and-transfers#transfer-options) for details. 123 TransferGroup string `json:"transfer_group"` 124 } 125 126 // TransferList is a list of Transfers as retrieved from a list endpoint. 127 type TransferList struct { 128 APIResource 129 ListMeta 130 Data []*Transfer `json:"data"` 131 } 132 133 // UnmarshalJSON handles deserialization of a Transfer. 134 // This custom unmarshaling is needed because the resulting 135 // property may be an id or the full struct if it was expanded. 136 func (t *Transfer) UnmarshalJSON(data []byte) error { 137 if id, ok := ParseID(data); ok { 138 t.ID = id 139 return nil 140 } 141 142 type transfer Transfer 143 var v transfer 144 if err := json.Unmarshal(data, &v); err != nil { 145 return err 146 } 147 148 *t = Transfer(v) 149 return nil 150 }