github.com/stripe/stripe-go/v76@v76.25.0/review.go (about) 1 // 2 // 3 // File generated from our OpenAPI spec 4 // 5 // 6 7 package stripe 8 9 import "encoding/json" 10 11 // 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`. 12 type ReviewClosedReason string 13 14 // List of values that ReviewClosedReason can take 15 const ( 16 ReviewClosedReasonApproved ReviewClosedReason = "approved" 17 ReviewClosedReasonDisputed ReviewClosedReason = "disputed" 18 ReviewClosedReasonRedacted ReviewClosedReason = "redacted" 19 ReviewClosedReasonRefunded ReviewClosedReason = "refunded" 20 ReviewClosedReasonRefundedAsFraud ReviewClosedReason = "refunded_as_fraud" 21 ) 22 23 // The reason the review was opened. One of `rule` or `manual`. 24 type ReviewOpenedReason string 25 26 // List of values that ReviewOpenedReason can take 27 const ( 28 ReviewOpenedReasonManual ReviewOpenedReason = "manual" 29 ReviewOpenedReasonRule ReviewOpenedReason = "rule" 30 ) 31 32 // The reason the review is currently open or closed. One of `rule`, `manual`, `approved`, `refunded`, `refunded_as_fraud`, `disputed`, or `redacted`. 33 type ReviewReason string 34 35 // List of values that ReviewReason can take 36 const ( 37 ReviewReasonApproved ReviewReason = "approved" 38 ReviewReasonDisputed ReviewReason = "disputed" 39 ReviewReasonManual ReviewReason = "manual" 40 ReviewReasonRefunded ReviewReason = "refunded" 41 ReviewReasonRefundedAsFraud ReviewReason = "refunded_as_fraud" 42 ReviewReasonRedacted ReviewReason = "redacted" 43 ReviewReasonRule ReviewReason = "rule" 44 ) 45 46 // 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. 47 type ReviewListParams struct { 48 ListParams `form:"*"` 49 // Only return reviews that were created during the given date interval. 50 Created *int64 `form:"created"` 51 // Only return reviews that were created during the given date interval. 52 CreatedRange *RangeQueryParams `form:"created"` 53 // Specifies which fields in the response should be expanded. 54 Expand []*string `form:"expand"` 55 } 56 57 // AddExpand appends a new field to expand. 58 func (p *ReviewListParams) AddExpand(f string) { 59 p.Expand = append(p.Expand, &f) 60 } 61 62 // Retrieves a Review object. 63 type ReviewParams struct { 64 Params `form:"*"` 65 // Specifies which fields in the response should be expanded. 66 Expand []*string `form:"expand"` 67 } 68 69 // AddExpand appends a new field to expand. 70 func (p *ReviewParams) AddExpand(f string) { 71 p.Expand = append(p.Expand, &f) 72 } 73 74 // Approves a Review object, closing it and removing it from the list of reviews. 75 type ReviewApproveParams struct { 76 Params `form:"*"` 77 // Specifies which fields in the response should be expanded. 78 Expand []*string `form:"expand"` 79 } 80 81 // AddExpand appends a new field to expand. 82 func (p *ReviewApproveParams) AddExpand(f string) { 83 p.Expand = append(p.Expand, &f) 84 } 85 86 // 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. 87 type ReviewIPAddressLocation struct { 88 // The city where the payment originated. 89 City string `json:"city"` 90 // Two-letter ISO code representing the country where the payment originated. 91 Country string `json:"country"` 92 // The geographic latitude where the payment originated. 93 Latitude float64 `json:"latitude"` 94 // The geographic longitude where the payment originated. 95 Longitude float64 `json:"longitude"` 96 // The state/county/province/region where the payment originated. 97 Region string `json:"region"` 98 } 99 100 // Information related to the browsing session of the user who initiated the payment. 101 type ReviewSession struct { 102 // The browser used in this browser session (e.g., `Chrome`). 103 Browser string `json:"browser"` 104 // Information about the device used for the browser session (e.g., `Samsung SM-G930T`). 105 Device string `json:"device"` 106 // The platform for the browser session (e.g., `Macintosh`). 107 Platform string `json:"platform"` 108 // The version for the browser session (e.g., `61.0.3163.100`). 109 Version string `json:"version"` 110 } 111 112 // Reviews can be used to supplement automated fraud detection with human expertise. 113 // 114 // Learn more about [Radar](https://stripe.com/radar) and reviewing payments 115 // [here](https://stripe.com/docs/radar/reviews). 116 type Review struct { 117 APIResource 118 // The ZIP or postal code of the card used, if applicable. 119 BillingZip string `json:"billing_zip"` 120 // The charge associated with this review. 121 Charge *Charge `json:"charge"` 122 // 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`. 123 ClosedReason ReviewClosedReason `json:"closed_reason"` 124 // Time at which the object was created. Measured in seconds since the Unix epoch. 125 Created int64 `json:"created"` 126 // Unique identifier for the object. 127 ID string `json:"id"` 128 // The IP address where the payment originated. 129 IPAddress string `json:"ip_address"` 130 // 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. 131 IPAddressLocation *ReviewIPAddressLocation `json:"ip_address_location"` 132 // Has the value `true` if the object exists in live mode or the value `false` if the object exists in test mode. 133 Livemode bool `json:"livemode"` 134 // String representing the object's type. Objects of the same type share the same value. 135 Object string `json:"object"` 136 // If `true`, the review needs action. 137 Open bool `json:"open"` 138 // The reason the review was opened. One of `rule` or `manual`. 139 OpenedReason ReviewOpenedReason `json:"opened_reason"` 140 // The PaymentIntent ID associated with this review, if one exists. 141 PaymentIntent *PaymentIntent `json:"payment_intent"` 142 // The reason the review is currently open or closed. One of `rule`, `manual`, `approved`, `refunded`, `refunded_as_fraud`, `disputed`, or `redacted`. 143 Reason ReviewReason `json:"reason"` 144 // Information related to the browsing session of the user who initiated the payment. 145 Session *ReviewSession `json:"session"` 146 } 147 148 // ReviewList is a list of Reviews as retrieved from a list endpoint. 149 type ReviewList struct { 150 APIResource 151 ListMeta 152 Data []*Review `json:"data"` 153 } 154 155 // UnmarshalJSON handles deserialization of a Review. 156 // This custom unmarshaling is needed because the resulting 157 // property may be an id or the full struct if it was expanded. 158 func (r *Review) UnmarshalJSON(data []byte) error { 159 if id, ok := ParseID(data); ok { 160 r.ID = id 161 return nil 162 } 163 164 type review Review 165 var v review 166 if err := json.Unmarshal(data, &v); err != nil { 167 return err 168 } 169 170 *r = Review(v) 171 return nil 172 }