diff --git a/src/rules.json b/src/rules.json index 9ea7a83c..102434fa 100644 --- a/src/rules.json +++ b/src/rules.json @@ -118,5 +118,38 @@ } } } + }, + { + "ruleId": 4, + "description": "verify received thirdparty transaction request", + "conditions": { + "all": [ + { + "fact": "path", + "operator": "equal", + "value": "/validate-thirdparty-transaction-request" + }, + { + "fact": "method", + "operator": "equal", + "value": "POST" + } + ] + }, + "event": { + "type": "FIXED_CALLBACK", + "params": { + "statusCode": 200, + "body": { + "isValid": true, + "payerPartyIdInfo": { + "partyIdType": "MSISDN", + "partyIdentifier": "123456789", + "fspId": "dfspa" + }, + "consentId": "46876aac-5db8-4353-bb3c-a6a905843ce7" + } + } + } } ] \ No newline at end of file diff --git a/src/simulator/api.yaml b/src/simulator/api.yaml index f52f2477..b3a24549 100644 --- a/src/simulator/api.yaml +++ b/src/simulator/api.yaml @@ -1059,7 +1059,7 @@ components: $ref: '#/components/schemas/initiatorType' description: Specifies the type of the transaction initiator geoCode: - $ref: '#/components/schemas/geoCode' + $ref: '#/components/schemas/GeoCode' description: Longitude and Latitude of the initiating Party. Can be used to detect fraud. note: type: string @@ -1107,7 +1107,7 @@ components: $ref: '#/components/schemas/initiatorType' description: Specifies the type of the transaction initiator geoCode: - $ref: '#/components/schemas/geoCode' + $ref: '#/components/schemas/GeoCode' description: Longitude and Latitude of the initiating Party. Can be used to detect fraud. note: type: string @@ -1185,7 +1185,7 @@ components: $ref: '#/components/schemas/timestamp' description: Timestamp specifying the validity period of the quotation geoCode: - $ref: '#/components/schemas/geoCode' + $ref: '#/components/schemas/GeoCode' description: Longitude and Latitude of the Payee. Can be used to detect fraud transactionRequestResponse: @@ -1852,7 +1852,7 @@ components: $ref: '#/components/schemas/transferParty' description: Information about the Payer in the proposed financial transaction. geoCode: - $ref: '#/components/schemas/geoCode' + $ref: '#/components/schemas/GeoCode' description: Longitude and Latitude of the initiating Party. Can be used to detect fraud. expiration: $ref: '#/components/schemas/timestamp' @@ -1978,7 +1978,7 @@ components: $ref: '#/components/schemas/timestamp' description: Timestamp specifying the validity period of the quotation geoCode: - $ref: '#/components/schemas/geoCode' + $ref: '#/components/schemas/GeoCode' description: Longitude and Latitude of the Payee. Can be used to detect fraud extensionList: $ref: '#/components/schemas/extensionList' @@ -2068,28 +2068,6 @@ components: type: string description: A Mojaloop API transfer identifier (UUID) - geoCode: - type: object - description: Indicates the geographic location from where the transaction was initiated. - properties: - latitude: - $ref: '#/components/schemas/latitude' - longitude: - $ref: '#/components/schemas/longitude' - required: - - latitude - - longitude - - latitude: - type: string - pattern: ^(\+|-)?(?:90(?:(?:\.0{1,6})?)|(?:[0-9]|[1-8][0-9])(?:(?:\.[0-9]{1,6})?))$ - description: The API data type Latitude is a JSON String in a lexical format that is restricted by a regular expression for interoperability reasons. - - longitude: - type: string - pattern: ^(\+|-)?(?:180(?:(?:\.0{1,6})?)|(?:[0-9]|[1-9][0-9]|1[0-7][0-9])(?:(?:\.[0-9]{1,6})?))$ - description: The API data type Longitude is a JSON String in a lexical format that is restricted by a regular expression for interoperability reasons. - errorResponse: type: object properties: @@ -2682,7 +2660,7 @@ components: $ref: '#/components/schemas/transferParty' description: Information about the Payer in the proposed financial transaction. geoCode: - $ref: '#/components/schemas/geoCode' + $ref: '#/components/schemas/GeoCode' description: Longitude and Latitude of the initiating Party. Can be used to detect fraud. expiration: $ref: '#/components/schemas/timestamp' @@ -2887,23 +2865,6 @@ components: type: string description: A Mojaloop API transfer identifier (UUID) - geoCode: - type: object - description: Data model for the complex type PartyIdInfo. - properties: - partyIdType: - $ref: '#/components/schemas/PartyIdTypeTPLink' - partyIdentifier: - $ref: '#/components/schemas/PartyIdentifier' - partySubIdOrType: - $ref: '#/components/schemas/PartySubIdOrType' - fspId: - $ref: '#/components/schemas/FspId' - extensionList: - $ref: '#/components/schemas/ExtensionList' - required: - - partyIdType - - partyIdentifier PartyIdType: title: PartyIdType type: string @@ -3015,17 +2976,24 @@ components: - THIRD_PARTY_LINK - TBD example: PERSONAL_ID - PartyIdentifier: - title: PartyIdentifier - pattern: ^(\+|-)?(?:90(?:(?:\.0{1,6})?)|(?:[0-9]|[1-8][0-9])(?:(?:\.[0-9]{1,6})?))$ - description: The API data type Latitude is a JSON String in a lexical format that is restricted by a regular expression for interoperability reasons. - + + longitude: type: string minLength: 1 maxLength: 128 + pattern: ^(\+|-)?(?:90(?:(?:\.0{1,6})?)|(?:[0-9]|[1-8][0-9])(?:(?:\.[0-9]{1,6})?))$ + description: The API data type Latitude is a JSON String in a lexical format that is restricted by a regular expression for interoperability reasons. + + PartyIdentifier: + title: PartyIdentifier description: Identifier of the Party. example: '16135551212' + type: string + minLength: 1 + maxLength: 128 + + PartySubIdOrType: title: PartySubIdOrType type: string diff --git a/src/test/integration/simulator/handlers.test.js b/src/test/integration/simulator/handlers.test.js index 86c163f0..4ce435eb 100644 --- a/src/test/integration/simulator/handlers.test.js +++ b/src/test/integration/simulator/handlers.test.js @@ -1,4 +1,5 @@ const axios = require('axios'); +const { v4 } = require('uuid'); const axiosConfig = { headers: { @@ -65,4 +66,48 @@ describe('handlers', () => { // Assert expect(result).toStrictEqual(expected); }); + + it('POST /validate-thirdparty-transaction-request a FIXED_CALLBACK`', async () => { + // Arrange + const payload = { + transactionRequestId: v4(), + payee: { + partyIdInfo: { + partyIdType: 'MSISDN', + partyIdentifier: '4412345678', + }, + }, + payer: { + partyIdType: 'THIRD_PARTY_LINK', + partyIdentifier: 'qwerty1234', + }, + amountType: 'SEND', + amount: { + currency: 'USD', + amount: '100', + }, + transactionType: { + scenario: 'TRANSFER', + initiator: 'PAYER', + initiatorType: 'CONSUMER', + }, + expiration: (new Date()).toISOString(), + }; + const expected = { + isValid: true, + payerPartyIdInfo: { + partyIdType: 'MSISDN', + partyIdentifier: '123456789', + fspId: 'dfspa', + }, + consentId: '46876aac-5db8-4353-bb3c-a6a905843ce7', + }; + const uri = 'http://localhost:3000/validate-thirdparty-transaction-request'; + + // Act + const result = (await axios.post(uri, payload, axiosConfig)).data; + + // Assert + expect(result).toStrictEqual(expected); + }); });