-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathapi_look_up_order_id.go
41 lines (35 loc) · 1.08 KB
/
api_look_up_order_id.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
package appstoreserverapi
import (
"net/http"
)
// ApiLookUpOrderId 查找订单 ID
// Look Up Order ID
// doc: https://developer.apple.com/documentation/appstoreserverapi/look_up_order_id
func (c *client) ApiLookUpOrderId(orderId string) (*OrderLookupResponse, error) {
reqUrl := c.apiLookupOrderIdUrl + orderId
r, err := c.doRequest(http.MethodGet, reqUrl, nil)
if err != nil {
return nil, err
}
result := &OrderLookupResponse{
raw: r.String(),
Status: r.Get("status").Int(),
}
signedTransactions := make([]JWSTransactionDecodedPayload, 0)
for _, item := range r.Get("signedTransactions").Array() {
signedTransaction := JWSTransactionDecodedPayload{}
Parse(item.String(), &signedTransaction)
signedTransactions = append(signedTransactions, signedTransaction)
}
result.SignedTransactions = signedTransactions
return result, nil
}
type OrderLookupResponse struct {
raw string
Status int64 `json:"status"`
// 原始数据
SignedTransactions []JWSTransactionDecodedPayload `json:"signedTransactions"`
}
func (r *OrderLookupResponse) Raw() string {
return r.raw
}