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

fix(api): fix issues with thirdparty api after merge issues #119

Merged
merged 3 commits into from
Oct 12, 2021
Merged
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
33 changes: 33 additions & 0 deletions src/rules.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}
}
}
]
68 changes: 18 additions & 50 deletions src/simulator/api.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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'
Expand Down Expand Up @@ -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'
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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'
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
45 changes: 45 additions & 0 deletions src/test/integration/simulator/handlers.test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
const axios = require('axios');
const { v4 } = require('uuid');

const axiosConfig = {
headers: {
Expand Down Expand Up @@ -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);
});
});