{
  "openapi": "3.1.0",
  "info": {
    "title": "Newpay Checkout",
    "version": "1.0",
    "contact": {
      "email": "api@dekopay.com"
    },
    "description": "Server-to-server integration for Superpayments, limited to Newpay.\nObtain a merchant bearer token, create a checkout, retrieve its current\nstate, and request cancellation or refund.\n\nAll Deko examples use the Deko preproduction environment. Credentials and\nidentifiers in examples are placeholders, not usable credentials.\nMonetary amounts are integer pence (GBP).\n\nKeep the unique merchant `reference` supplied at creation: retrieval and\nactions use that reference, not the Deko order UUID. Creation returns\ncheckout details, not a standalone transactionId field. The Deko order UUID\nis the final path segment of `_links.self.href`; callbacks also expose it\nas `id`, alongside the merchant `reference`.\n\nCreating a transaction does not itself complete a customer's Newpay credit\napplication or guarantee approval. This document covers checkout management,\nnot the consumer application journey. Superpayments' API-only management\nintegration must be coordinated with the agreed Newpay consumer journey.\n\nSupply `callbackUri` at creation to receive status updates. Treat callbacks\nas notifications to retrieve the latest state with the authenticated\nGET /transaction/{reference}. Callback order states and signed-receipt\nstates are different from the public checkout `status` values.\n\nThe Webhooks section defines the JSON payload DekoPay POSTs to your\ncallbackUri and the acknowledgement your endpoint must return. The same\nwebhook is linked from POST /transaction through an OpenAPI callback\nexpression, so its per-checkout destination is explicit.\n"
  },
  "servers": [
    {
      "url": "https://api.preprod.deko.dekopay.com",
      "description": "DekoPay preproduction"
    }
  ],
  "security": [
    {
      "MerchantBearerAuth": []
    }
  ],
  "tags": [
    {
      "name": "Authentication"
    },
    {
      "name": "Transactions"
    },
    {
      "name": "Webhooks",
      "description": "Outbound notifications delivered by DekoPay to Superpayments."
    }
  ],
  "webhooks": {
    "checkoutStatusChanged": {
      "$ref": "#/components/pathItems/CheckoutStatusWebhook"
    }
  },
  "paths": {
    "/auth": {
      "post": {
        "operationId": "AuthenticateSuperpayments",
        "tags": [
          "Authentication"
        ],
        "summary": "Generate a merchant access token",
        "description": "Use the merchant client credentials issued for preproduction.\nCache the token for its `expires_in` lifetime and send it as\n`Authorization: Bearer <access_token>` on transaction requests.\nNeither grant_type nor audience needs to be supplied.\nKeep credentials and tokens on the server, never in browser code.\n",
        "security": [],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AccessTokenRequest"
              },
              "example": {
                "client_id": "YOUR_PREPROD_CLIENT_ID",
                "client_secret": "YOUR_PREPROD_CLIENT_SECRET"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Merchant access token issued.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AccessTokenResponse"
                },
                "example": {
                  "access_token": "YOUR_ACCESS_TOKEN",
                  "expires_in": 86400,
                  "token_type": "Bearer"
                }
              }
            }
          },
          "400": {
            "description": "Missing or empty client credentials.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AuthError"
                },
                "example": {
                  "code": 0,
                  "message": "string",
                  "httpStatus": "string",
                  "fieldErrors": [
                    {}
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Invalid client credentials.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AuthError"
                },
                "example": {
                  "code": 401,
                  "message": "access_denied",
                  "httpStatus": "UNAUTHORIZED"
                }
              }
            }
          }
        },
        "x-codeSamples": [
          {
            "lang": "Shell + Curl",
            "source": "curl --request POST \\\n  --url https://api.preprod.deko.dekopay.com/auth \\\n  --header 'content-type: application/json' \\\n  --data '{\"client_id\":\"string\",\"client_secret\":\"string\"}'"
          },
          {
            "lang": "Csharp + Restsharp",
            "source": "var client = new RestClient(\"https://api.preprod.deko.dekopay.com/auth\");\nvar request = new RestRequest(Method.POST);\nrequest.AddHeader(\"content-type\", \"application/json\");\nrequest.AddParameter(\"application/json\", \"{\\\"client_id\\\":\\\"string\\\",\\\"client_secret\\\":\\\"string\\\"}\", ParameterType.RequestBody);\nIRestResponse response = client.Execute(request);"
          },
          {
            "lang": "Javascript + Xhr",
            "source": "const data = JSON.stringify({\n  \"client_id\": \"string\",\n  \"client_secret\": \"string\"\n});\n\nconst xhr = new XMLHttpRequest();\nxhr.withCredentials = true;\n\nxhr.addEventListener(\"readystatechange\", function () {\n  if (this.readyState === this.DONE) {\n    console.log(this.responseText);\n  }\n});\n\nxhr.open(\"POST\", \"https://api.preprod.deko.dekopay.com/auth\");\nxhr.setRequestHeader(\"content-type\", \"application/json\");\n\nxhr.send(data);"
          },
          {
            "lang": "Node + Request",
            "source": "const request = require('request');\n\nconst options = {\n  method: 'POST',\n  url: 'https://api.preprod.deko.dekopay.com/auth',\n  headers: {'content-type': 'application/json'},\n  body: {client_id: 'string', client_secret: 'string'},\n  json: true\n};\n\nrequest(options, function (error, response, body) {\n  if (error) throw new Error(error);\n\n  console.log(body);\n});\n"
          }
        ]
      }
    },
    "/transaction": {
      "post": {
        "operationId": "CreateNewpayTransaction",
        "tags": [
          "Transactions"
        ],
        "summary": "Create a Newpay checkout",
        "description": "Submit the basket with `product: newpay` and a unique merchant reference.\nCustomer details are optional and can prepopulate the consumer journey.\nSend the same UUID Idempotency-Key when retrying the same creation\nrequest, and a new key for a new checkout. Do not rely on reusing a\nreference to amend an existing transaction.\n\nInclude callbackUri for notification-driven checkout updates.\nA 200 response acknowledges creation, not successful payment.\nStore the merchant reference and the returned checkout self link.\nAppLinks may be returned for ASSISTED or BROKER journeys.\n",
        "parameters": [
          {
            "in": "header",
            "name": "Idempotency-Key",
            "required": true,
            "description": "UUID identifying this creation request; reuse for retries.",
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "example": "8f2b0d5e-1f5c-4a0e-9f3f-6c4f0b6b7a21"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/NewpayTransactionRequest"
              },
              "example": {
                "reference": "SP-CHECKOUT-100001",
                "product": "newpay",
                "basket": {
                  "currency": "GBP",
                  "total": 50000,
                  "items": [
                    {
                      "description": "Example purchase",
                      "price": 50000,
                      "quantity": 1,
                      "type": "sku",
                      "merchantItemId": "SKU-001"
                    }
                  ]
                },
                "callbackUri": "https://superpayments.example/deko/callback",
                "channelName": "UNASSISTED"
              }
            }
          }
        },
        "callbacks": {
          "checkoutStatusChanged": {
            "{$request.body#/callbackUri}": {
              "$ref": "#/components/pathItems/CheckoutStatusWebhook"
            }
          }
        },
        "responses": {
          "200": {
            "$ref": "#/components/responses/CheckoutDetails"
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "422": {
            "description": "Order creation or AppLink generation could not be completed.",
            "content": {
              "application/hal+json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          }
        },
        "x-codeSamples": [
          {
            "lang": "Shell + Curl",
            "source": "curl --request POST \\\n  --url https://api.preprod.deko.dekopay.com/transaction \\\n  --header 'Authorization: Bearer REPLACE_BEARER_TOKEN' \\\n  --header 'Idempotency-Key: 8f2b0d5e-1f5c-4a0e-9f3f-6c4f0b6b7a21' \\\n  --header 'content-type: application/json' \\\n  --data '{\"basket\":{\"currency\":\"GBP\",\"total\":0,\"items\":[{\"description\":\"string\",\"quantity\":1,\"price\":0,\"type\":\"sku\",\"merchantItemId\":\"string\",\"itemUri\":\"http://example.com\",\"imageUri\":\"http://example.com\",\"lineItemTerm\":0}],\"specialOffers\":[{\"id\":\"string\"}]},\"product\":\"newpay\",\"reference\":\"SP-CHECKOUT-100001\",\"callbackUri\":\"https://superpayments.example/deko/callback\",\"channelName\":\"UNASSISTED\",\"initialisedBy\":\"user@example.com\",\"customer\":{\"email\":\"user@example.com\",\"phone\":\"string\",\"birthDate\":\"2019-08-24\",\"billingAddress\":{\"title\":\"string\",\"firstName\":\"string\",\"middleName\":\"string\",\"lastName\":\"string\",\"address1\":\"string\",\"address2\":\"string\",\"town\":\"string\",\"county\":\"string\",\"postcode\":\"string\",\"country\":\"GB\"},\"shippingAddress\":{\"title\":\"string\",\"firstName\":\"string\",\"middleName\":\"string\",\"lastName\":\"string\",\"address1\":\"string\",\"address2\":\"string\",\"town\":\"string\",\"county\":\"string\",\"postcode\":\"string\",\"country\":\"GB\"},\"fulfilment\":\"HomeDelivery\"}}'"
          },
          {
            "lang": "Csharp + Restsharp",
            "source": "var client = new RestClient(\"https://api.preprod.deko.dekopay.com/transaction\");\nvar request = new RestRequest(Method.POST);\nrequest.AddHeader(\"Idempotency-Key\", \"8f2b0d5e-1f5c-4a0e-9f3f-6c4f0b6b7a21\");\nrequest.AddHeader(\"Authorization\", \"Bearer REPLACE_BEARER_TOKEN\");\nrequest.AddHeader(\"content-type\", \"application/json\");\nrequest.AddParameter(\"application/json\", \"{\\\"basket\\\":{\\\"currency\\\":\\\"GBP\\\",\\\"total\\\":0,\\\"items\\\":[{\\\"description\\\":\\\"string\\\",\\\"quantity\\\":1,\\\"price\\\":0,\\\"type\\\":\\\"sku\\\",\\\"merchantItemId\\\":\\\"string\\\",\\\"itemUri\\\":\\\"http://example.com\\\",\\\"imageUri\\\":\\\"http://example.com\\\",\\\"lineItemTerm\\\":0}],\\\"specialOffers\\\":[{\\\"id\\\":\\\"string\\\"}]},\\\"product\\\":\\\"newpay\\\",\\\"reference\\\":\\\"SP-CHECKOUT-100001\\\",\\\"callbackUri\\\":\\\"https://superpayments.example/deko/callback\\\",\\\"channelName\\\":\\\"UNASSISTED\\\",\\\"initialisedBy\\\":\\\"user@example.com\\\",\\\"customer\\\":{\\\"email\\\":\\\"user@example.com\\\",\\\"phone\\\":\\\"string\\\",\\\"birthDate\\\":\\\"2019-08-24\\\",\\\"billingAddress\\\":{\\\"title\\\":\\\"string\\\",\\\"firstName\\\":\\\"string\\\",\\\"middleName\\\":\\\"string\\\",\\\"lastName\\\":\\\"string\\\",\\\"address1\\\":\\\"string\\\",\\\"address2\\\":\\\"string\\\",\\\"town\\\":\\\"string\\\",\\\"county\\\":\\\"string\\\",\\\"postcode\\\":\\\"string\\\",\\\"country\\\":\\\"GB\\\"},\\\"shippingAddress\\\":{\\\"title\\\":\\\"string\\\",\\\"firstName\\\":\\\"string\\\",\\\"middleName\\\":\\\"string\\\",\\\"lastName\\\":\\\"string\\\",\\\"address1\\\":\\\"string\\\",\\\"address2\\\":\\\"string\\\",\\\"town\\\":\\\"string\\\",\\\"county\\\":\\\"string\\\",\\\"postcode\\\":\\\"string\\\",\\\"country\\\":\\\"GB\\\"},\\\"fulfilment\\\":\\\"HomeDelivery\\\"}}\", ParameterType.RequestBody);\nIRestResponse response = client.Execute(request);"
          },
          {
            "lang": "Javascript + Xhr",
            "source": "const data = JSON.stringify({\n  \"basket\": {\n    \"currency\": \"GBP\",\n    \"total\": 0,\n    \"items\": [\n      {\n        \"description\": \"string\",\n        \"quantity\": 1,\n        \"price\": 0,\n        \"type\": \"sku\",\n        \"merchantItemId\": \"string\",\n        \"itemUri\": \"http://example.com\",\n        \"imageUri\": \"http://example.com\",\n        \"lineItemTerm\": 0\n      }\n    ],\n    \"specialOffers\": [\n      {\n        \"id\": \"string\"\n      }\n    ]\n  },\n  \"product\": \"newpay\",\n  \"reference\": \"SP-CHECKOUT-100001\",\n  \"callbackUri\": \"https://superpayments.example/deko/callback\",\n  \"channelName\": \"UNASSISTED\",\n  \"initialisedBy\": \"user@example.com\",\n  \"customer\": {\n    \"email\": \"user@example.com\",\n    \"phone\": \"string\",\n    \"birthDate\": \"2019-08-24\",\n    \"billingAddress\": {\n      \"title\": \"string\",\n      \"firstName\": \"string\",\n      \"middleName\": \"string\",\n      \"lastName\": \"string\",\n      \"address1\": \"string\",\n      \"address2\": \"string\",\n      \"town\": \"string\",\n      \"county\": \"string\",\n      \"postcode\": \"string\",\n      \"country\": \"GB\"\n    },\n    \"shippingAddress\": {\n      \"title\": \"string\",\n      \"firstName\": \"string\",\n      \"middleName\": \"string\",\n      \"lastName\": \"string\",\n      \"address1\": \"string\",\n      \"address2\": \"string\",\n      \"town\": \"string\",\n      \"county\": \"string\",\n      \"postcode\": \"string\",\n      \"country\": \"GB\"\n    },\n    \"fulfilment\": \"HomeDelivery\"\n  }\n});\n\nconst xhr = new XMLHttpRequest();\nxhr.withCredentials = true;\n\nxhr.addEventListener(\"readystatechange\", function () {\n  if (this.readyState === this.DONE) {\n    console.log(this.responseText);\n  }\n});\n\nxhr.open(\"POST\", \"https://api.preprod.deko.dekopay.com/transaction\");\nxhr.setRequestHeader(\"Idempotency-Key\", \"8f2b0d5e-1f5c-4a0e-9f3f-6c4f0b6b7a21\");\nxhr.setRequestHeader(\"Authorization\", \"Bearer REPLACE_BEARER_TOKEN\");\nxhr.setRequestHeader(\"content-type\", \"application/json\");\n\nxhr.send(data);"
          },
          {
            "lang": "Node + Request",
            "source": "const request = require('request');\n\nconst options = {\n  method: 'POST',\n  url: 'https://api.preprod.deko.dekopay.com/transaction',\n  headers: {\n    'Idempotency-Key': '8f2b0d5e-1f5c-4a0e-9f3f-6c4f0b6b7a21',\n    Authorization: 'Bearer REPLACE_BEARER_TOKEN',\n    'content-type': 'application/json'\n  },\n  body: {\n    basket: {\n      currency: 'GBP',\n      total: 0,\n      items: [\n        {\n          description: 'string',\n          quantity: 1,\n          price: 0,\n          type: 'sku',\n          merchantItemId: 'string',\n          itemUri: 'http://example.com',\n          imageUri: 'http://example.com',\n          lineItemTerm: 0\n        }\n      ],\n      specialOffers: [{id: 'string'}]\n    },\n    product: 'newpay',\n    reference: 'SP-CHECKOUT-100001',\n    callbackUri: 'https://superpayments.example/deko/callback',\n    channelName: 'UNASSISTED',\n    initialisedBy: 'user@example.com',\n    customer: {\n      email: 'user@example.com',\n      phone: 'string',\n      birthDate: '2019-08-24',\n      billingAddress: {\n        title: 'string',\n        firstName: 'string',\n        middleName: 'string',\n        lastName: 'string',\n        address1: 'string',\n        address2: 'string',\n        town: 'string',\n        county: 'string',\n        postcode: 'string',\n        country: 'GB'\n      },\n      shippingAddress: {\n        title: 'string',\n        firstName: 'string',\n        middleName: 'string',\n        lastName: 'string',\n        address1: 'string',\n        address2: 'string',\n        town: 'string',\n        county: 'string',\n        postcode: 'string',\n        country: 'GB'\n      },\n      fulfilment: 'HomeDelivery'\n    }\n  },\n  json: true\n};\n\nrequest(options, function (error, response, body) {\n  if (error) throw new Error(error);\n\n  console.log(body);\n});\n"
          }
        ]
      }
    },
    "/transaction/{reference}": {
      "parameters": [
        {
          "$ref": "#/components/parameters/Reference"
        }
      ],
      "get": {
        "operationId": "GetNewpayTransaction",
        "tags": [
          "Transactions"
        ],
        "summary": "Retrieve a checkout and its current state",
        "description": "Use the merchant reference supplied to POST /transaction, scoped to\nthe merchant identified by the bearer token. URL-encode the reference\nas a path segment. Returns basket, public checkout status, available\nsubStatus/displayStatus details, timestamps and any refunds/AppLinks.\nUse this operation to reconcile callbacks and recover missed updates.\nExample: https://api.preprod.deko.dekopay.com/transaction/SP-CHECKOUT-100001\n",
        "responses": {
          "200": {
            "$ref": "#/components/responses/CheckoutDetails"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "404": {
            "description": "No transaction found for this reference under the authenticated merchant."
          }
        },
        "x-codeSamples": [
          {
            "lang": "Shell + Curl",
            "source": "curl --request GET \\\n  --url https://api.preprod.deko.dekopay.com/transaction/SP-CHECKOUT-100001 \\\n  --header 'Authorization: Bearer REPLACE_BEARER_TOKEN'"
          },
          {
            "lang": "Csharp + Restsharp",
            "source": "var client = new RestClient(\"https://api.preprod.deko.dekopay.com/transaction/SP-CHECKOUT-100001\");\nvar request = new RestRequest(Method.GET);\nrequest.AddHeader(\"Authorization\", \"Bearer REPLACE_BEARER_TOKEN\");\nIRestResponse response = client.Execute(request);"
          },
          {
            "lang": "Javascript + Xhr",
            "source": "const data = null;\n\nconst xhr = new XMLHttpRequest();\nxhr.withCredentials = true;\n\nxhr.addEventListener(\"readystatechange\", function () {\n  if (this.readyState === this.DONE) {\n    console.log(this.responseText);\n  }\n});\n\nxhr.open(\"GET\", \"https://api.preprod.deko.dekopay.com/transaction/SP-CHECKOUT-100001\");\nxhr.setRequestHeader(\"Authorization\", \"Bearer REPLACE_BEARER_TOKEN\");\n\nxhr.send(data);"
          },
          {
            "lang": "Node + Request",
            "source": "const request = require('request');\n\nconst options = {\n  method: 'GET',\n  url: 'https://api.preprod.deko.dekopay.com/transaction/SP-CHECKOUT-100001',\n  headers: {Authorization: 'Bearer REPLACE_BEARER_TOKEN'}\n};\n\nrequest(options, function (error, response, body) {\n  if (error) throw new Error(error);\n\n  console.log(body);\n});\n"
          }
        ]
      }
    },
    "/transaction/{reference}/{action}": {
      "parameters": [
        {
          "$ref": "#/components/parameters/Reference"
        },
        {
          "in": "path",
          "name": "action",
          "required": true,
          "description": "Lowercase action; must match the body's uppercase actionType.",
          "schema": {
            "type": "string",
            "enum": [
              "cancel",
              "refund"
            ]
          },
          "example": "refund"
        }
      ],
      "patch": {
        "operationId": "ActionNewpayTransaction",
        "tags": [
          "Transactions"
        ],
        "summary": "Cancel or refund a Newpay checkout",
        "description": "The existing transaction action API uses PATCH, not POST.\nActions are subject to the checkout's current state and merchant\npermissions. Do not assume every action is valid in every state.\nThis Newpay contract includes cancellation and refund only; it does not\nexpose generic actions for other products, such as merchant fulfilment.\nFor refund, options.refundAmount is required and is expressed in pence.\nUse a partial amount for a partial refund, or the remaining refundable\namount for a full refund.\n\nA 200 response returns checkout details; asynchronous processing may\nstill be underway. Use callbacks and authenticated retrieval to confirm\nthe final state. The creation Idempotency-Key contract does not apply\nto actions: do not blindly retry a financial action after an ambiguous\ntimeout; retrieve the transaction and reconcile first.\nExample: https://api.preprod.deko.dekopay.com/transaction/SP-CHECKOUT-100001/refund\n",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ActionRequest"
              },
              "examples": {
                "cancel": {
                  "summary": "Cancel a checkout",
                  "value": {
                    "actionType": "CANCEL",
                    "options": {}
                  }
                },
                "refund": {
                  "summary": "Refund GBP 50.00",
                  "value": {
                    "actionType": "REFUND",
                    "options": {
                      "refundAmount": 5000,
                      "description": "Customer returned an item"
                    }
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "$ref": "#/components/responses/CheckoutDetails"
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "404": {
            "description": "No transaction found for this reference under the authenticated merchant.",
            "content": {
              "application/hal+json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "code": 404,
                  "message": "Transaction not found by that ID"
                }
              }
            }
          },
          "default": {
            "description": "Action rejected or processing failed; inspect the error and retrieve current state.",
            "content": {
              "application/hal+json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          }
        },
        "x-codeSamples": [
          {
            "lang": "Shell + Curl",
            "source": "curl --request PATCH \\\n  --url https://api.preprod.deko.dekopay.com/transaction/SP-CHECKOUT-100001/refund \\\n  --header 'Authorization: Bearer REPLACE_BEARER_TOKEN' \\\n  --header 'content-type: application/json' \\\n  --data '{\"actionType\":\"CANCEL\",\"options\":{}}'"
          },
          {
            "lang": "Csharp + Restsharp",
            "source": "var client = new RestClient(\"https://api.preprod.deko.dekopay.com/transaction/SP-CHECKOUT-100001/refund\");\nvar request = new RestRequest(Method.PATCH);\nrequest.AddHeader(\"Authorization\", \"Bearer REPLACE_BEARER_TOKEN\");\nrequest.AddHeader(\"content-type\", \"application/json\");\nrequest.AddParameter(\"application/json\", \"{\\\"actionType\\\":\\\"CANCEL\\\",\\\"options\\\":{}}\", ParameterType.RequestBody);\nIRestResponse response = client.Execute(request);"
          },
          {
            "lang": "Javascript + Xhr",
            "source": "const data = JSON.stringify({\n  \"actionType\": \"CANCEL\",\n  \"options\": {}\n});\n\nconst xhr = new XMLHttpRequest();\nxhr.withCredentials = true;\n\nxhr.addEventListener(\"readystatechange\", function () {\n  if (this.readyState === this.DONE) {\n    console.log(this.responseText);\n  }\n});\n\nxhr.open(\"PATCH\", \"https://api.preprod.deko.dekopay.com/transaction/SP-CHECKOUT-100001/refund\");\nxhr.setRequestHeader(\"Authorization\", \"Bearer REPLACE_BEARER_TOKEN\");\nxhr.setRequestHeader(\"content-type\", \"application/json\");\n\nxhr.send(data);"
          },
          {
            "lang": "Node + Request",
            "source": "const request = require('request');\n\nconst options = {\n  method: 'PATCH',\n  url: 'https://api.preprod.deko.dekopay.com/transaction/SP-CHECKOUT-100001/refund',\n  headers: {\n    Authorization: 'Bearer REPLACE_BEARER_TOKEN',\n    'content-type': 'application/json'\n  },\n  body: {actionType: 'CANCEL', options: {}},\n  json: true\n};\n\nrequest(options, function (error, response, body) {\n  if (error) throw new Error(error);\n\n  console.log(body);\n});\n"
          }
        ]
      }
    }
  },
  "components": {
    "pathItems": {
      "CheckoutStatusWebhook": {
        "post": {
          "operationId": "ReceiveNewpayCheckoutNotification",
          "tags": [
            "Webhooks"
          ],
          "summary": "Receive a Newpay checkout status notification",
          "description": "DekoPay sends this outbound POST to the callbackUri supplied in\nPOST /transaction, for example\nhttps://superpayments.example/deko/callback.\nThis is an endpoint hosted by Superpayments, not by DekoPay.\nThe DekoPay preproduction server URL does not apply to this webhook.\nDeko sends Content-Type: application/json, with a signed JWT in\n`receipt`; it does not send the merchant bearer token or a\nDeko-Signature header on this notification.\n\nReturn a 2xx response promptly after safely accepting the event;\nno response body is required. Failed deliveries are retried;\nduplicates are possible and delivery order is not guaranteed.\nProcess idempotently and use statusLastUpdated when comparing\nnotifications. Do not depend on callbacks alone for recovery:\nreconcile by merchant reference with GET /transaction/{reference}.\n\nDo not trust an unverified JWT or the unsigned outer fields as\npayment confirmation. Receipt signature verification requires\nthe Deko public signing key matching the JWT header's kid,\nobtained through the separately agreed Deko key-distribution\nmechanism. Check the signature, approved algorithm, issuer,\naudience, expiry and merchant subject. The receipt contains an\nenvironment-qualified application claim, for example\nhttps://api.preprod.deko.dekopay.com/application, with status,\nproduct, links, last_updated, application_id (Deko order UUID)\nand transaction_id (merchant reference).\nThe outer payload is not itself covered by the receipt signature.\nUse an authenticated transaction retrieval to confirm the\ncurrent state before updating a checkout or releasing goods.\n",
          "security": [],
          "requestBody": {
            "required": true,
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CheckoutNotification"
                },
                "examples": {
                  "pending": {
                    "summary": "Checkout awaiting completion",
                    "value": {
                      "id": "d81fc604-f089-455e-b7c4-43b43399f211",
                      "reference": "SP-CHECKOUT-100001",
                      "productType": "NEWPAY",
                      "status": "PENDING",
                      "reason": null,
                      "statusLastUpdated": "2026-11-04T15:00:00Z",
                      "receipt": "SIGNED_DEKO_RECEIPT_JWT"
                    }
                  },
                  "successful": {
                    "summary": "Checkout successful",
                    "value": {
                      "id": "d81fc604-f089-455e-b7c4-43b43399f211",
                      "reference": "SP-CHECKOUT-100001",
                      "productType": "NEWPAY",
                      "status": "SUCCESSFUL",
                      "reason": null,
                      "statusLastUpdated": "2026-11-04T15:15:00Z",
                      "receipt": "SIGNED_DEKO_RECEIPT_JWT"
                    }
                  },
                  "refunded": {
                    "summary": "Checkout fully refunded",
                    "value": {
                      "id": "d81fc604-f089-455e-b7c4-43b43399f211",
                      "reference": "SP-CHECKOUT-100001",
                      "productType": "NEWPAY",
                      "status": "FULL_REFUNDED",
                      "reason": null,
                      "statusLastUpdated": "2026-11-04T16:00:00Z",
                      "receipt": "SIGNED_DEKO_RECEIPT_JWT"
                    }
                  }
                }
              }
            }
          },
          "responses": {
            "200": {
              "description": "Notification accepted; any 2xx response is accepted. No response body required."
            },
            "default": {
              "description": "Delivery unsuccessful; Deko may retry."
            }
          }
        }
      }
    },
    "securitySchemes": {
      "MerchantBearerAuth": {
        "type": "http",
        "scheme": "bearer",
        "bearerFormat": "JWT",
        "description": "Merchant access_token returned by POST /auth."
      }
    },
    "parameters": {
      "Reference": {
        "in": "path",
        "name": "reference",
        "required": true,
        "description": "Merchant Unique Reference supplied when the checkout was created, not the Deko UUID.",
        "schema": {
          "type": "string",
          "pattern": ".+",
          "description": "Unique merchant reference for a checkout.",
          "example": "SP-CHECKOUT-100001"
        },
        "example": "SP-CHECKOUT-100001"
      }
    },
    "responses": {
      "CheckoutDetails": {
        "description": "Checkout details; inspect status rather than interpreting HTTP 200 as payment success.",
        "content": {
          "application/hal+json": {
            "schema": {
              "$ref": "#/components/schemas/CheckoutResult"
            },
            "example": {
              "_links": {
                "self": {
                  "href": "https://api.preprod.deko.dekopay.com/checkout/newpay/d81fc604-f089-455e-b7c4-43b43399f211"
                }
              },
              "basket": {
                "currency": "GBP",
                "total": 50000,
                "items": [
                  {
                    "description": "Example purchase",
                    "price": 50000,
                    "quantity": 1,
                    "type": "sku",
                    "merchantItemId": "SKU-001"
                  }
                ]
              },
              "product": "newpay",
              "status": "pending",
              "created": "2026-11-04T15:00:00Z",
              "last_updated": "2026-11-04T15:00:00Z"
            }
          }
        }
      },
      "BadRequest": {
        "description": "Invalid request, basket validation failure or action not permitted in the current state.",
        "content": {
          "application/hal+json": {
            "schema": {
              "$ref": "#/components/schemas/ApiError"
            },
            "example": {
              "code": 400,
              "message": "Invalid request"
            }
          }
        }
      },
      "Unauthorized": {
        "description": "Bearer access token is missing, expired or invalid; obtain a valid merchant token."
      }
    },
    "schemas": {
      "AccessTokenRequest": {
        "type": "object",
        "required": [
          "client_id",
          "client_secret"
        ],
        "properties": {
          "client_id": {
            "type": "string",
            "minLength": 1
          },
          "client_secret": {
            "type": "string",
            "minLength": 1,
            "writeOnly": true
          }
        }
      },
      "AccessTokenResponse": {
        "type": "object",
        "required": [
          "access_token",
          "expires_in",
          "token_type"
        ],
        "properties": {
          "access_token": {
            "type": "string"
          },
          "expires_in": {
            "type": "integer",
            "description": "Token lifetime in seconds."
          },
          "token_type": {
            "type": "string",
            "enum": [
              "Bearer"
            ]
          }
        }
      },
      "MerchantReference": {
        "type": "string",
        "pattern": ".+",
        "description": "Unique merchant reference for a checkout.",
        "example": "SP-CHECKOUT-100001"
      },
      "NewpayProduct": {
        "type": "string",
        "enum": [
          "newpay"
        ]
      },
      "NewpayTransactionRequest": {
        "type": "object",
        "required": [
          "basket",
          "reference",
          "product"
        ],
        "properties": {
          "basket": {
            "$ref": "#/components/schemas/Basket"
          },
          "product": {
            "$ref": "#/components/schemas/NewpayProduct"
          },
          "reference": {
            "$ref": "#/components/schemas/MerchantReference"
          },
          "callbackUri": {
            "type": "string",
            "format": "uri",
            "description": "Superpayments' externally reachable HTTPS endpoint for Deko POST\nnotifications. Include this field for this integration; if omitted,\nno per-checkout callback destination is supplied.\n",
            "example": "https://superpayments.example/deko/callback"
          },
          "channelName": {
            "type": "string",
            "enum": [
              "UNASSISTED",
              "ASSISTED",
              "BROKER",
              "ONLINE",
              "INSTORE"
            ],
            "default": "UNASSISTED",
            "description": "All five values are accepted, case-sensitively. Canonical values\nare UNASSISTED, ASSISTED and BROKER. ONLINE is an alias for\nUNASSISTED; INSTORE is an alias for ASSISTED, not a separate channel.\nWhen omitted, the channel defaults to UNASSISTED.\n"
          },
          "initialisedBy": {
            "type": "string",
            "format": "email",
            "description": "Required for ASSISTED, its INSTORE alias, and BROKER; email identifier of the user creating the checkout."
          },
          "customer": {
            "$ref": "#/components/schemas/Customer"
          }
        }
      },
      "Basket": {
        "type": "object",
        "required": [
          "currency",
          "total",
          "items"
        ],
        "properties": {
          "currency": {
            "type": "string",
            "enum": [
              "GBP"
            ]
          },
          "total": {
            "type": "integer",
            "format": "int64",
            "description": "Basket total in pence, including discounts, shipping and tax."
          },
          "items": {
            "type": "array",
            "minItems": 1,
            "uniqueItems": true,
            "items": {
              "$ref": "#/components/schemas/LineItem"
            }
          },
          "specialOffers": {
            "type": "array",
            "uniqueItems": true,
            "items": {
              "type": "object",
              "required": [
                "id"
              ],
              "properties": {
                "id": {
                  "type": "string"
                }
              }
            }
          }
        }
      },
      "LineItem": {
        "type": "object",
        "required": [
          "description",
          "quantity",
          "price",
          "type"
        ],
        "properties": {
          "description": {
            "type": "string",
            "maxLength": 16384
          },
          "quantity": {
            "type": "integer",
            "minimum": 1
          },
          "price": {
            "type": "integer",
            "format": "int64",
            "description": "Monetary amount in pence."
          },
          "type": {
            "type": "string",
            "enum": [
              "sku",
              "discount",
              "shipping",
              "tax"
            ]
          },
          "merchantItemId": {
            "type": "string"
          },
          "itemUri": {
            "type": "string",
            "format": "uri",
            "maxLength": 4096
          },
          "imageUri": {
            "type": "string",
            "format": "uri",
            "maxLength": 4096
          },
          "lineItemTerm": {
            "type": "integer",
            "minimum": 0,
            "default": 0,
            "description": "Optional duration in months; non-zero values are only valid for sku items."
          }
        }
      },
      "Customer": {
        "type": "object",
        "properties": {
          "email": {
            "type": "string",
            "format": "email"
          },
          "phone": {
            "type": "string",
            "pattern": "^(|^[0-9 +()]{6,15})$"
          },
          "birthDate": {
            "type": "string",
            "format": "date",
            "description": "Valid date of birth; must not be in the future."
          },
          "billingAddress": {
            "$ref": "#/components/schemas/Address"
          },
          "shippingAddress": {
            "$ref": "#/components/schemas/Address"
          },
          "fulfilment": {
            "type": "string",
            "enum": [
              "HomeDelivery",
              "AlternativeAddress",
              "CollectInStore"
            ]
          }
        }
      },
      "Address": {
        "type": "object",
        "required": [
          "address1",
          "country",
          "county",
          "firstName",
          "lastName",
          "postcode",
          "town"
        ],
        "properties": {
          "title": {
            "type": "string"
          },
          "firstName": {
            "type": "string"
          },
          "middleName": {
            "type": "string"
          },
          "lastName": {
            "type": "string"
          },
          "address1": {
            "type": "string"
          },
          "address2": {
            "type": "string"
          },
          "town": {
            "type": "string"
          },
          "county": {
            "type": "string"
          },
          "postcode": {
            "type": "string",
            "description": "UK postcode."
          },
          "country": {
            "type": "string",
            "pattern": "^[A-Z]{2}$",
            "example": "GB"
          }
        }
      },
      "ActionRequest": {
        "description": "actionType must match the action path parameter.",
        "oneOf": [
          {
            "type": "object",
            "required": [
              "actionType",
              "options"
            ],
            "properties": {
              "actionType": {
                "type": "string",
                "enum": [
                  "CANCEL"
                ]
              },
              "options": {
                "type": "object"
              }
            }
          },
          {
            "type": "object",
            "required": [
              "actionType",
              "options"
            ],
            "properties": {
              "actionType": {
                "type": "string",
                "enum": [
                  "REFUND"
                ]
              },
              "options": {
                "type": "object",
                "required": [
                  "refundAmount"
                ],
                "properties": {
                  "refundAmount": {
                    "type": "integer",
                    "description": "Amount to refund in pence, within the remaining refundable amount.",
                    "example": 5000
                  },
                  "description": {
                    "type": "string"
                  }
                }
              }
            }
          }
        ]
      },
      "CheckoutResult": {
        "type": "object",
        "required": [
          "_links",
          "basket",
          "product",
          "status",
          "created",
          "last_updated"
        ],
        "properties": {
          "_links": {
            "type": "object",
            "properties": {
              "self": {
                "type": "object",
                "properties": {
                  "href": {
                    "type": "string",
                    "format": "uri",
                    "description": "Checkout resource URL whose final path segment is the Deko order UUID.",
                    "example": "https://api.preprod.deko.dekopay.com/checkout/newpay/d81fc604-f089-455e-b7c4-43b43399f211"
                  }
                }
              }
            }
          },
          "basket": {
            "$ref": "#/components/schemas/Basket"
          },
          "product": {
            "$ref": "#/components/schemas/NewpayProduct"
          },
          "status": {
            "type": "string",
            "enum": [
              "success",
              "denied",
              "failed",
              "pending",
              "referred",
              "fully refunded",
              "part refunded",
              "settled"
            ],
            "description": "Public checkout state, distinct from callback order status.\nRefunded values contain spaces, not underscores.\nInspect subStatus/displayStatus for further lifecycle detail;\na cancellation does not introduce a public \"cancelled\" enum value.\n"
          },
          "subStatus": {
            "type": "string",
            "description": "Workflow-specific detail; do not assume an exhaustive fixed list."
          },
          "displayStatus": {
            "type": "string",
            "description": "Human-readable status detail."
          },
          "created": {
            "type": "string",
            "format": "date-time"
          },
          "last_updated": {
            "type": "string",
            "format": "date-time"
          },
          "refunds": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Refund"
            }
          },
          "appLinks": {
            "type": "array",
            "description": "May be returned for ASSISTED/BROKER checkouts.",
            "items": {
              "$ref": "#/components/schemas/AppLink"
            }
          }
        }
      },
      "Refund": {
        "type": "object",
        "required": [
          "refundId",
          "amount",
          "description",
          "status",
          "creationDate"
        ],
        "properties": {
          "refundId": {
            "type": "string"
          },
          "amount": {
            "type": "integer",
            "format": "int64",
            "description": "Refund amount in pence."
          },
          "description": {
            "type": "string"
          },
          "status": {
            "type": "string",
            "example": "SUCCEEDED"
          },
          "creationDate": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "AppLink": {
        "type": "object",
        "properties": {
          "appLinkId": {
            "type": "string",
            "format": "uuid"
          },
          "orderId": {
            "type": "string",
            "format": "uuid"
          },
          "token": {
            "type": "string"
          },
          "url": {
            "type": "string"
          },
          "dataUri": {
            "type": "string"
          },
          "creationDate": {
            "type": "string",
            "format": "date-time"
          },
          "status": {
            "type": "string"
          },
          "expiryDate": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "CheckoutNotification": {
        "type": "object",
        "description": "JSON body POSTed to callbackUri when Deko sends an order status update.\nid identifies the Deko order; reference identifies the Superpayments\ncheckout. reason is optional and may be absent or null when no mapped\nreason exists. receipt is a compact signed JWT string, not a JSON object.\n",
        "required": [
          "id",
          "reference",
          "productType",
          "status",
          "statusLastUpdated",
          "receipt"
        ],
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid",
            "description": "Deko order UUID, not the merchant reference."
          },
          "reference": {
            "$ref": "#/components/schemas/MerchantReference"
          },
          "productType": {
            "type": "string",
            "enum": [
              "NEWPAY"
            ]
          },
          "status": {
            "type": "string",
            "description": "Uppercase order state, for example PENDING, REQUIRE_APPLICATION,\nSUCCESSFUL, FAILED, PART_REFUNDED or FULL_REFUNDED.\nPROCESSING_APPLICATION is sent as PENDING.\nNot an exhaustive enumeration; retrieve the transaction for the\ncurrent public checkout state.\n",
            "example": "SUCCESSFUL"
          },
          "reason": {
            "type": [
              "string",
              "null"
            ],
            "description": "Optional reason derived from the application's sub-status."
          },
          "statusLastUpdated": {
            "type": "string",
            "format": "date-time"
          },
          "receipt": {
            "type": "string",
            "description": "Compact signed JWT containing the application receipt.\nReceipt status uses its own vocabulary (success, failed,\nrequire_application, \"require application\", unknown), not the\npublic checkout status enum. Decoding alone is not verification.\n"
          }
        }
      },
      "ApiError": {
        "type": "object",
        "required": [
          "code",
          "message"
        ],
        "properties": {
          "code": {
            "type": "integer",
            "format": "int32"
          },
          "message": {
            "type": "string"
          }
        }
      },
      "AuthError": {
        "type": "object",
        "properties": {
          "code": {
            "type": "integer"
          },
          "message": {
            "type": "string"
          },
          "httpStatus": {
            "type": "string"
          },
          "fieldErrors": {
            "type": [
              "array",
              "null"
            ],
            "items": {
              "type": "object"
            }
          }
        }
      }
    }
  },
  "x-pub-settings": {
    "pub-ready": true,
    "team": "",
    "tags": [
      "Order Processing",
      "Aggregators",
      "Retailers",
      "NewPay"
    ],
    "commitDate": 1793809402000
  }
}