Authentication

Every request is authenticated with HMAC or Encryption, depending on whether you are PCI DSS certified. Paynetics sets the method for your instance at onboarding and provides the credentials. Each operation must also be enabled for your instance.

HMAC

For partners that are not PCI DSS certified. Card data is entered by the cardholder on the Paynetics hosted payment page (POST /v1/payment/page), so your requests carry no card data. Add the headers below to every request:

x-api-key string required

API key given by Paynetics.

x-timestamp integer required

Current UNIX timestamp in seconds.

x-hash string required

HMAC-SHA256 as a lowercase hex string, generated with your API secret over API key + timestamp + operation + content body (the body of POST and PUT requests; empty for GET and DELETE). The operation is the HMAC operation of the endpoint, listed under Operations. The query string is not part of the hash.

x-type integer

Optional. 1 (default) — instance credentials; 2 — merchant credentials, signed with the merchant API key and API secret.

The body is normalised before the hashes are compared. The JSON body is decoded and encoded again in compact form, and the hash is generated over the result:

  • whitespace outside the values is removed: { "name" : "Pay netics" } becomes {"name":"Pay netics"}
  • numbers are written in their shortest form: {"amount":25.50,"fee":10.00} becomes {"amount":25.5,"fee":10}
  • escaped slashes and Unicode characters are written as is: {"url":"https:\/\/shop.example"} becomes {"url":"https://shop.example"}
  • key order is kept

The simplest way is to send exactly the body you signed, already in this form.

The request timestamp may be at most 15 seconds older and 2 seconds newer than the current time.

If your request timestamp is 1591096701 and the current timestamp is 1591096720, the request is not authorised. Keep your server clock synchronised (NTP).

The hash generation examples on the right use the API key 07364675-5b2a-4d35-bd2c-b93e696aa53f, the API secret a6f0e1d2-3c4b-4a59-8e7f-1b2c3d4e5f60 and the timestamp 1625399941.

Encryption

For PCI DSS certified partners that send card data in the request. It can be used on all operations. Paynetics provides the API key and the shared key. Add all headers below to every request and encrypt the payload of POST and PUT requests with the shared key:

x-api-key string required

API key given by Paynetics.

x-timestamp integer required

Current UNIX timestamp in seconds (example: 1610489493).

x-authentication string required

The x-timestamp value encrypted with the shared key in the same way as the payload: base64(IV + AES-256-CBC(x-timestamp)).

x-type integer

Optional. 1 (default) — instance credentials; 2 — merchant credentials.

Payload encryption

Algorithm AES, key length 256, mode CBC, padding PKCS#7.

  • The shared key is provided base64 encoded; decode it to get the 32-byte key.
  • The request body is encrypted with AES-256-CBC using a random 16-byte IV, and the IV is prepended.
  • The result is sent base64 encoded, as the raw request body. GET and DELETE requests have no body to encrypt.

Example: JSON body {"card_number":"5555555555554444"}, IV: 16 random bytes, request body: base64(IV + encrypted JSON body), e.g. m5hbCBwbGVhc3VyZS4=.

Response decryption

When a request is authenticated with Encryption, the response body is encrypted in the same way — base64(IV + AES-256-CBC(JSON response)) with the shared key. This also applies to error responses. To read it, base64 decode the body, take the first 16 bytes as the IV and decrypt the rest.

Operations

The HMAC operation of each endpoint — the operation part of the x-hash string. Each operation must be enabled for your instance, whichever authentication method it uses.

EndpointOperation
POST /v1/initinit
POST /v1/{operation}/pagethe value of {operation}: payment, link or card
POST /v1/3d/enrollment/{init}3d_enrollment
POST /v1/3d/authenticate/{init}3d_authenticate
POST /v1/3d/result/{version}/{init}3d_result
POST /v1/avs/{init}avs
POST /v1/pre-authorization/{init}pre_authorization
POST /v1/capture/{transaction}capture
POST /v1/purchase/{init}purchase
POST /v1/credit/{init}credit
POST /v1/refund/{transaction}refund
POST /v1/reversal/{transaction}reversal
POST /v1/reversal-refund/{transaction}reversalRefund
POST /v1/reversal-credit/{transaction}reversalCredit
POST /v1/oct/{init}oct
POST /v1/cardscard_new
GET /v1/cards/{page}/{limit}cards_list
GET /v1/cards/{token}card_details
PUT /v1/cards/{token}card_update
DELETE /v1/cards/{token}card_delete
GET /v1/transactions/{page}/{limit}transactions_list
GET /v1/transactions/{token}transaction_details

Failed authentication

A request with missing headers, an unknown API key, a wrong hash (HMAC), an x-authentication or body that cannot be decrypted with the shared key (Encryption), a timestamp outside the allowed window, or an operation that is not enabled for your instance returns HTTP 401 with a plain-text body — not the JSON error format of the API (see Errors).

esc
↑↓ navigate ↵ open esc close
Copied