Skip to content

Commit

Permalink
Google Pay billing format (#221)
Browse files Browse the repository at this point in the history
* add google billing address format

* remove shipping address format (not a valid option for google pay)

* mod update

* fix tests
  • Loading branch information
TomK authored Oct 24, 2024
1 parent a718218 commit 3d1ca53
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 60 deletions.
30 changes: 11 additions & 19 deletions connectorconfig/googlePay.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ type GooglePayCredential interface {
GetGoogleCardAllowPrepaid() bool
GetGoogleCardAllowCredit() bool
GetGoogleCardBillingAddressReq() bool
GetGoogleCardBillingAddressFormat() GoogleCardBillingAddressFormat
GetGoogleCardBillingPhoneReq() bool
GetGoogleCardShippingAddressReq() bool
GetGoogleCardShippingPhoneReq() bool
Expand Down Expand Up @@ -62,7 +63,7 @@ type GooglePayCredentials struct {
// GoogleCardBillingPhoneReq (Card {parameters.billingAddressParameters.phoneNumberRequired) Set to true if a phone number is required to process the transaction.
GoogleCardBillingPhoneReq bool `json:"googleCardBillingPhoneReq,omitempty" yaml:"googleCardBillingPhoneReq,omitempty" validate:"-"`
// GoogleCardBillingAddressFormat (Card {parameters.billingAddressParameters.format) Billing address format required to complete the transaction.
GoogleCardBillingAddressFormat GoogleCardBillingAddressReq `json:"googleCardBillingAddressFormat,omitempty" yaml:"googleCardBillingAddressFormat,omitempty" validate:"required_with=GoogleMerchantId,omitempty,oneof=MIN FULL"`
GoogleCardBillingAddressFormat GoogleCardBillingAddressFormat `json:"googleCardBillingAddressFormat,omitempty" yaml:"googleCardBillingAddressFormat,omitempty" validate:"required_with=GoogleMerchantId,omitempty,oneof=MIN FULL"`
// GoogleCardTokenType (Card {tokenizationSpecification.type})
GoogleCardTokenType GoogleTokenType `json:"googleCardTokenType,omitempty" yaml:"googleCardTokenType,omitempty" validate:"required_with=GoogleMerchantId,omitempty,oneof=DIRECT PAYMENT_GATEWAY"`
// GoogleCardGateway (Card {tokenizationSpecification.parameters.gateway}) https://developers.google.com/pay/api/web/reference/request-objects#gateway
Expand All @@ -74,8 +75,6 @@ type GooglePayCredentials struct {
GoogleCardShippingAddressReq bool `json:"googleCardShippingAddressReq,omitempty" yaml:"googleCardShippingAddressReq,omitempty" validate:"-"`
// GoogleCardShippingPhoneReq Set to true if a phone number is required to process the transaction.
GoogleCardShippingPhoneReq bool `json:"googleCardShippingPhoneReq,omitempty" yaml:"googleCardShippingPhoneReq,omitempty" validate:"-"`
// GoogleCardShippingAddressFormat (Card {parameters.shippingAddressParameters.format) Shipping address format required to complete the transaction.
GoogleCardShippingAddressFormat GoogleCardBillingAddressReq `json:"googleCardShippingAddressFormat,omitempty" yaml:"googleCardShippingAddressFormat,omitempty" validate:"omitempty,oneof=MIN FULL"`

// GoogleAcquirerCountry The ISO 3166-1 alpha-2 country code where the transaction is processed. This property is required for merchants who process transactions in European Economic Area (EEA) countries and any other countries that are subject to Strong Customer Authentication (SCA). Merchants must specify the acquirer bank country code.
GoogleAcquirerCountry string `json:"googleAcquirerCountry,omitempty" yaml:"googleAcquirerCountry,omitempty" validate:"omitempty,oneof=AF AX AL DZ AS AD AO AI AQ AG AR AM AW AU AT AZ BS BH BD BB BY BE BZ BJ BM BT BO BQ BA BW BV BR IO BN BG BF BI KH CM CA CV KY CF TD CL CN CX CC CO KM CG CD CK CR CI HR CU CW CY CZ DK DJ DM DO EC EG SV GQ ER EE ET FK FO FJ FI FR GF PF TF GA GM GE DE GH GI GR GL GD GP GU GT GG GN GW GY HT HM HN HK HU IS IN ID IR IQ IE IM IL IT JM JP JE JO KZ KE KI KP KR KW KG LA LV LB LS LR LY LI LT LU MO MK MG MW MY MV ML MT MH MQ MR MU YT MX FM MD MC MN ME MS MA MZ MM NA NR NP NC NZ NI NE NG NU NF MP NO OM PK PW PS PA PG PY PE PH PN PL PT PR QA RE RO RU RW BL SH KN LC MF VC WS SM ST SA SN RS SC SL SG SX SK SI SB SO ZA GS SS ES LK PM SD SR SJ SZ SE CH SY TW TJ TZ TH NL TL TG TK TO TT TN TR TM TC TV UG UA AE GB US UM UY UZ VU VA VE VN VG VI WF EH YE ZM ZW"`
Expand Down Expand Up @@ -237,7 +236,7 @@ func (g *GooglePayCredentials) GetGoogleCardBillingAddressReq() bool {
}
return g.GoogleCardBillingAddressReq
}
func (g *GooglePayCredentials) GetGoogleCardBillingAddressFormat() GoogleCardBillingAddressReq {
func (g *GooglePayCredentials) GetGoogleCardBillingAddressFormat() GoogleCardBillingAddressFormat {
if g == nil {
return ""
}
Expand All @@ -256,13 +255,6 @@ func (g *GooglePayCredentials) GetGoogleCardShippingAddressReq() bool {
}
return g.GoogleCardShippingAddressReq
}
func (g *GooglePayCredentials) GetGoogleCardShippingAddressFormat() GoogleCardBillingAddressReq {
if g == nil {
return ""
}

return g.GoogleCardShippingAddressFormat
}
func (g *GooglePayCredentials) GetGoogleCardShippingPhoneReq() bool {
if g == nil {
return false
Expand Down Expand Up @@ -295,17 +287,17 @@ func (g *GooglePayCredentials) GetGoogleAcquirerCountry() string {
}

type (
GoogleEnvironment string
GoogleCardGateway string
GoogleCardAuthMethod string
GoogleTokenType string
GoogleCardNetwork string
GoogleCardBillingAddressReq string
GoogleEnvironment string
GoogleCardGateway string
GoogleCardAuthMethod string
GoogleTokenType string
GoogleCardNetwork string
GoogleCardBillingAddressFormat string
)

const (
GoogleCardBillingAddressReqMIN GoogleCardBillingAddressReq = "MIN" // Name, country code, and postal code (default).
GoogleCardBillingAddressReqFULL GoogleCardBillingAddressReq = "FULL" // Name, street address, locality, region, country code, and postal code.
GoogleCardBillingAddressReqMIN GoogleCardBillingAddressFormat = "MIN" // Name, country code, and postal code (default).
GoogleCardBillingAddressReqFULL GoogleCardBillingAddressFormat = "FULL" // Name, street address, locality, region, country code, and postal code.

GoogleEnvironmentTEST GoogleEnvironment = "TEST"
GoogleEnvironmentPROD GoogleEnvironment = "PRODUCTION"
Expand Down
16 changes: 8 additions & 8 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
module github.com/chargehive/configuration

go 1.22
go 1.23

require (
github.com/chargehive/proto v1.13.0
github.com/chargehive/proto v1.14.0
github.com/go-playground/assert/v2 v2.2.0
github.com/go-playground/locales v0.14.1
github.com/go-playground/universal-translator v0.18.1
Expand All @@ -15,13 +15,13 @@ replace github.com/go-playground/validator/v10 => github.com/go-playground/valid

require (
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
github.com/gabriel-vasile/mimetype v1.4.5 // indirect
github.com/gabriel-vasile/mimetype v1.4.6 // indirect
github.com/google/go-cmp v0.6.0 // indirect
github.com/leodido/go-urn v1.4.0 // indirect
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
golang.org/x/crypto v0.26.0 // indirect
golang.org/x/net v0.28.0 // indirect
golang.org/x/sys v0.25.0 // indirect
golang.org/x/text v0.18.0 // indirect
google.golang.org/protobuf v1.34.2 // indirect
golang.org/x/crypto v0.28.0 // indirect
golang.org/x/net v0.30.0 // indirect
golang.org/x/sys v0.26.0 // indirect
golang.org/x/text v0.19.0 // indirect
google.golang.org/protobuf v1.35.1 // indirect
)
28 changes: 14 additions & 14 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
github.com/chargehive/proto v1.13.0 h1:0QnW/lwSZesV7f8ArVyHvnEocMAAsh6+of4kkjeb0RY=
github.com/chargehive/proto v1.13.0/go.mod h1:TSxF4AoWlaa2uwtEk3v+TC/jnKua1tk56m7Zi+85Dn0=
github.com/chargehive/proto v1.14.0 h1:6yWA8/6HdjmD3F/0NaLVjlVUTVnSRJBfFRWaP76errs=
github.com/chargehive/proto v1.14.0/go.mod h1:TSxF4AoWlaa2uwtEk3v+TC/jnKua1tk56m7Zi+85Dn0=
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1VwoXQT9A3Wy9MM3WgvqSxFWenqJduM=
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/gabriel-vasile/mimetype v1.4.5 h1:J7wGKdGu33ocBOhGy0z653k/lFKLFDPJMG8Gql0kxn4=
github.com/gabriel-vasile/mimetype v1.4.5/go.mod h1:ibHel+/kbxn9x2407k1izTA1S81ku1z/DlgOW2QE0M4=
github.com/gabriel-vasile/mimetype v1.4.6 h1:3+PzJTKLkvgjeTbts6msPJt4DixhT4YtFNf1gtGe3zc=
github.com/gabriel-vasile/mimetype v1.4.6/go.mod h1:JX1qVKqZd40hUPpAfiNTe0Sne7hdfKSbOqqmkq8GCXc=
github.com/go-playground/assert/v2 v2.2.0 h1:JvknZsQTYeFEAhQwI4qEt9cyV5ONwRHC+lYKSsYSR8s=
github.com/go-playground/assert/v2 v2.2.0/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4=
github.com/go-playground/locales v0.14.1 h1:EWaQ/wswjilfKLTECiXz7Rh+3BjFhfDFKv/oXslEjJA=
Expand All @@ -20,15 +20,15 @@ github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 h1:Jamvg5psRI
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk=
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
golang.org/x/crypto v0.26.0 h1:RrRspgV4mU+YwB4FYnuBoKsUapNIL5cohGAmSH3azsw=
golang.org/x/crypto v0.26.0/go.mod h1:GY7jblb9wI+FOo5y8/S2oY4zWP07AkOJ4+jxCqdqn54=
golang.org/x/net v0.28.0 h1:a9JDOJc5GMUJ0+UDqmLT86WiEy7iWyIhz8gz8E4e5hE=
golang.org/x/net v0.28.0/go.mod h1:yqtgsTWOOnlGLG9GFRrK3++bGOUEkNBoHZc8MEDWPNg=
golang.org/x/sys v0.25.0 h1:r+8e+loiHxRqhXVl6ML1nO3l1+oFoWbnlu2Ehimmi34=
golang.org/x/sys v0.25.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/text v0.18.0 h1:XvMDiNzPAl0jr17s6W9lcaIhGUfUORdGCNsuLmPG224=
golang.org/x/text v0.18.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY=
google.golang.org/protobuf v1.34.2 h1:6xV6lTsCfpGD21XK49h7MhtcApnLqkfYgPcdHftf6hg=
google.golang.org/protobuf v1.34.2/go.mod h1:qYOHts0dSfpeUzUFpOMr/WGzszTmLH+DiWniOlNbLDw=
golang.org/x/crypto v0.28.0 h1:GBDwsMXVQi34v5CCYUm2jkJvu4cbtru2U4TN2PSyQnw=
golang.org/x/crypto v0.28.0/go.mod h1:rmgy+3RHxRZMyY0jjAJShp2zgEdOqj2AO7U0pYmeQ7U=
golang.org/x/net v0.30.0 h1:AcW1SDZMkb8IpzCdQUaIq2sP4sZ4zw+55h6ynffypl4=
golang.org/x/net v0.30.0/go.mod h1:2wGyMJ5iFasEhkwi13ChkO/t1ECNC4X4eBKkVFyYFlU=
golang.org/x/sys v0.26.0 h1:KHjCJyddX0LoSTb3J+vWpupP9p0oznkqVk/IfjymZbo=
golang.org/x/sys v0.26.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/text v0.19.0 h1:kTxAhCbGbxhK0IwgSKiMO5awPoDQ0RpfiVYBfK860YM=
golang.org/x/text v0.19.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY=
google.golang.org/protobuf v1.35.1 h1:m3LfL6/Ca+fqnjnlqQXNpFPABW1UD7mjh8KO2mKFytA=
google.golang.org/protobuf v1.35.1/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
37 changes: 18 additions & 19 deletions utils/generate.go
Original file line number Diff line number Diff line change
Expand Up @@ -238,25 +238,24 @@ func buildSpec(conf Template) (object.Specification, error) {
},
GooglePayPageId: chg,
GooglePay: &connectorconfig.GooglePayCredentials{
GoogleEnvironment: connectorconfig.GoogleEnvironmentTEST,
GoogleMerchantId: chg,
GoogleMerchantName: chg,
GoogleExistingMethodRequired: false,
GoogleEmailReq: false,
GoogleAcceptCard: true,
GoogleCardAuthMethods: []connectorconfig.GoogleCardAuthMethod{connectorconfig.GoogleCardAuthMethodPAN, connectorconfig.GoogleCardAuthMethod3DS},
GoogleCardNetworks: []connectorconfig.GoogleCardNetwork{connectorconfig.GoogleCardNetworkAMEX, connectorconfig.GoogleCardNetworkDISCOVER, connectorconfig.GoogleCardNetworkMASTERCARD, connectorconfig.GoogleCardNetworkVISA},
GoogleCardAllowPrepaid: true,
GoogleCardAllowCredit: true,
GoogleCardBillingAddressReq: false,
GoogleCardBillingAddressFormat: connectorconfig.GoogleCardBillingAddressReqMIN,
GoogleCardBillingPhoneReq: false,
GoogleCardShippingAddressReq: false,
GoogleCardShippingAddressFormat: connectorconfig.GoogleCardBillingAddressReqMIN,
GoogleCardShippingPhoneReq: false,
GoogleCardTokenType: connectorconfig.GoogleCardTokenTypeGATEWAY,
GoogleCardGateway: string(connectorconfig.GoogleCardGatewayVANTIV),
GoogleCardMerchantId: chg,
GoogleEnvironment: connectorconfig.GoogleEnvironmentTEST,
GoogleMerchantId: chg,
GoogleMerchantName: chg,
GoogleExistingMethodRequired: false,
GoogleEmailReq: false,
GoogleAcceptCard: true,
GoogleCardAuthMethods: []connectorconfig.GoogleCardAuthMethod{connectorconfig.GoogleCardAuthMethodPAN, connectorconfig.GoogleCardAuthMethod3DS},
GoogleCardNetworks: []connectorconfig.GoogleCardNetwork{connectorconfig.GoogleCardNetworkAMEX, connectorconfig.GoogleCardNetworkDISCOVER, connectorconfig.GoogleCardNetworkMASTERCARD, connectorconfig.GoogleCardNetworkVISA},
GoogleCardAllowPrepaid: true,
GoogleCardAllowCredit: true,
GoogleCardBillingAddressReq: false,
GoogleCardBillingAddressFormat: connectorconfig.GoogleCardBillingAddressReqMIN,
GoogleCardBillingPhoneReq: false,
GoogleCardShippingAddressReq: false,
GoogleCardShippingPhoneReq: false,
GoogleCardTokenType: connectorconfig.GoogleCardTokenTypeGATEWAY,
GoogleCardGateway: string(connectorconfig.GoogleCardGatewayVANTIV),
GoogleCardMerchantId: chg,
},
})

Expand Down

0 comments on commit 3d1ca53

Please sign in to comment.