Answer the question
In order to leave comments, you need to log in
How to translate PHP to js?
It is necessary to translate PHP into JS, because it is not possible to pull out $data, $signature in value input in WordPress in ways possible in PHP (please do not write about shortcodes, plugins, widgets, I tried everything, nothing works), but it is necessary that to send a request.
At the same time, it is necessary that $amount be read and passed to processing even before submitting the form, so $POST_['amount'] is not very suitable, but I wanted to solve this issue after.
I am by no means an expert in JS. Undertook to translate, but a jamb pops up, after a jamb, please help.
form method="POST" action="/action.php">
<input type="hidden" id ="data" name="data" value="<?php echo $data; ?>"/>
<input type="hidden" id ="signature" name="signature" value="<?php echo $signature; ?>"/>
<input type="number" id ="amount" name="amount" value="10"/>
<input type="image" src="/button.png"/>
$order_id = date("d/m/Y-H:i:s");
$amount = $_POST['amount'];
$private_key = "i00000000";
$public_key = "i00000000";
$arr = array('version' => 3,
'public_key' => $public_key,
'amount' => $amount,
'action' => 'pay',
'currency' => 'UAH',
'description' => 'Donate',
'order_id' => $order_id,
);
$data = base64_encode( json_encode($arr));
$signature = base64_encode( sha1($private_key .$data .$private_key, 1 ));
Answer the question
In order to leave comments, you need to log in
Or alternatively how to convert $data to text value?
Now the shortcode displays as it says $data, not the value of the variable...
function data_text_shortcode() {
return '$data';
}
add_shortcode('datashortcode', 'data_text_shortcode');
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question