---
title: Complete an asynchronous purchase
slug: docs/demo/complete-an-asynchronous-purchase
description: Learn how to use cURL to send a PATCH request to a specific API endpoint with this helpful code example. Discover how to set headers for accepting and sending JSON data, and explore a JSON payload that includes efficient asynchronous processing parameters
docTags: 
createdAt: 2022-03-21T20:12:45.000Z
---

{
  "id": "W54WMbpolvvXcn-3WHyXA",
  "data": {
    "url": "https://api.fictive.com/REST/api/accounts/{accountReference}/payments",
    "name": "Complete an asynchronous purchase",
    "method": "PATCH",
    "request": {
      "pathParameters": [
        {
          "kind": "required",
          "name": "accountReference",
          "type": "string",
          "description": "Account reference"
        }
      ],
      "queryParameters": [],
      "headerParameters": [
        {
          "kind": "optional",
          "name": "X-TokenId",
          "type": "string",
          "description": "The eSuite Token Id"
        },
        {
          "kind": "optional",
          "name": "X-SessionId",
          "type": "string",
          "description": "The eSuite Session Id"
        },
        {
          "kind": "required",
          "name": "X-Version",
          "type": "string",
          "description": "The eSuite Version"
        },
        {
          "kind": "optional",
          "name": "Origin",
          "type": "string",
          "description": "The eSuite Origin"
        }
      ],
      "bodyDataParameters": [
        {
          "kind": "required",
          "name": "request",
          "type": "object",
          "schema": [
            {
              "kind": "optional",
              "name": "asynchronousProcessingParameters",
              "type": "object",
              "schema": [],
              "example": {},
              "description": "Asynchronous Processing Parameters"
            }
          ],
          "modelRef": "#/definitions/FictiveGlobal.Api.Rest.Dtos.v1.CompletePurchase",
          "customType": "FictiveGlobal.Api.Rest.Dtos.v1.CompletePurchase",
          "isExpanded": true,
          "description": "Complete purchase class"
        }
      ],
      "formDataParameters": []
    },
    "responses": [
      {
        "schema": [
          {
            "kind": "optional",
            "type": "object",
            "schema": [
              {
                "kind": "optional",
                "name": "sessionToken",
                "type": "string",
                "example": "",
                "description": "Gets or sets the session token"
              },
              {
                "kind": "optional",
                "name": "basketNumber",
                "type": "string",
                "example": "",
                "description": "Gets or sets the basket number"
              },
              {
                "kind": "optional",
                "name": "orders",
                "type": "array",
                "schema": [
                  {
                    "kind": "optional",
                    "name": "orderId",
                    "type": "integer<int32>",
                    "example": 0,
                    "description": "Gets or sets the order id"
                  },
                  {
                    "kind": "optional",
                    "name": "externalOrderReference",
                    "type": "string",
                    "example": "",
                    "description": "Gets or sets the external order reference"
                  }
                ],
                "modelRef": "#/definitions/FictiveGlobal.Api.Rest.Dtos.v1.ProcessPaymentOrderInfo",
                "customType": "FictiveGlobal.Api.Rest.Dtos.v1.ProcessPaymentOrderInfo[]",
                "description": "Gets or sets the process payment orders"
              },
              {
                "kind": "optional",
                "name": "asynchronousProcessingParameters",
                "type": "object",
                "schema": [],
                "example": {},
                "description": "Asynchronous Processing Parameters"
              }
            ],
            "modelRef": "#/definitions/FictiveGlobal.Api.Rest.Dtos.v1.ProcessPaymentSummaryDirect",
            "customType": "FictiveGlobal.Api.Rest.Dtos.v1.ProcessPaymentSummaryDirect",
            "isExpanded": true,
            "description": "Process payment summary class"
          }
        ],
        "isExpanded": true,
        "statusCode": "200",
        "description": "OK",
        "jsonExample": "{\n  \"basketNumber\": \"433M098765\",\n  \"orders\": [\n    {\n      \"orderId\": 154874,\n      \"externalOrderReference\": \"134Order\"\n    }\n  ]\n}"
      },
      {
        "isExpanded": true,
        "statusCode": "401",
        "description": "Not Authorized",
        "jsonExample": ""
      },
      {
        "isExpanded": true,
        "statusCode": "403",
        "description": "Forbidden",
        "jsonExample": ""
      },
      {
        "isExpanded": true,
        "statusCode": "404",
        "description": "Not Found",
        "jsonExample": ""
      },
      {
        "isExpanded": true,
        "statusCode": "500",
        "description": "Internal Server Error",
        "jsonExample": ""
      },
      {
        "isExpanded": true,
        "statusCode": "503",
        "description": "Unable to validate the 3D Secure Process due to downstream partners",
        "jsonExample": ""
      }
    ],
    "contentType": "application/json",
    "description": "This endpoint will provide the ability to complete a payment that has been made using an asynchronous payment method. An asynchronous payment method is classified as PayPal, 3D Secure, etc.",
    "examples": {
      "languages": [
        {
          "id": "7hSVotCMRiSx39MRaZ5U5",
          "language": "curl",
          "label": "cURL",
          "code": "curl --request PATCH \\\n     --url https://api.fictive.com/REST/api/accounts/{accountReference}/payments \\\n     --header 'accept: application/json' \\\n     --header 'x-version: string'"
        },
        {
          "id": "6h1cNd1ckfXwvvxbdGEBq",
          "language": "javascript",
          "label": "javascript",
          "code": "var myHeaders = new Headers();\nmyHeaders.append(\"accept\", \"application/json\");\nmyHeaders.append(\"content-type\", \"application/json\");\nmyHeaders.append(\"x-version\", \"string\");\n\nvar requestOptions = {\n   method: 'PATCH',\n   headers: myHeaders,\n   redirect: 'follow'\n};\n\nfetch(\"https://api.fictive.com/REST/api/accounts/{accountReference}/payments\", requestOptions)\n   .then(response => response.text())\n   .then(result => console.log(result))\n   .catch(error => console.log('error', error));"
        },
        {
          "id": "eBtpaFjVHs3LpTd_yS2DR",
          "language": "ruby",
          "label": "Ruby",
          "code": "require \"uri\"\nrequire \"json\"\nrequire \"net/http\"\n\nurl = URI(\"https://api.fictive.com/REST/api/accounts/{accountReference}/payments\")\n\nhttps = Net::HTTP.new(url.host, url.port)\nhttps.use_ssl = true\n\nrequest = Net::HTTP::Patch.new(url)\nrequest[\"accept\"] = \"application/json\"\nrequest[\"content-type\"] = \"application/json\"\nrequest[\"x-version\"] = \"string\"\n\nresponse = https.request(request)\nputs response.read_body\n"
        },
        {
          "id": "5uUWA0q3YYYnf7LMPlM_y",
          "language": "python",
          "label": "Python",
          "code": "import requests\nimport json\n\nurl = \"https://api.fictive.com/REST/api/accounts/{accountReference}/payments\"\n\npayload = {}\nheaders = {\n   'accept': 'application/json',\n   'content-type': 'application/json',\n   'x-version': 'string'\n}\n\nresponse = requests.request(\"PATCH\", url, headers=headers, data=payload)\n\nprint(response.text)\n"
        }
      ],
      "selectedLanguageId": "7hSVotCMRiSx39MRaZ5U5"
    },
    "results": {
      "languages": [
        {
          "id": "response-0-200",
          "language": "200",
          "code": "{\n  \"basketNumber\": \"433M098765\",\n  \"orders\": [\n    {\n      \"orderId\": 154874,\n      \"externalOrderReference\": \"134Order\"\n    }\n  ]\n}"
        },
        {
          "id": "response-1-401",
          "language": "401",
          "code": "// Not Authorized\n"
        },
        {
          "id": "response-2-403",
          "language": "403",
          "code": "// Forbidden\n"
        },
        {
          "id": "response-3-404",
          "language": "404",
          "code": "// Not Found\n"
        },
        {
          "id": "response-4-500",
          "language": "500",
          "code": "// Internal Server Error\n"
        },
        {
          "id": "response-5-503",
          "language": "503",
          "code": "// Unable to validate the 3D Secure Process due to downstream partners\n"
        }
      ],
      "selectedLanguageId": "response-0-200"
    }
  },
  "type": "api-oas-v2",
  "children": [
    {
      "text": ""
    }
  ]
}