-
Notifications
You must be signed in to change notification settings - Fork 472
/
Copy pathreview.go
172 lines (151 loc) · 6.69 KB
/
review.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
//
//
// File generated from our OpenAPI spec
//
//
package stripe
import "encoding/json"
// The reason the review was closed, or null if it has not yet been closed. One of `approved`, `refunded`, `refunded_as_fraud`, `disputed`, or `redacted`.
type ReviewClosedReason string
// List of values that ReviewClosedReason can take
const (
ReviewClosedReasonApproved ReviewClosedReason = "approved"
ReviewClosedReasonDisputed ReviewClosedReason = "disputed"
ReviewClosedReasonRedacted ReviewClosedReason = "redacted"
ReviewClosedReasonRefunded ReviewClosedReason = "refunded"
ReviewClosedReasonRefundedAsFraud ReviewClosedReason = "refunded_as_fraud"
)
// The reason the review was opened. One of `rule` or `manual`.
type ReviewOpenedReason string
// List of values that ReviewOpenedReason can take
const (
ReviewOpenedReasonManual ReviewOpenedReason = "manual"
ReviewOpenedReasonRule ReviewOpenedReason = "rule"
)
// The reason the review is currently open or closed. One of `rule`, `manual`, `approved`, `refunded`, `refunded_as_fraud`, `disputed`, or `redacted`.
type ReviewReason string
// List of values that ReviewReason can take
const (
ReviewReasonApproved ReviewReason = "approved"
ReviewReasonDisputed ReviewReason = "disputed"
ReviewReasonManual ReviewReason = "manual"
ReviewReasonRefunded ReviewReason = "refunded"
ReviewReasonRefundedAsFraud ReviewReason = "refunded_as_fraud"
ReviewReasonRedacted ReviewReason = "redacted"
ReviewReasonRule ReviewReason = "rule"
)
// Returns a list of Review objects that have open set to true. The objects are sorted in descending order by creation date, with the most recently created object appearing first.
type ReviewListParams struct {
ListParams `form:"*"`
// Only return reviews that were created during the given date interval.
Created *int64 `form:"created"`
// Only return reviews that were created during the given date interval.
CreatedRange *RangeQueryParams `form:"created"`
// Specifies which fields in the response should be expanded.
Expand []*string `form:"expand"`
}
// AddExpand appends a new field to expand.
func (p *ReviewListParams) AddExpand(f string) {
p.Expand = append(p.Expand, &f)
}
// Retrieves a Review object.
type ReviewParams struct {
Params `form:"*"`
// Specifies which fields in the response should be expanded.
Expand []*string `form:"expand"`
}
// AddExpand appends a new field to expand.
func (p *ReviewParams) AddExpand(f string) {
p.Expand = append(p.Expand, &f)
}
// Approves a Review object, closing it and removing it from the list of reviews.
type ReviewApproveParams struct {
Params `form:"*"`
// Specifies which fields in the response should be expanded.
Expand []*string `form:"expand"`
}
// AddExpand appends a new field to expand.
func (p *ReviewApproveParams) AddExpand(f string) {
p.Expand = append(p.Expand, &f)
}
// Information related to the location of the payment. Note that this information is an approximation and attempts to locate the nearest population center - it should not be used to determine a specific address.
type ReviewIPAddressLocation struct {
// The city where the payment originated.
City string `json:"city"`
// Two-letter ISO code representing the country where the payment originated.
Country string `json:"country"`
// The geographic latitude where the payment originated.
Latitude float64 `json:"latitude"`
// The geographic longitude where the payment originated.
Longitude float64 `json:"longitude"`
// The state/county/province/region where the payment originated.
Region string `json:"region"`
}
// Information related to the browsing session of the user who initiated the payment.
type ReviewSession struct {
// The browser used in this browser session (e.g., `Chrome`).
Browser string `json:"browser"`
// Information about the device used for the browser session (e.g., `Samsung SM-G930T`).
Device string `json:"device"`
// The platform for the browser session (e.g., `Macintosh`).
Platform string `json:"platform"`
// The version for the browser session (e.g., `61.0.3163.100`).
Version string `json:"version"`
}
// Reviews can be used to supplement automated fraud detection with human expertise.
//
// Learn more about [Radar](https://stripe.com/radar) and reviewing payments
// [here](https://stripe.com/docs/radar/reviews).
type Review struct {
APIResource
// The ZIP or postal code of the card used, if applicable.
BillingZip string `json:"billing_zip"`
// The charge associated with this review.
Charge *Charge `json:"charge"`
// The reason the review was closed, or null if it has not yet been closed. One of `approved`, `refunded`, `refunded_as_fraud`, `disputed`, or `redacted`.
ClosedReason ReviewClosedReason `json:"closed_reason"`
// Time at which the object was created. Measured in seconds since the Unix epoch.
Created int64 `json:"created"`
// Unique identifier for the object.
ID string `json:"id"`
// The IP address where the payment originated.
IPAddress string `json:"ip_address"`
// Information related to the location of the payment. Note that this information is an approximation and attempts to locate the nearest population center - it should not be used to determine a specific address.
IPAddressLocation *ReviewIPAddressLocation `json:"ip_address_location"`
// Has the value `true` if the object exists in live mode or the value `false` if the object exists in test mode.
Livemode bool `json:"livemode"`
// String representing the object's type. Objects of the same type share the same value.
Object string `json:"object"`
// If `true`, the review needs action.
Open bool `json:"open"`
// The reason the review was opened. One of `rule` or `manual`.
OpenedReason ReviewOpenedReason `json:"opened_reason"`
// The PaymentIntent ID associated with this review, if one exists.
PaymentIntent *PaymentIntent `json:"payment_intent"`
// The reason the review is currently open or closed. One of `rule`, `manual`, `approved`, `refunded`, `refunded_as_fraud`, `disputed`, or `redacted`.
Reason ReviewReason `json:"reason"`
// Information related to the browsing session of the user who initiated the payment.
Session *ReviewSession `json:"session"`
}
// ReviewList is a list of Reviews as retrieved from a list endpoint.
type ReviewList struct {
APIResource
ListMeta
Data []*Review `json:"data"`
}
// UnmarshalJSON handles deserialization of a Review.
// This custom unmarshaling is needed because the resulting
// property may be an id or the full struct if it was expanded.
func (r *Review) UnmarshalJSON(data []byte) error {
if id, ok := ParseID(data); ok {
r.ID = id
return nil
}
type review Review
var v review
if err := json.Unmarshal(data, &v); err != nil {
return err
}
*r = Review(v)
return nil
}