Skip to content

CORE-2783: Add outcome and cardDecisionSource mapping to DTOs and models#3

Merged
henriquesalvaro merged 1 commit into
masterfrom
henriquesalvarofurtado/core-2783-update-unit-sdk-to-include-outcome-and-carddecisionsource
Jun 1, 2026
Merged

CORE-2783: Add outcome and cardDecisionSource mapping to DTOs and models#3
henriquesalvaro merged 1 commit into
masterfrom
henriquesalvarofurtado/core-2783-update-unit-sdk-to-include-outcome-and-carddecisionsource

Conversation

@henriquesalvaro
Copy link
Copy Markdown
Collaborator

@henriquesalvaro henriquesalvaro commented Jun 1, 2026

Description of PR and Why

Unit is adding new fields to help understanding the decisions behind an authorization being approved or declined, their SDK isn't updated very frequently, and we use it in a lot of places in our codebase.

More info on their docs: Understanding Authorization Decisions, and on this slack announcement.

This PR just adds the outcome and card_decision_source to the proper authorization request / authorization / transaction DTOs and models.

Risks and Impacted Systems

No risk, I'll bump the unit version on a benefitsapi PR where we start tracking those fields.

Related Links


Note

Low Risk
Additive optional JSON:API field mapping with no behavior changes; risk is limited to consumers assuming new attributes are always present.

Overview
Adds Unit API fields that explain card authorization decisions: outcome on authorization-request DTOs and cardDecisionSource on authorization and card-related transaction DTOs.

BaseAuthorizationRequest now maps optional outcome (Approved, Declined, PostTimeout, etc.). AuthorizationDTO gains cardDecisionSource with a typed literal (Org, Unit, IssuerStandIn, timeout defaults, etc.). Purchase, ATM, and card transaction DTOs expose the same cardDecisionSource attribute from JSON:API.

E2e tests assert decoding for these fields across authorization requests, authorizations, and the three transaction types; purchase authorization request tests now fully decode and assert outcome.

Reviewed by Cursor Bugbot for commit 692f9fa. Bugbot is set up for automated code reviews on this repo. Configure here.

@linear-code
Copy link
Copy Markdown

linear-code Bot commented Jun 1, 2026

CORE-2783

Copy link
Copy Markdown

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 692f9fa. Configure here.

from unit.utils import date_utils

PurchaseAuthorizationRequestStatus = Literal["Pending", "Approved", "Declined"]
AuthorizationRequestOutcome = Literal["Approved", "Declined", "PostTimeout", "PostError", "WaitTimeout"]
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unused type alias AuthorizationRequestOutcome never referenced

Low Severity

AuthorizationRequestOutcome is defined as a Literal type alias but is never used in any type annotation. The outcome field in BaseAuthorizationRequest is stored via attributes.get("outcome") without referencing this type. Compare this with CardDecisionSource in authorization.py, which is actually used as a type hint for card_decision_source in AuthorizationDTO.__init__.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 692f9fa. Configure here.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that is also true for the PurchaseAuthorizationRequestStatus 🤷 this is an SDK that can be imported by others, so those literals can be used by SDK users, just following w/e established pattern Unit defined. The AuthorizationRequest object is not handled the same way the authorization/transaction objects are.

@henriquesalvaro henriquesalvaro merged commit 270e1ea into master Jun 1, 2026
2 of 4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants