---
title: Pay sale with client credit
slug: import-test-pdf/pay-sale-with-client-credit
createdAt: 2025-10-28T16:28:34.274Z
---

{
  "id": "-P0uXR6tBpS-W2SCrbXXA",
  "type": "api-oas-v2",
  "data": {
    "method": "POST",
    "url": "/api/v1/sales/{id}/pay-with-credit",
    "servers": [],
    "name": "Pay sale with client credit",
    "description": "<p>If amount sent is greater than sale amount due, after the sale is paid, difference between amount sent and sale amount due is used to pay outstanding balance sales.\n<a href=\"https://app.shortcut.com/digitail/story/8660/pay-sale-with-client-credit\" target=\"_blank\">undefined</a></p>",
    "contentType": "application/json",
    "request": {
      "pathParameters": [],
      "headerParameters": [],
      "queryParameters": [],
      "bodyDataParameters": [
        {
          "kind": "required",
          "name": "body",
          "type": "object",
          "description": "",
          "schema": [
            {
              "name": "amount",
              "kind": "optional",
              "type": "number<double>",
              "description": "",
              "example": "100,00"
            },
            {
              "name": "type",
              "kind": "optional",
              "type": "integer",
              "description": "Payment from client credit has type 8",
              "example": 0,
              "default": 8
            },
            {
              "name": "date",
              "kind": "optional",
              "type": "string<date-time>",
              "description": "Payment date.",
              "example": ""
            },
            {
              "name": "notes",
              "kind": "optional",
              "type": "string",
              "description": "Payment notes - if not sent then the notes from the charge will be used",
              "example": "Paid with credit"
            }
          ],
          "isExpanded": true
        }
      ],
      "formDataParameters": [],
      "oAuthParameters": []
    },
    "responses": [
      {
        "statusCode": "200",
        "description": "Successful operation - return sale's payments",
        "jsonExample": "",
        "isExpanded": true,
        "schema": [
          {
            "kind": "optional",
            "type": "object",
            "description": "",
            "schema": [
              {
                "name": "data",
                "kind": "optional",
                "type": "object",
                "description": "",
                "example": "",
                "schema": [
                  {
                    "name": "id",
                    "kind": "optional",
                    "type": "integer",
                    "description": "",
                    "example": 6
                  },
                  {
                    "name": "amount",
                    "kind": "optional",
                    "type": "number<double>",
                    "description": "",
                    "example": "100.00"
                  },
                  {
                    "name": "amount_refunded",
                    "kind": "optional",
                    "type": "number<double>",
                    "description": "",
                    "example": "0.00"
                  },
                  {
                    "name": "amount_left",
                    "kind": "optional",
                    "type": "number<double>",
                    "description": "",
                    "example": "0.00"
                  },
                  {
                    "name": "date",
                    "kind": "optional",
                    "type": "string<date-time>",
                    "description": "",
                    "example": "2022-05-13T00:00:00Z"
                  },
                  {
                    "name": "notes",
                    "kind": "optional",
                    "type": "string",
                    "description": "",
                    "example": ""
                  },
                  {
                    "name": "sale_id",
                    "kind": "optional",
                    "type": "integer",
                    "description": "",
                    "example": 5
                  },
                  {
                    "name": "sale",
                    "kind": "optional",
                    "type": "object",
                    "description": "",
                    "example": "",
                    "schema": []
                  },
                  {
                    "name": "charge_id",
                    "kind": "optional",
                    "type": "integer",
                    "description": "",
                    "example": 4
                  },
                  {
                    "name": "charge",
                    "kind": "optional",
                    "type": "object",
                    "description": "",
                    "example": "",
                    "schema": []
                  }
                ]
              }
            ],
            "isExpanded": true
          }
        ]
      }
    ],
    "hasXCodeSamples": false,
    "examples": {
      "languages": [
        {
          "id": "example-0-curl",
          "language": "curl",
          "label": "cURL",
          "code": "curl --request POST \\\n     --url /api/v1/sales/{id}/pay-with-credit \\\n     --header 'accept: application/json' \\\n     --header 'content-type: application/json' \\\n     --data '{\n     \"type\": 8\n     }'"
        },
        {
          "id": "example-1-javascript",
          "language": "javascript",
          "label": "javascript",
          "code": "var myHeaders = new Headers();\nmyHeaders.append(\"accept\", \"application/json\");\nmyHeaders.append(\"content-type\", \"application/json\");\n\nvar raw = JSON.stringify({\n   \"type\": 8\n});\n\nvar requestOptions = {\n   method: 'POST',\n   headers: myHeaders,\n   body: raw,\n   redirect: 'follow'\n};\n\nfetch(\"/api/v1/sales/{id}/pay-with-credit\", requestOptions)\n   .then(response => response.text())\n   .then(result => console.log(result))\n   .catch(error => console.log('error', error));"
        },
        {
          "id": "example-2-ruby",
          "language": "ruby",
          "label": "Ruby",
          "code": "require \"uri\"\nrequire \"json\"\nrequire \"net/http\"\n\nurl = URI(\"/api/v1/sales/{id}/pay-with-credit\")\n\nhttp = Net::HTTP.new(url.host, url.port);\nrequest = Net::HTTP::Post.new(url)\nrequest[\"accept\"] = \"application/json\"\nrequest[\"content-type\"] = \"application/json\"\nrequest.body = JSON.dump({\n   \"type\": 8\n})\n\nresponse = http.request(request)\nputs response.read_body\n"
        },
        {
          "id": "example-3-python",
          "language": "python",
          "label": "Python",
          "code": "import requests\nimport json\n\nurl = \"/api/v1/sales/{id}/pay-with-credit\"\n\npayload = json.dumps({\n   \"type\": 8\n})\nheaders = {\n   'accept': 'application/json',\n   'content-type': 'application/json'\n}\n\nresponse = requests.request(\"POST\", url, headers=headers, data=payload)\n\nprint(response.text)\n"
        }
      ],
      "selectedLanguageId": "example-0-curl"
    },
    "results": {
      "languages": [
        {
          "id": "response-0-200",
          "language": "200",
          "code": "// Successful operation - return sale's payments\n{\n  \"data\": {\n    \"id\": 6,\n    \"amount\": \"100.00\",\n    \"amount_refunded\": \"0.00\",\n    \"amount_left\": \"0.00\",\n    \"date\": \"2022-05-13T00:00:00Z\",\n    \"notes\": \"\",\n    \"sale_id\": 5,\n    \"sale\": {},\n    \"charge_id\": 4,\n    \"charge\": {}\n  }\n}"
        }
      ],
      "selectedLanguageId": "response-0-200"
    }
  },
  "children": [
    {
      "text": ""
    }
  ]
}