Validation Learn how Payyo validates requests and how you can do it client-side

JSON Schema

Payyo uses JSON Schema to validate all JSON-RPC requests. Clients can access these schemas as well and (optionally) validate requests before sending.

For a full list of JSON schemas please refer to the RPC Methods page.

JSON-RPC envelope

All schemas provided by Payyo only contain the definition of the params property inside a JSON-RPC request envelope.

{
  "jsonrpc": "2.0",
  "method": "transaction.reverse",
  "params": {
    ... THIS PART HERE ...
  },
  "id": 1
}

JSON-RPC requests are explained in more details in the introduction.

Example

The JSON Schema for the transaction.reverse method looks like this:

{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "description": "Reversing (void, cancel or refund) a transaction",
  "type": "object",
  "required": [
    "transaction_id"
  ],
  "properties": {
    "transaction_id": {
      "description": "Transaction identifier as returned in the authorization request",
      "type": "string",
      "pattern": "^tra_[a-zA-Z0-9]{28}$"
    }
  }
}

Combined with the envelope a valid request would look like this:

{
  "jsonrpc": "2.0",
  "method": "transaction.capture",
  "params": {
    "transaction_id": "tra_052ac2da03aa9ec53b0581a0dfd6"
  },
  "id": 1
}

Errors

Validation errors will result in a 400 error code within the JSON-RPC response.

{
  "jsonrpc": "2.0",
  "error": {
    "code": 400,
    "message": "Request validation failed: transaction_id:pattern",
    "data": {
      "errors": {
        "transaction_id": "Does not match the regex pattern ^tra_[a-zA-Z0-9]{28}$"
      }
    }
  },
  "id": 1
}