Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/395.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 使用RESTAPI的Payumoney支付网关集成_Javascript_Node.js_Payment Gateway_Payu_Payumoney - Fatal编程技术网

Javascript 使用RESTAPI的Payumoney支付网关集成

Javascript 使用RESTAPI的Payumoney支付网关集成,javascript,node.js,payment-gateway,payu,payumoney,Javascript,Node.js,Payment Gateway,Payu,Payumoney,我正在开发使用angular和后端nodejs、express和mongodb的完全restful前端web应用程序。我正在尝试将payumoney支付网关与我的web应用程序集成。当我点击支付端点时,Plz通过这个api返回html页面。我不知道如何让用户重定向到payumoney支付页面。在此之前,我得到的错误校验和失败。iam正在以这种格式发送数据 request.post({ url: 'https://test.payu.in/_payment',

我正在开发使用angular和后端nodejs、express和mongodb的完全restful前端web应用程序。我正在尝试将payumoney支付网关与我的web应用程序集成。当我点击支付端点时,Plz通过这个api返回html页面。我不知道如何让用户重定向到payumoney支付页面。在此之前,我得到的错误校验和失败。iam正在以这种格式发送数据

request.post({
                url: 'https://test.payu.in/_payment',
                headers: {
                    Authorization:'4sOSsCZXIopj4XvbddLX8kF7tmlTu2UZsjHVAwPt404=' 
                       },
                form:  { 
      key: 'lfX7uR',
      txnid: 578cb861e9c38ecc185ec8e7,
      firstname: 'Rayees',
      lastname: 'Mir',
      email: 'rayees@mir.com',
      phone: '9797187225',
      productinfo: '{"_id":"57611c58763eb9c0116d6def","expiryDate":"2016-09-15T09:14:00.536Z","amount":8600,"updated":"2016-06-22T13:55:43.176Z","user":"5757c59e3d47bd50118e07c7","__v":27,"status":"active","created":"2016-06-15T09:14:00.533Z","products":[{"_id":"575a9257685404601d1da5c0","quantity":3,"salesPrice":200,"addedDate":"2016-06-15T15:29:29.525Z","listPrice":50},{"_id":"575a9286ee1ca30c27abb9eb","quantity":20,"salesPrice":400,"addedDate":"2016-06-22T13:55:43.176Z","listPrice":210}]}',
      amount: 8200,
      surl: 'https://www.google.com',
      furl: 'https://www.facebook.com',
      hash: '',
      service_provider: '',
      address1: '',
      address2: '',
      city: '',
      state: '',
      country: '',
      zipcode: '',
      udf1: '',
      udf2: '',
      udf3: '',
      udf4: '',
      udf5: '',
      udf6: '',
      udf7: '',
      udf8: '',
      udf9: '',
      udf10: '' }
            },function(result){
                console.log(result);
            });

您的散列丢失请尝试在php中使用sha512算法生成散列,
不允许jquery请求您必须使用form post方法发送所有参数

您需要在继续之前计算请求数据的哈希值,根据您应该在服务器端创建哈希值的文档,以下是示例代码:

<?php
error_reporting(0);

$salt = "eCwWELxi"; # salt value need to be picked from your database
$amount = $_POST["amount"]; # amount need to be picked up from your database
$reverseHash = generateReverseHash();

if ($_POST["hash"] == $reverseHash) {
    # transaction is successful
    # do the required javascript task
    echo("Transaction Success & Verified");
    AndroidSuccess($_POST["amount"]);
}
else{
    # transaction is tempered
    # handle it as required
    echo("<br>");
    echo "\nInvalid transaction";
}

# For Android Success
function AndroidSuccess($input) {
    echo '<script type="text/javascript">';
    echo 'PayU.onSuccess("Amount =" +'.$_POST["amount"].')';
    echo "</script>";
}

# Function to generate reverse hash
function generateReverseHash() {
    global $salt;
    global $amount;
    if ($_POST["additional_charges"] != null) {
        $reversehash_string = $_POST["additional_charges"] . "|" . $salt . "|" . $_POST["status"]  . "||||||" . $_POST["udf5"] . "|" . $_POST["udf4"] . "|" . $_POST["udf3"] . "|" . $_POST["udf2"] . "|" . $_POST["udf1"] . "|" .
        $_POST["email"] . "|" . $_POST["firstname"] . "|" . $_POST["productinfo"] . "|" . $amount . "|" . $_POST["txnid"] . "|" . $_POST["key"] ;
    }
    else{
        $reversehash_string =  $salt . "|" . $_POST["status"]  . "||||||" . $_POST["udf5"] . "|" . $_POST["udf4"] . "|" . $_POST["udf3"] . "|" . $_POST["udf2"] . "|" . $_POST["udf1"] . "|" .
             $_POST["email"] . "|" . $_POST["firstname"] . "|" . $_POST["productinfo"] . "|" . $amount . "|" . $_POST["txnid"] . "|" . $_POST["key"] ;
    }

//  echo($reversehash_string);
    $reverseHash = strtolower(hash("sha512", $reversehash_string));
    return $reverseHash;
}

缺少使用SHA512的校验和。是否可以执行此操作。如果是,你能分享代码吗?我正在尝试类似的方法并寻找一些参考代码嗨,你是否使用rest APIThank@John Conde获得输出:如何将payumoney整合到angular6/7/8中?