Skip to content

Commit 5e35708

Browse files
committed
feat(api): add get transaction info api
1 parent 9e03c37 commit 5e35708

File tree

3 files changed

+27
-1
lines changed

3 files changed

+27
-1
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ func main() {
123123

124124
# Support
125125

126-
App Store Server API [1.6](https://developer.apple.com/documentation/appstoreserverapi)
126+
App Store Server API [1.8](https://developer.apple.com/documentation/appstoreserverapi)
127127

128128
# License
129129

model.go

+5
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,11 @@ type OrderLookupResponse struct {
88
SignedTransactions []string `json:"signedTransactions"`
99
}
1010

11+
// TransactionInfoResponse https://developer.apple.com/documentation/appstoreserverapi/transactioninforesponse
12+
type TransactionInfoResponse struct {
13+
SignedTransactionInfo string `json:"signedTransactionInfo"`
14+
}
15+
1116
// HistoryResponse https://developer.apple.com/documentation/appstoreserverapi/historyresponse
1217
type HistoryResponse struct {
1318
AppAppleId int `json:"appAppleId"`

store.go

+21
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ const (
2121
HostSandBox = "https://api.storekit-sandbox.itunes.apple.com"
2222
HostProduction = "https://api.storekit.itunes.apple.com"
2323

24+
PathTransactionInfo = "/inApps/v1/transactions/{transactionId}"
2425
PathLookUp = "/inApps/v1/lookup/{orderId}"
2526
PathTransactionHistory = "/inApps/v1/history/{originalTransactionId}"
2627
PathRefundHistory = "/inApps/v2/refund/lookup/{originalTransactionId}"
@@ -113,6 +114,26 @@ func (c *StoreClient) GetALLSubscriptionStatuses(ctx context.Context, originalTr
113114
return rsp, nil
114115
}
115116

117+
// GetTransactionInfo https://developer.apple.com/documentation/appstoreserverapi/get_transaction_info
118+
func (c *StoreClient) GetTransactionInfo(ctx context.Context, transactionId string) (*TransactionInfoResponse, error) {
119+
URL := c.hostUrl + PathTransactionInfo
120+
URL = strings.Replace(URL, "{transactionId}", transactionId, -1)
121+
122+
var client HTTPClient
123+
client = c.httpCli
124+
client = SetInitializer(client, c.initHttpClient)
125+
client = RequireResponseStatus(client, http.StatusOK)
126+
client = SetRequest(ctx, client, http.MethodGet, URL)
127+
rsp := &TransactionInfoResponse{}
128+
client = SetResponseBodyHandler(client, json.Unmarshal, rsp)
129+
130+
_, err := client.Do(nil)
131+
if err != nil {
132+
return nil, err
133+
}
134+
return rsp, nil
135+
}
136+
116137
// LookupOrderID https://developer.apple.com/documentation/appstoreserverapi/look_up_order_id
117138
func (c *StoreClient) LookupOrderID(ctx context.Context, orderId string) (*OrderLookupResponse, error) {
118139
URL := c.hostUrl + PathLookUp

0 commit comments

Comments
 (0)