File tree 2 files changed +33
-1
lines changed
2 files changed +33
-1
lines changed Original file line number Diff line number Diff line change
1
+ package api
2
+
3
+ import (
4
+ "context"
5
+ "errors"
6
+ )
7
+
8
+ // IAPAPIClient is an interface to call validation API in App Store Server API
9
+ type IAPAPIClient interface {
10
+ Verify (ctx context.Context , transactionId string ) (* TransactionInfoResponse , error )
11
+ }
12
+
13
+ type APIClient struct {
14
+ productionCli * StoreClient
15
+ sandboxCli * StoreClient
16
+ }
17
+
18
+ func NewAPIClient (config StoreConfig ) * APIClient {
19
+ prodConf := config
20
+ prodConf .Sandbox = false
21
+ sandboxConf := config
22
+ sandboxConf .Sandbox = true
23
+ return & APIClient {productionCli : NewStoreClient (& prodConf ), sandboxCli : NewStoreClient (& sandboxConf )}
24
+ }
25
+
26
+ func (c * APIClient ) Verify (ctx context.Context , transactionId string ) (* TransactionInfoResponse , error ) {
27
+ result , err := c .productionCli .GetTransactionInfo (ctx , transactionId )
28
+ if err != nil && errors .Is (err , TransactionIdNotFoundError ) {
29
+ result , err = c .sandboxCli .GetTransactionInfo (ctx , transactionId )
30
+ }
31
+ return result , err
32
+ }
Original file line number Diff line number Diff line change @@ -39,7 +39,7 @@ type Client struct {
39
39
httpCli * http.Client
40
40
}
41
41
42
- // list of errore
42
+ // list of errors
43
43
var (
44
44
ErrAppStoreServer = errors .New ("AppStore server error" )
45
45
You can’t perform that action at this time.
0 commit comments