Однако я пытаюсь интегрировать платежный шлюз, хотя я все и сделал, за исключением того, что мне нужно, чтобы значение суммы var передавалось как поле переключателя, но оно принимается только как поле ввода.что делает большую проблему здесь.Пожалуйста, пройдите код, который я пробовал до сих пор.
Не беспокойтесь об идентификаторе продавца или хэш-ключе.
Я попытался добавить поле суммы в качестве переключателя, но оно не будет принято, но при добавлении в качестве поля ввода оно принимает.
<?php
$MERCHANT_KEY = "####";
$SALT = "####";
$PAYU_BASE_URL = "https://secure.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|amount|productinfo|firstname|email|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['amount'])
|| empty($posted['firstname'])
|| empty($posted['email'])
|| empty($posted['phone'])
|| empty($posted['productinfo'])
|| 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';
}
?>
<script>
var hash = '<?php echo $hash ?>';
function submitPayuForm() {
if(hash == '') {
return;
}
var payuForm = document.forms.payuForm;
payuForm.submit();
}
</script>
<body onload="submitPayuForm()">
<?php if($formError) { ?>
<span style="color:red">Please fill all mandatory fields.</span>
<br/>
<br/>
<?php } ?>
<section style="padding-top:50px;padding-bottom:50px"class="section-padding banner-6 parallax-bg bg-fixed overlay light-9" data-stellar-background-ratio="0.5">
<div class="container">
<div class="text-center mb-80">
<h2 class="section-title text-uppercase"><u style="text-decoration: none;border-bottom: 1px solid #673ab7;border-top: 1px solid #673ab7;border-right: 1px solid #673ab7;border-left: 1px solid #673ab7;padding-left:3px;padding-right:3px;">    Register Here   </u></h2>
</div>
<div class="row" style="
border-top-color: #673ab7;
border-right-color: #673ab7;
border-bottom-color:#673ab7;
border-left-color: #673ab7;
border-width:1px;
border-style: solid;
text-align:center;">
<div class="col-md-3"></div>
<div class="col-md-6" >
<form name="payuForm" action="<?php echo $action; ?>" method="post" name="payuForm">
<input type="hidden" name="key" value="<?php echo $MERCHANT_KEY ?>" />
<input type="hidden" name="hash" value="<?php echo $hash ?>"/>
<input type="hidden" name="txnid" value="<?php echo $txnid ?>" />
<input type="hidden" name="service_provider" value="payu_paisa" size="64" />
<div class="row">
<div class="col-md-6">
<div class="input-field">
<label class="sr-only" for="email">Username/Email</label>
<input type="email" name="email" id="email" value="<?php echo (empty($posted['email'])) ? '' : $posted['email']; ?>" class="validate">
<label for="email" data-error="wrong" data-success="right">Email</label>
</div>
</div>
<div class="col-md-6">
<div class="input-field">
<input type="password" name="password" value="<?php echo (empty($posted['password'])) ? '' : $posted['password']; ?>" class="validate" id="name">
<label for="name">Password</label>
</div>
</div>
</div>
<div class="row">
<div class="col-md-6">
<div class="input-field">
<input type="text" name="firstname" id="firstname" value="<?php echo (empty($posted['firstname'])) ? '' : $posted['firstname']; ?>" class="validate">
<label for="name">Name</label>
</div>
</div>
<div class="col-md-6">
<div class="input-field">
<input name="phone" value="<?php echo (empty($posted['phone'])) ? '' : $posted['phone']; ?>" type="tel" class="validate">
<label for="phone">Phone Number</label>
</div>
</div>
</div>
<div class="row">
<div class="col-md-6">
<div class="input-field">
<input id="phone" type="tel" name="productinfo" value="<?php echo (empty($posted['productinfo'])) ? '' : $posted['productinfo'] ?>" class="validate">
<label for="phone">Your Profession</label>
</div>
</div>
<div class="col-md-6">
<div class="input-field">
<input id="website" type="text" name="address" value="<?php echo (empty($posted['address'])) ? '' : $posted['address']; ?>" class="validate">
<label for="website">Address</label>
</div>
</div>
</div>
<div class="row">
<div class="col-md-3">
<center>
<div class="input-field">
<input id="sedan" type="radio" value="<?php echo (empty($posted['amount'])) ? '' : $posted['amount'] ?>1" name="amount" >Sedan
<label for="sedan">.</label>
</div>
</center>
</div>
<div class="col-md-3">
<center>
<div class="input-field">
<input id="suv" type="radio" value="<?php echo (empty($posted['amount'])) ? '' : $posted['amount'] ?>1" name="amount" >SUV
<label for="suv">.</label>
</div>
</center>
</div>
<div class="col-md-3">
<center>
<div class="input-field">
<input id="sedansuv" type="radio" value="<?php echo (empty($posted['amount'])) ? '' : $posted['amount'] ?>2" name="amount" >Both
<label for="sedansuv">.</label>
</div>
</center>
</div>
</div>
<div class="row">
<div class="col-md-3"></div>
<div class="col-md-6">
<center>
<div class="input-field" id="sedanonly">
<input name="amount" type="text" value="<?php echo (empty($posted['amount'])) ? '' : $posted['amount'] ?>" />
<label for="sedan">Total (in Rupees)</label>
</div>
</center>
</div>
</div>
<div class="row">
<div class="col-md-6">
<div class="input-field">
<input type="text" name="surl" readonly value="http://sgdcontest.com/success.php" size="64" />
<label for="phone">For Office Use Only</label>
</div>
</div>
<div class="col-md-6">
<div class="input-field">
<input type="text" name="furl" readonly value="http://sgdcontest.com/failure.php" size="64" />
<label for="website">For Office Use Only</label>
</div>
</div>
</div>
<div class="row">
<div class="col-md-4"></div>
<div class="col-md-4">
<center>
<?php if(!$hash) { ?>
<button type="submit" style="width:140px"name="submit" class="waves-effect waves-light btn pink mt-30" value="Submit" />Register</button>
<?php } ?>
</center>
</div>
</div>
</form>
</div>
</div>
</div>
</section>`