Hi everyone,
I’m trying to integrate the Robokassa payment gateway API into an n8n workflow to generate payment links. The API requires a JWT token sent as a raw string in a POST request, but I’m hitting several roadblocks due to n8n’s Code Node sandbox limitations.
Robokassa API Requirements (as per their support)
According to their documentation and a support screenshot I received:
-
Header and Payload must be JSON objects encoded in base64url.
-
Signature is generated using HMAC-SHA256 over the string
"{encodedHeader}.{encodedPayload}". -
The secret key for HMAC is a composite string:
"{MerchantLogin}:{Password1}". -
Crucial detail: The resulting HMAC signature (binary hash) must be converted to base64 from the hash itself, not by encoding the hex string as text.
-
The final JWT is assembled as
"{encodedHeader}.{encodedPayload}.{signatureBase64Url}". -
The JWT must be sent in a POST request with
Content-Type: text/plainand the raw JWT string as the body (no JSON wrapper).
Problems encountered in n8n
-
Code Node limitations:
Buffer,crypto, andbtoaare all disallowed in the sandboxed environment. I cannot use them. -
Crypto Node limitations: The built-in Crypto node requires a Credential to be saved for HMAC operations. However, saving a Credential is restricted on my plan (I believe it requires an Enterprise plan or a different setup), and I cannot pass dynamic secrets into the Credential form anyway.
-
Workaround attempt: I implemented a pure JavaScript HMAC-SHA256 and base64url encoder inside a Code Node. This worked to produce a JWT, but when I send it via an HTTP Request node (with
Content-Type: text/plainand body ={{ $json.jwt }}), Robokassa returns a 415 Unsupported Media Type error.
I suspect the signature conversion step may still be incorrect (perhaps I’m mishandling the binary-to-base64 conversion), or there might be another subtle requirement I’m missing.
My questions for the community
-
Is there a recommended way to perform HMAC-SHA256 with binary-to-base64url conversion in n8n without using built-in modules, that is known to work with services like Robokassa?
-
Are there any community nodes that could simplify this (e.g., a JWT node that handles raw signing with custom secrets)?
-
Has anyone successfully integrated Robokassa’s new JWT-based API in n8n and could share a working workflow snippet?
-
Any idea why I’m still getting a
415even withtext/plain? Could it be related to the way I’m constructing the signature?
Additional context
-
n8n version:
2.13.2(self-hosted) -
I’m using the Code Node to generate the JWT because the Crypto node is blocked by credential requirements.
-
The workflow structure is:
Set (input data)→Code (encode header/payload)→Code (HMAC + assemble JWT)→HTTP Request (POST).
Any guidance, code snippets, or pointers to relevant community nodes would be greatly appreciated. Thank you in advance!
Attachments (optional): you can mention you’ll attach the support screenshot if needed.