get:
  tags:
    - Transactions
  summary: List transactions (payments, returns, chargebacks)
  description: |
    Returns a list of transactions where you get a commission for. This includes payments, refunds 
    and chargebacks from joint venture sales.
  parameters:
    - name: from
      in: query
      description: |
        Point of time to filter transaction creation date from. Examples:
        - "2014-02-28 23:11:24"
        - "2021-10-08T07:20:11-05:00" (ISO 8601)
        - "now" for current time
        - "-3d" for 3 days ago
        - "start" for first available date
      schema:
        type: string
        default: "-24h"
    - name: to
      in: query
      description: Point of time to filter transaction creation date to
      schema:
        type: string
        default: "now"
    - name: search
      in: query
      description: Search criteria
      schema:
        type: object
        properties:
          role:
            type: string
            description: Filter by role (vendor, affiliate, other). Comma-separated for multiple.
          product_id: 
            type: string
            description: Filter by product ID(s). Comma-separated for multiple.
          first_name:
            type: string
            description: Filter by buyer first name
          last_name:
            type: string
            description: Filter by buyer last name
          email:
            type: string
            description: Filter by buyer email
          has_affiliate:
            type: boolean
            description: Filter transactions with/without affiliate
          affiliate_name:
            type: string
            description: Filter by affiliate name
          pay_method:
            type: string
            description: Filter by payment method(s). Comma-separated for multiple.
          billing_type:
            type: string
            description: Filter by billing type(s). Comma-separated for multiple.
          transaction_type:
            type: string
            description: Filter by transaction type(s) (payment, refund, chargeback, refund_request)
          currency:
            type: string
            description: Filter by currency code
          purchase_id:
            type: string
            description: Filter by purchase ID(s). Comma-separated for multiple.
    - name: sort_by
      in: query
      description: Field to sort results by
      schema:
        type: string
        enum: [date, earning, amount]
        default: date
    - name: sort_order
      in: query
      description: Sort direction
      schema:
        type: string
        enum: [asc, desc]
        default: asc
    - name: page_no
      in: query
      description: Page number (starts at 1)
      schema:
        type: integer
        minimum: 1
        default: 1
    - name: page_size
      in: query
      description: Number of entries per page
      schema:
        type: integer
        minimum: 1
        maximum: 1000
        default: 500
  responses:
    '200':
      description: Successful response
      content:
        application/json:
          schema:
            type: object
            properties:
              api_version:
                type: string
              current_time:
                type: string
                format: date-time
              result:
                type: string
              data:
                type: object
                properties:
                  from:
                    type: string
                    format: date-time
                  to:
                    type: string
                    format: date-time
                  page_size:
                    type: integer
                  page_no:
                    type: integer
                  page_count:
                    type: integer
                  summary:
                    type: object
                    properties:
                      amounts:
                        type: object
                        additionalProperties:
                          type: object
                          properties:
                            count:
                              type: integer
                            total_amount:
                              type: number
                            vat_amount:
                              type: number
                            earned_amount:
                              type: number
                      count:
                        type: integer
                  transaction_list:
                    type: array
                    items:
                      type: object
                      properties:
                        id:
                          type: integer
                        purchase_id:
                          type: string
                        amount:
                          type: number
                        currency:
                          type: string
                        transaction_type:
                          type: string
                        transaction_type_msg:
                          type: string
                        created_at:
                          type: string
                          format: date-time
                        created_by_id:
                          type: string
                          description: User ID of the sales team member who created the order. Only set for orders attributed to a sales team (phone orders and orders assigned to a sales team); empty string otherwise.
                        created_by_name:
                          type: string
                          description: Username of the sales team member who created the order ("Purchase created by" in the purchase overview). Only set for orders attributed to a sales team; empty string otherwise. Not returned to joint venture partners without order-detail rights.
                        payplan_id:
                          type: string
                          description: ID of the payment plan the order was placed on (`payment_plan.id`); empty string when the order was not placed on a payment plan. Identifies the same payment plan the IPN reports for the purchase. Usually one of the plans listPaymentPlans returns for the order's main product, but not guaranteed - plans deleted since the order was placed are no longer listed there, and a small share of orders reference a plan belonging to another product. Not returned to joint venture partners without order-detail rights.
                        buyer:
                          type: object
                          properties:
                            id:
                              type: integer
                            email:
                              type: string
                            first_name:
                              type: string
                            last_name:
                              type: string
  security:
    - ApiKeyAuth: []
