Merge pull request #2 from fubotv/sandbox_url

Add the ability to override the sandbox url
This commit is contained in:
Dan Worth
2015-12-02 13:38:45 -05:00

View File

@@ -16,6 +16,14 @@ const (
ProductionURL string = "https://appstore-sdk.amazon.com" ProductionURL string = "https://appstore-sdk.amazon.com"
) )
func getSandboxUrl() string {
url := os.Getenv("IAP_SANDBOX_URL")
if url == "" {
url = SandboxURL
}
return url
}
// Config is a configuration to initialize client // Config is a configuration to initialize client
type Config struct { type Config struct {
IsProduction bool IsProduction bool
@@ -53,7 +61,7 @@ type Client struct {
// New creates a client object // New creates a client object
func New(secret string) IAPClient { func New(secret string) IAPClient {
client := Client{ client := Client{
URL: SandboxURL, URL: getSandboxUrl(),
Secret: secret, Secret: secret,
TimeOut: time.Second * 5, TimeOut: time.Second * 5,
} }
@@ -70,7 +78,7 @@ func NewWithConfig(config Config) Client {
} }
client := Client{ client := Client{
URL: SandboxURL, URL: getSandboxUrl(),
Secret: config.Secret, Secret: config.Secret,
TimeOut: config.TimeOut, TimeOut: config.TimeOut,
} }