openapi: 3.0.1
info:
  title: Elevate Payment and Refund API
  description: >
    ### Payment Management

    Provides read & write access to payment entities.


    #### Definitions

    * PaymentProvider - a representation of a system that Elevate will
    interoperate with to collect payments, e.g. Go Cardless 

    * SitePaymentMandate - a token from the payment provider that gives
    authority to take a direct debit from a bank account 

    * InvoicePayment - a single payment for an invoice that has happened
    externally or passed to a payment provider to collect funds

    * AdhocInvoicePayment - a single payment for an adhoc invoice that has
    happened externally or passed to a payment provider to collect funds

    * Refund - the funds returned to the customer that have previously been
    collected

    * CustomerPayments - a single payment to an invoice or customer outstanding
    balance

    * CustomerOutstandingBalance - the amount a customer is in debt (if
    negative) or has in credit (if positive)

    * CustomerCreditStatus - returns a customer balance versus their credit
    threshold

    * PaymentProviderPaymentLink - An external hyperlink that allows a customer
    to pay for an invoice or any amount towards the customer balance
  version: '1.37'
servers:
  - url: https://rest.elevatebilling.com/v1
tags:
  - name: payment-providers
    description: >-
      A representation of a system that Elevate will interoperate with to
      collect payments, e.g. Go Cardless or Finastra
  - name: invoice-payments
    description: >-
      An event related to a normal invoice payment (For example a manual
      payment, a successful submission to a third party payment provider, or an
      update received back)
  - name: adhoc-invoice-payments
    description: >-
      An event related to an adhoc invoice payment (For example a manual
      payment, a successful submission to a third party payment provider, or a
      status update received back)
  - name: refunds
    description: >-
      Refunds represent the funds returned to the customer that have previously
      been collected. If the payment method is left blank or the invoice is auto
      collected, then same payment method of the last successful payment will be
      used
  - name: site-payment-mandates
    description: >-
      A token from the payment provider that gives authority to take a direct
      debit from a bank account
  - name: payment-provider-mandates
    description: Mandate details from the payment provider
  - name: customer-payments
    description: >-
      A payment against a customer. The amount will be used to pay off any
      unpaid invoices starting from the oldest first. Overpayments will be added
      to the customer-balance
  - name: customer-balances
    description: >-
      The customer's outstanding balance. Negative means a debt, Positive means
      they have credit
  - name: customer-credit-status
    description: >-
      The customer's credit status - returns current balance versus their credit
      threshold
  - name: payment-provider-payment-link
    description: >-
      An external hyperlink that allows a customer to pay for a normal/adhoc
      invoice or towards the customer balance
  - name: payment-provider-reprocess
    description: >-
      Synchronise Elevate payment statuses by reprocessing payment provider
      events
  - name: invoice-payment-reprocess
    description: Reprocess a normal or adhoc invoice payment
  - name: invoice-payment-cancel
    description: Cancel a pending payment collection
  - name: instant-bank-payment-for-mandate
    description: >-
      An instant first payment—typically made via Instant Bank Payment—processed
      as part of the mandate creation flow. Currently supported only when using
      the GoCardless payment provider
paths:
  /instant-bank-payment-for-mandate:
    get:
      tags:
        - instant-bank-payment-for-mandate
      summary: Get the instant bank payment for a mandate
      operationId: getInstantBankPaymentForMandate
      x-si-permissions:
        - VIEW_CUSTOMER
      security:
        - bearerAuth: []
      parameters:
        - name: mandateReference
          in: query
          description: Mandate reference
          required: true
          schema:
            type: string
            minLength: 0
            maxLength: 255
            pattern: '[\w\p{L}\s%£@&#='':;`’,|!_—–\(\)\\/\-\+\.\?\*\$]*'
        - name: paymentMethod
          in: query
          description: Payment Method
          required: true
          schema:
            $ref: '#/components/schemas/PaymentMethod'
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/InstantBankPayment'
        '400':
          description: Bad Request
          content: {}
        '401':
          description: Unauthorized
          content: {}
        '403':
          description: Forbidden
          content: {}
  /customer-balances:
    get:
      tags:
        - customer-balances
      summary: Get the outstanding balance for a customer
      operationId: getCustomerBalance
      x-si-permissions:
        - VIEW_CUSTOMER
      security:
        - bearerAuth: []
      parameters:
        - name: customer_id
          in: query
          description: Customer identifier
          required: true
          schema:
            $ref: '#/components/schemas/IdParam'
      responses:
        '200':
          description: Customer outstanding balance found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CustomerOutstandingBalance'
        '400':
          description: Bad Request
          content: {}
        '401':
          description: Unauthorized
          content: {}
        '403':
          description: Forbidden
          content: {}
  /customer-balance-adjustments:
    post:
      tags:
        - customer-balances
      summary: Make a manual adjustment to a customer's outstanding balance
      operationId: createCustomerBalanceAdjustment
      x-si-permissions:
        - UPDATE_CUSTOMER
      security:
        - bearerAuth: []
      requestBody:
        description: New customer balance adjustment
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CustomerBalanceAdjustment'
        required: true
      responses:
        '200':
          description: Customer balance adjusted
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CustomerBalanceAdjustment'
        '400':
          description: Bad Request
          content: {}
        '401':
          description: Unauthorized
          content: {}
        '403':
          description: Forbidden
          content: {}
  /customer-payments:
    get:
      tags:
        - customer-payments
      summary: Get a list of customer or invoice payments
      operationId: getCustomerPayments
      x-si-permissions:
        - VIEW_CUSTOMER_PAYMENTS
      security:
        - bearerAuth: []
      x-si-filterable: true
      parameters:
        - name: customer_id
          in: query
          description: Customer identifier
          required: true
          schema:
            $ref: '#/components/schemas/IdParam'
        - $ref: '#/components/parameters/page'
        - $ref: '#/components/parameters/pageSize'
        - $ref: '#/components/parameters/sort'
        - $ref: '#/components/parameters/fields'
        - name: filter
          in: query
          description: Filter by text
          schema:
            $ref: '#/components/schemas/StringFilterParam'
          required: false
        - name: customerPaymentType
          in: query
          description: Filter by customer payment type
          schema:
            $ref: '#/components/schemas/StringFilterParam'
          required: false
        - name: excludeDebits
          in: query
          description: Filter out negative payments
          schema:
            $ref: '#/components/schemas/StringFilterParam'
          required: false
        - name: excludeCredits
          in: query
          description: Filter out zero and positive payments
          schema:
            $ref: '#/components/schemas/StringFilterParam'
          required: false
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/CustomerPayment'
        '400':
          description: Bad Request
          content: {}
        '401':
          description: Unauthorized
          content: {}
        '403':
          description: Forbidden
          content: {}
    post:
      tags:
        - customer-payments
      summary: Create a new customer payment
      description: >-
        Create a new customer payment to be disbursed to invoices and/or
        customer's outstanding balance
      operationId: createCustomerPayment
      x-si-permissions:
        - CREATE_CUSTOMER_PAYMENTS
      security:
        - bearerAuth: []
      requestBody:
        description: New customer payment
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CustomerPayment'
        required: true
      responses:
        '200':
          description: Customer payment created
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CustomerPayment'
        '400':
          description: Bad Request
          content: {}
        '401':
          description: Unauthorized
          content: {}
        '403':
          description: Forbidden
          content: {}
  /customer-payments/{customer_payment_id}:
    get:
      tags:
        - customer-payments
      summary: Get a specific customer payment
      operationId: getCustomerPayment
      x-si-permissions:
        - VIEW_CUSTOMER_PAYMENTS
      security:
        - bearerAuth: []
      parameters:
        - name: customer_payment_id
          in: path
          description: Customer payment identifier
          required: true
          schema:
            $ref: '#/components/schemas/IdParam'
      responses:
        '200':
          description: Payment provider found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CustomerPayment'
        '400':
          description: Bad Request
          content: {}
        '401':
          description: Unauthorized
          content: {}
        '403':
          description: Forbidden
          content: {}
        '404':
          description: Not Found
          content: {}
  /payment-providers:
    get:
      tags:
        - payment-providers
      summary: Get a list of payment providers
      operationId: getPaymentProviders
      x-si-permissions:
        - VIEW_PAYMENT_PROVIDER
      security:
        - bearerAuth: []
      x-si-filterable: true
      parameters:
        - $ref: '#/components/parameters/page'
        - $ref: '#/components/parameters/pageSize'
        - $ref: '#/components/parameters/sort'
        - $ref: '#/components/parameters/fields'
        - name: type
          in: query
          description: Filter by payment type
          schema:
            $ref: '#/components/schemas/StringFilterParam'
          required: false
        - name: contractOwnerId
          in: query
          description: Filter by contract owner id
          schema:
            $ref: '#/components/schemas/IdParam'
          required: false
        - name: instantBankPayments
          in: query
          description: Filter by those payment providers that support instant bank payments
          schema:
            $ref: '#/components/schemas/BooleanFilterParam'
          required: false
        - name: retryIfPossible
          in: query
          description: Filter by those payment provider's retryIfPossible flag
          schema:
            $ref: '#/components/schemas/BooleanFilterParam'
          required: false
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/PaymentProvider'
        '400':
          description: Bad Request
          content: {}
        '401':
          description: Unauthorized
          content: {}
        '403':
          description: Forbidden
          content: {}
    post:
      tags:
        - payment-providers
      summary: Create a payment provider
      operationId: createPaymentProvider
      x-si-permissions:
        - CREATE_PAYMENT_PROVIDER
      security:
        - bearerAuth: []
      requestBody:
        description: New payment provider
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/PaymentProvider'
        required: true
      responses:
        '200':
          description: Payment provider created
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PaymentProvider'
        '201':
          description: Created
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/PaymentProvider'
        '400':
          description: Bad Request
          content: {}
        '401':
          description: Unauthorized
          content: {}
        '403':
          description: Forbidden
          content: {}
  /payment-providers/{payment_provider_id}:
    get:
      tags:
        - payment-providers
      summary: Get a specific payment provider
      operationId: getPaymentProvider
      x-si-permissions:
        - VIEW_PAYMENT_PROVIDER
      security:
        - bearerAuth: []
      parameters:
        - name: payment_provider_id
          in: path
          description: Payment provider identifier
          required: true
          schema:
            $ref: '#/components/schemas/IdParam'
      responses:
        '200':
          description: Payment provider found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PaymentProvider'
        '400':
          description: Bad Request
          content: {}
        '401':
          description: Unauthorized
          content: {}
        '403':
          description: Forbidden
          content: {}
        '404':
          description: Not Found
          content: {}
    patch:
      tags:
        - payment-providers
      summary: Update the payment provider
      operationId: updatePaymentProvider
      x-si-json-patch: true
      x-si-allow-patch:
        - /name
        - /type
        - /status
        - /instantBankPayments
        - /retryIfPossible
        - /acceptExternalPayments
        - /syncInstantBankPaymentsWithMandateCreation
        - /contractOwnerIds/.*
      x-si-permissions:
        - UPDATE_PAYMENT_PROVIDER
      security:
        - bearerAuth: []
      parameters:
        - name: payment_provider_id
          in: path
          description: Payment provider identifier
          required: true
          schema:
            $ref: '#/components/schemas/IdParam'
      requestBody:
        description: A set of JSONPatch operations to be performed
        content:
          application/json-patch+json:
            schema:
              $ref: '#/components/schemas/PatchRequest'
            examples:
              Rename:
                value:
                  - op: replace
                    path: /name
                    value: My Payment Provider
              UpdateFlags:
                value:
                  - op: replace
                    path: /retryIfPossible
                    value: 'false'
        required: true
      responses:
        '200':
          description: Success
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PaymentProvider'
        '400':
          description: Invalid Request
          content: {}
        '401':
          description: Unauthorized
          content: {}
        '403':
          description: Forbidden
          content: {}
        '404':
          description: Not Found
          content: {}
  /site-payment-mandates:
    get:
      tags:
        - site-payment-mandates
      summary: Get a list of site payment mandates
      operationId: getSitePaymentMandates
      x-si-permissions:
        - VIEW_SITE
      security:
        - bearerAuth: []
      x-si-filterable: true
      parameters:
        - $ref: '#/components/parameters/page'
        - $ref: '#/components/parameters/pageSize'
        - $ref: '#/components/parameters/sort'
        - $ref: '#/components/parameters/fields'
        - name: siteId
          in: query
          description: Filter by site id
          schema:
            $ref: '#/components/schemas/IdParam'
          required: false
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/SitePaymentMandate'
        '400':
          description: Bad Request
          content: {}
        '401':
          description: Unauthorized
          content: {}
        '403':
          description: Forbidden
          content: {}
    post:
      tags:
        - site-payment-mandates
      summary: Create a new site payment mandate
      operationId: createSitePaymentMandate
      x-si-permissions:
        - CREATE_SITE_MANDATE
      security:
        - bearerAuth: []
      requestBody:
        description: New site payment mandate
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/SitePaymentMandate'
        required: true
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SitePaymentMandate'
        '201':
          description: Created
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SitePaymentMandate'
        '400':
          description: Bad Request
          content: {}
        '401':
          description: Unauthorized
          content: {}
        '403':
          description: Forbidden
          content: {}
  /invoice-payments:
    get:
      tags:
        - invoice-payments
      summary: Get a list of available invoice payment events
      operationId: getInvoicePayments
      x-si-permissions:
        - VIEW_SITE
      security:
        - bearerAuth: []
      x-si-filterable: true
      parameters:
        - $ref: '#/components/parameters/page'
        - $ref: '#/components/parameters/pageSize'
        - $ref: '#/components/parameters/sort'
        - $ref: '#/components/parameters/fields'
        - name: billRunId
          in: query
          description: Filter by bill run id
          schema:
            $ref: '#/components/schemas/StringFilterParam'
          required: false
        - name: customerPaymentType
          in: query
          description: Filter by customer payment type
          schema:
            $ref: '#/components/schemas/StringFilterParam'
          required: false
        - name: customerPaymentId
          in: query
          description: Customer payment id
          required: false
          schema:
            $ref: '#/components/schemas/IdFilterParam'
        - name: generatedInvoiceId
          in: query
          description: Invoice id
          required: false
          schema:
            $ref: '#/components/schemas/IdFilterParam'
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/InvoicePayment'
        '400':
          description: Bad Request
          content: {}
        '401':
          description: Unauthorized
          content: {}
        '403':
          description: Forbidden
          content: {}
    post:
      tags:
        - invoice-payments
      summary: Create a new invoice payment
      operationId: createInvoicePayment
      x-si-permissions:
        - UPDATE_CUSTOMER
      security:
        - bearerAuth: []
      requestBody:
        description: New invoice payment
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/InvoicePayment'
        required: true
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/InvoicePayment'
        '201':
          description: Created
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/InvoicePayment'
        '400':
          description: Bad Request
          content: {}
        '401':
          description: Unauthorized
          content: {}
        '403':
          description: Forbidden
          content: {}
  /invoice-payment-cancel:
    post:
      tags:
        - invoice-payment-cancel
      summary: Cancel an invoice payment
      operationId: cancelInvoicePayment
      security:
        - bearerAuth: []
      x-si-permissions:
        - CREATE_REPORTING_INVOICES
      requestBody:
        description: Cancel a pending invoice payment
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CancelPaymentRequest'
        required: true
      responses:
        '202':
          description: Accepted
          content: {}
        '400':
          description: Bad Request
          content: {}
        '401':
          description: Unauthorized
          content: {}
        '403':
          description: Forbidden
          content: {}
  /invoice-payment-reprocess:
    post:
      tags:
        - invoice-payment-reprocess
      summary: Reprocess an invoice payment
      operationId: reprocessInvoicePayment
      x-si-permissions:
        - CREATE_REPORTING_INVOICES
      security:
        - bearerAuth: []
      requestBody:
        description: Reprocess an invoice payment
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ReprocessPaymentRequest'
        required: true
      responses:
        '200':
          description: OK
          content: {}
        '400':
          description: Bad Request
          content: {}
        '401':
          description: Unauthorized
          content: {}
        '403':
          description: Forbidden
          content: {}
  /invoice-payments/{invoice_payment_id}:
    get:
      tags:
        - invoice-payments
      summary: Get a specific invoice payment event
      operationId: getInvoicePayment
      x-si-permissions:
        - VIEW_SITE
      security:
        - bearerAuth: []
      parameters:
        - name: invoice_payment_id
          in: path
          description: Invoice payment identifier
          required: true
          schema:
            $ref: '#/components/schemas/IdParam'
      responses:
        '200':
          description: Invoice payment found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/InvoicePayment'
        '400':
          description: Bad Request
          content: {}
        '401':
          description: Unauthorized
          content: {}
        '403':
          description: Forbidden
          content: {}
        '404':
          description: Not Found
          content: {}
  /adhoc-invoice-payments:
    get:
      tags:
        - adhoc-invoice-payments
      summary: Get a list of available adhoc invoice payments
      operationId: getAdhocInvoicePayments
      x-si-permissions:
        - VIEW_SITE
      security:
        - bearerAuth: []
      x-si-filterable: true
      parameters:
        - $ref: '#/components/parameters/page'
        - $ref: '#/components/parameters/pageSize'
        - $ref: '#/components/parameters/sort'
        - $ref: '#/components/parameters/fields'
        - name: adhocBillRunId
          in: query
          description: Filter by adhoc bill run id
          schema:
            $ref: '#/components/schemas/StringFilterParam'
          required: false
        - name: customerPaymentType
          in: query
          description: Filter by customer payment type
          schema:
            $ref: '#/components/schemas/StringFilterParam'
          required: false
        - name: customerPaymentId
          in: query
          description: Customer payment id
          required: false
          schema:
            $ref: '#/components/schemas/IdFilterParam'
        - name: generatedAdhocInvoiceId
          in: query
          description: Adhoc invoice id
          required: false
          schema:
            $ref: '#/components/schemas/IdFilterParam'
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/AdhocInvoicePayment'
        '400':
          description: Bad Request
          content: {}
        '401':
          description: Unauthorized
          content: {}
        '403':
          description: Forbidden
          content: {}
    post:
      tags:
        - adhoc-invoice-payments
      summary: Create a new adhoc invoice payment
      operationId: createAdhocInvoicePayment
      x-si-permissions:
        - UPDATE_CUSTOMER
      security:
        - bearerAuth: []
      requestBody:
        description: New invoice payment
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/AdhocInvoicePayment'
        required: true
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AdhocInvoicePayment'
        '201':
          description: Created
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AdhocInvoicePayment'
        '400':
          description: Bad Request
          content: {}
        '401':
          description: Unauthorized
          content: {}
        '403':
          description: Forbidden
          content: {}
  /adhoc-invoice-payments/{adhoc_invoice_payment_id}:
    get:
      tags:
        - adhoc-invoice-payments
      summary: Get a specific adhoc invoice payment
      operationId: getAdhocInvoicePayment
      x-si-permissions:
        - VIEW_SITE
      security:
        - bearerAuth: []
      parameters:
        - name: adhoc_invoice_payment_id
          in: path
          description: Invoice payment identifier
          required: true
          schema:
            $ref: '#/components/schemas/IdParam'
      responses:
        '200':
          description: Adhoc Invoice payment found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AdhocInvoicePayment'
        '400':
          description: Bad Request
          content: {}
        '401':
          description: Unauthorized
          content: {}
        '403':
          description: Forbidden
          content: {}
        '404':
          description: Not Found
          content: {}
  /payment-provider-mandates/{paymentMethod}/{mandateReference}:
    get:
      tags:
        - payment-provider-mandates
      summary: Get details of a mandate
      description: Get details of a mandate for a given payment provider
      operationId: getPaymentProviderMandate
      x-si-permissions:
        - VIEW_SITE
      security:
        - bearerAuth: []
      parameters:
        - name: paymentMethod
          in: path
          description: Payment Method
          required: true
          schema:
            $ref: '#/components/schemas/PaymentMethod'
        - name: mandateReference
          in: path
          description: Mandate reference
          required: true
          schema:
            type: string
            minLength: 0
            maxLength: 255
            pattern: '[\w\p{L}\s%£@&#='':;`’,|!_—–\(\)\\/\-\+\.\?\*\$]*'
        - name: thirdPartyCustomerReference
          in: query
          description: >-
            Reference to a customer in a third party system. For example, Stripe
            Customer ID (mandatory if a Stripe mandate is provided), or optional
            references like GO_CARDLESS Customer Reference or FINASTRA Account
            Number
          required: false
          schema:
            type: string
            minLength: 0
            maxLength: 100
            pattern: '[\w\p{L}\s%£@&#='':;`’,|!_—–\(\)\\/\-\+\.\?\*\$]*'
        - name: contractOwnerId
          in: query
          description: Filter by contract owner id
          schema:
            $ref: '#/components/schemas/IdParam'
          required: false
      responses:
        '200':
          description: Payment provider mandate
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PaymentProviderMandate'
        '400':
          description: Bad Request
          content: {}
        '401':
          description: Unauthorized
          content: {}
        '403':
          description: Forbidden
          content: {}
        '404':
          description: Not Found
          content: {}
  /refunds:
    get:
      tags:
        - refunds
      summary: Get a list of refunds
      operationId: getRefunds
      x-si-permissions:
        - VIEW_CUSTOMER_PAYMENTS
      security:
        - bearerAuth: []
      x-si-filterable: true
      parameters:
        - name: customerId
          in: query
          description: Customer identifier
          required: false
          schema:
            $ref: '#/components/schemas/IdParam'
        - name: invoiceId
          in: query
          description: Invoice identifier
          required: false
          schema:
            $ref: '#/components/schemas/IdParam'
        - name: billRunType
          in: query
          description: Bill Run Type
          required: false
          schema:
            $ref: '#/components/schemas/BillRunType'
        - $ref: '#/components/parameters/page'
        - $ref: '#/components/parameters/pageSize'
        - $ref: '#/components/parameters/sort'
        - $ref: '#/components/parameters/fields'
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/Refund'
        '400':
          description: Bad Request
          content: {}
        '401':
          description: Unauthorized
          content: {}
        '403':
          description: Forbidden
          content: {}
    post:
      tags:
        - refunds
      summary: Trigger a refund for an invoice or an adhoc invoice payment
      operationId: createRefund
      x-si-permissions:
        - UPDATE_SITE
      security:
        - bearerAuth: []
      requestBody:
        description: Create a refund for an invoice
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/Refund'
        required: true
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Refund'
        '201':
          description: Created
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Refund'
        '400':
          description: Bad Request
          content: {}
        '401':
          description: Unauthorized
          content: {}
        '403':
          description: Forbidden
          content: {}
  /customer-credit-status:
    get:
      tags:
        - customer-credit-status
      summary: Get a list of credit status threshold information
      description: >-
        Get a list of credit status threshold information for customers
        including customer balance and open bill values
      operationId: getCustomerCreditStatus
      x-si-permissions:
        - VIEW_CUSTOMER
      x-si-filterable: true
      security:
        - bearerAuth: []
      parameters:
        - $ref: '#/components/parameters/page'
        - $ref: '#/components/parameters/pageSize'
        - $ref: '#/components/parameters/sort'
        - $ref: '#/components/parameters/fields'
        - name: customerId
          in: query
          description: Filter by customer
          required: false
          schema:
            $ref: '#/components/schemas/IdFilterParam'
        - name: percentageDifference
          in: query
          description: Filter by percentageDifference
          required: false
          schema:
            $ref: '#/components/schemas/StringFilterParam'
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/CustomerCreditStatus'
        '400':
          description: Bad Request
          content: {}
        '401':
          description: Unauthorized
          content: {}
        '403':
          description: Forbidden
          content: {}
  /payment-provider-payment-link:
    post:
      tags:
        - payment-provider-payment-link
      summary: Create a new payment link
      description: Create a new payment link for an invoice, adhoc invoice or customer
      operationId: createPaymentProviderPaymentLink
      x-si-permissions:
        - CREATE_CUSTOMER_PAYMENTS
      security:
        - bearerAuth: []
      requestBody:
        description: New payment provider payment link
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/PaymentProviderPaymentLink'
        required: true
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PaymentProviderPaymentLink'
        '201':
          description: Created
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PaymentProviderPaymentLink'
        '400':
          description: Bad Request
          content: {}
        '401':
          description: Unauthorized
          content: {}
        '403':
          description: Forbidden
          content: {}
  /payment-provider-reprocess:
    post:
      tags:
        - payment-provider-reprocess
      summary: Synchronise Elevate payment statuses
      description: >-
        Synchronise Elevate payment statuses by reprocessing payment provider
        events
      operationId: paymentProviderReprocess
      x-si-permissions:
        - UPDATE_PAYMENT_PROVIDER
      security:
        - bearerAuth: []
      requestBody:
        description: Payment provider reprocess request
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/PaymentProviderReprocessRequest'
        required: true
      responses:
        '202':
          description: Accepted
          content: {}
        '400':
          description: Bad Request
          content: {}
        '401':
          description: Unauthorized
          content: {}
        '403':
          description: Forbidden
          content: {}
components:
  schemas:
    InstantBankPayment:
      required:
        - mandateReference
        - amountInMajorCurrency
        - description
        - paymentMethod
        - reference
        - when
      type: object
      properties:
        mandateReference:
          description: >-
            Mandate reference. If GO_CARDLESS, only accepted Created, Pending
            Submission, Submitted, Active, Reinstated, Customer approval granted
            and Customer approval skipped
          type: string
          minLength: 0
          maxLength: 255
          pattern: '[\w\p{L}\s%£@&#='':;`’,|!_—–\(\)\\/\-\+\.\?\*\$]*'
        amountInMajorCurrency:
          description: Amount in major currency (e.g pounds/dollars/euros)
          type: number
          example: 10.5
          minimum: 0.01
          maximum: 100000
        description:
          description: description of the payment
          type: string
          minLength: 0
          maxLength: 255
          pattern: '[\w\p{L}\s%£@&#='':;`’,|!_—–\(\)\\/\-\+\.\?\*\$]*'
        paymentMethod:
          $ref: '#/components/schemas/PaymentMethod'
        reference:
          description: unique reference for the payment from the payment provider
          type: string
          minLength: 0
          maxLength: 255
          pattern: '[\w\p{L}\s%£@&#='':;`’,|!_—–\(\)\\/\-\+\.\?\*\$]*'
        creationDate:
          readOnly: true
          description: when was the payment made
          type: string
          format: date-time
    PaymentProviderReprocessRequest:
      required:
        - paymentProviderId
      type: object
      properties:
        paymentProviderId:
          description: Payment provider identifier
          type: integer
          format: int64
          example: 0
        invoiceId:
          description: Invoice identifier - if provided, billRunType is also required
          type: integer
          format: int64
          example: 0
        billRunType:
          $ref: '#/components/schemas/BillRunType'
        externalEventReference:
          description: Event reference from external payment provider
          type: string
          minLength: 0
          maxLength: 255
          pattern: '[a-zA-Z0-9]*'
        externalPaymentReference:
          description: Payment reference from external payment provider
          type: string
          minLength: 0
          maxLength: 255
          pattern: '[a-zA-Z0-9]*'
    PaymentProviderPaymentLink:
      required:
        - paymentProviderId
        - amountInMajorCurrency
        - description
      type: object
      properties:
        id:
          description: Payment link identifier
          type: integer
          readOnly: true
          format: int64
          example: 1
        paymentProviderId:
          description: Payment provider identifier
          type: integer
          format: int32
          x-si-validation: '@ValidId'
          example: 1
        amountInMajorCurrency:
          description: Amount in major currency (e.g pounds/dollars/euros)
          type: number
          example: 10.5
          minimum: 0.01
          maximum: 100000
        currencyId:
          description: Currency Id
          readOnly: true
          type: integer
          format: int64
          x-si-validation: '@ValidId'
          example: 1
        description:
          description: Description of the payment
          type: string
        emailAddress:
          description: Customer email address
          type: string
        invoiceId:
          description: Invoice identifier, if payment is for an invoice
          type: integer
          format: int64
          x-si-validation: '@ValidId'
          example: 1
        adhocInvoiceId:
          description: adhoc invoice identifier, if payment is for an adhoc invoice
          type: integer
          format: int64
          x-si-validation: '@ValidId'
          example: 1
        customerId:
          description: Customer identifier, if payment is for a customer
          type: integer
          format: int64
          x-si-validation: '@ValidId'
          example: 1
        paymentLink:
          description: Generated instant payment link
          type: string
          minLength: 0
          maxLength: 255
          readOnly: true
          example: https://instantpaymentlink/exampleref
    CustomerPayment:
      required:
        - customerId
        - amountInMajorCurrency
        - currencyId
        - type
      type: object
      properties:
        id:
          description: Customer Payment identifier
          type: integer
          readOnly: true
          format: int64
          example: 1
        customerId:
          description: Customer identifier
          type: integer
          format: int32
          x-si-validation: '@ValidId'
          example: 1
        amountInMajorCurrency:
          description: Amount in major currency (e.g pounds/dollars/euros)
          type: number
          example: 10.5
          minimum: 0.01
          maximum: 9999999.99
        resultingCustomerBalance:
          description: >-
            customer balance after transaction has been applied in major
            currency (e.g pounds/dollars/euros)
          type: number
          readOnly: true
          example: 10.5
          minimum: 0.01
          maximum: 9999999.99
        currencyId:
          description: Currency Id
          readOnly: true
          type: integer
          format: int64
          x-si-validation: '@ValidId'
          example: 1
        description:
          description: Payment description
          type: string
          minLength: 0
          maxLength: 255
          pattern: '[\w\p{L}\s%£@&#='':;`’,|!_—–\(\)\\/\-\+\.\?\*\$]*'
        reference:
          description: Payment reference from third party payment system
          type: string
          minLength: 0
          maxLength: 255
          pattern: '[\w\p{L}\s%£@&#='':;`’,|!_—–\(\)\\/\-\+\.\?\*\$]*'
        type:
          $ref: '#/components/schemas/PaymentMethod'
        paymentDate:
          description: When payment was made
          readOnly: true
          type: string
          format: date
        customerPaymentType:
          $ref: '#/components/schemas/CustomerPaymentType'
        txnType:
          $ref: '#/components/schemas/TxnType'
        invoiceNumber:
          description: Invoice Number
          readOnly: true
          type: string
        invoiceId:
          description: Invoice identifier
          type: integer
          format: int64
          readOnly: true
          example: 0
        billRunType:
          $ref: '#/components/schemas/BillRunType'
    CustomerOutstandingBalance:
      required:
        - customerId
      type: object
      properties:
        id:
          description: Customer outstanding balance identifier
          type: integer
          readOnly: true
          format: int64
          example: 1
        customerId:
          description: Customer identifier
          type: integer
          format: int32
          x-si-validation: '@ValidId'
          example: 1
        balance:
          description: Outstanding balance
          type: number
        totalPayments:
          readOnly: true
          description: Sum of all payments against the customer
          type: number
        totalPaymentsSinceLastInvoice:
          readOnly: true
          description: Sum of all payments against the customer since the last invoice
          type: number
        paymentMethodSummary:
          $ref: '#/components/schemas/PaymentMethodSummary'
        repaymentPlanSummary:
          $ref: '#/components/schemas/RepaymentPlanSummary'
    RepaymentPlanSummary:
      required:
        - summaryType
      type: object
      description: >-
        Summary of customer's repayment plan. This is from a site that is
        'live', meaning has no end date, or end date is in the future.
      properties:
        repaymentPlanAmount:
          readOnly: true
          description: >-
            The repayment plan period amount in major currency (e.g
            pounds/dollars/euros)
          type: number
          format: decimal
          minimum: 1
          maximum: 100000
        repaymentPlanRemainingPeriods:
          readOnly: true
          description: The repayment plan remaining periods (typically in months)
          type: integer
          format: int64
          maximum: 240
          minimum: 0
          example: 0
        summaryType:
          $ref: '#/components/schemas/SummaryType'
    PaymentMethodSummary:
      required:
        - summaryType
      type: object
      description: >-
        Summary of customer's payment method. This is from a site that is
        'live', meaning has no end date, or end date is in the future.
      properties:
        paymentMethod:
          $ref: '#/components/schemas/PaymentMethod'
        summaryType:
          $ref: '#/components/schemas/SummaryType'
    SummaryType:
      description: Type of summary
      type: string
      readOnly: true
      enum:
        - NONE
        - SINGLE
        - MULTIPLE
    CustomerBalanceAdjustment:
      required:
        - customerId
        - amountInMajorCurrency
      type: object
      properties:
        id:
          description: Customer balance adjustment identifier
          type: integer
          readOnly: true
          format: int64
          example: 1
        customerId:
          description: Customer identifier
          type: integer
          format: int32
          x-si-validation: '@ValidId'
          example: 1
        amountInMajorCurrency:
          description: Amount in major currency (e.g pounds/dollars/euros)
          type: number
          example: 10.5
          minimum: -100000
          maximum: 100000
        currencyId:
          description: Currency Id
          type: integer
          readOnly: true
          format: int64
          x-si-validation: '@ValidId'
          example: 1
        description:
          description: Adjustment description
          type: string
          minLength: 0
          maxLength: 255
          pattern: '[\w\p{L}\s%£@&#='':;`’,|!_—–\(\)\\/\-\+\.\?\*\$]*'
    PaymentProviderMandate:
      required:
        - mandateReference
      type: object
      properties:
        mandateReference:
          description: >-
            Mandate reference. If GO_CARDLESS, only accepted Created, Pending
            Submission, Submitted, Active, Reinstated, Customer approval granted
            and Customer approval skipped
          type: string
          minLength: 0
          maxLength: 255
          pattern: '[\w\p{L}\s%£@&#='':;`’,|!_—–\(\)\\/\-\+\.\?\*\$]*'
        thirdPartyCustomerReference:
          description: >-
            Reference to a customer in a third party system. For example, Stripe
            Customer ID (mandatory if a Stripe mandate is provided), or optional
            references like GO_CARDLESS Customer Reference or FINASTRA Account
            Number
          type: string
          minLength: 0
          maxLength: 255
          pattern: '[\w\p{L}\s%£@&#='':;`’,|!_—–\(\)\\/\-\+\.\?\*\$]*'
        createdAt:
          description: Created at
          type: string
          minLength: 0
          maxLength: 255
          pattern: '[\w\p{L}\s%£@&#='':;`’,|!_—–\(\)\\/\-\+\.\?\*\$]*'
        emailAddress:
          description: Email address
          type: string
          minLength: 0
          maxLength: 255
          pattern: '[\w\p{L}\s%£@&#='':;`’,|!_—–\(\)\\/\-\+\.\?\*\$]*'
        firstName:
          description: First name
          type: string
          minLength: 0
          maxLength: 255
          pattern: '[\w\p{L}\s%£@&#='':;`’,|!_—–\(\)\\/\-\+\.\?\*\$]*'
        lastName:
          description: Last name
          type: string
          minLength: 0
          maxLength: 255
          pattern: '[\w\p{L}\s%£@&#='':;`’,|!_—–\(\)\\/\-\+\.\?\*\$]*'
        companyName:
          description: Company name
          type: string
          minLength: 0
          maxLength: 255
          pattern: '[\w\p{L}\s%£@&#='':;`’,|!_—–\(\)\\/\-\+\.\?\*\$]*'
        addressLine1:
          description: Address line 1
          type: string
          minLength: 0
          maxLength: 255
          pattern: '[\w\p{L}\s%£@&#='':;`’,|!_—–\(\)\\/\-\+\.\?\*\$]*'
        addressLine2:
          description: Address line 2
          type: string
          minLength: 0
          maxLength: 255
          pattern: '[\w\p{L}\s%£@&#='':;`’,|!_—–\(\)\\/\-\+\.\?\*\$]*'
        addressLine3:
          description: Address line 3
          type: string
          minLength: 0
          maxLength: 255
          pattern: '[\w\p{L}\s%£@&#='':;`’,|!_—–\(\)\\/\-\+\.\?\*\$]*'
        city:
          description: City
          type: string
          minLength: 0
          maxLength: 255
          pattern: '[\w\p{L}\s%£@&#='':;`’,|!_—–\(\)\\/\-\+\.\?\*\$]*'
        region:
          description: Region
          type: string
          minLength: 0
          maxLength: 255
          pattern: '[\w\p{L}\s%£@&#='':;`’,|!_—–\(\)\\/\-\+\.\?\*\$]*'
        postcode:
          description: Postcode
          type: string
          minLength: 0
          maxLength: 255
          pattern: '[\w\p{L}\s%£@&#='':;`’,|!_—–\(\)\\/\-\+\.\?\*\$]*'
        countryCode:
          description: Country code
          type: string
          minLength: 0
          maxLength: 255
          pattern: '[\w\p{L}\s%£@&#='':;`’,|!_—–\(\)\\/\-\+\.\?\*\$]*'
        telephoneNumber:
          description: Telephone number
          type: string
          minLength: 0
          maxLength: 255
          pattern: '[\w\p{L}\s%£@&#='':;`’,|!_—–\(\)\\/\-\+\.\?\*\$]*'
        status:
          $ref: '#/components/schemas/PaymentProviderMandateStatus'
    SitePaymentMandate:
      required:
        - siteId
        - returnURL
      type: object
      properties:
        id:
          description: Site payment mandate identifier
          type: integer
          readOnly: true
          format: int64
          example: 1
        redirectURL:
          description: URL to the site payment provider to give to end users
          type: string
          minLength: 0
          maxLength: 255
          pattern: '[\w\p{L}\s%£@&#='':;`’,|!_—–\(\)\\/\-\+\.\?\*\$]*'
        flowToken:
          $ref: '#/components/schemas/FlowToken'
        siteId:
          description: Site identifier
          type: integer
          format: int64
          example: 1
        returnURL:
          description: >-
            URL the payment provider will redirect the browser to at the end of
            their data collection process
          type: string
          minLength: 0
          maxLength: 255
          pattern: '[\w\p{L}\s%£@&#='':;`’,|!_—–\(\)\\/\-\+\.\?\*\$]*'
        mandateReference:
          description: >-
            Mandate reference. Required when the paymentType is an integrated
            one, for example GO_CARDLESS, FINASTRA or STRIPE. If GO_CARDLESS,
            only accepted Created, Pending Submission, Submitted, Active,
            Reinstated, Customer approval granted and Customer approval skipped
          type: string
          minLength: 0
          maxLength: 255
          readOnly: true
        thirdPartyCustomerReference:
          description: >-
            Reference to a customer in a third party system. For example, Stripe
            Customer ID (mandatory if a Stripe mandate is provided), or optional
            references like GO_CARDLESS Customer Reference or FINASTRA Account
            Number
          type: string
          minLength: 0
          maxLength: 255
          readOnly: true
        exitURL:
          description: URL to an alternative payment page when payment provider unavailable
          type: string
          minLength: 0
          maxLength: 255
          pattern: '[\w\p{L}\s%£@&#='':;`’,|!_—–\(\)\\/\-\+\.\?\*\$]*'
    PaymentProvider:
      required:
        - type
        - name
        - status
        - contractOwnerIds
      type: object
      properties:
        id:
          description: Payment Provider identifier
          type: integer
          readOnly: true
          format: int64
          example: 1
        type:
          $ref: '#/components/schemas/PaymentMethod'
        name:
          description: Payment provider name
          type: string
          minLength: 0
          maxLength: 255
          pattern: '[\w\p{L}\s%£@&#='':;`’,|!_—–\(\)\\/\-\+\.\?\*\$]*'
        directDebitWithName:
          description: Payment provider direct debit name
          type: string
          minLength: 0
          maxLength: 255
          pattern: '[\w\p{L}\s%£@&#='':;`’,|!_—–\(\)\\/\-\+\.\?\*\$]*'
        status:
          $ref: '#/components/schemas/PaymentProviderStatus'
        creditorIdentifier:
          description: Payment provider creditor identifier
          type: string
          minLength: 0
          maxLength: 255
          pattern: '[\w\p{L}\s%£@&#='':;`’,|!_—–\(\)\\/\-\+\.\?\*\$]*'
        instantBankPayments:
          description: Does this payment provider support instant bank payments
          type: boolean
          default: false
        retryIfPossible:
          description: Payment provider will retry the payment if possible
          type: boolean
          default: false
        acceptExternalPayments:
          description: >-
            Payment provider will accept payment events that originated outside
            of the system
          type: boolean
          default: false
        contractOwnerIds:
          description: Contract owner identifiers
          type: array
          items:
            type: integer
            format: int32
            x-si-validation: '@ValidId'
            example: 1
          minItems: 1
        syncInstantBankPaymentsWithMandateCreation:
          description: >-
            If a Go Cardless mandate is created as part of an instant bank
            payment billing flow, Elevate will automatically treat the instant
            payment as an upfront credit on the customer’s account
          type: boolean
          default: false
    InvoicePayment:
      required:
        - generatedInvoiceId
        - amountInMajorCurrency
        - description
        - paymentMethod
      type: object
      properties:
        id:
          description: Invoice Payment identifier
          type: integer
          readOnly: true
          format: int64
          example: 1
        generatedInvoiceId:
          description: Generated Invoice identifier
          type: integer
          format: int64
          example: 1
        thirdPartyPaymentStatus:
          $ref: '#/components/schemas/ThirdPartyPaymentStatus'
        amountInMajorCurrency:
          description: Amount in major currency (e.g pounds/dollars/euros)
          type: number
          example: 10.5
          minimum: -100000
          maximum: 100000
        currencyId:
          description: Currency Id
          readOnly: true
          type: integer
          format: int64
          x-si-validation: '@ValidId'
          example: 1
        description:
          description: Payment description
          type: string
          minLength: 0
          maxLength: 255
          pattern: '[\w\p{L}\s%£@&#='':;`’,|!_—–\(\)\\/\-\+\.\?\*\$]*'
        metaData:
          description: Meta data
          readOnly: true
          type: string
          minLength: 0
          maxLength: 255
          pattern: '[\w\p{L}\s%£@&#='':;`’,|!_—–\(\)\\/\-\+\.\?\*\$]*'
        errorInfo:
          description: Error information from payment provider
          readOnly: true
          type: string
          minLength: 0
          maxLength: 255
          pattern: '[\w\p{L}\s%£@&#='':;`’,|!_—–\(\)\\/\-\+\.\?\*\$]*'
        paymentMethod:
          $ref: '#/components/schemas/PaymentMethod'
        paymentDate:
          description: When payment was made
          readOnly: true
          type: string
          format: date
        customerPaymentType:
          $ref: '#/components/schemas/CustomerPaymentType'
        customerPaymentId:
          description: Customer payment id
          readOnly: true
          type: integer
          format: int64
          x-si-validation: '@ValidId'
          example: 1
    AdhocInvoicePayment:
      required:
        - generatedAdhocInvoiceId
        - amountInMajorCurrency
        - description
        - paymentMethod
      type: object
      properties:
        id:
          description: Invoice Payment identifier
          type: integer
          readOnly: true
          format: int64
          example: 1
        generatedAdhocInvoiceId:
          description: Generated Adhoc Invoice identifier
          type: integer
          format: int64
          example: 1
        thirdPartyPaymentStatus:
          $ref: '#/components/schemas/ThirdPartyPaymentStatus'
        amountInMajorCurrency:
          description: Amount in major currency (e.g pounds/dollars/euros)
          type: number
          example: 10.5
          minimum: -100000
          maximum: 100000
        currencyId:
          description: Currency Id
          readOnly: true
          type: integer
          format: int64
          x-si-validation: '@ValidId'
          example: 1
        description:
          description: Payment description
          type: string
          minLength: 0
          maxLength: 255
          pattern: '[\w\p{L}\s%£@&#='':;`’,|!_—–\(\)\\/\-\+\.\?\*\$]*'
        metaData:
          description: Meta data. Not applicable for manual payments
          readOnly: true
          type: string
          minLength: 0
          maxLength: 255
          pattern: '[\w\p{L}\s%£@&#='':;`’,|!_—–\(\)\\/\-\+\.\?\*\$]*'
        errorInfo:
          description: >-
            Error information from payment provider. Not applicable for manual
            payments
          readOnly: true
          type: string
          minLength: 0
          maxLength: 255
          pattern: '[\w\p{L}\s%£@&#='':;`’,|!_—–\(\)\\/\-\+\.\?\*\$]*'
        paymentMethod:
          $ref: '#/components/schemas/PaymentMethod'
        paymentDate:
          description: When payment was made
          readOnly: true
          type: string
          format: date
        customerPaymentType:
          $ref: '#/components/schemas/CustomerPaymentType'
        customerPaymentId:
          description: Customer payment id
          readOnly: true
          type: integer
          format: int64
          x-si-validation: '@ValidId'
          example: 1
    Refund:
      type: object
      properties:
        id:
          type: integer
          description: Refund identifier
          format: int64
          readOnly: true
          example: 1
        invoiceId:
          type: integer
          description: Invoice identifier
          format: int64
          example: 1
        customerId:
          type: integer
          description: Customer identifier
          format: int64
          readOnly: true
          example: 1
        billRunType:
          $ref: '#/components/schemas/BillRunType'
        thirdPartyRefundStatus:
          $ref: '#/components/schemas/ThirdPartyRefundStatus'
        description:
          description: Refund description
          type: string
          minLength: 0
          maxLength: 255
          pattern: '[\w\p{L}\s%£@&#='':;`’,|!_—–\(\)\\/\-\+\.\?\*\$]*'
        errorInfo:
          description: Error information from third party payment provider
          type: string
          readOnly: true
          minLength: 0
          maxLength: 255
          pattern: '[\w\p{L}\s%£@&#='':;`’,|!_—–\(\)\\/\-\+\.\?\*\$]*'
        paymentMethod:
          $ref: '#/components/schemas/PaymentMethod'
        amountInMajorCurrency:
          description: Amount to refund in major currency (e.g pounds/dollars/euros)
          type: number
          example: 10.5
          minimum: 0.01
          maximum: 100000
    CancelPaymentRequest:
      required:
        - billRunType
        - invoiceId
      type: object
      properties:
        invoiceId:
          type: integer
          description: Invoice identifier
          format: int64
          example: 0
        billRunType:
          $ref: '#/components/schemas/BillRunType'
        notes:
          maxLength: 255
          minLength: 0
          pattern: '[\w\p{L}\s%Â£@&#='':;`â€™,|!_â€”â€“\(\)\\/\-\+\.\?\*\$]*'
          type: string
          description: Reason for payment cancellation request
    ReprocessPaymentRequest:
      required:
        - invoiceId
        - billRunType
      type: object
      properties:
        invoiceId:
          description: Invoice identifier
          type: integer
          format: int64
          example: 0
        billRunType:
          $ref: '#/components/schemas/BillRunType'
        notes:
          description: Reason for payment reprocess request
          type: string
          minLength: 0
          maxLength: 255
          pattern: '[\w\p{L}\s%£@&#='':;`’,|!_—–\(\)\\/\-\+\.\?\*\$]*'
    ThirdPartyRefundStatus:
      description: Third party refund status
      type: string
      readOnly: true
      enum:
        - CREATED
        - PENDING_SUBMISSION
        - SUBMITTED
        - PAID
        - CANCELLED
        - BOUNCED
        - FUNDS_RETURNED
        - MANUALLY_REFUNDED
        - REFUND_SETTLED
    BillRunType:
      description: Bill run type
      type: string
      enum:
        - NORMAL
        - ADHOC
    FlowToken:
      description: token from payment provider to confirm mandate
      type: string
      readOnly: true
      minLength: 0
      maxLength: 255
      pattern: '[\w\p{L}\s%£@&#='':;`’,|!_—–\(\)\\/\-\+\.\?\*\$]*'
    PaymentProviderStatus:
      description: Payment provider status
      type: string
      enum:
        - ACTIVE
        - INACTIVE
    ThirdPartyPaymentStatus:
      description: Invoice payment status. Not applicable for manual payments
      type: string
      enum:
        - NEW
        - CREATED
        - PENDING_CUSTOMER_APPROVAL
        - PENDING_SUBMISSION
        - SUBMITTED
        - CONFIRMED
        - PAID_OUT
        - CANCELLED
        - FAILED
        - FAILED_RETRYING
        - CHARGED_BACK
        - CUSTOMER_APPROVAL_GRANTED
        - CUSTOMER_APPROVAL_DENIED
        - CHARGEBACK_CANCELLED
        - LATE_FAILURE_SETTLED
        - CHARGEBACK_SETTLED
        - SURCHARGE_FEE_DEBITED
        - RESUBMISSION_REQUESTED
        - UNSUPPORTED_PAYMENT_TYPE
        - UNAUTHORISED_PAYMENT_TYPE
        - CUSTOMER_APPROVAL_MISSING
        - SURCHARGE_FEE_CREDITED
        - MANUALLY_PAID
        - UNSENT
        - REFUNDED
        - PARTIALLY_REFUNDED
        - REFUND_PENDING
    PaymentProviderMandateStatus:
      description: Invoice payment status
      type: string
      enum:
        - NEW
        - INACTIVE
        - CREATED
        - CUSTOMER_APPROVAL_GRANTED
        - CUSTOMER_APPROVAL_SKIPPED
        - ACTIVE
        - CANCELLED
        - FAILED
        - TRANSFERRED
        - EXPIRED
        - SUBMITTED
        - RESUBMISSION_REQUESTED
        - PENDING_SUBMISSION
        - REINSTATED
        - REPLACED
        - PENDING_CUSTOMER_APPROVAL
        - CONSUMED
        - BLOCKED
        - UNKNOWN
    CustomerPaymentType:
      description: Type of payment
      type: string
      readOnly: true
      enum:
        - CUSTOMER
        - NORMAL_INVOICE
        - ADHOC_INVOICE
        - ADJUSTMENT
    TxnType:
      description: Type of transaction
      type: string
      readOnly: true
      enum:
        - INVOICE_CREATED
        - INVOICE_DISPUTED
        - INVOICE_WRITTEN_OFF
        - INVOICE_UNDISPUTED
        - INVOICE_UNWRITTEN_OFF
        - INVOICE_REFUNDED
        - INVOICE_CHARGED_BACK
        - INVOICE_PAYMENT
        - CUSTOMER_PAYMENT
        - BALANCE_ADJUSTMENT
        - INVOICE_UNPAID
    CustomerCreditStatus:
      type: object
      properties:
        customerId:
          type: integer
          description: Customer identifier
          format: int64
          readOnly: true
          example: 1
        creditThreshold:
          type: number
          description: Credit threshold value for this customer
          readOnly: true
          example: 100
        billAmount:
          type: number
          description: Customer balance for this customer
          readOnly: true
          example: 60
        valueDifference:
          type: number
          description: >-
            The difference in monetary value between the creditThreshold and the
            billValue (Customer balance)
          readOnly: true
          example: 40
        percentageDifference:
          type: number
          description: >-
            The billValue(Current balance) as a percentage of the
            creditThreshold
          readOnly: true
          example: 80
        openBillRunValue:
          type: number
          description: Open bill run value for this customer
          readOnly: true
          example: 60
    PaymentMethod:
      description: Payment method
      type: string
      enum:
        - CHEQUE
        - DIRECT_DEBIT
        - CANCELLED_DD
        - CANCELLED_CARD
        - CREDIT_CARD
        - PAYPAL
        - BACS
        - POST_OFFICE_PAYMENT_CARD
        - EZYPAY
        - GO_CARDLESS
        - GC_INSTANT_BANK_PAYMENTS
        - STRIPE
        - STRIPE_CARD
        - STRIPE_DD
        - FINASTRA
        - FAST_PAY
        - OTHER
    IdParam:
      description: Identifier
      minimum: 1
      type: integer
      format: int64
      example: 1
    PageParam:
      description: Page of results to show
      minimum: 1
      type: integer
      format: int32
      example: 1
    ResultsPerPageParam:
      description: Results to return per page
      maximum: 1000
      minimum: 1
      type: integer
      format: int32
      example: 100
    SortParam:
      description: >-
        Comma-delimited list of the fields to sort by - defaults to ascending
        order, suffix :desc to change
      example: id,name | name:desc
      type: string
    FieldsParam:
      description: >-
        Comma-delimited list of the field(s) to return if only a subset is
        required
      example: id,name
      type: string
    StringFilterParam:
      description: >-
        Filter by this string value where value can optionally be prefixed
        (in:|like:)
      example: xyz | in:x,y | like:xyz
      type: string
    BooleanFilterParam:
      description: Filter by this boolean value (true or false)
      example: true | false
      type: string
    PatchDocument:
      description: A JSONPatch document as defined by RFC 6902
      required:
        - op
        - path
      type: object
      properties:
        op:
          type: string
          description: The JSON Patch operation to be performed
          x-si-exclude: true
          enum:
            - add
            - remove
            - replace
            - move
            - copy
            - test
        path:
          type: string
          description: A JSON-Pointer
        value:
          type: object
          properties: {}
          description: The value to be used within the operations
        from:
          type: string
          description: A string containing a JSON Pointer value
    PatchRequest:
      type: array
      description: >-
        JSON Patch is a format for describing changes to a JSON document as
        specified in RFC 6902. Refer to [jsonpatch.com](http://jsonpatch.com/)
        for more information
      items:
        $ref: '#/components/schemas/PatchDocument'
    IdFilterParam:
      description: Filter by this numeric id value
      example: '0'
      type: string
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT
  parameters:
    page:
      name: page
      in: query
      description: Page of results to show
      schema:
        $ref: '#/components/schemas/PageParam'
      required: true
    pageSize:
      name: pageSize
      description: Results to return per page
      in: query
      schema:
        $ref: '#/components/schemas/ResultsPerPageParam'
      required: true
    sort:
      name: sort
      in: query
      description: >-
        Comma-delimited list of the fields to sort by - defaults to ascending
        order, suffix :desc to change
      schema:
        $ref: '#/components/schemas/SortParam'
      required: false
    fields:
      name: fields
      in: query
      description: >-
        Comma-delimited list of the field(s) to return if only a subset is
        required
      schema:
        $ref: '#/components/schemas/FieldsParam'
      required: false
