如何在将PHP金额发送到支付网关之前添加5.5%的费用? [英] How to add 5.5% fees before sending amount in PHP to payment gateway?

查看:67
本文介绍了如何在将PHP金额发送到支付网关之前添加5.5%的费用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我想在将字段数量发送到支付网关之前,将5.5%的费用添加到字段数量中。我可以在文本框中添加费用并显示。但我无法发送到支付网关..它说校验和错误。请帮忙!

工作版本这里

输入一个虚拟名称,虚拟电子邮件,虚拟电话,金额和点击提交..它将重新加载一次并进入支付网关的页面,这将显示校验和错误。

错误是字段金额。实际上Payu提供代码

Hi all,
I want to add 5.5% fees to the field amount before sending it to the payment gateway..I am able to add the fees and show in a text box. But I couldn't send to payment gateway..It says "Checksum error". Please help!
The working version is given here
Enter a dummy name, dummy email, dummy phone, amount and click submit.. It will reload once and take to payment gateway's page which will show checksum error.
The error is with the field "amount". Actually Payu provide the code

<input name="amount" value="<?php echo (empty($posted['amount'])) ? '' : $posted['amount'] ?>" />

但我只想添加5.5%的金额。



But I just want to add 5.5% to that amount.

<?php
// Merchant key here as provided by Payu
$MERCHANT_KEY = "JBZaLc";

// Merchant Salt as provided by Payu
$SALT = "GQs7yium";

// End point - change to https://secure.payu.in for LIVE mode
$PAYU_BASE_URL = "https://test.payu.in";

$action = '';

$posted = array();
if(!empty($_POST)) {
    //print_r($_POST);
  foreach($_POST as $key => $value) {    
    $posted[$key] = $value; 
	
  }
}

$formError = 0;

if(empty($posted['txnid'])) {
  // Generate random transaction id
  $txnid = substr(hash('sha256', mt_rand() . microtime()), 0, 20);
} else {
  $txnid = $posted['txnid'];
}
$hash = '';
// Hash Sequence
$hashSequence = "key|txnid|firstname|email|productinfo|amount|udf1|udf2|udf3|udf4|udf5|udf6|udf7|udf8|udf9|udf10";
if(empty($posted['hash']) && sizeof($posted) > 0) {
  if(
          empty($posted['key'])
          || empty($posted['txnid'])
          
          || empty($posted['firstname'])
          || empty($posted['email'])
					|| empty($posted['productinfo'])
					|| empty($posted['amount'])
          || empty($posted['phone'])
          
          || empty($posted['surl'])
          || empty($posted['furl'])
		  || empty($posted['service_provider'])
  ) {
    $formError = 1;
  } else {
    //$posted['productinfo'] = json_encode(json_decode('[{"name":"tutionfee","description":"","value":"500","isRequired":"false"},{"name":"developmentfee","description":"monthly tution fee","value":"1500","isRequired":"false"}]'));
	$hashVarsSeq = explode('|', $hashSequence);
    $hash_string = '';	
	foreach($hashVarsSeq as $hash_var) {
      $hash_string .= isset($posted[$hash_var]) ? $posted[$hash_var] : '';
      $hash_string .= '|';
    }

    $hash_string .= $SALT;


    $hash = strtolower(hash('sha512', $hash_string));
    $action = $PAYU_BASE_URL . '/_payment';
  }
} elseif(!empty($posted['hash'])) {
  $hash = $posted['hash'];
  $action = $PAYU_BASE_URL . '/_payment';
}
?>
<html>
  <head>
  <script>
    var hash = '<?php echo $hash ?>';
    function submitPayuForm() {
      if(hash == '') {
        return;
      }
      var payuForm = document.forms.payuForm;
      payuForm.submit();
    }
  </script>
	<!-- CDN -->
		<script src="http://code.jquery.com/jquery.min.js"></script>
		<script src="http://cdnjs.cloudflare.com/ajax/libs/prettify/r224/prettify.js"></script>
		<link href="http://cdnjs.cloudflare.com/ajax/libs/prettify/r224/prettify.css" rel="stylesheet">
		<link href='http://fonts.googleapis.com/css?family=Open+Sans:300italic,400italic,600italic,700italic,400,300,600,700&subset=latin,latin-ext' rel='stylesheet' type='text/css'>
		<!-- foundation start -->
		<!-- Set the viewport width to device width for mobile -->
		<meta name="viewport" content="width=device-width, initial-scale=1.0" />
		<!-- Included CSS Files (Compressed) -->
		<link rel="stylesheet" href="foundation/stylesheets/foundation.min.css">
		<link rel="stylesheet" href="foundation/stylesheets/app.css">
		<script src="foundation/javascripts/modernizr.foundation.js"></script>
		<!-- foundation end -->
		<!-- foundation datepicker start -->
		<script src="js/foundation-datepicker.js"></script>
		<link rel="stylesheet" href="stylesheets/foundation-datepicker.css">
		<!-- foundation datepicker end -->
		<link rel="stylesheet" href="stylesheets/example.css">
		<!--[if lt IE 9]>
			<script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
		<![endif]-->
		
		<script language="javascript">
function KeyUpEvent()
{
var txt1 = document.getElementById("txt1");
var txt2 = document.getElementById("txt2");
var amount = document.getElementById("amount");
if ((txt1.value != "") && (txt2.value != ""))
{
amount.value = parseInt(txt1.value) + parseInt(txt1.value) * (txt2.value);
}
}

</script>

  </head>
  <body onload="submitPayuForm()">
    <h2>Homestaysatwaya

推荐答案

发布['amount']))? '':
posted['amount'])) ? '' :


已发布['金额']?> / >
posted['amount'] ?>" />

但我只想添加5.5%的金额。



But I just want to add 5.5% to that amount.

<?php
// Merchant key here as provided by Payu


MERCHANT_KEY = JBZaLc;

// Payu提供的商家盐
MERCHANT_KEY = "JBZaLc"; // Merchant Salt as provided by Payu


这篇关于如何在将PHP金额发送到支付网关之前添加5.5%的费用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆