Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- // Merchant key here as provided by Payu
- $MERCHANT_KEY = "T3TppB4T";
- // Merchant Salt as provided by Payu
- $SALT = "CLtIKOCX0Y";
- // End point - change to https://secure.payu.in for LIVE mode
- $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';
- }
- ?>
- <html>
- <head>
- <script>
- var hash = '<?php echo $hash ?>';
- function submitPayuForm() {
- if (hash == '') {
- return;
- }
- var payuForm = document.forms.payuForm;
- payuForm.submit();
- }
- </script>
- </head>
- <body onload="submitPayuForm()">
- <div class="wrapper">
- <div class="container">
- <h2>Green Line Travels Form</h2>
- <br/>
- <?php if ($formError) { ?>
- <?php } ?>
- <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 ?>" />
- <?php
- $form_all_data = $data1[0];
- $form_all_data->price;
- ?>
- <div class="greenlineform">
- <div class="col-sm-8 greenlineforms" id="bgcolor">
- <div class="row">
- <!--start-->
- <div class="col-sm-6">
- <div class=" form-group">
- <label>Amount : <span>*</span></label>
- <br>
- <input name="amount" class="form-control" value="<?php echo $form_all_data->price; ?>" />
- </div>
- code by my side:
- <div class="col-sm-6">
- <div class=" form-group">
- <label>First Name : <span>*</span> </label>
- <br>
- <input name="firstname" class="form-control" id="firstname" value="<?php echo (empty($posted['firstname'])) ? '' : $posted['firstname']; ?>" required />
- </div>
- </div>
- </div>
- <div class="row">
- <div class="col-sm-6">
- <div class=" form-group">
- <label>Email : <span>*</span> </label>
- <br>
- <input name="email" class="form-control" id="email" value="<?php echo (empty($posted['email'])) ? '' : $posted['email']; ?>" required />
- </div>
- </div>
- <div class="col-sm-6">
- <div class=" form-group">
- <label>Phone : <span>*</span></label>
- <br>
- <input name="phone" class="form-control" value="<?php echo (empty($posted['phone'])) ? '' : $posted['phone']; ?>" required />
- </div>
- </div>
- </div>
- <p colspan="3">
- <textarea name="productinfo" style="display: none;">Testing</textarea>
- </p>
- <!--td>Success URI: </td-->
- <p colspan="3">
- <input name="surl" type="hidden" value="<?php echo site_url('Welcome/Success'); ?>" size="64" />
- </p>
- <!--td>Failure URI: </td-->
- <p colspan="3">
- <input name="furl" type="hidden" value="<?php echo site_url('Welcome/Failure'); ?>" size="64" />
- </p>
- <p colspan="3">
- <input type="hidden" name="service_provider" value="payu_paisa" size="64" />
- </p>
- <div class="row">
- <div class="col-sm-6">
- <div class=" form-group">
- <label>Address1: </label>
- <br>
- <input name="address1" class="form-control" value="<?php echo (empty($posted['address1'])) ? '' : $posted['address1']; ?>" required />
- </div>
- </div>
- <div class="col-sm-6">
- <div class=" form-group">
- <label>Address2:</label>
- <br>
- <input name="address2" class="form-control" value="<?php echo (empty($posted['address2'])) ? '' : $posted['address2']; ?>" required />
- </div>
- </div>
- </div>
- <div class="row">
- <div class="col-sm-6">
- <div class=" form-group">
- <label>City : </label>
- <br>
- <input name="city" class="form-control" value="<?php echo (empty($posted['city'])) ? '' : $posted['city']; ?>" required />
- </div>
- </div>
- <div class="col-sm-6">
- <div class=" form-group">
- <label>State: </label>
- <br>
- <input name="state" class="form-control" value="<?php echo (empty($posted['state'])) ? '' : $posted['state']; ?>" required />
- </div>
- </div>
- </div>
- <div class="row">
- <div class="col-sm-6">
- <div class=" form-group">
- <label>Country : </label>
- <br>
- <input name="country" class="form-control" value="<?php echo (empty($posted['country'])) ? '' : $posted['country']; ?>" required/>
- </div>
- </div>
- <div class="col-sm-6">
- <div class=" form-group">
- <label>Zipcode: </label>
- <br>
- <td>
- <input name="zipcode" class="form-control" value="<?php echo (empty($posted['zipcode'])) ? '' : $posted['zipcode']; ?>" required />
- </div>
- </div>
- </div>
- <!--td>UDF1: </td-->
- <p>
- <input name="udf1" type="hidden" value="<?php echo (empty($posted['udf1'])) ? '' : $posted['udf1']; ?>" />
- </p>
- <!--td>UDF2: </td-->
- <p>
- <input name="udf2" type="hidden" value="<?php echo (empty($posted['udf2'])) ? '' : $posted['udf2']; ?>" />
- </p>
- <!--td>UDF3: </td-->
- <p>
- <input name="udf3" type="hidden" value="<?php echo (empty($posted['udf3'])) ? '' : $posted['udf3']; ?>" />
- </p>
- <!--td>UDF4: </td-->
- <p>
- <input name="udf4" type="hidden" value="<?php echo (empty($posted['udf4'])) ? '' : $posted['udf4']; ?>" />
- </p>
- <!--td>UDF5: </td-->
- <p>
- <input name="udf5" type="hidden" value="<?php echo (empty($posted['udf5'])) ? '' : $posted['udf5']; ?>" />
- </p>
- <!--td>PG: </td-->
- <p>
- <input name="pg" type="hidden" value="<?php echo (empty($posted['pg'])) ? '' : $posted['pg']; ?>" />
- </p>
- <?php if (!$hash) { ?>
- <td colspan="4"><input type="submit" class="btn green-btn" value="Submit" /></td>
- <?php } ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement