openapi: 3.1.0
info:
  title: Spense Payment Management
  version: v1
  x-logo:
    url: http://app.spensepay.com/assets/spense-logo.svg
    altText: Spense
servers:
  - url: https://api.spense.no
    description: Production API (legacy)
paths:
  /api/payments:
    post:
      summary: Create Payment
      operationId: create_payment
      security:
        - OAuth2ClientCredentials:
            - organization:payflow:create
      parameters:
        - name: X-Organization-Id
          in: header
          required: false
          schema:
            type: string
            description: >-
              Required if the account is part of multiple organizations. If the
              account only has access to one organization, this header is not
              required.
            title: X-Organization-Id
          description: >-
            Required if the account is part of multiple organizations. If the
            account only has access to one organization, this header is not
            required.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/LegacyPaymentRequest'
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/LegacyPaymentResponse'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
  /api/payments/uploadDocument:
    post:
      summary: Upload Document
      operationId: upload_document
      security:
        - OAuth2ClientCredentials:
            - organization:payflow:update
      parameters:
        - name: X-Organization-Id
          in: header
          required: false
          schema:
            type: string
            description: >-
              Required if the account is part of multiple organizations. If the
              account only has access to one organization, this header is not
              required.
            title: X-Organization-Id
          description: >-
            Required if the account is part of multiple organizations. If the
            account only has access to one organization, this header is not
            required.
      requestBody:
        required: true
        content:
          multipart/form-data:
            schema:
              $ref: '#/components/schemas/Body_upload_document'
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/LegacyDocumentUploadResponse'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
  /api/payments/uploadDocument/{payflow_id}/{document_id}:
    delete:
      summary: Delete Document
      operationId: delete_document
      security:
        - OAuth2ClientCredentials:
            - organization:payflow:update
      parameters:
        - name: payflow_id
          in: path
          required: true
          schema:
            anyOf:
              - type: string
                pattern: ^[a-fA-F0-9]{24}$
              - type: string
                format: uuid
            title: Payflow Id
        - name: document_id
          in: path
          required: true
          schema:
            type: string
            pattern: ^[a-fA-F0-9]{24}$
            title: Document Id
        - name: X-Organization-Id
          in: header
          required: false
          schema:
            type: string
            description: >-
              Required if the account is part of multiple organizations. If the
              account only has access to one organization, this header is not
              required.
            title: X-Organization-Id
          description: >-
            Required if the account is part of multiple organizations. If the
            account only has access to one organization, this header is not
            required.
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                type: object
                title: Response Delete Document
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
  /api/payments/{payflow_id}:
    delete:
      summary: Delete Payment
      operationId: delete_payment
      security:
        - OAuth2ClientCredentials:
            - organization:payflow:update
      parameters:
        - name: payflow_id
          in: path
          required: true
          schema:
            anyOf:
              - type: string
                pattern: ^[a-fA-F0-9]{24}$
              - type: string
                format: uuid
            title: Payflow Id
        - name: X-Organization-Id
          in: header
          required: false
          schema:
            type: string
            description: >-
              Required if the account is part of multiple organizations. If the
              account only has access to one organization, this header is not
              required.
            title: X-Organization-Id
          description: >-
            Required if the account is part of multiple organizations. If the
            account only has access to one organization, this header is not
            required.
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                type: object
                title: Response Delete Payment
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
  /api/refund:
    post:
      summary: Refund Payment
      operationId: refund_payment
      security:
        - OAuth2ClientCredentials:
            - organization:payflow:update
      parameters:
        - name: X-Organization-Id
          in: header
          required: false
          schema:
            type: string
            description: >-
              Required if the account is part of multiple organizations. If the
              account only has access to one organization, this header is not
              required.
            title: X-Organization-Id
          description: >-
            Required if the account is part of multiple organizations. If the
            account only has access to one organization, this header is not
            required.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/LegacyPaymentRefundRequest'
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/LegacyPaymentRefundResponse'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
  /api/payments/{payflow_id}/paymentStatus:
    get:
      summary: Get Payment Status
      operationId: get_payment_status
      security:
        - OAuth2ClientCredentials:
            - organization:payflow:read
      parameters:
        - name: payflow_id
          in: path
          required: true
          schema:
            anyOf:
              - type: string
                pattern: ^[a-fA-F0-9]{24}$
              - type: string
                format: uuid
            title: Payflow Id
        - name: X-Organization-Id
          in: header
          required: false
          schema:
            type: string
            description: >-
              Required if the account is part of multiple organizations. If the
              account only has access to one organization, this header is not
              required.
            title: X-Organization-Id
          description: >-
            Required if the account is part of multiple organizations. If the
            account only has access to one organization, this header is not
            required.
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/LegacyPaymentStatusResponse'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
  /api/payments/{payflow_id}/installments/create:
    post:
      summary: Create Installment
      operationId: create_installment
      security:
        - OAuth2ClientCredentials:
            - organization:payflow:read
      parameters:
        - name: payflow_id
          in: path
          required: true
          schema:
            type: string
            pattern: ^[a-fA-F0-9]{24}$
            title: Payflow Id
        - name: X-Organization-Id
          in: header
          required: false
          schema:
            type: string
            description: >-
              Required if the account is part of multiple organizations. If the
              account only has access to one organization, this header is not
              required.
            title: X-Organization-Id
          description: >-
            Required if the account is part of multiple organizations. If the
            account only has access to one organization, this header is not
            required.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/LegacyInstallment'
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/LegacyInstallmentResponse'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
  /api/payments/{payflow_id}/installments/{installment_id}:
    get:
      summary: Get Installment
      operationId: get_installment
      security:
        - OAuth2ClientCredentials:
            - organization:payflow:read
      parameters:
        - name: payflow_id
          in: path
          required: true
          schema:
            type: string
            pattern: ^[a-fA-F0-9]{24}$
            title: Payflow Id
        - name: installment_id
          in: path
          required: true
          schema:
            type: string
            pattern: ^[a-fA-F0-9]{24}$
            title: Installment Id
        - name: X-Organization-Id
          in: header
          required: false
          schema:
            type: string
            description: >-
              Required if the account is part of multiple organizations. If the
              account only has access to one organization, this header is not
              required.
            title: X-Organization-Id
          description: >-
            Required if the account is part of multiple organizations. If the
            account only has access to one organization, this header is not
            required.
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/LegacyInstallmentResponse'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
    put:
      summary: Update Installment
      operationId: update_installment
      security:
        - OAuth2ClientCredentials:
            - organization:payflow:read
      parameters:
        - name: payflow_id
          in: path
          required: true
          schema:
            type: string
            pattern: ^[a-fA-F0-9]{24}$
            title: Payflow Id
        - name: installment_id
          in: path
          required: true
          schema:
            type: string
            pattern: ^[a-fA-F0-9]{24}$
            title: Installment Id
        - name: X-Organization-Id
          in: header
          required: false
          schema:
            type: string
            description: >-
              Required if the account is part of multiple organizations. If the
              account only has access to one organization, this header is not
              required.
            title: X-Organization-Id
          description: >-
            Required if the account is part of multiple organizations. If the
            account only has access to one organization, this header is not
            required.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/LegacyUpdateInstallmentRequest'
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema: {}
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
    delete:
      summary: Delete Installment
      operationId: delete_installment
      security:
        - OAuth2ClientCredentials:
            - organization:payflow:read
      parameters:
        - name: payflow_id
          in: path
          required: true
          schema:
            type: string
            pattern: ^[a-fA-F0-9]{24}$
            title: Payflow Id
        - name: installment_id
          in: path
          required: true
          schema:
            type: string
            pattern: ^[a-fA-F0-9]{24}$
            title: Installment Id
        - name: X-Organization-Id
          in: header
          required: false
          schema:
            type: string
            description: >-
              Required if the account is part of multiple organizations. If the
              account only has access to one organization, this header is not
              required.
            title: X-Organization-Id
          description: >-
            Required if the account is part of multiple organizations. If the
            account only has access to one organization, this header is not
            required.
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema: {}
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
webhooks:
  legacy-payment-update:
    post:
      tags:
        - Webhooks
      summary: 'Webhook: Payment Update'
      description: >-
        A webhook that is called when a payment is updated. This can be used to

        update your internal systems, or to trigger other actions.


        To use this webhook, you need to pass in the URL when creating the
        payment.
      operationId: legacy_payment_updatelegacy_payment_update_post
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/LegacyPaymentWebhookPayload'
        required: true
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema: {}
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
components:
  schemas:
    Body_upload_document:
      properties:
        id:
          anyOf:
            - type: string
              pattern: ^[a-fA-F0-9]{24}$
            - type: string
              format: uuid
          title: Id
        file:
          type: string
          format: binary
          title: File
        name:
          type: string
          title: Name
          default: ''
        description:
          type: string
          title: Description
          default: ''
      type: object
      required:
        - id
        - file
      title: Body_upload_document
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    InstallmentsMode:
      type: string
      enum:
        - pay-down
        - subscription
      title: InstallmentsMode
    InvoiceLine:
      properties:
        description:
          type: string
          title: Description
        grossUnitPrice:
          type: number
          title: Grossunitprice
        netUnitPrice:
          type: number
          title: Netunitprice
        quantity:
          type: number
          title: Quantity
        vatAmount:
          type: number
          title: Vatamount
        taxRate:
          type: number
          title: Taxrate
      type: object
      required:
        - description
        - grossUnitPrice
        - netUnitPrice
        - quantity
        - vatAmount
        - taxRate
      title: InvoiceLine
    LegacyAddress:
      properties:
        careOf:
          type: string
          title: Careof
          default: ''
        street:
          type: string
          title: Street
          default: ''
        secondary:
          type: string
          title: Secondary
          default: ''
        postalCode:
          type: string
          title: Postalcode
          default: ''
        city:
          type: string
          title: City
          default: ''
        country:
          type: string
          title: Country
          default: ''
      type: object
      title: LegacyAddress
    LegacyBehaviour:
      properties:
        redirectSuccessUrl:
          anyOf:
            - type: string
              maxLength: 2083
              minLength: 1
              format: uri
            - type: 'null'
          title: Redirectsuccessurl
          description: >-
            If set, the user will be redirected to this URL after the payment is
            successful.
        redirectCancelUrl:
          anyOf:
            - type: string
              maxLength: 2083
              minLength: 1
              format: uri
            - type: 'null'
          title: Redirectcancelurl
          description: >-
            If set, the user will be redirected to this URL after the payment is
            cancelled. A payment is cancelled if the user clicks the cancel
            button.
        cancelButtonText:
          type: string
          title: Cancelbuttontext
          description: >-
            Text for the cancel button, only visible if `redirectCancelUrl` is
            set.
          default: Cancel
      type: object
      title: LegacyBehaviour
    LegacyCallback:
      properties:
        url:
          type: string
          title: >-
            This webhook URL will be called when the payment is completed
            successfully.
          default: ''
          deprecated: true
        status_update_url:
          type: string
          title: >-
            This webhook URL will be called when the status of the payment
            changes. It is triggered by any status update, including when the
            payment is completed successfully.
          default: ''
        terminal_failure_url:
          type: string
          title: >-
            Currently not implemented. We might add this functionality in the
            future.
          default: ''
        api_key:
          anyOf:
            - type: string
            - type: 'null'
          title: Will be passed to the webhook URLs in the `Authorization` header.
      type: object
      title: LegacyCallback
    LegacyCommunication:
      properties:
        send_payment_link:
          type: boolean
          title: Send Payment Link
          default: true
        send_payment_reminder:
          type: boolean
          title: Send Payment Reminder
          default: true
      type: object
      title: LegacyCommunication
    LegacyCustomerOrganization:
      properties:
        email:
          anyOf:
            - type: string
            - type: 'null'
          title: Email
          default: ''
        phone:
          allOf:
            - $ref: '#/components/schemas/LegacyPhoneNumber'
          default:
            countryCode: ''
            number: ''
        organizationName:
          type: string
          title: Organizationname
          default: ''
        organizationNumber:
          type: string
          title: Organizationnumber
          default: ''
        customerNumber:
          type: string
          title: Customernumber
          default: ''
        billingAddress:
          allOf:
            - $ref: '#/components/schemas/LegacyAddress'
          default:
            careOf: ''
            street: ''
            secondary: ''
            postalCode: ''
            city: ''
            country: ''
        type:
          type: string
          enum:
            - organization
          const: organization
          title: Type
          default: organization
      type: object
      title: LegacyCustomerOrganization
    LegacyCustomerPerson:
      properties:
        email:
          anyOf:
            - type: string
            - type: 'null'
          title: Email
          default: ''
        phone:
          allOf:
            - $ref: '#/components/schemas/LegacyPhoneNumber'
          default:
            countryCode: ''
            number: ''
        firstName:
          type: string
          title: Firstname
          default: ''
        lastName:
          type: string
          title: Lastname
          default: ''
        customerNumber:
          type: string
          title: Customernumber
          default: ''
        billingAddress:
          allOf:
            - $ref: '#/components/schemas/LegacyAddress'
          default:
            careOf: ''
            street: ''
            secondary: ''
            postalCode: ''
            city: ''
            country: ''
        type:
          type: string
          enum:
            - person
          const: person
          title: Type
          default: person
      type: object
      title: LegacyCustomerPerson
    LegacyDocumentUploadResponse:
      properties:
        id:
          type: string
          pattern: ^[a-fA-F0-9]{24}$
          title: Id
        name:
          type: string
          title: Name
        description:
          type: string
          title: Description
        url:
          type: string
          title: Url
      type: object
      required:
        - id
        - name
        - description
        - url
      title: LegacyDocumentUploadResponse
    LegacyInstallment:
      properties:
        date:
          type: string
          format: date
          title: Date
        grossAmount:
          type: number
          exclusiveMinimum: 0
          title: Grossamount
        items:
          items:
            $ref: '#/components/schemas/LegacyPaymentItem'
          type: array
          title: Items
      type: object
      required:
        - date
        - grossAmount
      title: LegacyInstallment
    LegacyInstallmentResponse:
      properties:
        id:
          type: string
          title: Id
        date:
          type: string
          format: date
          title: Date
        type:
          $ref: '#/components/schemas/Type'
        grossAmount:
          type: number
          title: Grossamount
        status:
          $ref: '#/components/schemas/PaymentStatus'
        numTried:
          type: integer
          title: Numtried
        successfullyChargedAt:
          anyOf:
            - type: string
              format: date-time
            - type: 'null'
          title: Successfullychargedat
        numFailed:
          type: integer
          title: Numfailed
        lastFailedAt:
          anyOf:
            - type: string
              format: date-time
            - type: 'null'
          title: Lastfailedat
      type: object
      required:
        - id
        - date
        - type
        - grossAmount
        - status
        - numTried
        - successfullyChargedAt
        - numFailed
        - lastFailedAt
      title: LegacyInstallmentResponse
    LegacyInstallmentUpdate:
      properties:
        installmentId:
          type: string
          title: Installmentid
        installmentStatus:
          $ref: '#/components/schemas/PaymentStatus'
      type: object
      required:
        - installmentId
        - installmentStatus
      title: LegacyInstallmentUpdate
    LegacyObject:
      properties:
        type:
          $ref: '#/components/schemas/LegacyObjectType'
        numberPlate:
          type: string
          title: Numberplate
          default: ''
        brand:
          type: string
          title: Brand
          default: ''
        model:
          type: string
          title: Model
          default: ''
        color:
          type: string
          title: Color
          default: ''
        year:
          type: string
          title: Year
          default: ''
        vinNumber:
          type: string
          title: Vinnumber
          default: ''
      type: object
      required:
        - type
      title: LegacyObject
    LegacyObjectType:
      type: string
      enum:
        - ''
        - newCar
        - tradeInCAR
      title: LegacyObjectType
    LegacyOrder:
      properties:
        orderNumber:
          type: string
          title: Ordernumber
          default: ''
        objects:
          items:
            $ref: '#/components/schemas/LegacyObject'
          type: array
          title: Objects
          default: []
      type: object
      title: LegacyOrder
    LegacyPayment:
      properties:
        currency:
          type: string
          title: Currency
          default: ''
        totalGrossAmount:
          type: number
          exclusiveMinimum: 0
          title: Totalgrossamount
        totalNetAmount:
          type: number
          exclusiveMinimum: 0
          title: Totalnetamount
        installments:
          anyOf:
            - items:
                $ref: '#/components/schemas/LegacyInstallment'
              type: array
            - type: 'null'
          title: Installments
          description: >-
            Split the total gross amount of the payment into installments, which
            will be automatically debited at the specified dates.
        installmentsMode:
          anyOf:
            - $ref: '#/components/schemas/InstallmentsMode'
            - type: 'null'
          x-enumNames:
            - PAY_DOWN
            - SUBSCRIPTION
        items:
          items:
            $ref: '#/components/schemas/LegacyPaymentItem'
          type: array
          title: Items
          default: []
        dueDate:
          type: string
          format: date
          title: Duedate
        paymentRef:
          type: string
          title: Paymentref
          default: ''
        invoiceNumber:
          type: string
          title: Invoicenumber
          default: ''
        invoiceComments:
          anyOf:
            - type: string
            - type: 'null'
          title: Invoicecomments
          description: >-
            Comments to be added to the invoice. These will be visible to the
            customer.
        profileId:
          anyOf:
            - type: string
              pattern: ^[a-fA-F0-9]{24}$
            - type: 'null'
          title: Profileid
          description: >-
            The ID of the payment profile that the payment shall be created for.
            If the organization has two or more payment profiles, either
            `profileId` or `paymentDepartment` must be specified. We highly
            recommend to always specify either `profileId` or
            `paymentDepartment`.
        paymentDepartment:
          anyOf:
            - $ref: '#/components/schemas/PaymentDepartment'
            - type: 'null'
          description: >-
            This field can be used as a simpler alternative for specifying the
            payment profile that the payment shall be created for. If
            `profileId` is not specified and the organization has a payment
            profile for the department which is specified in
            `paymentDepartment`, that payment profile will be used. If the
            organization has two or more payment profiles, either `profileId` or
            `paymentDepartment` must be specified. We highly recommend to always
            specify either `profileId` or `paymentDepartment`.
        internalRef:
          type: string
          title: Internalref
          default: ''
        externalRef:
          type: string
          title: Externalref
          default: ''
      type: object
      required:
        - totalGrossAmount
        - totalNetAmount
        - dueDate
      title: LegacyPayment
    LegacyPaymentItem:
      properties:
        description:
          type: string
          title: Description
          default: ''
        grossUnitPrice:
          type: number
          title: Grossunitprice
          default: 0
        netUnitPrice:
          type: number
          title: Netunitprice
          default: 0
        grossTotalPrice:
          anyOf:
            - type: number
            - type: 'null'
          title: Grosstotalprice
          description: >-
            If set, this will override the total price calculated from
            grossUnitPrice * quantity.
        netTotalPrice:
          anyOf:
            - type: number
            - type: 'null'
          title: Nettotalprice
          description: >-
            If set, this will override the total price calculated from
            netUnitPrice * quantity
        vatAmount:
          type: number
          title: Vatamount
          default: 0
        quantity:
          type: number
          title: Quantity
          default: 0
        taxRate:
          type: number
          title: Taxrate
          description: The tax rate in percent, e.g. 25 for 25%% or 20.9 for 20.9%
          default: 0
        discountRate:
          type: number
          title: Discountrate
          default: 0
        lineType:
          allOf:
            - $ref: '#/components/schemas/PaymentCostLineType'
          default: regular
      type: object
      title: LegacyPaymentItem
    LegacyPaymentLinksResponse:
      properties:
        gui:
          type: string
          title: Gui
          description: >-
            The path of the payment link (without the domain). This property is
            deprecated and exists only to support legacy customer integrations.
            You should always use `longGui`. Specifically, if you combine the
            path provided in `gui` with a known Spense payment link domain (e.
            g. `pay.spense.no`), this might result in broken payment links or
            parts of the payflow functionality not working. One scenario where
            this can happen is when Spense has configured a custom payment link
            domain for the affected organization. `longGui` will always use the
            payment link domain that is configured at the time of payment
            creation.
          default: ''
          deprecated: true
        longGui:
          type: string
          title: Longgui
          description: The full URL of the payment link which is sent to the user.
          default: ''
      type: object
      title: LegacyPaymentLinksResponse
    LegacyPaymentRefundRequest:
      properties:
        crossPayment:
          anyOf:
            - type: string
              pattern: ^[a-fA-F0-9]{24}$
            - type: string
              format: uuid
          title: Crosspayment
        currency:
          type: string
          title: Currency
        totalGrossAmount:
          type: number
          title: Totalgrossamount
        totalNetAmount:
          type: number
          title: Totalnetamount
        invoiceLines:
          items:
            $ref: '#/components/schemas/InvoiceLine'
          type: array
          title: Invoicelines
          default: []
      type: object
      required:
        - crossPayment
        - currency
        - totalGrossAmount
        - totalNetAmount
      title: LegacyPaymentRefundRequest
    LegacyPaymentRefundResponse:
      properties:
        refundType:
          type: string
          title: Refundtype
        debtorAccountNumber:
          type: string
          title: Debtoraccountnumber
          default: ''
        originalAmount:
          type: number
          title: Originalamount
        originalCurrency:
          type: string
          title: Originalcurrency
        grossRefundedAmount:
          type: number
          title: Grossrefundedamount
        netRefundedAmount:
          type: number
          title: Netrefundedamount
        remainingAmount:
          anyOf:
            - type: number
            - type: 'null'
          title: Remainingamount
        refundId:
          type: string
          title: Refundid
      type: object
      required:
        - refundType
        - originalAmount
        - originalCurrency
        - grossRefundedAmount
        - netRefundedAmount
        - remainingAmount
        - refundId
      title: LegacyPaymentRefundResponse
    LegacyPaymentRequest:
      properties:
        customer:
          oneOf:
            - $ref: '#/components/schemas/LegacyCustomerPerson'
            - $ref: '#/components/schemas/LegacyCustomerOrganization'
          title: Customer
          discriminator:
            propertyName: type
            mapping:
              organization: '#/components/schemas/LegacyCustomerOrganization'
              person: '#/components/schemas/LegacyCustomerPerson'
        order:
          $ref: '#/components/schemas/LegacyOrder'
        payment:
          $ref: '#/components/schemas/LegacyPayment'
        communication:
          $ref: '#/components/schemas/LegacyCommunication'
        behaviour:
          $ref: '#/components/schemas/LegacyBehaviour'
        serviceAdvisorEmail:
          anyOf:
            - type: string
              format: email
            - type: 'null'
          title: Serviceadvisoremail
          description: >-
            Can be set to describe which user in the remote ERP system that
            created the payment or order, this is helpful for reporting purposes
            and if the user also have access to the Spense platform the payment
            will be attached to this user. If the user does not have an account,
            a user with no roles or access will be created.
        paymentMethodId:
          anyOf:
            - type: string
              pattern: ^[a-fA-F0-9]{24}$
            - type: 'null'
          title: Paymentmethodid
          description: >-
            New field added 2024-08-27. Use the partner API to fetch a list of
            payment methods. Sending `null` here will rely on the default
            payment method (standard way of creating payments). A payment method
            can be anything, for example a terminal, invoice, payment link or
            any other future types of payments that may be implemented.
        callback:
          $ref: '#/components/schemas/LegacyCallback'
        supportFunctions:
          items:
            anyOf:
              - $ref: '#/components/schemas/LegacySupportFunctionSharebox'
              - $ref: '#/components/schemas/LegacySupportFunctionKeybox'
          type: array
          title: Supportfunctions
      type: object
      required:
        - customer
        - order
        - payment
      title: LegacyPaymentRequest
    LegacyPaymentResponse:
      properties:
        id:
          type: string
          title: Id
          description: >-
            The ID of the payment, which is used to identify the payment in the
            system.
          examples:
            - 1234567890abcdef12345678
        _links:
          allOf:
            - $ref: '#/components/schemas/LegacyPaymentLinksResponse'
          default:
            gui: ''
            longGui: ''
          examples:
            - gui: /1234567890abcdef12345678
              longGui: https://pay.spense.no/1234567890abcdef12345678
        installments:
          anyOf:
            - items:
                $ref: '#/components/schemas/LegacyInstallmentResponse'
              type: array
            - type: 'null'
          title: Installments
      type: object
      required:
        - id
      title: LegacyPaymentResponse
    LegacyPaymentStatusResponse:
      properties:
        totalAmount:
          type: number
          title: Totalamount
        installments:
          anyOf:
            - items:
                $ref: '#/components/schemas/LegacyInstallmentResponse'
              type: array
            - type: 'null'
          title: Installments
        paymentId:
          type: string
          pattern: ^[a-fA-F0-9]{24}$
          title: Paymentid
        paymentNumber:
          type: integer
          title: Paymentnumber
        paymentStatus:
          $ref: '#/components/schemas/Status'
        merchantId:
          type: string
          title: Merchantid
        createdAt:
          type: string
          format: date-time
          title: Createdat
        dueDate:
          anyOf:
            - type: string
              format: date-time
            - type: 'null'
          title: Duedate
        files:
          items: {}
          type: array
          title: Files
          default: []
      type: object
      required:
        - totalAmount
        - paymentId
        - paymentNumber
        - paymentStatus
        - merchantId
        - createdAt
        - dueDate
      title: LegacyPaymentStatusResponse
    LegacyPaymentWebhookPayload:
      properties:
        id:
          type: string
          title: Id
        paymentStatus:
          $ref: '#/components/schemas/PayflowLegacyStatus'
        paymentMethod:
          anyOf:
            - $ref: '#/components/schemas/PaymentTypes'
            - type: 'null'
        installmentUpdate:
          anyOf:
            - $ref: '#/components/schemas/LegacyInstallmentUpdate'
            - type: 'null'
      type: object
      required:
        - id
        - paymentStatus
        - paymentMethod
      title: LegacyPaymentWebhookPayload
    LegacyPhoneNumber:
      properties:
        countryCode:
          anyOf:
            - type: string
            - type: 'null'
          title: Countrycode
          default: ''
        number:
          anyOf:
            - type: string
            - type: 'null'
          title: Number
          default: ''
      type: object
      title: LegacyPhoneNumber
    LegacySupportFunctionKeybox:
      properties:
        keybox:
          $ref: >-
            #/components/schemas/spense__legacy__api_emulator__emulator_models__LegacySupportFunctionKeybox__Data
      type: object
      required:
        - keybox
      title: LegacySupportFunctionKeybox
    LegacySupportFunctionSharebox:
      properties:
        sharebox:
          $ref: >-
            #/components/schemas/spense__legacy__api_emulator__emulator_models__LegacySupportFunctionSharebox__Data
      type: object
      required:
        - sharebox
      title: LegacySupportFunctionSharebox
    LegacyUpdateInstallmentRequest:
      properties:
        grossAmount:
          type: number
          exclusiveMinimum: 0
          title: Grossamount
        items:
          items:
            $ref: '#/components/schemas/LegacyPaymentItem'
          type: array
          title: Items
      type: object
      required:
        - grossAmount
      title: LegacyUpdateInstallmentRequest
    PayflowLegacyStatus:
      type: string
      enum:
        - DRAFT
        - OPENED
        - INITIATED
        - PENDING
        - SUCCESS
        - REJECTED
        - UNKNOWN
      title: PayflowLegacyStatus
    PaymentCostLineType:
      type: string
      enum:
        - regular
        - shipping
        - part-sum
      title: PaymentCostLineType
    PaymentDepartment:
      type: string
      enum:
        - UNKNOWN
        - CARSALE
        - SERVICE
        - PARTS
        - OTHER
      title: PaymentDepartment
    PaymentStatus:
      type: string
      enum:
        - DRAFT
        - CREATED
        - SENT
        - OPENED
        - FAILED
        - PENDING
        - PAID
        - CANCELLED
      title: PaymentStatus
    PaymentTypes:
      type: string
      enum:
        - CARD
        - CARD_TERMINAL
        - CASH
        - A2A
        - WALLET
        - INSTALLMENT
        - PARTPAYMENT
        - INVOICE
        - REVOLVING_CREDIT
      title: PaymentTypes
    Status:
      properties:
        paymentStatus:
          $ref: '#/components/schemas/PayflowLegacyStatus'
      type: object
      required:
        - paymentStatus
      title: Status
    Type:
      type: string
      enum:
        - initial
        - scheduled
      title: Type
    ValidationError:
      properties:
        loc:
          items:
            anyOf:
              - type: string
              - type: integer
          type: array
          title: Location
        msg:
          type: string
          title: Message
        type:
          type: string
          title: Error Type
      type: object
      required:
        - loc
        - msg
        - type
      title: ValidationError
    spense__legacy__api_emulator__emulator_models__LegacySupportFunctionKeybox__Data:
      properties:
        type:
          anyOf:
            - type: string
            - type: 'null'
          title: Type
        lockerindex:
          anyOf:
            - type: string
            - type: integer
            - type: 'null'
          title: Lockerindex
        pincode:
          anyOf:
            - type: string
            - type: 'null'
          title: Pincode
        plateNumber:
          anyOf:
            - type: string
            - type: 'null'
          title: Platenumber
      type: object
      title: Data
    spense__legacy__api_emulator__emulator_models__LegacySupportFunctionSharebox__Data:
      properties:
        useSharebox:
          type: boolean
          title: Usesharebox
          default: false
        plateNumber:
          anyOf:
            - type: string
            - type: 'null'
          title: Platenumber
      type: object
      title: Data
  securitySchemes:
    OAuth2ClientCredentials:
      type: oauth2
      flows:
        clientCredentials:
          scopes: {}
          tokenUrl: /partner/auth/token
