我正在尝试将payumoney与angularjs集成。但它显示错误,例如校验和失败'。
(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,"");
}
})();
<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;。
答案 0 :(得分:0)
当表单中的哈希值和传递值不匹配时,会发生此错误。 如果你传递2 udf,那么你也必须以名字的形式发送它。
如果你传递相同但仍然得到相同的错误,那么这是因为哈希生成中的问题。您正在使用$crypthmac
,但它不会创建完美的哈希值,无法创建使用或拥有sha512
算法,或使用API
来创建完美哈希。您可以检查$crypthmac
创建的哈希是不是完美地PayUMoney
完美解密它,这就是它返回错误的原因。只需检查已生成$crypthmac
和<?php echo hash('sha512', 'text') ?>
即可获得差异。