1// 2// 3// File generated from our OpenAPI spec 4// 5// 6 7package stripe 8 9import "encoding/json" 10 11type CustomerTaxAutomaticTax string 12 13const ( 14 CustomerTaxAutomaticTaxFailed CustomerTaxAutomaticTax = "failed" 15 CustomerTaxAutomaticTaxNotCollecting CustomerTaxAutomaticTax = "not_collecting" 16 CustomerTaxAutomaticTaxSupported CustomerTaxAutomaticTax = "supported" 17 CustomerTaxAutomaticTaxUnrecognizedLocation CustomerTaxAutomaticTax = "unrecognized_location" 18) 19 20type CustomerTaxLocationSource string 21 22const ( 23 CustomerTaxLocationSourceBillingAddress CustomerTaxLocationSource = "billing_address" 24 CustomerTaxLocationSourceIPAddress CustomerTaxLocationSource = "ip_address" 25 CustomerTaxLocationSourcePaymentMethod CustomerTaxLocationSource = "payment_method" 26 CustomerTaxLocationSourceShippingDestination CustomerTaxLocationSource = "shipping_destination" 27) 28 29// CustomerTaxExempt is the type of tax exemption associated with a customer. 30type CustomerTaxExempt string 31 32// List of values that CustomerTaxExempt can take. 33const ( 34 CustomerTaxExemptExempt CustomerTaxExempt = "exempt" 35 CustomerTaxExemptNone CustomerTaxExempt = "none" 36 CustomerTaxExemptReverse CustomerTaxExempt = "reverse" 37) 38 39// CustomerParams is the set of parameters that can be used when creating or updating a customer. 40// For more details see https://stripe.com/docs/api#create_customer and https://stripe.com/docs/api#update_customer. 41type CustomerParams struct { 42 Params `form:"*"` 43 Address *AddressParams `form:"address"` 44 Balance *int64 `form:"balance"` 45 Coupon *string `form:"coupon"` 46 DefaultSource *string `form:"default_source"` 47 Description *string `form:"description"` 48 Email *string `form:"email"` 49 InvoicePrefix *string `form:"invoice_prefix"` 50 InvoiceSettings *CustomerInvoiceSettingsParams `form:"invoice_settings"` 51 Name *string `form:"name"` 52 NextInvoiceSequence *int64 `form:"next_invoice_sequence"` 53 PaymentMethod *string `form:"payment_method"` 54 Phone *string `form:"phone"` 55 PreferredLocales []*string `form:"preferred_locales"` 56 PromotionCode *string `form:"promotion_code"` 57 Shipping *CustomerShippingDetailsParams `form:"shipping"` 58 Source *SourceParams `form:"*"` // SourceParams has custom encoding so brought to top level with "*" 59 Tax *CustomerTaxParams `form:"tax"` 60 TaxExempt *string `form:"tax_exempt"` 61 TaxIDData []*CustomerTaxIDDataParams `form:"tax_id_data"` 62 Token *string `form:"-"` // This doesn't seem to be used? 63} 64 65// CustomerInvoiceCustomFieldParams represents the parameters associated with one custom field on 66// the customer's invoices. 67type CustomerInvoiceCustomFieldParams struct { 68 Name *string `form:"name"` 69 Value *string `form:"value"` 70} 71 72// CustomerInvoiceSettingsParams is the structure containing the default settings for invoices 73// associated with this customer. 74type CustomerInvoiceSettingsParams struct { 75 CustomFields []*CustomerInvoiceCustomFieldParams `form:"custom_fields"` 76 DefaultPaymentMethod *string `form:"default_payment_method"` 77 Footer *string `form:"footer"` 78} 79 80// CustomerShippingDetailsParams is the structure containing shipping information. 81type CustomerShippingDetailsParams struct { 82 Address *AddressParams `form:"address"` 83 Name *string `form:"name"` 84 Phone *string `form:"phone"` 85} 86 87type CustomerTaxParams struct { 88 IPAddress *string `form:"ip_address"` 89} 90 91// CustomerTaxIDDataParams lets you pass the tax id details associated with a Customer. 92type CustomerTaxIDDataParams struct { 93 Type *string `form:"type"` 94 Value *string `form:"value"` 95} 96 97// SetSource adds valid sources to a CustomerParams object, 98// returning an error for unsupported sources. 99func (cp *CustomerParams) SetSource(sp interface{}) error { 100 source, err := SourceParamsFor(sp) 101 cp.Source = source 102 return err 103} 104 105// CustomerListParams is the set of parameters that can be used when listing customers. 106// For more details see https://stripe.com/docs/api#list_customers. 107type CustomerListParams struct { 108 ListParams `form:"*"` 109 Created *int64 `form:"created"` 110 CreatedRange *RangeQueryParams `form:"created"` 111 Email *string `form:"email"` 112} 113 114type CustomerTaxLocation struct { 115 Country string `json:"country"` 116 Source CustomerTaxLocationSource `json:"source"` 117 State string `json:"state"` 118} 119type CustomerTax struct { 120 AutomaticTax CustomerTaxAutomaticTax `json:"automatic_tax"` 121 IPAddress string `json:"ip_address"` 122 Location *CustomerTaxLocation `json:"location"` 123} 124 125// Customer is the resource representing a Stripe customer. 126// For more details see https://stripe.com/docs/api#customers. 127type Customer struct { 128 APIResource 129 Address Address `json:"address"` 130 Balance int64 `json:"balance"` 131 Created int64 `json:"created"` 132 Currency Currency `json:"currency"` 133 DefaultSource *PaymentSource `json:"default_source"` 134 Deleted bool `json:"deleted"` 135 Delinquent bool `json:"delinquent"` 136 Description string `json:"description"` 137 Discount *Discount `json:"discount"` 138 Email string `json:"email"` 139 ID string `json:"id"` 140 InvoicePrefix string `json:"invoice_prefix"` 141 InvoiceSettings *CustomerInvoiceSettings `json:"invoice_settings"` 142 Livemode bool `json:"livemode"` 143 Metadata map[string]string `json:"metadata"` 144 Name string `json:"name"` 145 NextInvoiceSequence int64 `json:"next_invoice_sequence"` 146 Object string `json:"object"` 147 Phone string `json:"phone"` 148 PreferredLocales []string `json:"preferred_locales"` 149 Shipping *CustomerShippingDetails `json:"shipping"` 150 Sources *SourceList `json:"sources"` 151 Subscriptions *SubscriptionList `json:"subscriptions"` 152 Tax *CustomerTax `json:"tax"` 153 TaxExempt CustomerTaxExempt `json:"tax_exempt"` 154 TaxIDs *TaxIDList `json:"tax_ids"` 155} 156 157// CustomerInvoiceCustomField represents a custom field associated with the customer's invoices. 158type CustomerInvoiceCustomField struct { 159 Name *string `form:"name"` 160 Value *string `form:"value"` 161} 162 163// CustomerInvoiceSettings is the structure containing the default settings for invoices associated 164// with this customer. 165type CustomerInvoiceSettings struct { 166 CustomFields []*CustomerInvoiceCustomField `json:"custom_fields"` 167 DefaultPaymentMethod *PaymentMethod `json:"default_payment_method"` 168 Footer string `json:"footer"` 169} 170 171// CustomerShippingDetails is the structure containing shipping information. 172type CustomerShippingDetails struct { 173 Address Address `json:"address"` 174 Name string `json:"name"` 175 Phone string `json:"phone"` 176} 177 178// CustomerList is a list of customers as retrieved from a list endpoint. 179type CustomerList struct { 180 APIResource 181 ListMeta 182 Data []*Customer `json:"data"` 183} 184 185// UnmarshalJSON handles deserialization of a Customer. 186// This custom unmarshaling is needed because the resulting 187// property may be an id or the full struct if it was expanded. 188func (c *Customer) UnmarshalJSON(data []byte) error { 189 if id, ok := ParseID(data); ok { 190 c.ID = id 191 return nil 192 } 193 194 type customer Customer 195 var v customer 196 if err := json.Unmarshal(data, &v); err != nil { 197 return err 198 } 199 200 *c = Customer(v) 201 return nil 202} 203