Skip to content

Commit

Permalink
(PC-34065)[API] fix: mark declined ubble checks as ko
Browse files Browse the repository at this point in the history
Our Ubble v1 flow marked declined checks as suspicious instead of ko.
This used to work because we always create a new identity verification
at every Ubble v1 attempt.

However, we reuse existing Ubble v2 identity verifications if they are
marked as suspicious. If the id verification is declined, Ubble v2
returns a 409 error. Therefore, we should not reuse declined Ubble v2
checks by marking them as KO instead of suspicious.
  • Loading branch information
dnguyen1-pass committed Jan 21, 2025
1 parent ef4195d commit 01a431d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
8 changes: 4 additions & 4 deletions api/src/pcapi/core/fraud/ubble/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,11 @@ def _ubble_result_fraud_item_using_status(
if id_provider_detected_eligibility:
return fraud_models.FraudItem(status=fraud_models.FraudStatus.OK, detail=detail, reason_codes=[])
return _ubble_not_eligible_fraud_item(user, content)
case (
ubble_serializers.UbbleIdentificationStatus.RETRY_REQUIRED
| ubble_serializers.UbbleIdentificationStatus.DECLINED
):
case ubble_serializers.UbbleIdentificationStatus.RETRY_REQUIRED:
status = fraud_models.FraudStatus.SUSPICIOUS
case ubble_serializers.UbbleIdentificationStatus.DECLINED:
status = fraud_models.FraudStatus.KO

case _:
raise ValueError(f"unhandled Ubble status {content.status} for identification {content.identification_id}")

Expand Down
2 changes: 1 addition & 1 deletion api/tests/core/subscription/ubble/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ def test_ubble_identification_declined(self, requests_mock):

ubble_content = fraud_check.resultContent
assert ubble_content["status"] == ubble_serializers.UbbleIdentificationStatus.DECLINED.value
assert fraud_check.status == fraud_models.FraudCheckStatus.SUSPICIOUS
assert fraud_check.status == fraud_models.FraudCheckStatus.KO
assert fraud_check.reasonCodes == [fraud_models.FraudReasonCode.ID_CHECK_DATA_MATCH]
assert "Ubble DECLINED" in fraud_check.reason

Expand Down

0 comments on commit 01a431d

Please sign in to comment.