Answer the question
In order to leave comments, you need to log in
Why is Liqpay not a valid signature?
I am writing a module for payment on express I want to generate a button for payment I look at the dock, I write according to the example in the dock I generate a button, I go over and give an error "Sorry. An error has occurred. Invalid request signature",
const express = require("express");
const bodyParser = require('body-parser')
const cors = require("cors");
const sha1 = require('sha1');
const LiqPay = require("liqpay");
const public_key = "sandbox_i6056143995"; //fake
const private_key = "sandbox_FYJPFYbeddSheWm20U31UPdgZ6mnpmXnLsTGRem"; //fake
// const liqpay = new LiqPay(public_key, private_key);
const Base64 = require('js-base64').Base64;
const app = express();
app.use(cors())
app.use(bodyParser.urlencoded({
extended: false
}))
app.use(bodyParser.json())
app.post('/pay', (req, res) => {
const json_string = {
"public_key": public_key,
"version": "3",
"action": "pay",
"amount": req.body.amount,
"currency": "UAH",
"description": "test",
"order_id": "000001",
'result_url': 'http://192.168.56.1:8080/',
'server_url': 'http://192.168.56.1:3000/order'
}
const json_strings = JSON.stringify(json_string);
const data = Base64.encode(json_strings); // отримуємо об'єкт закодований в base64
const sign_string = private_key + data + private_key;
const signature = Base64.encode(sha1(sign_string))
console.log(signature)
res.send(`<form method="POST" action="https://www.liqpay.ua/api/3/checkout" accept-charset="utf-8">
<input type="hidden" name="data" value="${data}"/>
<input type="hidden" name="signature" value="${signature}"/>
<input type="submit" />
</form>`)
})
app.listen(3000, () => {
console.log('start')
})
Answer the question
In order to leave comments, you need to log in
0. signature - unique signature of each request
base64_encode(
sha1( private_key + data + private_key) ),
Good evening! tell me, did you find a solution to the problem?
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question