forked from stripe/stripe-go
-
Notifications
You must be signed in to change notification settings - Fork 0
/
order_return.go
44 lines (38 loc) · 1.22 KB
/
order_return.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
package stripe
import "encoding/json"
type OrderReturn struct {
ID string `json:"id"`
Amount int64 `json:"amount"`
Created int64 `json:"created"`
Currency Currency `json:"currency"`
Items []OrderItem `json:"items"`
Live bool `json:"livemode"`
Order Order `json:"order"`
Refund *Refund `json:"refund"`
}
// OrderReturnList is a list of returns as retrieved from a list endpoint.
type OrderReturnList struct {
ListMeta
Values []*OrderReturn `json:"data"`
}
// OrderReturnListParams is the set of parameters that can be used when listing
// returns. For more details, see: https://stripe.com/docs/api#list_order_returns.
type OrderReturnListParams struct {
ListParams
Order string
}
// UnmarshalJSON handles deserialization of an OrderReturn.
// This custom unmarshaling is needed because the resulting
// property may be an id or the full struct if it was expanded.
func (ret *OrderReturn) UnmarshalJSON(data []byte) error {
type orderReturn OrderReturn
var rr orderReturn
err := json.Unmarshal(data, &rr)
if err == nil {
*ret = OrderReturn(rr)
} else {
// the id is surrounded by "\" characters, so strip them
ret.ID = string(data[1 : len(data)-1])
}
return nil
}