问题
First time integrating a payment gateway in any website. I'm using PayUmoney in the registration form and when I integrate the PayUmoney Bolt and proceed to payment it's just showing me the blank page. No error was given, if there isn't an error I can try to look for but couldn't.
register.php
<?php
error_reporting( E_ALL );
ini_set( 'display_errors', 1 );
/* change this to include YOUR db connection or edit as appropriate */
$dbhost = '127.0.0.1';
$dbuser = 'root';
$dbpwd = '';
$dbname = 'xxx';
$db = new mysqli( $dbhost, $dbuser, $dbpwd, $dbname );
if(strcasecmp($_SERVER['REQUEST_METHOD'], 'POST') == 0){
function uploaderror( $error ){
switch( $error ) {
case UPLOAD_ERR_INI_SIZE: return "The uploaded file exceeds the upload_max_filesize directive in php.ini";
case UPLOAD_ERR_FORM_SIZE: return "The uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the HTML form";
case UPLOAD_ERR_PARTIAL: return "The uploaded file was only partially uploaded";
case UPLOAD_ERR_NO_FILE: return "No file was uploaded";
case UPLOAD_ERR_NO_TMP_DIR: return "Missing a temporary folder";
case UPLOAD_ERR_CANT_WRITE: return "Failed to write file to disk";
case UPLOAD_ERR_EXTENSION: return "File upload stopped by extension";
default: return "Unknown upload error";
}
}
//Request hash
$contentType = isset($_SERVER["CONTENT_TYPE"]) ? trim($_SERVER["CONTENT_TYPE"]) : '';
if(strcasecmp($contentType, 'application/json') == 0){
$data = json_decode(file_get_contents('php://input'));
$hash=hash('sha512', $data->key.'|'.$data->txnid.'|'.$data->amount.'|'.$data->name.'|'.$data->email.'|||||'.$data->udf5.'||||||'.$data->salt);
$json=array();
$json['success'] = $hash;
echo json_encode($json);
}
exit(0);
$status=null;
$errors=[];
$valid_extensions = array('jpeg', 'jpg', 'png', 'gif', 'bmp' , 'pdf' , 'doc' , 'ppt');
/* Edit as appropriate */
$path = 'uploads/'; # 'uploads/'
/* all mandatory fields */
$required=array(
'name' => FILTER_SANITIZE_STRING,
'gender' => FILTER_SANITIZE_STRING,
'mobile' => FILTER_SANITIZE_STRING,
'email' => FILTER_SANITIZE_STRING,
'address' => FILTER_SANITIZE_STRING,
'performing' => FILTER_SANITIZE_STRING,
'facebook' => FILTER_SANITIZE_STRING,
'twitter' => FILTER_SANITIZE_STRING,
'instagram' => FILTER_SANITIZE_STRING,
'about' => FILTER_SANITIZE_STRING,
'amount' => FILTER_SANITIZE_STRING
);
/* Probably at least 1 is required */
$optional=array(
'dj' => FILTER_SANITIZE_NUMBER_INT,
'vj' => FILTER_SANITIZE_NUMBER_INT,
'producer' => FILTER_SANITIZE_NUMBER_INT,
'bollywood' => FILTER_SANITIZE_NUMBER_INT,
'techno' => FILTER_SANITIZE_NUMBER_INT,
'trap' => FILTER_SANITIZE_NUMBER_INT,
'trance' => FILTER_SANITIZE_NUMBER_INT,
'bigroom' => FILTER_SANITIZE_NUMBER_INT,
'hiphop' => FILTER_SANITIZE_NUMBER_INT,
'housemusic' => FILTER_SANITIZE_NUMBER_INT,
'substep' => FILTER_SANITIZE_NUMBER_INT,
'retro' => FILTER_SANITIZE_NUMBER_INT,
'psytrance' => FILTER_SANITIZE_NUMBER_INT,
'turntabulist' => FILTER_SANITIZE_NUMBER_INT,
'other' => FILTER_SANITIZE_NUMBER_INT
);
/* all required */
$filefields=array(
'image',
'attach_file'
);
/* Ensure that all the required fields are populated */
foreach( array_keys( $required ) as $key ){
try{
if( !isset( $_POST[ $key ] ) ) throw new Exception( sprintf( 'The field "%s" cannot be empty', $key ) );
}catch( Exception $e ){
$errors[]=$e->getMessage();
continue;
}
}
/* Ensure that all image fields are populated */
foreach( $filefields as $field ){
try{
if( empty( $_FILES[ $field ] ) ) throw new Exception( sprintf( 'The file field "%s" is required', $field ) );
}catch( Exception $e ){
$errors[]=$e->getMessage();
continue;
}
}
if( empty( $errors ) ){
$sql='insert into `registration`
( `name`,`gender`,`mobile`,`email`,`address`,`performing`,`dj`,`vj`,`producer`,`bollywood`,`techno`,`trap`,`trance`,`bigroom`,`hiphop`,`housemusic`,`dubstep`,`retro`,`psytrance`,`turntabulist`,`other`,`facebook`,`twitter`,`instagram`,`about`,`amount`,`image`,`attach_file` )
values
( ?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,? )';
$stmt=$db->prepare( $sql );
if( !$stmt ) {
/* Investigate errors and make corrections to db table &/or sql statement */
exit( sprintf( 'Bad Foo! - %s', $db->error ) );
}
$stmt->bind_param(
'ssssssiiiiiiiiiiiiiiisssssss',
$name,
$gender,
$mobile,
$email,
$address,
$performing,
$dj,
$vj,
$producer,
$bollywood,
$techno,
$trap,
$trance,
$bigroom,
$hiphop,
$housemusic,
$dubstep,
$retro,
$psytrance,
$turntabulist,
$other,
$facebook,
$twitter,
$instagram,
$about,
$amount,
$image,
$attach_file
);
$images=array();
foreach( $filefields as $index => $field ){
try{
/* assign a variable variable - cast as an object for convenience */
$obj=(object)$_FILES[ $field ];
if( isset( $obj ) ){
/* get details of the file */
$name=$obj->name;
$ext=strtolower( pathinfo( $name, PATHINFO_EXTENSION ) );
$tmp=$obj->tmp_name;
$size=$obj->size;
$error=$obj->error;
if( !in_array( $ext, $valid_extensions ) ) throw new Exception( sprintf('The file "%s" has an illegal file extension "%s"',$name,$ext ) );
if( $error==UPLOAD_ERR_OK && is_uploaded_file( $tmp ) ){
/* create the final name for the file to be saved */
$saveas = sprintf( '%s/%d.%s', $path, mt_rand( 1000, 1000000 ), $name );
$bytes = move_uploaded_file( $tmp, $saveas );
if( $bytes ){
$images[ $field ]=(object)array(
'name' => $name,
'size' => $size
);
} else {
throw new Exception( sprintf( 'There was an error storing "%s"', $name ) );
}
} else {
throw new Exception( sprintf( 'There was a problem with "%s" - %s', $name, uploaderror( $error ) ) );
}
}
}catch( Exception $e ){
$errors[]=$e->getMessage();
continue;
}
}
$args=array_merge( $required, $optional );
filter_input_array( INPUT_POST, $args );
extract( $_POST );
foreach( $filefields as $field ){
${$field}=$images[ $field ]->name;
}
if( empty( $errors ) ){
$status=$stmt->execute();
if( $stmt->errno!= 0 ) exit( sprintf( 'Critical Error: [%d] - %s',$stmt->errno,$stmt->error) );
$stmt->close();
}
}
}
?>
<!DOCTYPE html>
<html lang='en'>
<head>
<meta charset='utf-8' />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" >
<script id="bolt" src="https://sboxcheckout-static.citruspay.com/bolt/run/bolt.min.js" bolt-
color="e34524" bolt-logo="logo.png"></script>
</head>
<body>
<?php
function getCallbackUrl()
{
$protocol = ((!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != 'off') || $_SERVER['SERVER_PORT'] == 443) ? "https://" : "http://";
return $protocol . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'] . 'response.php';
}
?>
<form method='post' enctype='multipart/form-data'>
<input type="hidden" id="udf5" name="udf5" value="BOLT_KIT_PHP7" />
<input type="hidden" id="surl" name="surl" value="<?php echo getCallbackUrl(); ?>" />
<input type="hidden" id="key" name="key" value="hOxjEeU3" />
<input type="hidden" id="salt" name="salt" value="05TBBdE1ZG" />
<input type="hidden" id="hash" name="hash" placeholder="Hash" value="" />
<div class='row' style='margin-top: 50px;'>
<div class='col-md-6'>
<input type='text' class='form-control' id='name' name='name' placeholder='Enter name' required />
</div>
<div class='col-md-6'>
<input type='text' class='form-control' id='gender' name='gender' placeholder='Gender' required />
</div>
<div class='col-md-6'>
<input type='number' class='form-control' id='mobile' name='mobile' placeholder='Mobile Number' min="10" max="12" required />
</div>
<div class='col-md-6'>
<input type='text' class='form-control' id='email' name='email' placeholder='Email' required />
</div>
<div class='col-md-6'>
<input type='text' class='form-control' id='address' name='address' placeholder='Enter Your Full Address' required />
</div>
<div class='col-md-6'>
<input type='text' class='form-control' id='performing' name='performing' placeholder='Performing Since' required />
</div>
<div class='col-md-4' style='margin-top: 35px;'>
<input type='checkbox' name='dj' value='1'> DJ<br>
</div>
<div class='col-md-4' style='margin-top: 35px;'>
<input type='checkbox' name='vj' value='1'> VJ<br>
</div>
<div class='col-md-4' style='margin-top: 35px;'>
<input type='checkbox' name='producer' value='1'> Producer<br>
</div>
<div class='col-md-6' style='margin-top: 20px;'>
<h3>Category</h3>
</div>
<div class='col-md-6'></div>
<div class='col-md-4' style='margin-top: 5px;'>
<input type='checkbox' name='bollywood' value='1'> Bollywood DJ<br>
</div>
<div class='col-md-4' style='margin-top: 5px;'>
<input type='checkbox' name='techno' value='1'> Techno DJ<br>
</div>
<div class='col-md-4' style='margin-top: 5px;'>
<input type='checkbox' name='trap' value='1'> Trap DJ<br>
</div>
<div class='col-md-4' style='margin-top: 5px;'>
<input type='checkbox' name='trance' value='1'> Trance DJ<br>
</div>
<div class='col-md-4' style='margin-top: 5px;'>
<input type='checkbox' name='bigroom' value='1'> Big Room DJ<br>
</div>
<div class='col-md-4' style='margin-top: 5px;'>
<input type='checkbox' name='hiphop' value='1'> Hip Hop DJ<br>
</div>
<div class='col-md-4' style='margin-top: 5px;'>
<input type='checkbox' name='housemusic' value='1'> House Music DJ<br>
</div>
<div class='col-md-4' style='margin-top: 5px;'>
<input type='checkbox' name='dubstep' value='1'> dubstep dj<br>
</div>
<div class='col-md-4' style='margin-top: 5px;'>
<input type='checkbox' name='retro' value='1'> Retro DJ<br>
</div>
<div class='col-md-4' style='margin-top: 5px;'>
<input type='checkbox' name='psytrance' value='1'> Psy-Trance DJ<br>
</div>
<div class='col-md-4' style='margin-top: 5px;'>
<input type='checkbox' name='turntabulist' value='1'> Turntabulist DJ<br>
</div>
<div class='col-md-4' style='margin-top: 5px; margin-bottom: 20px;'>
<input type='checkbox' name='other' value='1'> Any Other<br>
</div>
<div class='col-md-6'>
<input class='form-control' type='file' accept='image/*' name='image' />
</div>
<div class='col-md-6'>
<input class='form-control' type='file' accept='image/*' name='attach_file' />
</div>
<div class='col-md-6'>
<input type='url' class='form-control' id='facebook' name='facebook' placeholder='Facebook Url' required />
</div>
<div class='col-md-6'>
<input type='url' class='form-control' id='twitter' name='twitter' placeholder='Twitter Url' required />
</div>
<div class='col-md-6'>
<input type='url' class='form-control' id='instagram' name='instagram' placeholder='Instagram Url' required />
</div>
<div class='col-md-6'>
<input type='text' class='form-control' id='about' name='about' placeholder='About Yourself' required />
</div>
<div class='col-md-12' style='background-color: #fff; color: #000; margin-top: 50px;'>
<textarea rows="5" cols="50" name="amount" value="2500" readonly>Registration Charges.., INR 2500 This includes • Nomination for delhiites top 50 DJ's of the year • Promotional kit for social media.
</textarea>
</div>
<div class="col-md-12" style="color: #000">
<input type="checkbox" name="" required="">I agree to the T&C of Delhiits top 50 DJ's of the year. Privicy Policy
</div>
</div>
<div class='col-md-12'>
<input type='submit' value="Proceed to Payment" onclick="launchBOLT(); return false;" />
</div>
</form>
<?php
if( $_SERVER['REQUEST_METHOD']=='POST' ){
/* were there any errors? display them perhaps... */
if( !empty( $errors ) ) printf( '<pre>%s</pre>', print_r( $errors, true ) );
}
?>
<script type="text/javascript"><!--
$('#payment_form').bind('keyup blur', function(){
$.ajax({
url: 'index.php',
type: 'post',
data: JSON.stringify({
key: $('#key').val(),
salt: $('#salt').val(),
txnid: $('#txnid').val(),
amount: $('#amount').val(),
name: $('#name').val(),
email: $('#email').val(),
mobile: $('#mobile').val(),
udf5: $('#udf5').val()
}),
contentType: "application/json",
dataType: 'json',
success: function(json) {
if (json['error']) {
$('#alertinfo').html('<i class="fa fa-info-circle"></i>'+json['error']);
}
else if (json['success']) {
$('#hash').val(json['success']);
}
}
});
});
//-->
</script>
<script type="text/javascript"><!--
function launchBOLT()
{
bolt.launch({
key: $('#key').val(),
txnid: $('#txnid').val(),
hash: $('#hash').val(),
amount: $('#amount').val(),
name: $('#name').val(),
email: $('#email').val(),
phone: $('#mobile').val(),
udf5: $('#udf5').val(),
surl : $('#surl').val(),
furl: $('#surl').val(),
mode: 'dropout'
},{ responseHandler: function(BOLT){
console.log( BOLT.response.txnStatus );
if(BOLT.response.txnStatus != 'CANCEL')
{
//Salt is passd here for demo purpose only. For practical use keep salt at server side only.
var fr = '<form action=\"'+$('#surl').val()+'\" method=\"post\">' +
'<input type=\"hidden\" name=\"key\" value=\"'+BOLT.response.key+'\" />' +
'<input type=\"hidden\" name=\"salt\" value=\"'+$('#salt').val()+'\" />' +
'<input type=\"hidden\" name=\"txnid\" value=\"'+BOLT.response.txnid+'\" />' +
'<input type=\"hidden\" name=\"amount\" value=\"'+BOLT.response.amount+'\" />' +
'<input type=\"hidden\" name=\"name\" value=\"'+BOLT.response.name+'\" />' +
'<input type=\"hidden\" name=\"email\" value=\"'+BOLT.response.email+'\" />' +
'<input type=\"hidden\" name=\"udf5\" value=\"'+BOLT.response.udf5+'\" />' +
'<input type=\"hidden\" name=\"mihpayid\" value=\"'+BOLT.response.mihpayid+'\" />' +
'<input type=\"hidden\" name=\"status\" value=\"'+BOLT.response.status+'\" />' +
'<input type=\"hidden\" name=\"hash\" value=\"'+BOLT.response.hash+'\" />' +
'</form>';
var form = jQuery(fr);
jQuery('body').append(form);
form.submit();
}
},
catchException: function(BOLT){
alert( BOLT.message );
}
});
}
//--
</script>
</body>
</html>
response.php
<?php
$postdata = $_POST;
$msg = '';
if (isset($postdata ['key'])) {
$key = $postdata['key'];
$salt = $postdata['salt'];
$txnid = $postdata['txnid'];
$amount = $postdata['amount'];
$name = $postdata['name'];
$email = $postdata['email'];
$udf5 = $postdata['udf5'];
$mihpayid = $postdata['mihpayid'];
$status = $postdata['status'];
$resphash = $postdata['hash'];
//Calculate response hash to verify
$keyString = $key.'|'.$txnid.'|'.$amount.'|'.$name.'|'.$email.'|||||'.$udf5.'|||||';
$keyArray = explode("|",$keyString);
$reverseKeyArray = array_reverse($keyArray);
$reverseKeyString = implode("|",$reverseKeyArray);
$CalcHashString = strtolower(hash('sha512', $salt.'|'.$status.'|'.$reverseKeyString));
if ($status == 'success' && $resphash == $CalcHashString) {
$msg = "Transaction Successful and Hash Verified...";
//Do success order processing here...
}
else {
//tampered or failed
$msg = "Payment failed for Hasn not verified...";
}
}
else exit(0);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</head>
<style type="text/css">
.main {
margin-left:30px;
font-family:Verdana, Geneva, sans-serif, serif;
}
.text {
float:left;
width:180px;
}
.dv {
margin-bottom:5px;
}
</style>
<body>
<div class="main">
<div>
<img src="images/payumoney.png" />
</div>
<div>
<h3>PHP7 BOLT Kit Response</h3>
</div>
<div class="dv">
<span class="text"><label>Merchant Key:</label></span>
<span><?php echo $key; ?></span>
</div>
<div class="dv">
<span class="text"><label>Merchant Salt:</label></span>
<span><?php echo $salt; ?></span>
</div>
<div class="dv">
<span class="text"><label>Transaction/Order ID:</label></span>
<span><?php echo $txnid; ?></span>
</div>
<div class="dv">
<span class="text"><label>Amount:</label></span>
<span><?php echo $amount; ?></span>
</div>
<div class="dv">
<span class="text"><label>First Name:</label></span>
<span><?php echo $name; ?></span>
</div>
<div class="dv">
<span class="text"><label>Email ID:</label></span>
<span><?php echo $email; ?></span>
</div>
<div class="dv">
<span class="text"><label>Mihpayid:</label></span>
<span><?php echo $mihpayid; ?></span>
</div>
<div class="dv">
<span class="text"><label>Hash:</label></span>
<span><?php echo $resphash; ?></span>
</div>
<div class="dv">
<span class="text"><label>Transaction Status:</label></span>
<span><?php echo $status; ?></span>
</div>
<div class="dv">
<span class="text"><label>Message:</label></span>
<span><?php echo $msg; ?></span>
</div>
</div>
</body>
</html>
Without the integration, the data is being stored in the database MySQL but after the integration of the payment gateway it's just blank didn't pop up the payment thing.
How my code should work, once the payment is successful data is being stored in the database.
MySQL
create table `registration` (
`id` int(10) unsigned not null auto_increment,
`name` varchar(25) not null,
`gender` varchar(10) not null,
`mobile` varchar(50) not null,
`email` varchar(50) not null,
`address` varchar(100) not null,
`performing` varchar(20) not null,
`dj` bit(1) null default null,
`vj` bit(1) null default null,
`producer` bit(1) null default null,
`bollywood` bit(1) null default null,
`techno` bit(1) null default null,
`trap` bit(1) null default null,
`trance` bit(1) null default null,
`bigroom` bit(1) null default null,
`hiphop` bit(1) null default null,
`housemusic` bit(1) null default null,
`dubstep` bit(1) null default null,
`retro` bit(1) null default null,
`psytrance` bit(1) null default null,
`turntabulist` bit(1) null default null,
`other` bit(1) null default null,
`image` varchar(128) not null,
`attach_file` varchar(128) not null,
`facebook` varchar(100) not null,
`twitter` varchar(100) not null,
`instagram` varchar(100) not null,
`about` varchar(500) not null,
`amount` varchar(20) not null,
primary key (`id`)
)
collate='utf8_general_ci'
engine=innodb;
Humble request if anyone can help me with this.
Thank you so much.
This is what I got from PayUmoney and response.php
<?php
if(strcasecmp($_SERVER['REQUEST_METHOD'], 'POST') == 0){
//Request hash
$contentType = isset($_SERVER["CONTENT_TYPE"]) ? trim($_SERVER["CONTENT_TYPE"]) : '';
if(strcasecmp($contentType, 'application/json') == 0){
$data = json_decode(file_get_contents('php://input'));
$hash=hash('sha512', $data->key.'|'.$data->txnid.'|'.$data->amount.'|'.$data->pinfo.'|'.$data->fname.'|'.$data->email.'|||||'.$data->udf5.'||||||'.$data->salt);
$json=array();
$json['success'] = $hash;
echo json_encode($json);
}
exit(0);
}
function getCallbackUrl()
{
$protocol = ((!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != 'off') || $_SERVER['SERVER_PORT'] == 443) ? "https://" : "http://";
return $protocol . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'] . 'response.php';
}
?>
<!DOCTYPE html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.0/jquery.min.js"></script>
<!-- BOLT Sandbox/test //-->
<script id="bolt" src="https://sboxcheckout-static.citruspay.com/bolt/run/bolt.min.js" bolt-
color="e34524" bolt-logo="http://boltiswatching.com/wp-content/uploads/2015/09/Bolt-Logo-e14421724859591.png"></script>
</head>
<style type="text/css">
.main {
margin-left:30px;
font-family:Verdana, Geneva, sans-serif, serif;
}
.text {
float:left;
width:180px;
}
.dv {
margin-bottom:5px;
}
</style>
<body>
<div class="main">
<div>
<img src="images/payumoney.png" />
</div>
<div>
<h3>PHP7 BOLT Kit</h3>
</div>
<form action="#" id="payment_form">
<input type="hidden" id="udf5" name="udf5" value="BOLT_KIT_PHP7" />
<input type="hidden" id="surl" name="surl" value="<?php echo getCallbackUrl(); ?>" />
<input type="hidden" id="key" name="key" value="hOxjEeU3" />
<input type="hidden" id="salt" name="salt" value="05TBBdE1ZG" />
<div class="dv">
<span class="text"><label>Transaction/Order ID:</label></span>
<span><input type="text" id="txnid" name="txnid" placeholder="Transaction ID" value="<?php echo "Txn" . rand(10000,99999999)?>" /></span>
</div>
<div class="dv">
<span class="text"><label>Amount:</label></span>
<span><input type="text" id="amount" name="amount" placeholder="Amount" value="6.00" /></span>
</div>
<div class="dv">
<span class="text"><label>Product Info:</label></span>
<span><input type="text" id="pinfo" name="pinfo" placeholder="Product Info" value="P01,P02" /></span>
</div>
<div class="dv">
<span class="text"><label>First Name:</label></span>
<span><input type="text" id="fname" name="fname" placeholder="First Name" value="" /></span>
</div>
<div class="dv">
<span class="text"><label>Email ID:</label></span>
<span><input type="text" id="email" name="email" placeholder="Email ID" value="" /></span>
</div>
<div class="dv">
<span class="text"><label>Mobile/Cell Number:</label></span>
<span><input type="text" id="mobile" name="mobile" placeholder="Mobile/Cell Number" value="" /></span>
</div>
<div class="dv">
<span class="text"><label>Hash:</label></span>
<span><input type="text" id="hash" name="hash" placeholder="Hash" value="" /></span>
</div>
<div><input type="submit" value="Pay" onclick="launchBOLT(); return false;" /></div>
</form>
</div>
<script type="text/javascript"><!--
$('#payment_form').bind('keyup blur', function(){
$.ajax({
url: 'index.php',
type: 'post',
data: JSON.stringify({
key: $('#key').val(),
salt: $('#salt').val(),
txnid: $('#txnid').val(),
amount: $('#amount').val(),
pinfo: $('#pinfo').val(),
fname: $('#fname').val(),
email: $('#email').val(),
mobile: $('#mobile').val(),
udf5: $('#udf5').val()
}),
contentType: "application/json",
dataType: 'json',
success: function(json) {
if (json['error']) {
$('#alertinfo').html('<i class="fa fa-info-circle"></i>'+json['error']);
}
else if (json['success']) {
$('#hash').val(json['success']);
}
}
});
});
//-->
</script>
<script type="text/javascript"><!--
function launchBOLT()
{
bolt.launch({
key: $('#key').val(),
txnid: $('#txnid').val(),
hash: $('#hash').val(),
amount: $('#amount').val(),
firstname: $('#fname').val(),
email: $('#email').val(),
phone: $('#mobile').val(),
productinfo: $('#pinfo').val(),
udf5: $('#udf5').val(),
surl : $('#surl').val(),
furl: $('#surl').val(),
mode: 'dropout'
},{ responseHandler: function(BOLT){
console.log( BOLT.response.txnStatus );
if(BOLT.response.txnStatus != 'CANCEL')
{
//Salt is passd here for demo purpose only. For practical use keep salt at server side only.
var fr = '<form action=\"'+$('#surl').val()+'\" method=\"post\">' +
'<input type=\"hidden\" name=\"key\" value=\"'+BOLT.response.key+'\" />' +
'<input type=\"hidden\" name=\"salt\" value=\"'+$('#salt').val()+'\" />' +
'<input type=\"hidden\" name=\"txnid\" value=\"'+BOLT.response.txnid+'\" />' +
'<input type=\"hidden\" name=\"amount\" value=\"'+BOLT.response.amount+'\" />' +
'<input type=\"hidden\" name=\"productinfo\" value=\"'+BOLT.response.productinfo+'\" />' +
'<input type=\"hidden\" name=\"firstname\" value=\"'+BOLT.response.firstname+'\" />' +
'<input type=\"hidden\" name=\"email\" value=\"'+BOLT.response.email+'\" />' +
'<input type=\"hidden\" name=\"udf5\" value=\"'+BOLT.response.udf5+'\" />' +
'<input type=\"hidden\" name=\"mihpayid\" value=\"'+BOLT.response.mihpayid+'\" />' +
'<input type=\"hidden\" name=\"status\" value=\"'+BOLT.response.status+'\" />' +
'<input type=\"hidden\" name=\"hash\" value=\"'+BOLT.response.hash+'\" />' +
'</form>';
var form = jQuery(fr);
jQuery('body').append(form);
form.submit();
}
},
catchException: function(BOLT){
alert( BOLT.message );
}
});
}
//--
</script>
</body>
</html>
回答1:
There is a lot going on here and I'm not sure of the programme flow here, but some points of interest perhaps:
You call $('#payment_form').bind(...
~ where is payment_form
?
Similarly you call $('#alertinfo')
where is alertinfo
??
Within the logic for processing the POST array there is a portion of code to generate the hash but you have an exit
after this so program execution will always stop at that point which is NOT what I think you intend - so perhaps more like:
//Request hash
$contentType = isset( $_SERVER["CONTENT_TYPE"] ) ? trim( $_SERVER["CONTENT_TYPE"] ) : '';
if( strcasecmp( $contentType, 'application/json') == 0 ){
$data = json_decode( file_get_contents( 'php://input' ) );
if( !$data )exit('ERROR');
$hash=hash( 'sha512', $data->key.'|'.$data->txnid.'|'.$data->amount.'|'.$data->name.'|'.$data->email.'|||||'.$data->udf5.'||||||'.$data->salt );
$json=array(
'success' => $hash
);
exit( json_encode( $json ) ); //exit here within the `IF` statement rather than after...
}
The new fields you have in your HTML form do not appear in the $args array used to FILTER
the POST array, they should. So these fields:
<input type="hidden" id="udf5" name="udf5" value="BOLT_KIT_PHP7" />
<input type="hidden" id="surl" name="surl" value="<?php echo getCallbackUrl(); ?>" />
<input type="hidden" id="key" name="key" value="hOxjEeU3" />
<input type="hidden" id="salt" name="salt" value="05TBBdE1ZG" />
<input type="hidden" id="hash" name="hash" placeholder="Hash" value="" />
The names probably ought to be included in the $args array... so:
$required=array(
'name' => FILTER_SANITIZE_STRING,
'gender' => FILTER_SANITIZE_STRING,
'mobile' => FILTER_SANITIZE_STRING,
'email' => FILTER_SANITIZE_STRING,
'address' => FILTER_SANITIZE_STRING,
'performing' => FILTER_SANITIZE_STRING,
'facebook' => FILTER_SANITIZE_STRING,
'twitter' => FILTER_SANITIZE_STRING,
'instagram' => FILTER_SANITIZE_STRING,
'about' => FILTER_SANITIZE_STRING,
'amount' => FILTER_SANITIZE_STRING,
/* new fields */
'udf5' => FILTER_SANITIZE_STRING,
'surl' => FILTER_SANITIZE_STRING,
'key' => FILTER_SANITIZE_STRING,
'salt' => FILTER_SANITIZE_STRING,
'hash' => FILTER_SANITIZE_STRING
);
I will not profess to understand what the javascript is really doing at this stage so the issue might lie there I don't know.
One thing would be to look at the PHP error log and see if there are obvious things there. Have you enabled error_reporting( E_ALL )
etc?
Perhaps the above might help in some way - hope so. Good luck
来源:https://stackoverflow.com/questions/58251190/first-time-integrating-payment-gateway-after-the-integration-of-payumoney-in-ph