如何在单击按钮时生成校验和

How to generate checksum on click of a button

我正在尝试为我的应用中的 paytm 集成生成校验和。

所以,我下载了 https://github.com/Paytm-Payments/Paytm_App_Checksum_Kit_NodeJs github 存储库。

然后在我的服务器端,我创建了一个名为 "paytm_mobile" 的文件夹,其中上传的结构如下所示。

然后我用我的详细信息

更新了 "paytm" 文件夹中的文件 "paytm_config"
module.exports = {
  paytm_config: {
    MID: 'V******************3',
    WEBSITE: 'WEBSTAGING',
    CHANNEL_ID: 'WAP',
    INDUSTRY_TYPE_ID: 'Retail',
    MERCHANT_KEY : '0Un**********y3R'
    }
}

然后按照上面提供的步骤link也就是

我尝试按照步骤 3 调用 "yoursite/generate_checksum",点击我的应用程序上的按钮,如下所示。

exports.generate_cheksum = function(){
    console.log("generate_cheksum");

    const httpModule = require("http");
    httpModule.request({
        url: "http://www.vis******ma.com/paytm_mobile/index.js",
        method: "GET"
    }).then((response) => {
        console.log(response); //[object Object]
        response.map(key=>console.log(key)); //not getting anything
    }, (e) => {
        console.log("----error");
        console.log(e);
    });
}

但是我没有弄明白的是如何调用它 "generate_checksum"。

将此 php 文件写入服务器上的任意位置 例如:generate_checksum.php

<?php

    require_once("encdec_paytm.php");

    define("merchantMid", "V******************3");
    // Key in your staging and production MID available in your dashboard
    define("merchantKey", "0**************R");

    // Key in your staging and production merchant key available in your dashboard
    define("orderId", "order1");
    define("channelId", "WEB");
    define("custId", "cust123");
    define("mobileNo", "7777777777");
    define("email", "username@emailprovider.com");
    define("txnAmount", "100.12");
    define("website", "WEBSTAGING");
    // This is the staging value. Production value is available in your dashboard
    define("industryTypeId", "Retail");
    // This is the staging value. Production value is available in your dashboard
    define("callbackUrl", "https://<Merchant_Response_URL>");
    $paytmParams = array();
    $paytmParams["MID"] = merchantMid;
    $paytmParams["ORDER_ID"] = orderId;
    $paytmParams["CUST_ID"] = custId;
    $paytmParams["MOBILE_NO"] = mobileNo;
    $paytmParams["EMAIL"] = email;
    $paytmParams["CHANNEL_ID"] = channelId;
    $paytmParams["TXN_AMOUNT"] = txnAmount;
    $paytmParams["WEBSITE"] = website;
    $paytmParams["INDUSTRY_TYPE_ID"] = industryTypeId;
    $paytmParams["CALLBACK_URL"] = callbackUrl;
    $paytmChecksum = getChecksumFromArray($paytmParams, merchantKey);
    $transactionURL = "https://securegw-stage.paytm.in/theia/processTransaction";
    // $transactionURL = "https://securegw.paytm.in/theia/processTransaction"; // for    production

    echo $paytmChecksum;
?>

添加此文件"require_once("encdec_paytm.php");"在这个 link

的同一文件夹中

https://github.com/Paytm-Payments/Paytm_App_Checksum_Kit_PHP/blob/master/lib/encdec_paytm.php

将必填字段传递到 php 文件的任务留给了您。你需要在那里提供你的 mid 和 mkey。