Skip to content

Commit

Permalink
Merge pull request #140 from OpenBankingUK/feature/fix-payment-frequency
Browse files Browse the repository at this point in the history
[REFAPP-1366] allow v4 payment frequency
  • Loading branch information
diego-m-ob authored Sep 9, 2024
2 parents ff07ba2 + b415711 commit 0c76e67
Show file tree
Hide file tree
Showing 6 changed files with 57 additions and 38 deletions.
4 changes: 4 additions & 0 deletions manifests/ob_4.0_payment_fca.json
Original file line number Diff line number Diff line change
Expand Up @@ -443,6 +443,8 @@
"instructedAmountValue": "$instructedAmountValue",
"instructedAmountCurrency": "$instructedAmountCurrency",
"frequency": "$payment_frequency",
"frequencyCountPerPeriod": "$payment_frequency_count_per_period",
"frequencyPointInTime": "$payment_frequency_point_in_time",
"firstPaymentDateTime": "$firstPaymentDateTime",
"postData": "$minimalDomesticStandingOrderConsentV4",
"requestConsent": "true"
Expand Down Expand Up @@ -522,6 +524,8 @@
"instructedAmountValue": "$instructedAmountValue",
"instructedAmountCurrency": "$instructedAmountCurrency",
"frequency": "$payment_frequency",
"frequencyCountPerPeriod": "$payment_frequency_count_per_period",
"frequencyPointInTime": "$payment_frequency_point_in_time",
"firstPaymentDateTime": "$firstPaymentDateTime",
"postData": "$minimalDomesticStandingOrderV4",
"consentId": "$OB-400-DOP-101200-ConsentId"
Expand Down
2 changes: 1 addition & 1 deletion pkg/server/config_handlers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -818,7 +818,7 @@ func TestServerConfigGlobalPostInvalid(t *testing.T) {
},
{
name: `payment_frequency_invalid`,
expectedBody: `{"error":"payment_frequency: must be in a valid format (^(EvryDay)$|^(EvryWorkgDay)$|^(IntrvlWkDay:0[1-9]:0[1-7])$|^(WkInMnthDay:0[1-5]:0[1-7])$|^(IntrvlMnthDay:(0[1-6]|12|24):(-0[1-5]|0[1-9]|[12][0-9]|3[01]))$|^(QtrDay:(ENGLISH|SCOTTISH|RECEIVED))$)."}`,
expectedBody: `{"error":"payment_frequency: must be in a valid format (^(EvryDay)$|^(EvryWorkgDay)$|^(IntrvlWkDay:0[1-9]:0[1-7])$|^(WkInMnthDay:0[1-5]:0[1-7])$|^(IntrvlMnthDay:(0[1-6]|12|24):(-0[1-5]|0[1-9]|[12][0-9]|3[01]))$|^(QtrDay:(ENGLISH|SCOTTISH|RECEIVED))$|^(ADHO)$|^(YEAR)$|^(DAIL)$|^(FRTN)$|^(INDA)$|^(MNTH)$|^(QURT)$|^(MIAN)$|^(WEEK)$)."}`,
expectedStatusCode: http.StatusBadRequest,
config: GlobalConfiguration{
SigningPrivate: privateKey,
Expand Down
70 changes: 36 additions & 34 deletions pkg/server/journey.go
Original file line number Diff line number Diff line change
Expand Up @@ -596,40 +596,42 @@ func (wj *AppJourney) makeRunDefinition() executors.RunDefinition {

// JourneyConfig main configuration variables
type JourneyConfig struct {
certificateSigning authentication.Certificate
certificateTransport authentication.Certificate
tppSignatureKID string
tppSignatureIssuer string
tppSignatureTAN string
clientID string
clientSecret string
tokenEndpoint string
ResponseType string
tokenEndpointAuthMethod string
authorizationEndpoint string
resourceBaseURL string
xXFAPIFinancialID string
xXFAPICustomerIPAddress string
redirectURL string
resourceIDs model.ResourceIDs
creditorAccount models.Payment
internationalCreditorAccount models.Payment
instructedAmount models.InstructedAmount
paymentFrequency models.PaymentFrequency
firstPaymentDateTime string
requestedExecutionDateTime string
currencyOfTransfer string
apiVersion string
transactionFromDate string
transactionToDate string
requestObjectSigningAlgorithm string
signingPrivate string
signingPublic string
useDynamicResourceID bool
AcrValuesSupported []string
conditionalProperties []discovery.ConditionalAPIProperties
cbpiiDebtorAccount discovery.CBPIIDebtorAccount
issuer string
certificateSigning authentication.Certificate
certificateTransport authentication.Certificate
tppSignatureKID string
tppSignatureIssuer string
tppSignatureTAN string
clientID string
clientSecret string
tokenEndpoint string
ResponseType string
tokenEndpointAuthMethod string
authorizationEndpoint string
resourceBaseURL string
xXFAPIFinancialID string
xXFAPICustomerIPAddress string
redirectURL string
resourceIDs model.ResourceIDs
creditorAccount models.Payment
internationalCreditorAccount models.Payment
instructedAmount models.InstructedAmount
paymentFrequency models.PaymentFrequency
paymentFrequencyCountPerPeriod int
paymentFrequencyPointInTime int
firstPaymentDateTime string
requestedExecutionDateTime string
currencyOfTransfer string
apiVersion string
transactionFromDate string
transactionToDate string
requestObjectSigningAlgorithm string
signingPrivate string
signingPublic string
useDynamicResourceID bool
AcrValuesSupported []string
conditionalProperties []discovery.ConditionalAPIProperties
cbpiiDebtorAccount discovery.CBPIIDebtorAccount
issuer string
}

// SetConfig -
Expand Down
4 changes: 4 additions & 0 deletions pkg/server/model_context.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ const (
CtxInstructedAmountCurrency = "instructedAmountCurrency"
CtxInstructedAmountValue = "instructedAmountValue"
CtxPaymentFrequency = "payment_frequency" // CtxPaymentFrequency - for example `EvryDay`.
CtxPaymentFrequencyCountPerPeriod = "payment_frequency_count_per_period"
CtxPaymentFrequencyPointInTime = "payment_frequency_point_in_time"
CtxFirstPaymentDateTime = "firstPaymentDateTime"
CtxRequestedExecutionDateTime = "requestedExecutionDateTime"
CtxCurrencyOfTransfer = "currencyOfTransfer"
Expand Down Expand Up @@ -85,6 +87,8 @@ func PutParametersToJourneyContext(config JourneyConfig, context model.Context)
context.PutString(CtxInstructedAmountCurrency, config.instructedAmount.Currency)
context.PutString(CtxInstructedAmountValue, config.instructedAmount.Value)
context.PutString(CtxPaymentFrequency, string(config.paymentFrequency))
context.Put(CtxPaymentFrequencyCountPerPeriod, config.paymentFrequencyCountPerPeriod)
context.Put(CtxPaymentFrequencyPointInTime, config.paymentFrequencyPointInTime)
context.PutString(CtxFirstPaymentDateTime, config.firstPaymentDateTime)
context.PutString(CtxRequestedExecutionDateTime, config.requestedExecutionDateTime)
context.PutString(CtxCurrencyOfTransfer, config.currencyOfTransfer)
Expand Down
4 changes: 2 additions & 2 deletions pkg/server/models/payment.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,12 +79,12 @@ func (a InstructedAmount) Validate() error {
}

const (
regexPaymentFrequencyErr = `must be in a valid format (^(EvryDay)$|^(EvryWorkgDay)$|^(IntrvlWkDay:0[1-9]:0[1-7])$|^(WkInMnthDay:0[1-5]:0[1-7])$|^(IntrvlMnthDay:(0[1-6]|12|24):(-0[1-5]|0[1-9]|[12][0-9]|3[01]))$|^(QtrDay:(ENGLISH|SCOTTISH|RECEIVED))$)`
regexPaymentFrequencyErr = `must be in a valid format (^(EvryDay)$|^(EvryWorkgDay)$|^(IntrvlWkDay:0[1-9]:0[1-7])$|^(WkInMnthDay:0[1-5]:0[1-7])$|^(IntrvlMnthDay:(0[1-6]|12|24):(-0[1-5]|0[1-9]|[12][0-9]|3[01]))$|^(QtrDay:(ENGLISH|SCOTTISH|RECEIVED))$|^(ADHO)$|^(YEAR)$|^(DAIL)$|^(FRTN)$|^(INDA)$|^(MNTH)$|^(QURT)$|^(MIAN)$|^(WEEK)$)`
)

var (
// nolint:gochecknoglobals
regexPaymentFrequency = regexp.MustCompile(`^(EvryDay)$|^(EvryWorkgDay)$|^(IntrvlWkDay:0[1-9]:0[1-7])$|^(WkInMnthDay:0[1-5]:0[1-7])$|^(IntrvlMnthDay:(0[1-6]|12|24):(-0[1-5]|0[1-9]|[12][0-9]|3[01]))$|^(QtrDay:(ENGLISH|SCOTTISH|RECEIVED))$`)
regexPaymentFrequency = regexp.MustCompile(`^(EvryDay)$|^(EvryWorkgDay)$|^(IntrvlWkDay:0[1-9]:0[1-7])$|^(WkInMnthDay:0[1-5]:0[1-7])$|^(IntrvlMnthDay:(0[1-6]|12|24):(-0[1-5]|0[1-9]|[12][0-9]|3[01]))$|^(QtrDay:(ENGLISH|SCOTTISH|RECEIVED))$|^(ADHO)$|^(YEAR)$|^(DAIL)$|^(FRTN)$|^(INDA)$|^(MNTH)$|^(QURT)$|^(MIAN)$|^(WEEK)$`)
)

type PaymentFrequency string
Expand Down
11 changes: 10 additions & 1 deletion web/src/components/config/PaymentFrequency.vue
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,23 @@ import * as _ from 'lodash';
const isNotEmpty = value => !_.isEmpty(value);
const validator = {
regex: /^(EvryDay)$|^(EvryWorkgDay)$|^(IntrvlWkDay:0[1-9]:0[1-7])$|^(WkInMnthDay:0[1-5]:0[1-7])$|^(IntrvlMnthDay:(0[1-6]|12|24):(-0[1-5]|0[1-9]|[12][0-9]|3[01]))$|^(QtrDay:(ENGLISH|SCOTTISH|RECEIVED))$/,
regex: /^(EvryDay)$|^(EvryWorkgDay)$|^(IntrvlWkDay:0[1-9]:0[1-7])$|^(WkInMnthDay:0[1-5]:0[1-7])$|^(IntrvlMnthDay:(0[1-6]|12|24):(-0[1-5]|0[1-9]|[12][0-9]|3[01]))$|^(QtrDay:(ENGLISH|SCOTTISH|RECEIVED))$|^(ADHO)$|^(YEAR)$|^(DAIL)$|^(FRTN)$|^(INDA)$|^(MNTH)$|^(QURT)$|^(MIAN)$|^(WEEK)$/,
frequencies: {
EvryDay: /^$/,
EvryWorkgDay: /^$/,
IntrvlWkDay: /^0[1-9]:0[1-7]$/,
WkInMnthDay: /^0[1-5]:0[1-7]$/,
IntrvlMnthDay: /^(0[1-6]|12|24):(-0[1-5]|0[1-9]|[12][0-9]|3[01])$/,
QtrDay: /^(ENGLISH|SCOTTISH|RECEIVED)$/,
ADHO: /^$/,
YEAR: /^$/,
DAIL: /^$/,
FRTN: /^$/,
INDA: /^$/,
MNTH: /^$/,
QURT: /^$/,
MIAN: /^$/,
WEEK: /^$/,
},
};
Expand Down

0 comments on commit 0c76e67

Please sign in to comment.