0

我正在尝试将 payumoney 与 angularjs 集成。但它显示错误,如“校验和失败”。

控制器.js

(function ()
{
'use strict';

angular
    .module('app.todo')
    .controller('TodoController', TodoController);

/** @ngInject */
function TodoController($document, $mdDialog, $mdSidenav, Tasks, Tags,$scope,$crypthmac)
{
    var vm = this;

    vm.txnid = "fd3e847h2";
    vm.firstname = "Hemanth";
    vm.email = "kevinguru888@gmail.com";
    vm.phone = "9901996148";
    vm.service_provider = "payu_paisa";
    vm.productinfo = "steering";
    vm.amount = "399.00";
    vm.surl = "http://localhost:3000/success";
    vm.furl = "http://localhost:3000/failure";
    vm.key = "OygoFs";
    vm.salt = "BV1QBwCv";

    var string = vm.key + '|' + vm.txnid + '|' + vm.amount + '|' + vm.productinfo + '|' + vm.firstname + '|' + vm.email + '|||||||||||' + vm.salt;
    vm.hash = $crypthmac.encrypt(string,"");


}
})();

.html 文件

<head>
<script type='text/javascript' src="../bower_components/angular-hmac-   sha512/angular-hmac-sha512.js"></script>
</head>

<div id="todo" class="page-layout simple tabbed">

<!-- HEADER -->
<div class="header md-accent-bg" layout="row" layout-align="start center">
     <div class="title">
        <span class="md-display-1 font-weight-300">PAY U Form</span>
     </div>

</div>
<!-- / HEADER -->
<md-content layout-padding>
    <div class="innerContent">
        <form action='https://test.payu.in/_payment', method='post', name="buyDetailsForm">
            <md-content class="md-padding">
                <div layout="row" layout-align="space-around">
                    <div flex style="max-width:400px;">
                        <md-input-container class="md-block">
                            <label>Transaction Id</label>
                            <input name="txnid" ng-model="vm.txnid">
                        </md-input-container>
                    </div>

                    <div flex style="max-width:400px;">
                        <md-input-container class="md-block">
                            <label>Name</label>
                            <input name='firstname' ng-model="vm.firstname">
                        </md-input-container>
                    </div>

                    <div flex style="max-width:400px;">
                        <md-input-container class="md-block" flex-gt-sm>
                            <label>Email</label>
                            <input name='email' ng-model="vm.email">
                        </md-input-container>
                    </div>
                </div>

                <div layout="row" layout-align="space-around">
                    <div flex style="max-width:400px;">
                        <md-input-container class="md-block">
                            <label>Mobile</label>
                            <input name='phone' ng-model="vm.phone">
                        </md-input-container>
                    </div>

                    <div flex style="max-width:400px;">
                        <md-input-container class="md-block" flex-gt-sm>
                            <label>Service Provider</label>
                            <input name='service_provider' ng-model="vm.service_provider">
                        </md-input-container>
                    </div>
                </div>

                <div layout="row" layout-align="space-around">
                    <div flex style="max-width:400px;">
                        <md-input-container class="md-block">
                            <label>Product Info</label>
                            <input name='productinfo' ng-model="vm.productinfo">
                        </md-input-container>
                    </div>

                    <div flex style="max-width:400px;">
                        <md-input-container class="md-block" flex-gt-sm>
                            <label>Amount</label>
                            <input name='amount' ng-model="vm.amount">
                        </md-input-container>
                    </div>
                </div>

                <div layout="row" layout-align="space-around">
                    <div flex style="max-width:400px;">
                        <md-input-container class="md-block">
                            <label>Success Url</label>
                            <input name='surl' ng-model="vm.surl">
                        </md-input-container>
                    </div>

                    <div flex style="max-width:400px;">
                        <md-input-container class="md-block" flex-gt-sm>
                            <label>Failure Url</label>
                            <input name='furl' ng-model="vm.furl">
                        </md-input-container>
                    </div>
                </div>

                <div layout="row" layout-align="space-around">
                    <div flex style="max-width:400px;">
                        <md-input-container class="md-block">
                            <label>Key</label>
                            <input name='key' ng-model="vm.key">
                        </md-input-container>
                    </div>

                    <div flex style="max-width:400px;">
                        <md-input-container class="md-block" flex-gt-sm>
                            <label>Hash</label>
                            <input name='hash' ng-model="vm.hash">
                        </md-input-container>
                    </div>
                </div>

            </md-content>
            <div layout="row" layout-align="end center">
                <md-button class="md-raised md-primary" ng-click="vm.cancel()">Cancel</md-button>
                <md-button class="md-raised md-primary" ng-click="vm.submit(buyDetailsForm)">Place Order</md-button>
            </div>
        </form>
    </div>
</md-content>   
</div>

错误显示为“抱歉!我们无法处理您的付款校验和失败”。

4

1 回答 1

0

当表单中的哈希值和传递值不匹配时,会发生此错误。如果您传递 2 udf,那么您还必须以带有名称的形式发送它。

如果您传递相同但仍然得到相同的错误,那么这是因为哈希生成问题。您正在使用$crypthmac但它不会创建完美的哈希,创建使用或自己的sha512算法,或使用API, 来创建完美的哈希。您可以检查由创建的哈希$crypthmac是否完美PayUMoney解密它,这就是它返回错误的原因。只需检查已生成,$crypthmac<?php echo hash('sha512', 'text') ?>就可以得到差异。

于 2017-01-11T12:46:42.260 回答