-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add Recaptcha policy * remove unused consts * rename to secretKey * set spec version to v1 * update field * update type * include clientKey * rename to SiteKey * fix tags * replace with fraud connector * add recaptcha to library register * add recaptcha to library validation * remove secret key as secure field, it's needed in assemble * remove required validation. allows omitting threshold (or setting it to zero) to permit all traffic
- Loading branch information
Showing
3 changed files
with
77 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
package connectorconfig | ||
|
||
import ( | ||
"encoding/json" | ||
|
||
"github.com/chargehive/configuration/environment" | ||
"github.com/chargehive/configuration/v1/connector" | ||
"github.com/chargehive/proto/golang/chargehive/chtype" | ||
) | ||
|
||
type RecaptchaCredentials struct { | ||
SiteKey string `json:"siteKey" yaml:"siteKey" validate:"required"` | ||
SecretKey string `json:"secretKey" yaml:"secretKey" validate:"required"` | ||
BlockThreshold float32 `json:"blockThreshold" yaml:"blockThreshold" validate:"min=0,max=1"` | ||
} | ||
|
||
func (c *RecaptchaCredentials) GetLibrary() Library { | ||
return LibraryRecaptcha | ||
} | ||
|
||
func (c *RecaptchaCredentials) GetSupportedTypes() []LibraryType { | ||
return []LibraryType{LibraryTypeFraud} | ||
} | ||
|
||
func (c *RecaptchaCredentials) Validate() error { | ||
return nil | ||
} | ||
|
||
func (c *RecaptchaCredentials) GetSecureFields() []*string { | ||
return []*string{} | ||
} | ||
|
||
func (c *RecaptchaCredentials) ToConnector() connector.Connector { | ||
con := connector.Connector{Library: string(c.GetLibrary())} | ||
con.Configuration, _ = json.Marshal(c) | ||
return con | ||
} | ||
|
||
func (c *RecaptchaCredentials) FromJson(input []byte) error { | ||
return json.Unmarshal(input, c) | ||
} | ||
|
||
func (c *RecaptchaCredentials) SupportsSca() bool { | ||
return true | ||
} | ||
|
||
func (c *RecaptchaCredentials) SupportsMethod(methodType chtype.PaymentMethodType, methodProvider chtype.PaymentMethodProvider) bool { | ||
if !c.GetLibrary().SupportsMethod(methodType, methodProvider) { | ||
return false | ||
} | ||
return true | ||
} | ||
|
||
func (c *RecaptchaCredentials) SupportsCountry(country string) bool { | ||
return true | ||
} | ||
|
||
func (c *RecaptchaCredentials) CanPlanModeUse(mode environment.Mode) bool { | ||
return true | ||
} | ||
|
||
func (c *RecaptchaCredentials) IsRecoveryAgent() bool { | ||
return false | ||
} | ||
|
||
func (c *RecaptchaCredentials) Supports3RI() bool { | ||
return false | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters