Jump to content

Basically I need help if someone can guide or point me in the right direction to rewrite PHP logic in JavaScript
What I want to do:

 

In POSTMAN I need to POST payment request to online checkout.
I have managed to fill the body form data, with all the needed key/values as I followed the documentation they provide (the place I need to post the request) but I stumbled upon the Signature as they require it to be calculated (not just copy pasted in the request) and the only example they provide is in PHP. Postman Pre-request script is only written in JavaScript so the PHP example they have can't be used.

Any help would be appreciated, I've tried writing it on my own, but nothing seems to work, so a reading material or tips would be of a great help!

 

This is the link to their PHP example that needs to be interpreted.

 

Link to comment
https://linustechtips.com/topic/1004364-interpreting-php-logic-in-javascript-help/
Share on other sites

Link to post
Share on other sites

How far have you got? Can you post your progress?

 

I would say start here.

 

log some pm.response variables until you find the Method Standard Properties mentioned here

 

use (or create) the variable array and concatenate the array to a string (array.join(seperator))

 

base64 encode the string

 

sign the signature

 

base64 encode the signature

 

add the signature property (look at pm.sendRequest here)

 

post request

 

 

 

 

If you're interested in a product please download and read the manual first.

Don't forget to tag or quote in your reply if you want me to know you've answered or have another question.

Link to post
Share on other sites

@keskparane thank you for your response !
All of their methods appear after I send the request, the problem is the signature, I can't seem to figuire how to calculate it. (I'm new..)
The Signature must be calculated before the request is done (Postman has this option as Pre-request Script) testing it afterwards won't do anything IMO as the request to the server would be already sent.

I think that I don't need to sign the signature (correct me if I'm wrong) as I'm trying to POST in Test environment, not in Production.

 

Do I need to make an array of all the methods that are required for the request and put the values in them or only for the signature ?
 

Sorry for making your head hurts

 

This is what I did without coding, see that I haven't putted value to the signature, if I do it returns "Wrong Signature", if I don't put Signature value it returns "Missing Parameter Signature"

 

 

Capture.PNG

Link to post
Share on other sites

it's too late I should be asleep, i may answer again when i'm awake


 

If you're interested in a product please download and read the manual first.

Don't forget to tag or quote in your reply if you want me to know you've answered or have another question.

Link to post
Share on other sites

ok 

make the signature out of all the data before the signature. so from IPCMethod to Amount_2:5

If you're interested in a product please download and read the manual first.

Don't forget to tag or quote in your reply if you want me to know you've answered or have another question.

Link to post
Share on other sites

15 hours ago, keskparane said:

ok 

make the signature out of all the data before the signature. so from IPCMethod to Amount_2:5

Um yeah...how should I do that ? Should every method be separated function and how should I logically connect them ?

Link to post
Share on other sites

Well according to their data it's "field=variable-field=variable-field=variable"

If you're interested in a product please download and read the manual first.

Don't forget to tag or quote in your reply if you want me to know you've answered or have another question.

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×