{"openapi":"3.1.0","info":{"title":"POST /api/v1/credit/payments","version":"1.0.0","description":"Record a payment"},"servers":[{"url":"https://api.ondayzero.com","description":"Production"}],"paths":{"/api/v1/credit/payments":{"post":{"tags":["credit"],"summary":"Record a payment","description":"Records a debit the partner executed and returns corrected balances. Allocation is not selectable: principal before accrued interest, earliest due date first. A payment can clear the full principal while interest remains outstanding — that cycle is not Paid, and the returned status is authoritative.","operationId":"record_payment_api_v1_credit_payments_post","parameters":[{"name":"authorization","in":"header","required":false,"schema":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Authorization"}},{"name":"x-business-id","in":"header","required":false,"schema":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"X-Business-Id"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/PaymentRecordRequest"}}}},"responses":{"201":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SuccessEnvelope_PaymentResponse_"}}}},"400":{"description":"Bad Request - Invalid input","content":{"application/json":{"example":{"detail":"Invalid request parameters"}}}},"401":{"description":"Unauthorized - Authentication required","content":{"application/json":{"example":{"detail":"Not authenticated"}}}},"403":{"description":"Forbidden - Insufficient permissions","content":{"application/json":{"example":{"detail":"Not enough permissions"}}}},"404":{"description":"Not Found - Resource does not exist","content":{"application/json":{"example":{"detail":"Resource not found"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}}},"components":{"schemas":{"CreditCycleResponse":{"properties":{"id":{"type":"string","title":"Id"},"status":{"$ref":"#/components/schemas/CycleStatusEnum"},"period_start":{"type":"string","format":"date","title":"Period Start"},"period_end":{"type":"string","format":"date","title":"Period End"},"closed_on":{"anyOf":[{"type":"string","format":"date"},{"type":"null"}],"title":"Closed On"},"statement_issued_on":{"anyOf":[{"type":"string","format":"date"},{"type":"null"}],"title":"Statement Issued On"},"due_date":{"anyOf":[{"type":"string","format":"date"},{"type":"null"}],"title":"Due Date"},"principal_cents":{"type":"integer","title":"Principal Cents"},"disbursement_fee_cents":{"type":"integer","title":"Disbursement Fee Cents"},"interest_cents":{"type":"integer","title":"Interest Cents"},"late_interest_cents":{"type":"integer","title":"Late Interest Cents","default":0},"late_fee_cents":{"type":"integer","title":"Late Fee Cents","default":0},"previous_balance_cents":{"type":"integer","title":"Previous Balance Cents","default":0},"draw_charges_cents":{"type":"integer","title":"Draw Charges Cents","description":"Principal plus fee plus term interest, fixed at close.","default":0},"amount_due_cents":{"type":"integer","title":"Amount Due Cents","description":"Everything this cycle owes, late charges included."},"amount_paid_cents":{"type":"integer","title":"Amount Paid Cents"},"outstanding_cents":{"type":"integer","title":"Outstanding Cents"},"term_days":{"anyOf":[{"type":"integer"},{"type":"null"}],"title":"Term Days"},"rate_bps":{"anyOf":[{"type":"integer"},{"type":"null"}],"title":"Rate Bps"},"settlement_count":{"type":"integer","title":"Settlement Count","default":0}},"type":"object","required":["id","status","period_start","period_end","principal_cents","disbursement_fee_cents","interest_cents","amount_due_cents","amount_paid_cents","outstanding_cents"],"title":"CreditCycleResponse","description":"One cycle, open or closed (§7.2 cycle history row)."},"CycleStatusEnum":{"type":"string","enum":["open","closed","issued","paid","late","written_off"],"title":"CycleStatusEnum","description":"Cycle state per FRD §10.5.\n\n* ``open`` — collecting settlements; no draw exists yet. Merchant sees\n  activity but nothing is owed (this interval is the float).\n* ``closed`` — draw created; interest and fees computed. Statement pending.\n* ``issued`` — statement generated and available; amount due and due date shown.\n* ``paid`` — outstanding reduced to zero, *including* accrued interest.\n* ``late`` — past due date with an amount outstanding.\n* ``written_off`` — charged off per collections policy."},"HTTPValidationError":{"properties":{"detail":{"items":{"$ref":"#/components/schemas/ValidationError"},"type":"array","title":"Detail"}},"type":"object","title":"HTTPValidationError"},"PaymentAllocationResponse":{"properties":{"cycle_id":{"type":"string","title":"Cycle Id"},"principal_cents":{"type":"integer","title":"Principal Cents"},"fee_cents":{"type":"integer","title":"Fee Cents"},"interest_cents":{"type":"integer","title":"Interest Cents"}},"type":"object","required":["cycle_id","principal_cents","fee_cents","interest_cents"],"title":"PaymentAllocationResponse","description":"How one payment split across a cycle's components."},"PaymentRecordRequest":{"properties":{"credit_line_id":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Credit Line Id"},"external_line_id":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"External Line Id"},"external_payment_id":{"type":"string","maxLength":128,"title":"External Payment Id","description":"Partner payment ID. The idempotency key."},"amount_cents":{"type":"integer","exclusiveMinimum":0.0,"title":"Amount Cents"},"paid_on":{"type":"string","format":"date","title":"Paid On","description":"Date the merchant pressed Pay, not the date funds landed."},"method":{"anyOf":[{"type":"string","maxLength":64},{"type":"null"}],"title":"Method"}},"additionalProperties":false,"type":"object","required":["external_payment_id","amount_cents","paid_on"],"title":"PaymentRecordRequest","description":"Record a debit the partner executed (§14, call 8).\n\nDayZero never moves money (§10.6). This records what happened,\nallocates it, posts the accounting, and returns corrected balances."},"PaymentStatusEnum":{"type":"string","enum":["recorded","reversed"],"title":"PaymentStatusEnum","description":"Recording state of a payment.\n\nDayZero never moves money (FRD §10.6) — these describe what Tie has\nreported to us about a debit it executed through Payliance."},"SuccessEnvelope_PaymentResponse_":{"properties":{"success":{"type":"boolean","title":"Success","default":true},"message":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Message"},"code":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Code"},"data":{"anyOf":[{"$ref":"#/components/schemas/app__api__v1__schemas__credit_line__PaymentResponse"},{"type":"null"}]}},"additionalProperties":true,"type":"object","title":"SuccessEnvelope[PaymentResponse]"},"ValidationError":{"properties":{"loc":{"items":{"anyOf":[{"type":"string"},{"type":"integer"}]},"type":"array","title":"Location"},"msg":{"type":"string","title":"Message"},"type":{"type":"string","title":"Error Type"},"input":{"title":"Input"},"ctx":{"type":"object","title":"Context"}},"type":"object","required":["loc","msg","type"],"title":"ValidationError"},"app__api__v1__schemas__credit_line__PaymentResponse":{"properties":{"id":{"type":"string","title":"Id"},"credit_line_id":{"type":"string","title":"Credit Line Id"},"external_payment_id":{"type":"string","title":"External Payment Id"},"status":{"$ref":"#/components/schemas/PaymentStatusEnum"},"amount_cents":{"type":"integer","title":"Amount Cents"},"paid_on":{"type":"string","format":"date","title":"Paid On"},"method":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Method"},"reversed_on":{"anyOf":[{"type":"string","format":"date"},{"type":"null"}],"title":"Reversed On"},"reversal_reason":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Reversal Reason"},"allocations":{"items":{"$ref":"#/components/schemas/PaymentAllocationResponse"},"type":"array","title":"Allocations"},"unapplied_cents":{"type":"integer","title":"Unapplied Cents","description":"Overpayment beyond everything outstanding. Disposition follows the program's excess-credit rule (§2.6).","default":0},"current_balance_cents":{"type":"integer","title":"Current Balance Cents","default":0},"affected_cycles":{"items":{"$ref":"#/components/schemas/CreditCycleResponse"},"type":"array","title":"Affected Cycles"}},"type":"object","required":["id","credit_line_id","external_payment_id","status","amount_cents","paid_on"],"title":"PaymentResponse","description":"Updated balances and cycle status after allocation."}},"securitySchemes":{"BearerAuth":{"type":"http","scheme":"bearer","bearerFormat":"API Token","description":"API token authentication. Format: `Bearer dz_...`"}}},"security":[{"BearerAuth":[]}]}