---
title: Initiate a service credit purchase
slug: docs/demo/initiate-a-service-credit-purchase
description: Learn how to use curl to send a secure POST request to an API endpoint in this code example. Explore the implementation of essential headers and data fields like payment method, currency, CVV, voucher code, and credit amounts for efficient API integration
createdAt: 2022-03-21T20:12:45.000Z
---

{
  "id": "0ng-5C_ZVLaLYt70lQaZW",
  "data": {
    "url": "https://api.fictive.com/REST/api/accounts/{accountReference}/service-credits",
    "name": "Initiate a service credit purchase",
    "method": "POST",
    "request": {
      "pathParameters": [
        {
          "kind": "required",
          "name": "accountReference",
          "type": "string",
          "description": "The 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": "paymentMethod",
              "type": "string",
              "example": "",
              "description": "Gets or sets the payment method"
            },
            {
              "kind": "optional",
              "name": "currency",
              "type": "string<ZZZ | GBP | EUR | USD | AUD | CAD | SEK | DKK | JPY | FictiveCREDITS | SAR | BGN | TWD | CZK | ILS | HUF | ISK | KRW | NOK | PLN | BRL | CHF | RON | RUB | HRK | ALL | THB | TRY | PKR | IDR | UAH | BYR | EEK | LVL | LTL | TJS | IRR | VND | AMD | AZN | MKD | ZAR | GEL | INR | MYR | KZT | KGS | KES | TMT | UZS | MNT | CNY | KHR | LAK | SYP | LKR | ETB | NPR | AFN | PHP | MVR | NIO | BOB | CLP | NZD | GTQ | RWF | XOF | IQD | MXN | CSD | BND | BDT | DZD | EGP | HKD | PEN | LYD | SGD | BAM | MOP | CRC | MAD | PAB | TND | DOP | OMR | JMD | VEB | YER | COP | RSD | BZD | JOD | TTD | ARS | LBP | ZWL | KWD | AED | UYU | BHD | PYG | QAR | HNL>",
              "example": "",
              "description": "Currency"
            },
            {
              "kind": "optional",
              "name": "cvv",
              "type": "string",
              "example": "",
              "description": "Gets or sets the cv2 number"
            },
            {
              "kind": "optional",
              "name": "voucherCode",
              "type": "string",
              "example": "",
              "description": "Gets or sets the voucher code"
            },
            {
              "kind": "optional",
              "name": "paidCredits",
              "type": "number<double>",
              "example": "",
              "description": "Gets or sets the paid credits"
            },
            {
              "kind": "optional",
              "name": "freeCredits",
              "type": "number<double>",
              "example": "",
              "description": "Gets or sets the free credits"
            },
            {
              "kind": "optional",
              "name": "asynchronousInitiationParameters",
              "type": "object",
              "schema": [],
              "example": {},
              "description": "Asynchronous Processing Parameters"
            },
            {
              "kind": "optional",
              "name": "enhancedProcessingData",
              "type": "object",
              "schema": [],
              "example": {},
              "description": "EnhancedProcessingData Processing Parameters"
            }
          ],
          "modelRef": "#/definitions/FictiveGlobal.Api.Rest.Dtos.v2.BuyCredits",
          "customType": "FictiveGlobal.Api.Rest.Dtos.v2.BuyCredits",
          "isExpanded": true,
          "description": "Buy credits class"
        }
      ],
      "formDataParameters": []
    },
    "responses": [
      {
        "schema": [
          {
            "kind": "optional",
            "type": "object",
            "schema": [
              {
                "kind": "optional",
                "name": "orderId",
                "type": "string",
                "example": "",
                "description": "Order Id"
              },
              {
                "kind": "optional",
                "name": "resourceReference",
                "type": "string",
                "example": "",
                "description": "Resource Reference"
              },
              {
                "kind": "optional",
                "name": "asynchronousProcessingParameters",
                "type": "object",
                "schema": [],
                "example": {},
                "description": "Asynchronous Processing Parameters"
              }
            ],
            "modelRef": "#/definitions/FictiveGlobal.Api.Rest.Dtos.v1.BuyCreditsSummary",
            "customType": "FictiveGlobal.Api.Rest.Dtos.v1.BuyCreditsSummary",
            "isExpanded": true,
            "description": "Buy credits response"
          }
        ],
        "isExpanded": true,
        "statusCode": "204",
        "description": "No Content",
        "jsonExample": "{\n  \"orderId\": \"123456\",\n  \"asynchronousProcessingParameters\": {\n    \"threeDSecureAcsUrl\": \"https%3A%2F%2Fwww.secpay.com%2Fjava-bin%2FACSSimulator%3Fpartner%3Dsecpay%26VAA%3DB\",\n    \"threeDSecureEnrolled\": \"false\",\n    \"threeDSecureHtml\": \"<head><title> 3-D Secure Verification</title></head>\",\n    \"threeDSecureMD\": \"2058804607\",\n    \"threeDSecurePaReq\": \"eJxVUctuwjAQvPcronwA65g32hilBKkcQtM2qtRjZFYQRAI4Tgl/XztNeFiytDP27I5mcV7nB+eXVJkdC9/1esydixdMdooo/CJZKRIYUVmmW3Kyje9yNpxM2GDExq7AOPiks8BWLoy6xxE6aHRK7tJCC0zl+XW1FoMpnzKG0ELMSa1CwZ4Pwj+NRZqTiOLYSajUTiDlsSo0QkNjA9RVTPgIoQNYqYPYaX2aASBYgHA3EVe2Ko24zjYi2gfee7i9rMOfy/oabFeL2/UR7A/cpJoEZ96ITdnQ8QazPp/1xwgNj2lupwqvsdwCPNkZwePLI4MmT0WF7Gx3CKk+HQsyP0x8txrh7njxZkOU2uTyvV/yKFnW0Yfv2ygb0nbITAKcMa9pYQGClUG7JWjXaKqn9f4BGD6mtQ==\",\n    \"threeDSecureStatus\": \"RedirectionToAuthSiteRequired\"\n  }\n}"
      },
      {
        "isExpanded": true,
        "statusCode": "401",
        "description": "Payment could not be 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": ""
      }
    ],
    "contentType": "application/json",
    "description": "This endpoint allows for the initiations of a purchase of service credits.If a synchronous payment method has been selected (credit or debit card) the payment will be completed immediately.If the payment method is asynchronous (PayPal, P24, Carrier Billing, etc.)",
    "examples": {
      "languages": [
        {
          "id": "example-0-curl",
          "language": "curl",
          "label": "cURL",
          "code": "curl --request POST \\\n     --url https://api.fictive.com/REST/api/accounts/{accountReference}/service-credits \\\n     --header 'accept: application/json' \\\n     --header 'x-version: string'"
        },
        {
          "id": "example-1-javascript",
          "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: 'POST',\n   headers: myHeaders,\n   redirect: 'follow'\n};\n\nfetch(\"https://api.fictive.com/REST/api/accounts/{accountReference}/service-credits\", 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(\"https://api.fictive.com/REST/api/accounts/{accountReference}/service-credits\")\n\nhttps = Net::HTTP.new(url.host, url.port)\nhttps.use_ssl = true\n\nrequest = Net::HTTP::Post.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": "example-3-python",
          "language": "python",
          "label": "Python",
          "code": "import requests\nimport json\n\nurl = \"https://api.fictive.com/REST/api/accounts/{accountReference}/service-credits\"\n\npayload = {}\nheaders = {\n   'accept': 'application/json',\n   'content-type': 'application/json',\n   'x-version': 'string'\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-204",
          "language": "204",
          "code": "{\n  \"orderId\": \"123456\",\n  \"asynchronousProcessingParameters\": {\n    \"threeDSecureAcsUrl\": \"https%3A%2F%2Fwww.secpay.com%2Fjava-bin%2FACSSimulator%3Fpartner%3Dsecpay%26VAA%3DB\",\n    \"threeDSecureEnrolled\": \"false\",\n    \"threeDSecureHtml\": \"<head><title> 3-D Secure Verification</title></head>\",\n    \"threeDSecureMD\": \"2058804607\",\n    \"threeDSecurePaReq\": \"eJxVUctuwjAQvPcronwA65g32hilBKkcQtM2qtRjZFYQRAI4Tgl/XztNeFiytDP27I5mcV7nB+eXVJkdC9/1esydixdMdooo/CJZKRIYUVmmW3Kyje9yNpxM2GDExq7AOPiks8BWLoy6xxE6aHRK7tJCC0zl+XW1FoMpnzKG0ELMSa1CwZ4Pwj+NRZqTiOLYSajUTiDlsSo0QkNjA9RVTPgIoQNYqYPYaX2aASBYgHA3EVe2Ko24zjYi2gfee7i9rMOfy/oabFeL2/UR7A/cpJoEZ96ITdnQ8QazPp/1xwgNj2lupwqvsdwCPNkZwePLI4MmT0WF7Gx3CKk+HQsyP0x8txrh7njxZkOU2uTyvV/yKFnW0Yfv2ygb0nbITAKcMa9pYQGClUG7JWjXaKqn9f4BGD6mtQ==\",\n    \"threeDSecureStatus\": \"RedirectionToAuthSiteRequired\"\n  }\n}"
        },
        {
          "id": "response-1-401",
          "language": "401",
          "code": "// Payment could not be 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"
        }
      ],
      "selectedLanguageId": "response-0-204"
    }
  },
  "type": "api-oas-v2",
  "children": [
    {
      "text": ""
    }
  ]
}