Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ClientsModule = fx.Provide( func( logger *zap.Logger, sSetting SettingParams, ) (out ClientsResult, err error) { if sSetting.PrivateKeyPath == "" { logger.Warn("Apple private key path is empty") } else if aClient, err := CreateAppleClient(sSetting); err != nil { logger.Error("Create apple client", zap.Error(err)) } else { logger.Info("Create apple client success", zap.Bool("sandbox", sSetting.Sandbox)) out.AppleClient = aClient } if sSetting.PublicKeyPath == "" { logger.Warn("Google public key path is empty") } else if gClient, err := CreateGoogleClient(sSetting); err != nil { logger.Error("create google client", zap.Error(err)) } else { logger.Info("Create google client success") out.GoogleClient = gClient } return }, )
ClientsModule is a fx module that provides an IAPClient
View Source
var SettingModule = fx.Provide( func() (SettingResult, error) { return CreateSetting() })
SettingModule is a fx setting module that provides an IAPClient
Functions ¶
func CreateAppleClient ¶
func CreateAppleClient( sSetting SettingParams, ) (*api.StoreClient, error)
CreateAppleClient creates a new Apple client
func CreateGoogleClient ¶
func CreateGoogleClient( sSetting SettingParams, ) (*playstore.Client, error)
CreateGoogleClient creates a new Google client
Types ¶
type ClientsParams ¶
type ClientsParams struct {
fx.In
AppleClient *api.StoreClient `name:"appleClient"`
GoogleClient *playstore.Client `name:"googleClient"`
}
ClientsParams is a struct that holds the parameters for the IAP clients
type ClientsResult ¶
type ClientsResult struct {
fx.Out
AppleClient *api.StoreClient `name:"appleClient"`
GoogleClient *playstore.Client `name:"googleClient"`
}
ClientsResult is a struct that holds the results for the IAP clients
type SettingParams ¶
type SettingParams struct {
fx.In
// ---------apple client setting --------
// Key ID for the given private key, described in App Store Connect
KID string `name:"appleKeyId"`
// Issuer ID for the App Store Connect team
Issuer string `name:"appleIssuer"`
// The bytes of the PKCS#8 private key created on App Store Connect. Keep this key safe as you can only download it once.
PrivateKeyPath string `name:"applePrivateKey"`
// Application's bundle ID, e.g. com.example.testbundleid2021
BID string `name:"appleBundleId"`
// A boolean value that indicates whether the token is for the App Store Connect API sandbox environment
Sandbox bool `name:"appleSandbox" `
// ---------google store client setting --------
// You need to prepare a public key for your Android app's in app billing
// at https://console.developers.google.com.
PublicKeyPath string `name:"googlePlayPublicKey"`
}
SettingParams is a struct that holds the parameters for the IAP clients
type SettingResult ¶
type SettingResult struct {
fx.Out
// ---------apple client setting --------
KID string `name:"appleKeyId" envconfig:"APPLE_KEY_ID" default:""`
Issuer string `name:"appleIssuer" envconfig:"APPLE_ISSUER" default:""`
PrivateKeyPath string `name:"applePrivateKey" envconfig:"APPLE_PRIVATE_KEY" default:""`
BID string `name:"appleBundleId" envconfig:"APPLE_BUNDLE_ID" default:""`
Sandbox bool `name:"appleSandbox" envconfig:"APPLE_SANDBOX" default:"true"`
// ---------google store client setting --------
// You need to prepare a public key for your Android app's in app billing
// at https://console.developers.google.com.
PublicKeyPath string `name:"googlePlayPublicKey" envconfig:"GOOGLE_PLAY_PUBLIC_KEY" default:""`
}
SettingResult is a struct that holds the results for the IAP clients
func CreateSetting ¶
func CreateSetting() (SettingResult, error)
CreateSetting load IAP settings from environment
Click to show internal directories.
Click to hide internal directories.