我尝试在结帐页面上整合payumoney。它可以工作,但是某些文件不存储在数据库中,例如姓氏,城市,州。所以,我在哪里做错了,不理解。请找出问题所在。我使用测试模式payumoney。在下面,我提供我尝试的代码。
结帐表格:-
<form 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="surl" value="<?php echo $surl ?>" />
<input type="hidden" name="furl" value="<?php echo $furl ?>" />
<input type="hidden" name="service_provider" value="payu_paisa"/>
<div class="row">
<div class="col-lg-6 col-md-6 col-sm-12 col-xs-12">
<h5>Review & Payment</h5><hr/>
<?php
$checkout = new Checkout();
echo $checkout->finalCheckout();
?>
</div>
<div class="col-lg-offset-1 col-md-5 col-sm-12 col-xs-12">
<h5>Shipping Details</h5><hr/>
<?php $productinfo = json_encode($_SESSION['productinfo']); ?>
<input type="hidden" class="form-control" name="productinfo" value='<?php echo $productinfo; ?>'>
<div class="row">
<div class="col-lg-6">
<div class="form-group">
<label for="firstname">First Name*</label>
<input type="text" class="form-control" id="firstname" name="firstname" value="<?php echo (empty($posted['firstname'])) ? '' : $posted['firstname']; ?>">
</div>
</div>
<div class="col-lg-6">
<div class="form-group">
<label for="lastname">Last Name*</label>
<input type="text" class="form-control" id="lastname" name="lastname" value="<?php echo (empty($posted['lastname'])) ? '' : $posted['lastname']; ?>">
</div>
</div>
</div>
<div class="row">
<div class="col-lg-6">
<div class="form-group">
<label for="email">Email*</label>
<input type="text" class="form-control" id="email" name="email" value="<?php echo (empty($posted['email'])) ? '' : $posted['email']; ?>">
</div>
</div>
<div class="col-lg-6">
<div class="form-group">
<label for="phone">Mobile*</label>
<input type="text" class="form-control" id="phone" name="phone" value="<?php echo (empty($posted['phone'])) ? '' : $posted['phone']; ?>">
</div>
</div>
</div>
<div class="row">
<div class="col-lg-12">
<div class="form-group">
<label for="address1">Address*</label>
<input type="text" class="form-control" id="address1" name="address1" value="<?php echo (empty($posted['address1'])) ? '' : $posted['address1']; ?>">
</div>
</div>
</div>
<div class="row">
<div class="col-lg-6">
<div class="form-group">
<label for="country">Country*</label>
<input type="text" class="form-control" id="country" name="country" value="India" disabled="disabled">
</div>
</div>
<div class="col-lg-6">
<div class="form-group">
<label for="state">State*</label>
<input type="text" class="form-control" id="state" name="state" id="state" value="">
</div>
</div>
</div>
<div class="row">
<div class="col-lg-6">
<div class="form-group">
<label for="city">Town/City*</label>
<input type="text" class="form-control" id="city" name="city" value="">
</div>
</div>
<div class="col-lg-6">
<div class="form-group">
<label for="zipcode">Postcode/Pincode*</label>
<input type="text" class="form-control" id="zipcode" name="zipcode" maxlength="6" value="<?php echo (empty($posted['zipcode'])) ? '' : $posted['zipcode']; ?>">
</div>
</div>
</div>
</div>
</div><hr>
<div class="row">
<div class="col-lg-12 text-right">
<div class="form-group">
<input type="button" class="btn btn-primary" value="GO BACK">
<?php if(!$hash){ ?>
<input type="submit" class="btn btn-success" value="CONTINUE">
<?php } ?>
</div>
</div>
</div>
</form>
PayUMoney集成代码:-
<?php
//CARD NO: 5123456789012346
//CARD VAILD: 05 20
//CARD CVV: 123
$MERCHANT_KEY = "hDkYGPQe";
$SALT = "yIEkykqEH3";
// Merchant Key and Salt as provided by Payu.
$PAYU_BASE_URL = "https://test.payu.in"; // For Sandbox Mode
//$PAYU_BASE_URL = "https://secure.payu.in"; // For Production Mode
$surl = "http://localhost/neelam/success.php";
$furl = "http://localhost/neelam/failed.php";
$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['firstname'])
|| empty($posted['lastname'])
|| empty($posted['email'])
|| empty($posted['phone'])
|| empty($posted['address1'])
|| empty($posted['zipcode'])
) {
$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';
}
?>
在这里,我将成功页面存储在databse中:-
$status=$_POST["status"];
$txnid=$_POST["txnid"];
$firstname=$_POST["firstname"];
$lastname=$_POST["lastname"];
$amount=$_POST["amount"];
$txnid=$_POST["txnid"];
$posted_hash=$_POST["hash"];
$key=$_POST["key"];
$productinfo=$_POST["productinfo"];
$email=$_POST["email"];
$phone=$_POST["phone"];
$address=$_POST["address1"];
$country=$_POST["country"];
$state=$_POST["state"];
$city=$_POST["city"];
$state=$_POST["state"];
$pincode=$_POST["zipcode"];
$salt="yIEkykqEH3";
INSERT INTO wm_orders(firstname,lastname,email,phone,address,country,state,city,pincode,productinfo,txnid,amount,payment_status,delivery_status) VALUES('{$firstname}','{$lastname}','{$email}','{$phone}','{$address}','{$country}','{$state}','{$city}','{$pincode}','{$productinfo}','{$txnid}','{$amount}','{$status}','N')