-
Notifications
You must be signed in to change notification settings - Fork 448
/
mandate.go
185 lines (154 loc) · 7.8 KB
/
mandate.go
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
package stripe
import "encoding/json"
// List of values that MandateStatus can take.
const (
MandateCustomerAcceptanceTypeOffline MandateCustomerAcceptanceType = "offline"
MandateCustomerAcceptanceTypeOnline MandateCustomerAcceptanceType = "online"
)
// MandateCustomerAcceptanceType is the list of allowed values for the type of customer acceptance
// for a given mandate.
type MandateCustomerAcceptanceType string
// List of values that MandateStatus can take.
const (
MandateStatusActive MandateStatus = "active"
MandateStatusInactive MandateStatus = "inactive"
MandateStatusPending MandateStatus = "pending"
)
// List of Stripe products where this mandate can be selected automatically.
type MandatePaymentMethodDetailsACSSDebitDefaultFor string
// List of values that MandatePaymentMethodDetailsACSSDebitDefaultFor can take
const (
MandatePaymentMethodDetailsACSSDebitDefaultForInvoice MandatePaymentMethodDetailsACSSDebitDefaultFor = "invoice"
MandatePaymentMethodDetailsACSSDebitDefaultForSubscription MandatePaymentMethodDetailsACSSDebitDefaultFor = "subscription"
)
// MandatePaymentMethodDetailsACSSDebitPaymentSchedule is the list of allowed values for an acss debit payment_schedule on payment_method_details
type MandatePaymentMethodDetailsACSSDebitPaymentSchedule string
// List of values that MandatePaymentMethodDetailsACSSDebitPaymentSchedule can take
const (
MandatePaymentMethodDetailsACSSDebitPaymentScheduleCombined MandatePaymentMethodDetailsACSSDebitPaymentSchedule = "combined"
MandatePaymentMethodDetailsACSSDebitPaymentScheduleInterval MandatePaymentMethodDetailsACSSDebitPaymentSchedule = "interval"
MandatePaymentMethodDetailsACSSDebitPaymentScheduleSporadic MandatePaymentMethodDetailsACSSDebitPaymentSchedule = "sporadic"
)
// MandatePaymentMethodDetailsACSSDebitTransactionType is the list of allowed values for an acss debit transaction type
type MandatePaymentMethodDetailsACSSDebitTransactionType string
// List of values that MandatePaymentMethodDetailsACSSDebitTransactionType can take
const (
MandatePaymentMethodDetailsACSSDebitTransactionTypeBusiness MandatePaymentMethodDetailsACSSDebitTransactionType = "business"
MandatePaymentMethodDetailsACSSDebitTransactionTypePersonal MandatePaymentMethodDetailsACSSDebitTransactionType = "personal"
)
// MandatePaymentMethodDetailsBACSDebitNetworkStatus is the list of allowed values for the status
// with the network for a given mandate.
type MandatePaymentMethodDetailsBACSDebitNetworkStatus string
// List of values that MandateStatus can take.
const (
MandatePaymentMethodDetailsBACSDebitNetworkStatusAccepted MandatePaymentMethodDetailsBACSDebitNetworkStatus = "accepted"
MandatePaymentMethodDetailsBACSDebitNetworkStatusPending MandatePaymentMethodDetailsBACSDebitNetworkStatus = "pending"
MandatePaymentMethodDetailsBACSDebitNetworkStatusRefused MandatePaymentMethodDetailsBACSDebitNetworkStatus = "refused"
MandatePaymentMethodDetailsBACSDebitNetworkStatusRevoked MandatePaymentMethodDetailsBACSDebitNetworkStatus = "revoked"
)
// MandateStatus is the list of allowed values for the mandate status.
type MandateStatus string
// List of values that MandateType can take.
const (
MandateTypeMultiUse MandateType = "multi_use"
MandateTypeSingleUse MandateType = "single_use"
)
// MandateType is the list of allowed values for the mandate type.
type MandateType string
// MandateParams is the set of parameters that can be used when retrieving a mandate.
type MandateParams struct {
Params `form:"*"`
}
// MandateCustomerAcceptanceOffline represents details about the customer acceptance of an offline
// mandate.
type MandateCustomerAcceptanceOffline struct {
}
// MandateCustomerAcceptanceOnline represents details about the customer acceptance of an online
// mandate.
type MandateCustomerAcceptanceOnline struct {
IPAddress string `json:"ip_address"`
UserAgent string `json:"user_agent"`
}
// MandateCustomerAcceptance represents details about the customer acceptance for a mandate.
type MandateCustomerAcceptance struct {
AcceptedAt int64 `json:"accepted_at"`
Offline *MandateCustomerAcceptanceOffline `json:"offline"`
Online *MandateCustomerAcceptanceOnline `json:"online"`
Type MandateCustomerAcceptanceType `json:"type"`
}
// MandateMultiUse represents details about a multi-use mandate.
type MandateMultiUse struct {
}
// MandatePaymentMethodDetailsACSSDebit represent details about the acss debit associated with this mandate.
type MandatePaymentMethodDetailsACSSDebit struct {
DefaultFor []MandatePaymentMethodDetailsACSSDebitDefaultFor `json:"default_for"`
IntervalDescription string `json:"interval_description"`
PaymentSchedule MandatePaymentMethodDetailsACSSDebitPaymentSchedule `json:"payment_schedule"`
TransactionType MandatePaymentMethodDetailsACSSDebitTransactionType `json:"transaction_type"`
}
// MandatePaymentMethodDetailsAUBECSDebit represents details about the Australia BECS debit account
// associated with this mandate.
type MandatePaymentMethodDetailsAUBECSDebit struct {
URL string `json:"url"`
}
// MandatePaymentMethodDetailsBACSDebit represents details about the BACS debit account
// associated with this mandate.
type MandatePaymentMethodDetailsBACSDebit struct {
NetworkStatus MandatePaymentMethodDetailsBACSDebitNetworkStatus `json:"network_status"`
Reference string `json:"reference"`
URL string `json:"url"`
}
// MandatePaymentMethodDetailsCard represents details about the card associated with this mandate.
type MandatePaymentMethodDetailsCard struct {
}
// MandatePaymentMethodDetailsSepaDebit represents details about the SEPA debit bank account
// associated with this mandate.
type MandatePaymentMethodDetailsSepaDebit struct {
Reference string `json:"reference"`
URL string `json:"url"`
}
// MandatePaymentMethodDetails represents details about the payment method associated with this
// mandate.
type MandatePaymentMethodDetails struct {
ACSSDebit *MandatePaymentMethodDetailsACSSDebit `json:"acss_debit"`
AUBECSDebit *MandatePaymentMethodDetailsAUBECSDebit `json:"au_becs_debit"`
BACSDebit *MandatePaymentMethodDetailsBACSDebit `json:"bacs_debit"`
Card *MandatePaymentMethodDetailsCard `json:"card"`
SepaDebit *MandatePaymentMethodDetailsSepaDebit `json:"sepa_debit"`
Type PaymentMethodType `json:"type"`
}
// MandateSingleUse represents details about a single-use mandate.
type MandateSingleUse struct {
Amount int64 `json:"amount"`
Currency Currency `json:"currency"`
}
// Mandate is the resource representing a Mandate.
type Mandate struct {
APIResource
CustomerAcceptance *MandateCustomerAcceptance `json:"customer_acceptance"`
ID string `json:"id"`
Livemode bool `json:"livemode"`
MultiUse *MandateMultiUse `json:"multi_use"`
Object string `json:"object"`
PaymentMethod *PaymentMethod `json:"payment_method"`
PaymentMethodDetails *MandatePaymentMethodDetails `json:"payment_method_details"`
SingleUse *MandateSingleUse `json:"single_use"`
Status MandateStatus `json:"status"`
Type MandateType `json:"type"`
}
// UnmarshalJSON handles deserialization of a Mandate.
// This custom unmarshaling is needed because the resulting
// property may be an id or the full struct if it was expanded.
func (i *Mandate) UnmarshalJSON(data []byte) error {
if id, ok := ParseID(data); ok {
i.ID = id
return nil
}
type ma Mandate
var v ma
if err := json.Unmarshal(data, &v); err != nil {
return err
}
*i = Mandate(v)
return nil
}