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

# Pay Invoice

> Forces an on-demand payment on a finalized invoice, outside the normal collection schedule. Charges the customer's default payment method off-session and returns the full updated invoice.



## OpenAPI

````yaml /openapi.json post /invoices/{provider_invoice_id}/payments
openapi: 3.1.0
info:
  title: OpenLoop API
  version: 0.1.0
  description: >-
    Unified reference for the OpenLoop Patient (clinical) and Payments & Revenue
    APIs.
servers:
  - url: https://api.openloophealth.com/v0.1
    description: Production partner edge
  - url: https://api-staging.openloophealth.com/v0.1
    description: Staging partner edge (sandbox credentials)
security: []
paths:
  /invoices/{provider_invoice_id}/payments:
    post:
      tags:
        - Invoices
      summary: Pay Invoice
      description: >-
        Forces an on-demand payment on a finalized invoice, outside the normal
        collection schedule. Charges the customer's default payment method
        off-session and returns the full updated invoice.
      parameters:
        - in: path
          name: provider_invoice_id
          required: true
          schema:
            type: string
          description: Provider invoice id (e.g. `test_invoice_id`).
        - in: header
          name: Idempotency-Key
          required: false
          schema:
            type: string
          description: >-
            Deduplicates retried requests with the same key and parameters
            instead of creating a second resource. Recommended: an opaque,
            randomly-generated value such as a UUID.
      responses:
        '200':
          description: Success.
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    properties:
                      provider_customer_id:
                        type: string
                        description: Provider customer id (e.g. `test_customer_id`).
                      provider_invoice_id:
                        type:
                          - string
                          - 'null'
                        description: >-
                          Invoice that was paid. Always present here, since the
                          invoice exists at this point.
                      provider_subscription_id:
                        type:
                          - string
                          - 'null'
                        description: Originating subscription, if any.
                      number:
                        type:
                          - string
                          - 'null'
                        description: Invoice number.
                      description:
                        type:
                          - string
                          - 'null'
                        description: Invoice description.
                      status:
                        type: string
                        description: Invoice status after payment (e.g. `paid`).
                      currency:
                        type: string
                        description: Currency code (e.g. `usd`).
                      paid_date:
                        type: number
                        description: Unix timestamp the invoice was paid (`0` if unset).
                      due_date:
                        type:
                          - number
                          - 'null'
                        description: Unix timestamp the invoice is due.
                      total_amount:
                        type: number
                        description: Invoice total in cents.
                      total_paid:
                        type: number
                        description: Amount paid in cents.
                      post_payment_credit_notes_amount:
                        type: number
                        description: >-
                          Total of all credit notes issued against the invoice
                          after it was paid, in cents. `0` when none exist;
                          above `0` means the invoice has been at least
                          partially refunded through a credit note. Does not
                          capture a refund issued directly on the payment.
                      period_end:
                        type: number
                        description: Billing period end (Unix timestamp).
                      period_start:
                        type: number
                        description: Billing period start (Unix timestamp).
                      billing_reason:
                        type:
                          - string
                          - 'null'
                        description: Why the invoice was created.
                      collection_method:
                        type: string
                        description: '`charge_automatically` or `send_invoice`.'
                      hosted_invoice_url:
                        type:
                          - string
                          - 'null'
                        description: URL to the hosted invoice page.
                      invoice_pdf:
                        type:
                          - string
                          - 'null'
                        description: URL to the invoice PDF.
                      metadata:
                        type: object
                        additionalProperties:
                          type: string
                        description: >-
                          Free-form string key/value pairs attached to the
                          invoice.
                      discounts:
                        type: array
                        items:
                          type: object
                          properties:
                            provider_discount_id:
                              type: string
                              description: Provider discount ID.
                            provider_coupon_id:
                              type:
                                - string
                                - 'null'
                              description: >-
                                Provider coupon ID that created the discount, or
                                `null`.
                            provider_promotion_code_id:
                              type:
                                - string
                                - 'null'
                              description: >-
                                Provider promotion code ID that created the
                                discount, or `null` when a coupon was applied
                                directly.
                        description: Discount details.
                      payments:
                        type: array
                        items:
                          type: object
                          properties:
                            provider_payment_id:
                              type: string
                              description: Provider payment (invoice-payment) ID.
                            provider_payment_intent_id:
                              type:
                                - string
                                - 'null'
                              description: >-
                                Provider payment intent ID for this payment.
                                `null` whenever the provider recorded no payment
                                intent for it — a charge payment, a
                                payment-record payment, or an invoice finalized
                                before 2019-03-15.
                            amount_paid_cents:
                              type: number
                              description: Amount paid in cents.
                            amount_requested_cents:
                              type: number
                              description: Amount requested in cents.
                            currency:
                              type: string
                              description: Currency code (e.g. `"usd"`).
                            created:
                              type: number
                              description: Unix timestamp the payment was created.
                        description: Payment details.
                      lines:
                        type: array
                        items:
                          type: object
                          properties:
                            provider_product_id:
                              type: string
                              description: Provider product ID.
                            provider_price_id:
                              type: string
                              description: Provider price ID.
                            product:
                              type:
                                - object
                                - 'null'
                              properties:
                                name:
                                  type:
                                    - string
                                    - 'null'
                                  description: Product name.
                                description:
                                  type:
                                    - string
                                    - 'null'
                                  description: Product description.
                                status:
                                  type: string
                                  description: Product status.
                                metadata:
                                  type: object
                                  description: Custom metadata (string key/value pairs).
                              description: Product details or `null`.
                            billing_interval:
                              type:
                                - string
                                - 'null'
                              description: Billing interval (e.g. `"month"`).
                            billing_interval_count:
                              type:
                                - number
                                - 'null'
                              description: Number of intervals per billing cycle.
                            currency:
                              type: string
                              description: Currency code (e.g. `"usd"`).
                            description:
                              type:
                                - string
                                - 'null'
                              description: Line description.
                            amount_cents:
                              type: number
                              description: Line amount in cents.
                            quantity:
                              type: number
                              description: Line quantity.
                            discounts:
                              type: array
                              items:
                                type: object
                                properties:
                                  provider_discount_id:
                                    type: string
                                    description: Provider discount ID.
                                  provider_coupon_id:
                                    type:
                                      - string
                                      - 'null'
                                    description: >-
                                      Provider coupon ID that created the
                                      discount, or `null`.
                                  provider_promotion_code_id:
                                    type:
                                      - string
                                      - 'null'
                                    description: >-
                                      Provider promotion code ID that created
                                      the discount, or `null` when a coupon was
                                      applied directly.
                              description: >-
                                Discounts applied to the line item (same shape
                                as the invoice `discounts` fields above).
                        description: Line item details.
                      created:
                        type:
                          - number
                          - 'null'
                        description: Unix timestamp of creation.
                required:
                  - data
              example:
                data:
                  provider_customer_id: test_customer_id
                  provider_invoice_id: test_invoice_id
                  provider_subscription_id: null
                  number: test_invoice_number
                  description: null
                  status: paid
                  currency: usd
                  paid_date: 1900
                  due_date: null
                  total_amount: 19900
                  total_paid: 19900
                  post_payment_credit_notes_amount: 0
                  period_end: 1900
                  period_start: 1800
                  billing_reason: manual
                  collection_method: charge_automatically
                  hosted_invoice_url: https://pay.stripe.com/invoice/abc
                  invoice_pdf: https://pay.stripe.com/invoice/abc/pdf
                  discounts: []
                  payments: []
                  lines: []
                  created: 1800
        '400':
          description: >-
            ValidationError: Missing `invoice_id`. ProviderError: the payment
            provider rejected the payment, for example the invoice is not
            finalized or has no default payment method. A declined charge is a
            `400` too, with `error_code` `PROVIDER_ERROR`.
        '401':
          description: Missing or invalid bearer token.
        '403':
          description: >-
            No configuration exists for your account, or provider access has
            been disabled for it.
        '500':
          description: >-
            An upstream provider error with no client-error status. An invoice
            that is already paid is not an error: it is returned as it is.
      security:
        - serviceToken: []
        - userToken: []
components:
  securitySchemes:
    serviceToken:
      type: oauth2
      description: >-
        Service (M2M) access token issued by POST /auth/token using the
        client_credentials grant. Required scopes, where known, are listed on
        each operation below.
      flows:
        clientCredentials:
          tokenUrl: https://api.openloophealth.com/v0.1/auth/token
          scopes: {}
    userToken:
      type: http
      scheme: bearer
      bearerFormat: JWT
      description: >-
        User access token issued by POST /auth/token via the verification-code
        grant (after Verify a one-time code) or the refresh_token grant.

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.