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

Implement patch notification for failure scenarios (following v1.1 update) #2556

Closed
25 of 28 tasks
elnyry-sam-k opened this issue Oct 28, 2021 · 16 comments
Closed
25 of 28 tasks
Assignees
Labels
oss-core This is an issue - story or epic related to a feature on a Mojaloop core service or related to it story
Milestone

Comments

@elnyry-sam-k
Copy link
Member

elnyry-sam-k commented Oct 28, 2021

Goal:

As a Payee FSP

I want to be able to receive a notification upon finalization of a transfer even in failure cases (success supported now)

so that I can use the notification to mitigate risk on payments to end-users

Acceptance Criteria:

  • A PATCH notification is sent to the Payee FSP when a transfer is ABORTED
  • Tests are added in the TTK GP test cases to cover the various scenarios using this patch notification (using transfer states reserved, committed when transfer is aborted, committed, etc)

Complexity: High

Uncertainty: Low


Tasks:

  • Review spec for pattern and existing implementation of patch notification on success cases
  • Implementation of patch on failure cases (when transfer is ABORTED)
    • central-ledger changes
    • central-services-shared changes
    • ml-api-adapter changes
  • Add TTK tests for failure notification with v1.1 (Payee fsp receives notification when a transfer is ABORTED; not just when a transfer is COMMITTED):
    • When a PUT /transfers/{ID} is sent from Payee FSP -> Switch with a status of ABORTED (invalid value), there is no PATCH /transfers/{ID} sent to the Payee FSP (this is an error condition covered in 1.2)
    • When a PUT /transfers/{ID} is sent from Payee FSP -> Switch with a status of RESERVED, and the transfer completes successfully, a PATCH /transfers/{ID} is sent to the Payee FSP with a status of COMMITTED (this is the existing case)
    • When a PUT /transfers/{ID} is sent from Payee FSP -> Switch with a status of RESERVED, and the transfer has a fulfilment that doesn't match the condition, the switch aborts the transfer and a PATCH /transfers/{ID} is sent to the Payee FSP with a status of ABORTED (new functionality)
    • where an invalid value is used for the completedTimestamp of the PUT /transfers/{ID} request by the Payee FSP; we have some validations on the switch which check for this so this can fail as well. (new functionality)
    • When a Payee FSP does not send a PUT /transfers/{ID}, and the transfer times out, no PATCH /transfers/{ID} is sent to the Payee FSP

Done

  • Acceptance Criteria pass
  • Designs are up-to date
  • Unit Tests pass
  • Integration Tests pass
  • Code Style & Coverage meets standards
  • Changes made to config (default.json) are broadcast to team and follow-up tasks added to update helm charts and other deployment config.

Pull Requests:

Follow-up:

  • N/A

Dependencies:

  • N/A

Accountability:

  • Owner: TBC
  • QA/Review: TBC
@elnyry-sam-k elnyry-sam-k added story oss-core This is an issue - story or epic related to a feature on a Mojaloop core service or related to it to-be-refined This story is ready to be groomed labels Oct 28, 2021
@elnyry-sam-k elnyry-sam-k mentioned this issue Nov 4, 2021
46 tasks
@elnyry-sam-k elnyry-sam-k added this to the Sprint 16.1 milestone Nov 5, 2021
@elnyry-sam-k elnyry-sam-k removed the to-be-refined This story is ready to be groomed label Nov 5, 2021
@lewisdaly
Copy link
Contributor

@mdebarros and I talked about this yesterday.

There isn't enough information in the different ABORT_* notifications for the ml-api-adapter to be able to infer whether or not it should send a PATCH /transfers/{ID} to the Payee with a status of ABORTED.

For this reason, we decided that the central-ledger should emit a new notification message for this case, and the ml-api-adapter, if it's API version is 1.1 should then send this message as a PATCH /transfers/{ID} to the Payee with a status of ABORTED.

@lewisdaly
Copy link
Contributor

@elnyry-sam-k @mdebarros I've written out 4 test cases above for the feature - can you please check that these are correct and add any that you think I've missed?

@elnyry-sam-k
Copy link
Member Author

elnyry-sam-k commented Nov 10, 2021

hi Lewis, thanks for noting these - it helps the discussion..

  1. When a PUT /transfers/{ID} is sent from Payee FSP -> Switch with a status of ABORTED, there is no extra PATCH /transfers/{ID} sent to the Payee FSP
  2. When a PUT /transfers/{ID} is sent from Payee FSP -> Switch with a status of RESERVED, and the transfer completes successfully, a PATCH /transfers/{ID} is sent to the Payee FSP with a status of COMMITTED (this is the existing case)
  3. When a PUT /transfers/{ID} is sent from Payee FSP -> Switch with a status of RESERVED, and the transfer has a fulfilment that doesn't match the condition, the switch aborts the transfer and a PATCH /transfers/{ID} is sent to the Payee FSP with a status of ABORTED
  4. When a Payee FSP does not send a PUT /transfers/{ID}, and the transfer times out, no PATCH /transfers/{ID} is sent to the Payee FSP

Cases 1 & 3 fall under the same category - invalid values being sent for required fields; from FSPIOP v1.1 onwards, 'ABORTED' is an invalid value if used as a transferState in a fulfil request (the Payee FSP should use an error callback, a PUT on /transfers/{ID}/error for this) and both these cases should now have this new behavior that we are introducing (in implementation) - the sending of PATCH with transferState as ABORTED.

As you pointed out option-2 should be currently existing functionality.

The last one option-4 is an interesting one. Right now yes, we're not sending a PATCH but we do PUT /transfers/{ID}/error error callbacks to both the Payer & Payee FSPs. This is not inline with the spec; but maybe its best to leave it as it is for now; lets discuss on one of the meetings and add a backlog item for item-4 while continuing for now as-is on it.

@lewisdaly
Copy link
Contributor

I'm not sure I follow your logic for #1. If it's invalid in the FSPIOP v1.1 API, option #1 should return a synchronous response such as 400 Bad Request.

@elnyry-sam-k
Copy link
Member Author

I'm not sure I follow your logic for #1. If it's invalid in the FSPIOP v1.1 API, option #1 should return a synchronous response such as 400 Bad Request.

There cannot be a synchronous response here (following schema validation) because ABORTED is a valid state for a transfer in general and it can be used in a PUT callback when it is sent in response to a GET /transfers/{ID}, but Payee FSPs cannot use this value to abort a transfer, they should use the error callback. More on this here: mojaloop/mojaloop-specification#47 (comment)

@elnyry-sam-k
Copy link
Member Author

@lewisdaly - In addition to the four scenarios you added, I'd suggest a scenario-5 where an invalid value is used for the completedTimestamp of the PUT /transfers/{ID} request by the Payee FSP; we have some validations on the switch which check for this so this can fail as well.

@lewisdaly
Copy link
Contributor

There cannot be a synchronous response here (following schema validation) because ABORTED is a valid state for a transfer in general and it can be used in a PUT callback when it is sent in response to a GET /transfers/{ID}

That's annoying. I still don't understand why that case should result in a PATCH /transfers/{ID} from the switch to the Payee though. I thought we only send the final status of the transfer in a PATCH /transfers/{ID} when the Payer FSP sends a PUT /transfers/{ID} with a status of RESERVED

@elnyry-sam-k
Copy link
Member Author

the last part is still correct Lewis, yes. As part of this story - we're looking at the patch only for transfers that use RESERVED state in the fulfil request

@elnyry-sam-k elnyry-sam-k modified the milestones: Sprint 16.1, Sprint 16.2 Nov 12, 2021
@elnyry-sam-k elnyry-sam-k modified the milestones: Sprint 16.2, Sprint 16.3 Dec 1, 2021
@lewisdaly
Copy link
Contributor

I'm having trouble locating the existing e2e test that demonstrates the payee FSP sending a RESERVED status, and expecting a PATCH /transfers/{ID} callback from the switch. @elnyry-sam-k or @vijayg10 can you please help me find it? That's the one I plan on extending for this.

@lewisdaly
Copy link
Contributor

I'm having trouble writing E2E tests for this - see #2624

@elnyry-sam-k
Copy link
Member Author

hi @lewisdaly , will discuss this with Vijay today

mdebarros added a commit to mojaloop/helm that referenced this issue Jan 5, 2022
Story: mojaloop/project#2528
View change-log: https://github.com/mojaloop/helm/blob/release/v13.1.0/.changelog/release-v13.1.0.md

**NOTE: This PR merge is for a candidate release.**

1. If you want to see the changes/features are to be included, consult the  [v13.1.0 Release Report](https://github.com/mojaloop/project/issues#workspaces/mojaloop-ref-arch-59edee71d1407922110cf083/reports/release?release=Z2lkOi8vcmFwdG9yL1JlbGVhc2UvNjYzODQ).
2. Final release is blocked by the following missing feature: mojaloop/project#2556
@elnyry-sam-k elnyry-sam-k modified the milestones: Sprint 16.3, Sprint 16.5 Jan 6, 2022
@lewisdaly lewisdaly removed their assignment Jan 13, 2022
@lewisdaly
Copy link
Contributor

I'm not able to continue working on this ticket.

I got up to the point where I was writing the above TTK tests, and ran into issues setting up custom rules to help simulate the different scenarios. We later determined that this was an issue only on firefox, so this is no longer blocked.

Once we have the updated TTK E2E tests, then we can be confident that this is working as expected, and finish up those open PRs.

@elnyry-sam-k elnyry-sam-k modified the milestones: Sprint 16.5, Sprint 17.1 Feb 1, 2022
@mdebarros
Copy link
Member

mdebarros commented Feb 7, 2022

@lewisdaly, would you be so kind to give me write permissions to your forked repos so I can continue the work on this?

I.e. resolving merge conflicts, etc.

I would like to finalise these PRs ASAP!

mdebarros added a commit to mojaloop/central-services-shared that referenced this issue Feb 7, 2022
… scenarios (following v1.1 update) (#321)

* feat(unit): adding test cases for RESERVED_ABORTED

* feat(flow): add handling for notification/reserved-aborted to TopicMap

* chore: remove consoles

* chore: remove unused test

* fix(vulns): run npm audit, ignore unfixable medium vulns for 1 month

* chore: updated dependencies

- updated dependencies
- removed  "@mojaloop/sdk-standard-components" from `ncurc.json` file
- fixed lint issues

Co-authored-by: Lewis Daly <lewis@vesselstech.com>
@lewisdaly
Copy link
Contributor

Hey it looks like you've just recreated my branches elsewhere? So you don't need me to do this?

@mdebarros
Copy link
Member

mdebarros commented Feb 8, 2022

Hey it looks like you've just recreated my branches elsewhere? So you don't need me to do this?

Yeah....decided to go with that approach. Sorry about that. Needed to get these PRs sorted, and it sounded like you were not going to be available for awhile due to travel :D/

@lewisdaly
Copy link
Contributor

Nah all good - thanks for sorting it out :)

mdebarros added a commit to mojaloop/testing-toolkit-test-cases that referenced this issue Feb 11, 2022
Added the following test-case scenarios for patch notifications:
- p2p_money_transfer_patch_notifications - payee receives PATCH Notification with COMMITTED after sending callback with RESERVED - mojaloop/project#2676
- p2p_money_transfer_patch_notifications - payee receives PATCH Notification with ABORTED status after sending invalid fulfilment - mojaloop/project#2556
mdebarros added a commit to mojaloop/central-ledger that referenced this issue Feb 22, 2022
… scenarios (#874)

PR re-based from #872 from @lewisdaly. 

feat(mojaloop/project/issue2556): Implement patch notification for failure scenarios (following v1.1 update) - mojaloop/project#2556

chore: updated dependencies
- updated dependencies
- fixed audit issues
- fixed lint issues

fix([#2697](mojaloop/project#2697)): Central-Ledger Fulfil Handler does not correctly invalidate requests with an incorrect/non-existent FSP-ID in the FSPIOP-Destination header - mojaloop/project#2697
- fixed/added unit tests
- improved test coverage
mdebarros added a commit to mojaloop/ml-api-adapter that referenced this issue Feb 22, 2022
… scenarios (#492)

PR re-based from #489 from @lewisdaly.

feat([mojaloop/project/issue](mojaloop/project#2556): Implement patch notification for failure scenarios (following v1.1 update) - mojaloop/project#2556
- fixed unit tests

chore: updated dependencies
- updated dependencies
- fixed audit issues
- fixed lint issues

fix([#2697](mojaloop/project#2697)): Central-Ledger Fulfil Handler does not correctly invalidate requests with an incorrect/non-existent FSP-ID in the FSPIOP-Destination header - mojaloop/project#2697
- fixed/added unit tests
- improved test coverage
mdebarros added a commit to mojaloop/ml-testing-toolkit that referenced this issue Feb 22, 2022
…ios (#200)

Added callback rules:
- ttkpayeefsp PATCH Notifications Success Test-case - mojaloop/project#2676
- ttkpayeefsp PATCH Notifications Failure due to invalid fulfiment Test-case - mojaloop/project#2556
- ttkpayeefsp PUT Notifications Failure Test-case due to invalid FSPIOP-Destination  Test-case - mojaloop/project#2697
- ttkpayeefsp PATCH Notifications Failure Test-case due to invalid FSPIOP-Destination Test-case - mojaloop/project#2697
 
~Blocked by mojaloop/project#2696
mdebarros added a commit to mojaloop/testing-toolkit-test-cases that referenced this issue Feb 22, 2022
Added the following feature test-case scenarios for patch notifications:
- p2p_money_transfer_patch_notifications - payee receives PATCH Notification with COMMITTED after sending callback with RESERVED - mojaloop/project#2676
- p2p_money_transfer_patch_notifications - payee receives PATCH Notification with ABORTED status after sending invalid fulfilment - mojaloop/project#2556

Added the following bug-fix test-case scenarios for patch notifications:
- p2p_money_transfer_patch_notifications - payee sends PUT callback with COMMITTED with invalid FSPIOP-Destination Header - mojaloop/project#2676
- p2p_money_transfer_patch_notifications - payee sends PUT callback with RESERVED with invalid FSPIOP-Destination Header - mojaloop/project#2676
mdebarros added a commit to mojaloop/helm that referenced this issue Feb 25, 2022
- ml-api-adapter upgraded to v12.3.0
- central-ledger upgraded to v13.15.4
- ml-testing-toolkit backend upgraded to v14.0.4

These upgrades address the following issues:
- Implement patch notification for failure scenarios (following v1.1 update) #2556 - mojaloop/project#2556
- Central-Ledger Fulfil Handler does not correctly invalidate requests with an incorrect/non-existent FSP-ID in the FSPIOP-Destination header #2697 - mojaloop/project#2697
- TTK GP Tests for patch notifications - positive scenarios #2676
 - mojaloop/project#2676
mdebarros added a commit to mojaloop/helm that referenced this issue Feb 28, 2022
- ml-api-adapter upgraded to v12.3.0
- central-ledger upgraded to v13.15.4
- ml-testing-toolkit backend upgraded to v14.0.4

These upgrades address the following issues (inc. updated changelog):
- Implement patch notification for failure scenarios (following v1.1 update) #2556 - mojaloop/project#2556
- Central-Ledger Fulfil Handler does not correctly invalidate requests with an incorrect/non-existent FSP-ID in the FSPIOP-Destination header #2697 - mojaloop/project#2697
- TTK GP Tests for patch notifications - positive scenarios #2676 - mojaloop/project#2676
@elnyry-sam-k elnyry-sam-k modified the milestones: Sprint 17.1, Sprint 17.2 Feb 28, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
oss-core This is an issue - story or epic related to a feature on a Mojaloop core service or related to it story
Projects
None yet
Development

No branches or pull requests

3 participants