#808 — Retrieve and Map EMS Deal Status in map_deal_to_merchant_ems

Repo: Twill-AI/facade State: closed | Status: done Assignee: meliascosta, nadddder

Created: 2025-12-04 · Updated: 2025-12-26

Description

When an EMS application (deal) is created, we don’t have a MID and must periodically check the deal status via map_deal_to_merchant_ems. Currently, this function only retrieves the MID. We also need to retrieve and store the deal status. The EMS API returns a Status field with the following possible values: ‘Unprocessed’ ‘Out for e-Sig’ ‘e-Sig Declined’ ‘UDW Under Review’ ‘UDW Final Review’ ‘Bank Review’ ‘Canceled’ ‘Rejected/Declined’ (when rejected, the status includes the reject reason: ‘Rejected - Reject Reason’) ‘Pushback’ ‘Held’ ‘Approved’ (when boarded, the underwriting status is returned)

Acceptance Criteria

  • Status Retrieval: Modify map_deal_to_merchant_ems in app/integrations/ems/helpers.py to extract and store the Status field from the get_deal_status response. Store the status in the appropriate merchant field (e.g., external_status or status_message).
  • Status Mapping: Update the mapping logic in app/integrations/ems/mappings.py to handle the new deal status values. Ensure the calculate_merchant_status_from_ems function (or a new function if needed) properly maps these deal statuses to the internal MerchantStatus enum, accounting for special cases like rejected deals (which include reject reasons) and approved deals (which may include underwriting status).

Notes

Add implementation notes, blockers, and context here

Add wikilinks to related people, meetings, or other tickets