Both charges and refunds in v2 orders

I’m migrating from v1/payments to v2/orders/search to obtain a customer’s transactions. In v1/payments it is possible to have a payment with money being taken and money being returned. That is, the total_collected_money.amount can have a non-zero amount (e.g. 500) and the refunds[].refunded_money.amount can have a non-zero amount. All the sandbox data I’ve obtained from v2/orders/search seems to indicate this isn’t the case on those transactions. I’m searching only for orders whose state is COMPLETED. All the sandbox data has 0 values for total_money.amount and non-zero amounts in return_amounts.total_money.amount.

Is this always the case? For v2/orders are returns always a separate order object from a payment?

Yes, refunds will always appear as a new/separate Order object with the refund information. It will also have a source_order_id so you know what the original order_id is, if you need to link it or look it up.

Great! Thanks. I’ve been using that source_id to make the connection and just wanted to confirm.

@sjosey Thanks again for your help. I’m hoping you can help me with this order I came across from v2/orders/search. I’ve pasted the data below with the only changes being redacting any identifying information. Looking at the data it appears the customer return items and bought items at the same time and that the return value exceeded the purchase value resulting in a refund. In this case there are both non-zero values for total_money.amount and return_amounts.total_money.amount. It looks like this is something we should anticipate seeing. Is that correct?

{
  "id": "[REDACTED]",
  "location_id": "[REDACTED]",
  "line_items": [
    {
      "uid": "[REDACTED]",
      "catalog_object_id": "[REDACTED]",
      "quantity": "1",
      "name": "[REDACTED]",
      "variation_name": "[REDACTED]",
      "base_price_money": {
        "amount": 50000,
        "currency": "USD"
      },
      "note": "[REDACTED]",
      "gross_sales_money": {
        "amount": 50000,
        "currency": "USD"
      },
      "total_tax_money": {
        "amount": 3875,
        "currency": "USD"
      },
      "total_discount_money": {
        "amount": 0,
        "currency": "USD"
      },
      "total_money": {
        "amount": 53875,
        "currency": "USD"
      },
      "variation_total_price_money": {
        "amount": 50000,
        "currency": "USD"
      },
      "applied_taxes": [
        {
          "uid": "[REDACTED]",
          "tax_uid": "[REDACTED]",
          "applied_money": {
            "amount": 3875,
            "currency": "USD"
          }
        }
      ],
      "item_type": "ITEM"
    }
  ],
  "taxes": [
    {
      "uid": "[REDACTED]",
      "catalog_object_id": "[REDACTED]",
      "name": "[REDACTED]",
      "percentage": "7.75",
      "type": "ADDITIVE",
      "applied_money": {
        "amount": 3875,
        "currency": "USD"
      },
      "scope": "LINE_ITEM"
    }
  ],
  "created_at": "2021-05-14T17:11:01.000Z",
  "updated_at": "2021-05-14T17:40:45.000Z",
  "state": "COMPLETED",
  "total_tax_money": {
    "amount": 3875,
    "currency": "USD"
  },
  "total_discount_money": {
    "amount": 0,
    "currency": "USD"
  },
  "total_tip_money": {
    "amount": 0,
    "currency": "USD"
  },
  "total_money": {
    "amount": 53875,
    "currency": "USD"
  },
  "closed_at": "2021-05-14T17:40:45.000Z",
  "total_service_charge_money": {
    "amount": 0,
    "currency": "USD"
  },
  "returns": [
    {
      "source_order_id": "[REDACTED]",
      "return_line_items": [
        {
          "uid": "[REDACTED]",
          "source_line_item_uid": "[REDACTED]",
          "name": "[REDACTED]",
          "quantity": "1",
          "catalog_object_id": "[REDACTED]",
          "variation_name": "[REDACTED]",
          "item_type": "ITEM",
          "return_modifiers": [
            {
              "uid": "[REDACTED]",
              "catalog_object_id": "[REDACTED]",
              "name": "6",
              "base_price_money": {
                "amount": 0,
                "currency": "USD"
              },
              "total_price_money": {
                "amount": 0,
                "currency": "USD"
              }
            }
          ],
          "applied_taxes": [
            {
              "uid": "[REDACTED]",
              "tax_uid": "[REDACTED]",
              "applied_money": {
                "amount": 4262,
                "currency": "USD"
              }
            }
          ],
          "base_price_money": {
            "amount": 55000,
            "currency": "USD"
          },
          "variation_total_price_money": {
            "amount": 55000,
            "currency": "USD"
          },
          "gross_return_money": {
            "amount": 55000,
            "currency": "USD"
          },
          "total_tax_money": {
            "amount": 4262,
            "currency": "USD"
          },
          "total_discount_money": {
            "amount": 0,
            "currency": "USD"
          },
          "total_money": {
            "amount": 59262,
            "currency": "USD"
          }
        }
      ],
      "return_taxes": [
        {
          "uid": "[REDACTED]",
          "catalog_object_id": "[REDACTED]",
          "name": "[REDACTED]",
          "type": "ADDITIVE",
          "percentage": "7.75",
          "applied_money": {
            "amount": 4262,
            "currency": "USD"
          },
          "scope": "LINE_ITEM"
        }
      ]
    }
  ],
  "return_amounts": {
    "total_money": {
      "amount": 59262,
      "currency": "USD"
    },
    "tax_money": {
      "amount": 4262,
      "currency": "USD"
    },
    "discount_money": {
      "amount": 0,
      "currency": "USD"
    },
    "tip_money": {
      "amount": 0,
      "currency": "USD"
    },
    "service_charge_money": {
      "amount": 0,
      "currency": "USD"
    }
  },
  "net_amounts": {
    "total_money": {
      "amount": -5387,
      "currency": "USD"
    },
    "tax_money": {
      "amount": -387,
      "currency": "USD"
    },
    "discount_money": {
      "amount": 0,
      "currency": "USD"
    },
    "tip_money": {
      "amount": 0,
      "currency": "USD"
    },
    "service_charge_money": {
      "amount": 0,
      "currency": "USD"
    }
  },
  "refunds": [
    {
      "id": "[REDACTED]",
      "location_id": "[REDACTED]",
      "transaction_id": "[REDACTED]",
      "tender_id": "[REDACTED]",
      "created_at": "2021-05-14T17:11:01Z",
      "reason": "Exchange",
      "amount_money": {
        "amount": 5387,
        "currency": "USD"
      },
      "status": "APPROVED",
      "processing_fee_money": {
        "amount": 137,
        "currency": "USD"
      }
    }
  ],
  "customer_id": "[REDACTED]"
}