> ## Documentation Index
> Fetch the complete documentation index at: https://docs.sagescreen.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Deal payment callback (Zapier)

> Called by Zapier when payment is confirmed on an invoiced deal.
When `paid` is true the deal transitions through `ss_paid` to `ss_closed`,
provisions a council (new or existing), creates the admin user, and fires
the `deal_paid` webhook.

When `paid` is false, no action is taken and the response reflects the
current `ss_invoiced` status.

Requires the `X-API-Key` header.




## OpenAPI

````yaml /openapi/private/specs/wp/wp-webhooks.yml post /deal/payment
openapi: 3.1.0
info:
  title: >-
    SageScreen — Webhooks & CRM Integrations (Billing · Council · User · Deal ·
    Sage)
  version: 1.0.0
servers:
  - url: https://{domain}/wp-json/sagescreen/v1
    description: WordPress REST API
    variables:
      domain:
        default: api.sagescreen.app
security: []
tags:
  - name: Billing – Stripe
    description: Stripe webhook and subscription endpoints
  - name: Billing – Broadcast
    description: Postmark broadcast unsubscribe endpoint
  - name: Billing – Pipedrive
    description: Pipedrive CRM ID set-* webhook endpoints (called by Zapier)
  - name: Billing – AJAX
    description: Credit ledger, reactivation, and portal AJAX endpoints
  - name: Council – REST
    description: Zapier-facing REST endpoints for council data sync
  - name: Council – AJAX
    description: Council user and sage management AJAX endpoints
  - name: User – REST
    description: Zapier-facing REST endpoints
  - name: User – AJAX
    description: Council user management AJAX endpoints
  - name: User – Profile
    description: Self-service profile updates
  - name: Deal REST
    description: REST API endpoints authenticated via X-API-Key
  - name: Deal AJAX
    description: AJAX endpoints authenticated via WordPress nonce + capability check
  - name: Sage – REST
    description: REST API endpoints for sage operations and Python callbacks
  - name: Sage – CRUD
    description: AJAX endpoints for sage creation, editing, and status management
  - name: Sage – Build Workflow
    description: AJAX endpoints for the multi-step sage build process
paths:
  /deal/payment:
    post:
      tags:
        - Deal REST
      summary: Deal payment callback (Zapier)
      description: >
        Called by Zapier when payment is confirmed on an invoiced deal.

        When `paid` is true the deal transitions through `ss_paid` to
        `ss_closed`,

        provisions a council (new or existing), creates the admin user, and
        fires

        the `deal_paid` webhook.


        When `paid` is false, no action is taken and the response reflects the

        current `ss_invoiced` status.


        Requires the `X-API-Key` header.
      operationId: dealPayment
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/DealPaymentRequest'
            examples:
              paid:
                summary: Payment confirmed
                value:
                  deal_uuid: 3d55ae7a-af8b-46c1-ae1c-09afa207ac7f
                  paid: true
                  external_invoice_id: INV-00589
                  payment_date: '2026-02-19 14:30:00'
              notPaid:
                summary: Payment not yet received
                value:
                  deal_uuid: 3d55ae7a-af8b-46c1-ae1c-09afa207ac7f
                  paid: false
      responses:
        '200':
          description: Payment processed (or no-op if paid=false)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/DealPaymentResponse'
              examples:
                paid:
                  summary: Payment processed, council provisioned
                  value:
                    success: true
                    data:
                      deal_id: 1042
                      status: ss_closed
                      council_id: a1b2c3d4-e5f6-7890-abcd-ef1234567890
                      user_id: 42
                noop:
                  summary: paid=false, no action taken
                  value:
                    success: true
                    data:
                      deal_id: 1042
                      status: ss_invoiced
                      note: paid=false, no action taken
        '400':
          description: Bad request — missing UUID
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/DealPublicWPError'
              example:
                code: missing_uuid
                message: deal_uuid is required
                data:
                  status: 400
        '401':
          description: Missing or invalid API key
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/DealPublicWPError'
              example:
                code: invalid_api_key
                message: Invalid or missing API key
                data:
                  status: 401
        '404':
          description: Deal not found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/DealPublicWPError'
              example:
                code: deal_not_found
                message: Deal not found
                data:
                  status: 404
        '409':
          description: Deal is not in the expected status
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/DealPublicWPError'
              example:
                code: invalid_status
                message: 'Deal is not invoiced (current: ss_approved)'
                data:
                  status: 409
        '500':
          description: API key not configured
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/DealPublicWPError'
              example:
                code: key_not_configured
                message: API key not configured on server
                data:
                  status: 500
      security:
        - apiKey: []
components:
  schemas:
    DealPaymentRequest:
      type: object
      required:
        - deal_uuid
      properties:
        deal_uuid:
          type: string
          format: uuid
          examples:
            - 3d55ae7a-af8b-46c1-ae1c-09afa207ac7f
        paid:
          type: boolean
          description: true to confirm payment, false for no-op
          examples:
            - true
        external_invoice_id:
          type: string
          description: Stripe invoice reference
          examples:
            - INV-00589
        payment_date:
          type: string
          description: Payment date (MySQL datetime). Defaults to current time if omitted.
          examples:
            - '2026-02-19 14:30:00'
    DealPaymentResponse:
      type: object
      properties:
        success:
          type: boolean
          const: true
        data:
          type: object
          properties:
            deal_id:
              type: integer
              examples:
                - 1042
            status:
              type: string
              description: New deal status (ss_closed or ss_invoiced)
              examples:
                - ss_closed
            council_id:
              type:
                - string
                - 'null'
              description: Council UUID (present when provisioned)
              examples:
                - a1b2c3d4-e5f6-7890-abcd-ef1234567890
            user_id:
              type:
                - integer
                - 'null'
              description: WordPress user ID of created/linked admin user
              examples:
                - 42
            note:
              type: string
              description: Present when paid=false
              examples:
                - paid=false, no action taken
    DealPublicWPError:
      type: object
      description: Standard WordPress REST API error envelope
      required:
        - code
        - message
        - data
      properties:
        code:
          type: string
          description: Machine-readable error code
          examples:
            - deal_not_found
        message:
          type: string
          description: Human-readable error message
          examples:
            - Deal not found
        data:
          type: object
          required:
            - status
          properties:
            status:
              type: integer
              description: HTTP status code
              examples:
                - 404
  securitySchemes:
    apiKey:
      type: apiKey
      in: header
      name: X-API-Key
      description: SageScreen API key stored in `ss_zapier_api_key` option

````