forked from Mirrors/go-iap
Add the ability to override the sandbox url
Using an envirnoment variable called `IAP_SANDBOX_URL` you can override the sandbox url
This commit is contained in:
@@ -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,
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user