Need Help with some JS code

I tried to make hash (sha256) using this code:

const hmac = require(‘crypto-js/hmac-sha256’);

const body = {
order_id: ‘123’,
currency: ‘uah’,
wallet_type: ‘ecom’,
amount: 10,
payway: ‘card’,
// …
};

const signature = hmac(JSON.stringify(body), ‘secretKey’)
.toString();

I used Pragmaflow Java script Component.

Unfortunately simply nothing happens :frowning:

Is it possible to use cryptographic functions in this component? Maybe someone knows how to do it… I need to create hashed signature to be used in API authentication process for payment provider…

Hello,

I can help you, what exactly are you asking for? a sha256 working code?

Hi! Thanks for your reply!

Pragmaflow team released JS component for Adalo, you can find it here: PragmaFlow Adalo Toolkit

It is called Arbitrary Javascript

I tried to use it (it executes JS code), and I used the code

const hmac = require(‘crypto-js/hmac-sha256’);

const body = {
order_id: ‘123’,
currency: ‘uah’,
wallet_type: ‘ecom’,
amount: 10,
payway: ‘card’,
// …
};

const signature = hmac(JSON.stringify(body), ‘secretKey’)
.toString();

I tried to get encrypted string (sha256 or sha512) with parameters (from body).

For some reason that code did not work in the component and I don’t know the reason…

I am trying to make encrypted auth signature for later use in API requests

Here is the API docs if you ask.
https://docs.crosspay.net

First of all it says:
Signature

How to sign?

You need to generate a signature on your side, based on request data and your secret key. We use HMAC-SHA256.

Simple JS like this component doesn’t allow you to install package; crypto-js/hmac-sha256 is an npm package, so you can’t do it this way

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.