-
Notifications
You must be signed in to change notification settings - Fork 6
/
transaction.go
35 lines (30 loc) · 1.3 KB
/
transaction.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
package apple
import (
"bytes"
"encoding/json"
"net/http"
)
const (
kTransaction = "/v1/transactions/"
kTransactionHistory = "/v1/history/"
kTransactionConsumption = "/v1/transactions/consumption/"
)
// GetTransaction https://developer.apple.com/documentation/appstoreserverapi/get_transaction_info
func (c *Client) GetTransaction(transactionId string) (result *TransactionResponse, err error) {
err = c.request(http.MethodGet, c.BuildAPI(kTransaction, transactionId), nil, nil, &result)
return result, err
}
// GetTransactionHistory https://developer.apple.com/documentation/appstoreserverapi/get_transaction_history
func (c *Client) GetTransactionHistory(transactionId string, param TransactionHistoryParam) (result *TransactionHistoryResponse, err error) {
err = c.request(http.MethodGet, c.BuildAPI(kTransactionHistory, transactionId), param, nil, &result)
return result, err
}
// SendConsumptionInformation https://developer.apple.com/documentation/appstoreserverapi/send_consumption_information
func (c *Client) SendConsumptionInformation(transactionId string, param ConsumptionParam) (err error) {
data, err := json.Marshal(param)
if err != nil {
return err
}
err = c.request(http.MethodPut, c.BuildAPI(kTransactionConsumption, transactionId), nil, bytes.NewReader(data), nil)
return err
}