0

我正在使用 Angular 和后端 nodejs、express 和 mongodb 开发完全宁静的前端 Web 应用程序。我正在尝试将 payumoney 支付网关与我的网络应用程序集成。请通过此https://www.payumoney.com/developer-doc-api.html api 在我点击付款端点https://test.payu.in/_payment时返回 html 页面。我不知道如何让用户重定向到 payumoney 支付页面。在这一切之前,我收到错误校验和失败在 Html 页面中返回错误。我以这种格式发送数据

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);
            });
4

2 回答 2

0

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

<?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;
}
于 2018-09-21T19:21:29.500 回答
-1

您的哈希丢失尝试在 php 中使用 sha512 算法生成哈希,不允许 jquery 请求您必须使用表单发布方法发送所有参数

于 2018-09-20T18:29:11.080 回答