0

I have online payment form. On-click I should pass following information to online payment company.

  • Mid--->Merchant ID
  • Amount--->Transaction amount (Integer: $50.25 = 5025)
  • Currency--->Transaction currency code (ISO 4217)
  • Description--->Transaction description (Can be used for item assignment)
  • Reference--->Transaction reference (unique transaction value set by merchant)
  • Language--->Language{az/en/ru)
  • Signature--->MD5 hash of concatenated parameter length + value with secret key

Signature example:

$signature = Strtoupper(md5(strlen($mid).$mid.strlen($amount).$amount.strlen($currency).$currency.(!empty($description)? strlen($description).$description :"0").strlen($reference).$reference.strlen($language).$language.$key));

The resulting URL should be like this:

 https://test.millikart.az:7444/gateway/payment/register?mid=Test&amount=5025&currency=944&description=test1000&reference=T7D3EDB885A5BC3C&language=az&signature=9A9E510BE7094D94284F1AFFE00FA4DA

The amount of information that should be sent to an online payment company is a JavaScript variable that I get as a result of JavaScript calculations. I couldn't figure out how to achieve it. Any kind of help is appreciated. Thanks

scunliffe
  • 62,582
  • 25
  • 126
  • 161
  • 2
    Possible duplicate of [Access a JavaScript variable from PHP](https://stackoverflow.com/questions/2338942/access-a-javascript-variable-from-php) – Tom Marienfeld Sep 09 '19 at 12:54
  • Possible duplicate of [Access a JavaScript variable from PHP](https://stackoverflow.com/questions/2338942/access-a-javascript-variable-from-php) – jpeg Sep 09 '19 at 13:03

1 Answers1

0

with ajax and FormData:

$(document).ready( function(){

        
            let calculated = 3;
            
            let fd = new FormData();

            fd.append('calculated', calculated);
            
            
            $.ajax({
                url: "the_php_file_that_you_need_to_pass_it.php",
                type: "POST",
                data: fd,
                processData: false,
                contentType: false,

                complete: function (results) {
                    try {
                        let str = JSON.parse(results.responseText);
                         console.log(str)
                    } catch (e) {
                        console.error(e.message);
                    }
                },
            });


        }) ;
Klienblat Moshe
  • 322
  • 1
  • 6