Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add flexpay config #203

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
81 changes: 81 additions & 0 deletions connectorconfig/flexpay.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
package connectorconfig

import (
"encoding/json"

"github.com/chargehive/configuration/environment"
"github.com/chargehive/configuration/v1/connector"
"github.com/chargehive/proto/golang/chargehive/chtype"
)

type FlexPayEnvironment string

const (
FlexPayEnvironmentSandbox FlexPayEnvironment = "sandbox"
FlexPayEnvironmentProduction FlexPayEnvironment = "production"
)

type FlexPayCredentials struct {
ApiKey *string `json:"apiKey" yaml:"apiKey" validate:"required"`
Environment FlexPayEnvironment `json:"environment" yaml:"environment" validate:"oneof=sandbox production"`
}

func (c *FlexPayCredentials) GetMID() string {
return *c.ApiKey
}

func (c *FlexPayCredentials) GetLibrary() Library {
return LibraryFlexPay
}

func (c *FlexPayCredentials) GetSupportedTypes() []LibraryType {
return []LibraryType{LibraryTypeRecoveryAgent}
}

func (c *FlexPayCredentials) Validate() error {
return nil
}

func (c *FlexPayCredentials) GetSecureFields() []*string {
return []*string{c.ApiKey}
}

func (c *FlexPayCredentials) ToConnector() connector.Connector {
con := connector.Connector{Library: string(c.GetLibrary())}
con.Configuration, _ = json.Marshal(c)
return con
}

func (c *FlexPayCredentials) FromJson(input []byte) error {
return json.Unmarshal(input, c)
}

func (c *FlexPayCredentials) SupportsSca() bool {
return false
}

func (c *FlexPayCredentials) SupportsMethod(methodType chtype.PaymentMethodType, methodProvider chtype.PaymentMethodProvider) bool {
if !c.GetLibrary().SupportsMethod(methodType, methodProvider) {
return false
}
return true
}

func (c *FlexPayCredentials) SupportsCountry(country string) bool {
return true
}

func (c *FlexPayCredentials) CanPlanModeUse(mode environment.Mode) bool {
if mode == environment.ModeSandbox && c.Environment == FlexPayEnvironmentProduction {
return false
}
return true
}

func (c *FlexPayCredentials) IsRecoveryAgent() bool {
return true
}

func (c *FlexPayCredentials) Supports3RI() bool {
return false
}
8 changes: 8 additions & 0 deletions connectorconfig/library.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ const (
LibraryNuvei Library = "nuvei"
LibraryGPayments Library = "gpayments"
LibrarySandbanx Library = "sandbanx"
LibraryFlexPay Library = "flexpay"

// Fraud Libraries
LibraryChargeHive Library = "chargehive"
Expand Down Expand Up @@ -351,4 +352,11 @@ var LibraryRegister = map[Library]LibraryDef{
return methodType == chtype.PAYMENT_METHOD_TYPE_CARD
},
},
LibraryFlexPay: {
DisplayName: "FlexPay",
Credentials: func() Credentials { return &FlexPayCredentials{} },
SupportsMethod: func(methodType chtype.PaymentMethodType, methodProvider chtype.PaymentMethodProvider) bool {
return methodType == chtype.PAYMENT_METHOD_TYPE_CARD
},
},
}
8 changes: 8 additions & 0 deletions utils/generate.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ const (
confConnYapstone Template = "con_yapstone"
confConnTokenEx Template = "con_tokenex"
confConnTokenExNT Template = "con_tokenex_network_tokenization"
confConnFlexPay Template = "con_flexpay"

// connector Pool
confConnectorPool Template = "con_pool"
Expand Down Expand Up @@ -88,6 +89,7 @@ var Templates = map[Template]string{
confConnVindicia: "Connector: Vindicia",
confConnWorldPay: "Connector: Worldpay",
confConnYapstone: "Connector: Yapstone",
confConnFlexPay: "Connector: FlexPay",
confIntSlack: "Integration: Slack",
confPolCascade: "Policy: Cascade",
confPolChargeExpiry: "Policy: Charge Expiry",
Expand Down Expand Up @@ -334,6 +336,12 @@ func buildSpec(conf Template) (object.Specification, error) {
APIKey: &chg,
})
return connector.Connector{Library: string(connectorconfig.LibraryTokenExNetworkTokenization), Configuration: j}, nil
case confConnFlexPay:
j, _ := json.Marshal(connectorconfig.FlexPayCredentials{
Environment: connectorconfig.FlexPayEnvironmentSandbox,
ApiKey: &chg,
})
return connector.Connector{Library: string(connectorconfig.LibraryFlexPay), Configuration: j}, nil
case confConnectorPool:
return connector.Pool{Restriction: "unrestricted", Connectors: []connector.PoolItem{{ConnectorID: chg}}}, nil
case confIntSlack:
Expand Down
2 changes: 1 addition & 1 deletion v1/connector/connector.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const (
// Connector is a configuration file for a single payment processing entity
type Connector struct {
ProcessingState ProcessingState `json:"processingState,omitempty" yaml:"processingState,omitempty"`
Library string `json:"library" yaml:"library" validate:"omitempty,oneof=adyen bluesnap gpayments nuvei inoviopay threedsecureio sandbox sandbanx applepay authorize braintree qualpay stripe paysafe worldpay paypal-websitepaymentspro paypal-expresscheckout vindicia maxmind cybersource paysafe-accountupdater bottomline checkout kount clearhaus trust-payments cwams yapstone tokenex-accountupdater tokenex-networktokenization sticky-io googlepay"`
Library string `json:"library" yaml:"library" validate:"omitempty,oneof=flexpay adyen bluesnap gpayments nuvei inoviopay threedsecureio sandbox sandbanx applepay authorize braintree qualpay stripe paysafe worldpay paypal-websitepaymentspro paypal-expresscheckout vindicia maxmind cybersource paysafe-accountupdater bottomline checkout kount clearhaus trust-payments cwams yapstone tokenex-accountupdater tokenex-networktokenization sticky-io googlepay"`
Configuration []byte `json:"configuration" yaml:"configuration" validate:"required"`
ConfigID string `json:"configId,omitempty" yaml:"configId,omitempty"`
ConfigAuth string `json:"configAuth,omitempty" yaml:"configAuth,omitempty"`
Expand Down
Loading