~evanj/cms

ref: 99a3bb7fc511e3f448a358691896ba1300f73a93 cms/vendor/github.com/stripe/stripe-go/v71/setupintent.go -rw-r--r-- 9.7 KiB
99a3bb7fEvan M Jones WIP(rbac): Decorator object complete. TODO: Specify role in invite. 1 year, 1 month ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
package stripe

import (
	"encoding/json"
)

// SetupIntentCancellationReason is the list of allowed values for the cancelation reason.
type SetupIntentCancellationReason string

// List of values that SetupIntentCancellationReason can take.
const (
	SetupIntentCancellationReasonAbandoned           SetupIntentCancellationReason = "abandoned"
	SetupIntentCancellationReasonFailedInvoice       SetupIntentCancellationReason = "failed_invoice"
	SetupIntentCancellationReasonFraudulent          SetupIntentCancellationReason = "fraudulent"
	SetupIntentCancellationReasonRequestedByCustomer SetupIntentCancellationReason = "requested_by_customer"
)

// SetupIntentNextActionType is the list of allowed values for the next action's type.
type SetupIntentNextActionType string

// List of values that SetupIntentNextActionType can take.
const (
	SetupIntentNextActionTypeRedirectToURL SetupIntentNextActionType = "redirect_to_url"
)

// SetupIntentPaymentMethodOptionsCardRequestThreeDSecure is the list of allowed values controlling
// when to request 3D Secure on a SetupIntent.
type SetupIntentPaymentMethodOptionsCardRequestThreeDSecure string

// List of values that SetupIntentNextActionType can take.
const (
	SetupIntentPaymentMethodOptionsCardRequestThreeDSecureAny       SetupIntentPaymentMethodOptionsCardRequestThreeDSecure = "any"
	SetupIntentPaymentMethodOptionsCardRequestThreeDSecureAutomatic SetupIntentPaymentMethodOptionsCardRequestThreeDSecure = "automatic"
)

// SetupIntentStatus is the list of allowed values for the setup intent's status.
type SetupIntentStatus string

// List of values that SetupIntentStatus can take.
const (
	SetupIntentStatusCanceled              SetupIntentStatus = "canceled"
	SetupIntentStatusProcessing            SetupIntentStatus = "processing"
	SetupIntentStatusRequiresAction        SetupIntentStatus = "requires_action"
	SetupIntentStatusRequiresConfirmation  SetupIntentStatus = "requires_confirmation"
	SetupIntentStatusRequiresPaymentMethod SetupIntentStatus = "requires_payment_method"
	SetupIntentStatusSucceeded             SetupIntentStatus = "succeeded"
)

// SetupIntentUsage is the list of allowed values for the setup intent's usage.
type SetupIntentUsage string

// List of values that SetupIntentUsage can take.
const (
	SetupIntentUsageOffSession SetupIntentUsage = "off_session"
	SetupIntentUsageOnSession  SetupIntentUsage = "on_session"
)

// SetupIntentCancelParams is the set of parameters that can be used when canceling a setup intent.
type SetupIntentCancelParams struct {
	Params             `form:"*"`
	CancellationReason *string `form:"cancellation_reason"`
}

// SetupIntentConfirmParams is the set of parameters that can be used when confirming a setup intent.
type SetupIntentConfirmParams struct {
	Params               `form:"*"`
	MandateData          *SetupIntentMandateDataParams          `form:"mandate_data"`
	PaymentMethod        *string                                `form:"payment_method"`
	PaymentMethodOptions *SetupIntentPaymentMethodOptionsParams `form:"payment_method_options"`
	ReturnURL            *string                                `form:"return_url"`
}

// SetupIntentMandateDataCustomerAcceptanceOfflineParams is the set of parameters for the customer
// acceptance of an offline mandate.
type SetupIntentMandateDataCustomerAcceptanceOfflineParams struct {
}

// SetupIntentMandateDataCustomerAcceptanceOnlineParams is the set of parameters for the customer
// acceptance of an online mandate.
type SetupIntentMandateDataCustomerAcceptanceOnlineParams struct {
	IPAddress *string `form:"ip_address"`
	UserAgent *string `form:"user_agent"`
}

// SetupIntentMandateDataCustomerAcceptanceParams is the set of parameters for the customer
// acceptance of a mandate.
type SetupIntentMandateDataCustomerAcceptanceParams struct {
	AcceptedAt int64                                                  `form:"accepted_at"`
	Offline    *SetupIntentMandateDataCustomerAcceptanceOfflineParams `form:"offline"`
	Online     *SetupIntentMandateDataCustomerAcceptanceOnlineParams  `form:"online"`
	Type       MandateCustomerAcceptanceType                          `form:"type"`
}

// SetupIntentMandateDataParams is the set of parameters controlling the creation of the mandate
// associated with this SetupIntent.
type SetupIntentMandateDataParams struct {
	CustomerAcceptance *SetupIntentMandateDataCustomerAcceptanceParams `form:"customer_acceptance"`
}

// SetupIntentPaymentMethodOptionsCardParams represents the card-specific options applied to a
// SetupIntent.
type SetupIntentPaymentMethodOptionsCardParams struct {
	MOTO                *bool   `form:"moto"`
	RequestThreeDSecure *string `form:"request_three_d_secure"`
}

// SetupIntentPaymentMethodOptionsParams represents the type-specific payment method options
// applied to a SetupIntent.
type SetupIntentPaymentMethodOptionsParams struct {
	Card *SetupIntentPaymentMethodOptionsCardParams `form:"card"`
}

// SetupIntentSingleUseParams represents the single-use mandate-specific parameters.
type SetupIntentSingleUseParams struct {
	Amount   *int64  `form:"amount"`
	Currency *string `form:"currency"`
}

// SetupIntentParams is the set of parameters that can be used when handling a setup intent.
type SetupIntentParams struct {
	Params               `form:"*"`
	Confirm              *bool                                  `form:"confirm"`
	Customer             *string                                `form:"customer"`
	Description          *string                                `form:"description"`
	MandateData          *SetupIntentMandateDataParams          `form:"mandate_data"`
	OnBehalfOf           *string                                `form:"on_behalf_of"`
	PaymentMethod        *string                                `form:"payment_method"`
	PaymentMethodOptions *SetupIntentPaymentMethodOptionsParams `form:"payment_method_options"`
	PaymentMethodTypes   []*string                              `form:"payment_method_types"`
	ReturnURL            *string                                `form:"return_url"`
	SingleUse            *SetupIntentSingleUseParams            `form:"single_use"`
	Usage                *string                                `form:"usage"`
}

// SetupIntentListParams is the set of parameters that can be used when listing setup intents.
// For more details see https://stripe.com/docs/api#list_payouts.
type SetupIntentListParams struct {
	ListParams    `form:"*"`
	Created       *int64            `form:"created"`
	CreatedRange  *RangeQueryParams `form:"created"`
	Customer      *string           `form:"customer"`
	PaymentMethod *string           `form:"payment_method"`
}

// SetupIntentNextActionRedirectToURL represents the resource for the next action of type
// "redirect_to_url".
type SetupIntentNextActionRedirectToURL struct {
	ReturnURL string `json:"return_url"`
	URL       string `json:"url"`
}

// SetupIntentNextAction represents the type of action to take on a setup intent.
type SetupIntentNextAction struct {
	RedirectToURL *SetupIntentNextActionRedirectToURL `json:"redirect_to_url"`
	Type          SetupIntentNextActionType           `json:"type"`
}

// SetupIntentPaymentMethodOptionsCard represents the card-specific options applied to a
// SetupIntent.
type SetupIntentPaymentMethodOptionsCard struct {
	RequestThreeDSecure SetupIntentPaymentMethodOptionsCardRequestThreeDSecure `json:"request_three_d_secure"`
}

// SetupIntentPaymentMethodOptions represents the type-specific payment method options applied to a
// SetupIntent.
type SetupIntentPaymentMethodOptions struct {
	Card *SetupIntentPaymentMethodOptionsCard `json:"card"`
}

// SetupIntent is the resource representing a Stripe payout.
// For more details see https://stripe.com/docs/api#payment_intents.
type SetupIntent struct {
	APIResource
	Application          *Application                     `json:"application"`
	CancellationReason   SetupIntentCancellationReason    `json:"cancellation_reason"`
	ClientSecret         string                           `json:"client_secret"`
	Created              int64                            `json:"created"`
	Customer             *Customer                        `json:"customer"`
	Description          string                           `json:"description"`
	ID                   string                           `json:"id"`
	LastSetupError       *Error                           `json:"last_setup_error"`
	Livemode             bool                             `json:"livemode"`
	Mandate              *Mandate                         `json:"mandate"`
	Metadata             map[string]string                `json:"metadata"`
	NextAction           *SetupIntentNextAction           `json:"next_action"`
	Object               string                           `json:"object"`
	OnBehalfOf           *Account                         `json:"on_behalf_of"`
	PaymentMethod        *PaymentMethod                   `json:"payment_method"`
	PaymentMethodOptions *SetupIntentPaymentMethodOptions `json:"payment_method_options"`
	PaymentMethodTypes   []string                         `json:"payment_method_types"`
	SingleUseMandate     *Mandate                         `json:"single_use_mandate"`
	Status               SetupIntentStatus                `json:"status"`
	Usage                SetupIntentUsage                 `json:"usage"`
}

// SetupIntentList is a list of setup intents as retrieved from a list endpoint.
type SetupIntentList struct {
	APIResource
	ListMeta
	Data []*SetupIntent `json:"data"`
}

// UnmarshalJSON handles deserialization of a SetupIntent.
// This custom unmarshaling is needed because the resulting
// property may be an id or the full struct if it was expanded.
func (p *SetupIntent) UnmarshalJSON(data []byte) error {
	if id, ok := ParseID(data); ok {
		p.ID = id
		return nil
	}

	type setupIntent SetupIntent
	var v setupIntent
	if err := json.Unmarshal(data, &v); err != nil {
		return err
	}

	*p = SetupIntent(v)
	return nil
}