---
title: Complete an asynchronous subscription purchase
slug: docs/demo/complete-an-asynchronous-subscription-purchase
description: Learn how to make a PATCH request to the REST API of a fictive company using cURL. This document provides a code example that demonstrates sending the request to the /accounts/{accountReference}/subscriptions endpoint. It also covers the necessary headers
docTags: 
createdAt: 2022-03-21T20:12:45.000Z
---

{
  "id": "PqpEnSLOX2IkCn-HcsjfF",
  "data": {
    "url": "https://api.fictive.com/REST/api/accounts/{accountReference}/subscriptions",
    "name": "Complete an asynchronous subscription purchase",
    "method": "PATCH",
    "request": {
      "pathParameters": [
        {
          "kind": "required",
          "name": "accountReference",
          "type": "string",
          "description": "The account reference identifier."
        }
      ],
      "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": "amountCharged",
                "type": "number<double>",
                "example": "",
                "description": "Amount charged"
              },
              {
                "kind": "optional",
                "name": "currency",
                "type": "string",
                "example": "",
                "description": "Currency"
              },
              {
                "kind": "optional",
                "name": "paymentType",
                "type": "string",
                "example": "",
                "description": "Payment type"
              },
              {
                "kind": "optional",
                "name": "subscriptionStatus",
                "type": "string",
                "example": "",
                "description": "Subscription status"
              },
              {
                "kind": "optional",
                "name": "renewalDay",
                "type": "integer<int32>",
                "example": 0,
                "description": "Renewal day"
              },
              {
                "kind": "optional",
                "name": "renewalDayOffset",
                "type": "integer<int32>",
                "example": 0,
                "description": "Renewal day offset"
              },
              {
                "kind": "optional",
                "name": "startDate",
                "type": "string<date-time>",
                "example": "2021-09-21T05:33:10.1821164",
                "description": "Start date"
              },
              {
                "kind": "optional",
                "name": "renewalDate",
                "type": "string<date-time>",
                "example": "2021-09-21T05:33:10.1821164",
                "description": "Renewal date"
              },
              {
                "kind": "optional",
                "name": "orderReference",
                "type": "string",
                "example": "",
                "description": "Order reference"
              },
              {
                "kind": "optional",
                "name": "contractReference",
                "type": "string",
                "example": "",
                "description": "Contract reference (encoded ServiceID)"
              },
              {
                "kind": "optional",
                "name": "subscriptionPriceReference",
                "type": "string",
                "example": "",
                "description": "Subscription price reference"
              },
              {
                "kind": "optional",
                "name": "subscriptionReference",
                "type": "string",
                "example": "",
                "description": "Subscription reference"
              },
              {
                "kind": "optional",
                "name": "resourceReference",
                "type": "string",
                "example": "",
                "description": "Resource reference"
              },
              {
                "kind": "optional",
                "name": "asynchronousProcessingParameters",
                "type": "object",
                "schema": [],
                "example": {},
                "description": "Asynchronous Processing Parameters"
              },
              {
                "kind": "optional",
                "name": "shippingAddressReference",
                "type": "string",
                "example": "",
                "description": "Address reference for the shipping address"
              },
              {
                "kind": "optional",
                "name": "invoiceAddressReference",
                "type": "string",
                "example": "",
                "description": "Address reference for the invoice address"
              },
              {
                "kind": "optional",
                "name": "sessionToken",
                "type": "string",
                "example": "",
                "description": "Session token"
              },
              {
                "kind": "optional",
                "name": "cartReference",
                "type": "string",
                "example": "",
                "description": "Cart reference (if this was a Bundle Purchase subscription)"
              }
            ],
            "modelRef": "#/definitions/FictiveGlobal.Api.Rest.Dtos.v4.AddSubscriptionSummary",
            "customType": "FictiveGlobal.Api.Rest.Dtos.v4.AddSubscriptionSummary",
            "isExpanded": true,
            "description": "Add subscription response object"
          }
        ],
        "isExpanded": true,
        "statusCode": "200",
        "description": "OK",
        "jsonExample": "{\n  \"amountCharged\": 10,\n  \"currency\": \"GBP\",\n  \"paymentType\": \"eWallet\",\n  \"subscriptionStatus\": \"Active\",\n  \"renewalDay\": 1,\n  \"renewalDayOffset\": 0,\n  \"startDate\": \"2021-09-21T05:33:10.3696265+00:00\",\n  \"renewalDate\": \"2021-09-21T05:33:10.3696265+00:00\",\n  \"orderReference\": \"0010KFS4AXAQTC1VE6\",\n  \"contractReference\": \"0010KFS4WXAQTD1IV1\",\n  \"subscriptionPriceReference\": \"0010NU1UB9TFEGEZ61\",\n  \"subscriptionReference\": \"SubscriptionReference\",\n  \"resourceReference\": \"ResourceReference\",\n  \"asynchronousProcessingParameters\": {\n    \"name1\": \"value1\"\n  },\n  \"shippingAddressReference\": \"0010D0ZRRUGNBNUKM1\",\n  \"invoiceAddressReference\": \"0010DDXSRHB9ZU07Z1\",\n  \"cartReference\": \"CDE456\"\n}"
      },
      {
        "isExpanded": true,
        "statusCode": "400",
        "description": "Request is invalid.",
        "jsonExample": ""
      },
      {
        "isExpanded": true,
        "statusCode": "403",
        "description": "Unable to authenticate using the provided session.",
        "jsonExample": ""
      },
      {
        "isExpanded": true,
        "statusCode": "500",
        "description": "Internal Server Error.",
        "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, P24, Carrier Billing, etc.",
    "examples": {
      "languages": [
        {
          "id": "ubUSLm3JzIHUlrYS-cets",
          "language": "curl",
          "label": "cURL",
          "code": "curl --request PATCH \\\n     --url https://api.fictive.com/REST/api/accounts/{accountReference}/subscriptions \\\n     --header 'accept: application/json' \\\n     --header 'x-version: string'"
        },
        {
          "id": "5asxhL6fDO3RWOr8MQJMT",
          "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}/subscriptions\", requestOptions)\n   .then(response => response.text())\n   .then(result => console.log(result))\n   .catch(error => console.log('error', error));"
        },
        {
          "id": "RQQlzdObVAd8lqVhPugTP",
          "language": "ruby",
          "label": "Ruby",
          "code": "require \"uri\"\nrequire \"json\"\nrequire \"net/http\"\n\nurl = URI(\"https://api.fictive.com/REST/api/accounts/{accountReference}/subscriptions\")\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": "ETa57Lnk6XPMf2pr5I4Li",
          "language": "python",
          "label": "Python",
          "code": "import requests\nimport json\n\nurl = \"https://api.fictive.com/REST/api/accounts/{accountReference}/subscriptions\"\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": "ubUSLm3JzIHUlrYS-cets"
    },
    "results": {
      "languages": [
        {
          "id": "response-0-200",
          "language": "200",
          "code": "{\n  \"amountCharged\": 10,\n  \"currency\": \"GBP\",\n  \"paymentType\": \"eWallet\",\n  \"subscriptionStatus\": \"Active\",\n  \"renewalDay\": 1,\n  \"renewalDayOffset\": 0,\n  \"startDate\": \"2021-09-21T05:33:10.3696265+00:00\",\n  \"renewalDate\": \"2021-09-21T05:33:10.3696265+00:00\",\n  \"orderReference\": \"0010KFS4AXAQTC1VE6\",\n  \"contractReference\": \"0010KFS4WXAQTD1IV1\",\n  \"subscriptionPriceReference\": \"0010NU1UB9TFEGEZ61\",\n  \"subscriptionReference\": \"SubscriptionReference\",\n  \"resourceReference\": \"ResourceReference\",\n  \"asynchronousProcessingParameters\": {\n    \"name1\": \"value1\"\n  },\n  \"shippingAddressReference\": \"0010D0ZRRUGNBNUKM1\",\n  \"invoiceAddressReference\": \"0010DDXSRHB9ZU07Z1\",\n  \"cartReference\": \"CDE456\"\n}"
        },
        {
          "id": "response-1-400",
          "language": "400",
          "code": "// Request is invalid.\n"
        },
        {
          "id": "response-2-403",
          "language": "403",
          "code": "// Unable to authenticate using the provided session.\n"
        },
        {
          "id": "response-3-500",
          "language": "500",
          "code": "// Internal Server Error.\n"
        }
      ],
      "selectedLanguageId": "response-0-200"
    }
  },
  "type": "api-oas-v2",
  "children": [
    {
      "text": ""
    }
  ]
}