-
Notifications
You must be signed in to change notification settings - Fork 461
/
dispute.go
192 lines (175 loc) · 8.39 KB
/
dispute.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
186
187
188
189
190
191
192
package stripe
import (
"encoding/json"
)
// DisputeReason is the list of allowed values for a discount's reason.
type DisputeReason string
const (
DisputeReasonCreditNotProcessed DisputeReason = "credit_not_processed"
DisputeReasonDuplicate DisputeReason = "duplicate"
DisputeReasonFraudulent DisputeReason = "fraudulent"
DisputeReasonGeneral DisputeReason = "general"
DisputeReasonProductNotReceived DisputeReason = "product_not_received"
DisputeReasonProductUnacceptable DisputeReason = "product_unacceptable"
DisputeReasonSubscriptionCanceled DisputeReason = "subscription_canceled"
DisputeReasonUnrecognized DisputeReason = "unrecognized"
)
// DisputeStatus is the list of allowed values for a discount's status.
type DisputeStatus string
const (
DisputeStatusChargeRefunded DisputeStatus = "charge_refunded"
DisputeStatusLost DisputeStatus = "lost"
DisputeStatusNeedsResponse DisputeStatus = "needs_response"
DisputeStatusUnderReview DisputeStatus = "under_review"
DisputeStatusWarningClosed DisputeStatus = "warning_closed"
DisputeStatusWarningNeedsResponse DisputeStatus = "warning_needs_response"
DisputeStatusWarningUnderReview DisputeStatus = "warning_under_review"
DisputeStatusWon DisputeStatus = "won"
)
// DisputeParams is the set of parameters that can be used when updating a dispute.
// For more details see https://stripe.com/docs/api#update_dispute.
type DisputeParams struct {
Params `form:"*"`
Evidence *DisputeEvidenceParams `form:"evidence"`
Submit *bool `form:"submit"`
}
// DisputeEvidenceParams is the set of parameters that can be used when submitting
// evidence for disputes.
type DisputeEvidenceParams struct {
AccessActivityLog *string `form:"access_activity_log"`
BillingAddress *string `form:"billing_address"`
CancellationPolicy *string `form:"cancellation_policy"`
CancellationPolicyDisclosure *string `form:"cancellation_policy_disclosure"`
CancellationRebuttal *string `form:"cancellation_rebuttal"`
CustomerCommunication *string `form:"customer_communication"`
CustomerEmailAddress *string `form:"customer_email_address"`
CustomerName *string `form:"customer_name"`
CustomerPurchaseIP *string `form:"customer_purchase_ip"`
CustomerSignature *string `form:"customer_signature"`
DuplicateChargeDocumentation *string `form:"duplicate_charge_documentation"`
DuplicateChargeExplanation *string `form:"duplicate_charge_explanation"`
DuplicateChargeID *string `form:"duplicate_charge_id"`
ProductDescription *string `form:"product_description"`
Receipt *string `form:"receipt"`
RefundPolicy *string `form:"refund_policy"`
RefundPolicyDisclosure *string `form:"refund_policy_disclosure"`
RefundRefusalExplanation *string `form:"refund_refusal_explanation"`
ServiceDate *string `form:"service_date"`
ServiceDocumentation *string `form:"service_documentation"`
ShippingAddress *string `form:"shipping_address"`
ShippingCarrier *string `form:"shipping_carrier"`
ShippingDate *string `form:"shipping_date"`
ShippingDocumentation *string `form:"shipping_documentation"`
ShippingTrackingNumber *string `form:"shipping_tracking_number"`
UncategorizedFile *string `form:"uncategorized_file"`
UncategorizedText *string `form:"uncategorized_text"`
}
// DisputeListParams is the set of parameters that can be used when listing disputes.
// For more details see https://stripe.com/docs/api#list_disputes.
type DisputeListParams struct {
ListParams `form:"*"`
Created *int64 `form:"created"`
CreatedRange *RangeQueryParams `form:"created"`
}
// Dispute is the resource representing a Stripe dispute.
// For more details see https://stripe.com/docs/api#disputes.
type Dispute struct {
Amount int64 `json:"amount"`
BalanceTransactions []*BalanceTransaction `json:"balance_transactions"`
Charge *Charge `json:"charge"`
Created int64 `json:"created"`
Currency Currency `json:"currency"`
Evidence *DisputeEvidence `json:"evidence"`
EvidenceDetails *EvidenceDetails `json:"evidence_details"`
ID string `json:"id"`
IsChargeRefundable bool `json:"is_charge_refundable"`
Livemode bool `json:"livemode"`
Metadata map[string]string `json:"metadata"`
Reason DisputeReason `json:"reason"`
Status DisputeStatus `json:"status"`
}
// DisputeList is a list of disputes as retrieved from a list endpoint.
type DisputeList struct {
ListMeta
Data []*Dispute `json:"data"`
}
// EvidenceDetails is the structure representing more details about
// the dispute.
type EvidenceDetails struct {
DueBy int64 `json:"due_by"`
HasEvidence bool `json:"has_evidence"`
PastDue bool `json:"past_due"`
SubmissionCount int64 `json:"submission_count"`
}
// DisputeEvidence is the structure that contains various details about
// the evidence submitted for the dispute.
// Almost all fields are strings since there structures (i.e. address)
// do not typically get parsed by anyone and are thus presented as-received.
type DisputeEvidence struct {
AccessActivityLog string `json:"access_activity_log"`
BillingAddress string `json:"billing_address"`
CancellationPolicy *File `json:"cancellation_policy"`
CancellationPolicyDisclosure string `json:"cancellation_policy_disclosure"`
CancellationRebuttal string `json:"cancellation_rebuttal"`
CustomerCommunication *File `json:"customer_communication"`
CustomerEmailAddress string `json:"customer_email_address"`
CustomerName string `json:"customer_name"`
CustomerPurchaseIP string `json:"customer_purchase_ip"`
CustomerSignature *File `json:"customer_signature"`
DuplicateChargeDocumentation *File `json:"duplicate_charge_documentation"`
DuplicateChargeExplanation string `json:"duplicate_charge_explanation"`
DuplicateChargeID string `json:"duplicate_charge_id"`
ProductDescription string `json:"product_description"`
Receipt *File `json:"receipt"`
RefundPolicy *File `json:"refund_policy"`
RefundPolicyDisclosure string `json:"refund_policy_disclosure"`
RefundRefusalExplanation string `json:"refund_refusal_explanation"`
ServiceDate string `json:"service_date"`
ServiceDocumentation *File `json:"service_documentation"`
ShippingAddress string `json:"shipping_address"`
ShippingCarrier string `json:"shipping_carrier"`
ShippingDate string `json:"shipping_date"`
ShippingDocumentation *File `json:"shipping_documentation"`
ShippingTrackingNumber string `json:"shipping_tracking_number"`
UncategorizedFile *File `json:"uncategorized_file"`
UncategorizedText string `json:"uncategorized_text"`
}
// File represents a link to downloadable content.
type File struct {
Created int64 `json:"created"`
ID string `json:"id"`
MIMEType string `json:"mime_type"`
Purpose string `json:"purpose"`
Size int64 `json:"size"`
URL string `json:"url"`
}
// UnmarshalJSON handles deserialization of a Dispute.
// This custom unmarshaling is needed because the resulting
// property may be an id or the full struct if it was expanded.
func (t *Dispute) UnmarshalJSON(data []byte) error {
type dispute Dispute
var dd dispute
err := json.Unmarshal(data, &dd)
if err == nil {
*t = Dispute(dd)
} else {
// the id is surrounded by "\" characters, so strip them
t.ID = string(data[1 : len(data)-1])
}
return nil
}
// UnmarshalJSON handles deserialization of a File.
// This custom unmarshaling is needed because the resulting
// property may be an id or the full struct if it was expanded.
func (f *File) UnmarshalJSON(data []byte) error {
type file File
var ff file
err := json.Unmarshal(data, &ff)
if err == nil {
*f = File(ff)
} else {
// the id is surrounded by "\" characters, so strip them
f.ID = string(data[1 : len(data)-1])
}
return nil
}