PayUmoney与angularjs集成,给Checksum失败错误

时间:2016-12-07 06:26:33

标签: angularjs payment-gateway payumoney

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

controller.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>

错误显示为&#34; SORRY!我们无法处理您的付款Checksum失败&#34;。

1 个答案:

答案 0 :(得分:0)

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

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