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

# Attempt payment for an invoice

> Trigger a new attempt by canceling any existing attempts for this invoice and creating a new Payment. This will trigger another attempt to charge the Customer's configured Payment Gateway. 
Payment can only be attempted if all of the following are true:
  - The Metronome Invoice is finalized
  - PLG Invoicing is configured for the Customer
  - You cannot attempt payments for invoices that have already been `paid` or `voided`.

Attempting to payment on an ineligible Invoice or Customer will result in a `400` response.




## OpenAPI

````yaml /openapi.json post /v1/payments/attempt
openapi: 3.0.1
info:
  title: Metronome
  version: 1.0.0
servers:
  - url: https://api.metronome.com
    description: Production server
security:
  - bearerAuth: []
tags:
  - name: Customers
    description: >-
      [Customers](https://docs.metronome.com/provisioning/create-customers/) in
      Metronome represent your users for all billing and reporting. Use these
      endpoints to create, retrieve, update, and archive customers and their
      billing configuration.
  - name: Billable metrics
    description: >-
      [Billable
      metrics](https://docs.metronome.com/understanding-metronome/how-metronome-works#billable-metrics)
      in Metronome represent the various consumption components that Metronome
      meters and aggregates.
  - name: Usage
    description: >-
      [Usage
      events](https://docs.metronome.com/connecting-metronome/send-usage-data/)
      are the basis for billable metrics. Use these endpoints to send usage
      events to Metronome and retrieve aggregated event data.
  - name: Products
    description: Products are the items that customers purchase.
  - name: Rate cards
    description: Rate cards are used to define default pricing for products.
  - name: Contracts
    description: >-
      A contract defines a customer’s products, pricing, discounts, commitments,
      and more. Use these endpoints to create and update contracts data.
  - name: Credits and commits
    description: Credits and commits are used to manage customer balances.
  - name: Invoices
    description: >-
      [Invoices](https://docs.metronome.com/invoicing/) reflect how much a
      customer spent during a period, which is the basis for billing. Metronome
      automatically generates invoices based upon your pricing, packaging, and
      usage events. Use these endpoints to retrieve invoices.
  - name: Alerts
    description: >-
      [Alerts](https://docs.metronome.com/connecting-metronome/alerts/) monitor
      customer spending, balances, and other billing factors. Use these
      endpoints to create, retrieve, and archive customer alerts. To view sample
      alert payloads by alert type, navigate
      [here.](https://docs.metronome.com/manage-product-access/create-manage-alerts/#webhook-notifications)
  - name: Custom fields
    description: >-
      [Custom fields](https://docs.metronome.com/integrations/custom-fields/)
      enable adding additional data to Metronome entities. Use these endpoints
      to create, retrieve, update, and delete custom fields.
  - name: Security
    description: >-
      [Security](https://docs.metronome.com/developer-resources/security/)
      endpoints allow you to retrieve security-related data.
  - name: Settings
    description: >-
      Use these endpoints to configure a billing API key, a webhook secret, or
      invoice finalization behavior.
  - name: Named schedules
    description: >-
      Named schedules are used for storing custom data that can change over
      time. Named schedules are often used in custom pricing logic.
paths:
  /v1/payments/attempt:
    post:
      tags:
        - Payments
      summary: Attempt payment for an invoice
      description: >
        Trigger a new attempt by canceling any existing attempts for this
        invoice and creating a new Payment. This will trigger another attempt to
        charge the Customer's configured Payment Gateway. 

        Payment can only be attempted if all of the following are true:
          - The Metronome Invoice is finalized
          - PLG Invoicing is configured for the Customer
          - You cannot attempt payments for invoices that have already been `paid` or `voided`.

        Attempting to payment on an ineligible Invoice or Customer will result
        in a `400` response.
      operationId: attemptPayment-v1
      requestBody:
        content:
          application/json:
            schema:
              type: object
              required:
                - customer_id
                - invoice_id
              properties:
                customer_id:
                  type: string
                  format: uuid
                invoice_id:
                  type: string
                  format: uuid
            example:
              customer_id: 13117714-3f05-48e5-a6e9-a66093f13b4d
              invoice_id: 6162d87b-e5db-4a33-b7f2-76ce6ead4e85
      responses:
        '200':
          description: Success
          content:
            application/json:
              schema:
                type: object
                required:
                  - data
                properties:
                  data:
                    $ref: '#/components/schemas/Payment'
        '400':
          description: Bad request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '404':
          $ref: '#/components/responses/NotFound'
components:
  schemas:
    Payment:
      type: object
      required:
        - id
      properties:
        id:
          type: string
          format: uuid
        invoice_id:
          type: string
          format: uuid
        customer_id:
          type: string
          format: uuid
        contract_id:
          type: string
          format: uuid
        payment_gateway:
          oneOf:
            - $ref: '#/components/schemas/StripePaymentGateway'
        fiat_credit_type:
          $ref: '#/components/schemas/CreditType'
        revenue_system_payments:
          type: array
          items:
            $ref: '#/components/schemas/RevenueSystemPayment'
        amount:
          type: number
        amount_paid:
          type: number
        status:
          $ref: '#/components/schemas/PaymentStatus'
          type: string
        error_message:
          type: string
        updated_at:
          type: string
          format: date-time
          example: '2022-02-01T00:00:00Z'
        created_at:
          type: string
          format: date-time
          example: '2022-02-01T00:00:00Z'
    Error:
      required:
        - message
      type: object
      properties:
        message:
          type: string
    StripePaymentGateway:
      type: object
      required:
        - type
        - stripe
      properties:
        type:
          type: string
          enum:
            - stripe
        stripe:
          type: object
          required:
            - payment_intent_id
          properties:
            payment_intent_id:
              type: string
            payment_method_id:
              type: string
            error:
              type: object
              properties:
                type:
                  type: string
                code:
                  type: string
                decline_code:
                  type: string
    CreditType:
      required:
        - name
        - id
      type: object
      properties:
        name:
          type: string
        id:
          type: string
          format: uuid
    RevenueSystemPayment:
      type: object
      required:
        - revenue_system_provider
        - sync_status
      properties:
        revenue_system_provider:
          type: string
        revenue_system_external_payment_id:
          type: string
        sync_status:
          type: string
        error_message:
          type: string
          description: The error message from the revenue system, if available.
    PaymentStatus:
      type: string
      enum:
        - pending
        - requires_intervention
        - paid
        - canceled
  responses:
    NotFound:
      description: The specified resource was not found
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer

````