Skip to content

Commit c49c98a

Browse files
authored
Add config options to explicitly manage sca n or r results (#252)
* Add config options to explicitly manage sca n or r results * Update readme with new config options * Update tests to include new config options * Change default return values for should auth on n and r to true
1 parent a693e69 commit c49c98a

File tree

3 files changed

+24
-2
lines changed

3 files changed

+24
-2
lines changed

docs/policy/sca.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@ As with all configs, the standard wrapper is used.
1717
"shouldIdentify": true, // Enable or disable identification step
1818
"shouldChallengeOptional": true, // If challenge is optional from issuer, use this value to decide
1919
"shouldByPassChallenge": "", // If challenge is required, override with this value (see below for options)
20-
"shouldAuthOnError": true // If the gateway authentication response is an error, authorize payment anyway
20+
"shouldAuthOnError": true, // If the gateway authentication response is an error, authorize payment anyway
21+
"shouldAuthOnN": true, // If the gateway authentication response is an N, authorize payment anyway
22+
"shouldAuthOnR": true // If the gateway authentication response is an R, authorize payment anyway
2123
}
2224
}
2325
```

utils/generate.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -385,7 +385,7 @@ func buildSpec(conf Template) (object.Specification, error) {
385385
case confPolMethodVerify:
386386
return policy.MethodVerifyPolicy{Amount: 100, AmountCurrency: "GBP", ConnectorID: chg, VerifyMethodOnTokenization: new(bool)}, nil
387387
case confPolSCA:
388-
return policy.ScaPolicy{ShouldIdentify: new(bool), ShouldChallengeOptional: new(bool), ShouldByPassChallenge: "cascade", ShouldAuthOnError: new(bool), RequireSca: new(bool)}, nil
388+
return policy.ScaPolicy{ShouldIdentify: new(bool), ShouldChallengeOptional: new(bool), ShouldByPassChallenge: "cascade", ShouldAuthOnError: new(bool), ShouldAuthOnN: new(bool), ShouldAuthOnR: new(bool), RequireSca: new(bool)}, nil
389389
case confSchInitiator:
390390
return scheduler.Initiator{Type: scheduler.InitiatorTypeAuth, InitialConnector: scheduler.ConnectorSelectorConfig, AttemptConfig: &scheduler.AttemptConfig{PoolType: scheduler.PoolTypeCascade, MethodSelector: scheduler.MethodSelectorPrimaryMethod, OverridePoolConnectorIDs: []string{}, CascadeDelay: new(time.Duration)}}, nil
391391
case confSchOnDemand:

v1/policy/sca.go

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,12 @@ type ScaPolicy struct {
5454
// ShouldAuthOnError if true and an error response is returned from the connector; proceed to auth anyway
5555
ShouldAuthOnError *bool `json:"shouldAuthOnError" yaml:"shouldAuthOnError" validate:"required"`
5656

57+
// ShouldAuthOnN if true and an "N" response is returned from the connector; proceed to auth anyway
58+
ShouldAuthOnN *bool `json:"shouldAuthOnN" yaml:"shouldAuthOnN" validate:"required"`
59+
60+
// ShouldAuthOnR if true and an "R" response is returned from the connector; proceed to auth anyway
61+
ShouldAuthOnR *bool `json:"shouldAuthOnR" yaml:"shouldAuthOnR" validate:"required"`
62+
5763
ChallengePreference ChallengePreference `json:"challengePreference" yaml:"challengePreference" validate:"omitempty,oneof=no-preference no-challenge request mandate"`
5864
}
5965

@@ -85,6 +91,20 @@ func (s ScaPolicy) GetShouldAuthOnError() bool {
8591
return *s.ShouldAuthOnError
8692
}
8793

94+
func (s ScaPolicy) GetShouldAuthOnN() bool {
95+
if s.ShouldAuthOnN == nil {
96+
return true
97+
}
98+
return *s.ShouldAuthOnN
99+
}
100+
101+
func (s ScaPolicy) GetShouldAuthOnR() bool {
102+
if s.ShouldAuthOnR == nil {
103+
return true
104+
}
105+
return *s.ShouldAuthOnR
106+
}
107+
88108
// GetKind returns the ScaPolicy kind
89109
func (ScaPolicy) GetKind() object.Kind { return KindPolicySCA }
90110

0 commit comments

Comments
 (0)