I have to parse this jQuery output <span id="chargetotal" class="chargetotal">Amount</strong></span>
to a PSP shopping card page.
From this page i try to parse the 'Total amount' (Quantity * Value), and the rest of the form variables to the PSP shopping card page (https://test.ipg-online.com/connect/gateway/processing
).
On the voucher page i include ipg-util.php
which look like this:
<?php
$dateTime = date("Y:m:d-H:i:s");
function getDateTime() {
global $dateTime;
return $dateTime;
}
function createHash($chargetotal, $currency) {
$storeId = "XXX storeId XXX";
$sharedSecret = "XXX sharedSecret XXX";
$stringToHash = $storeId . getDateTime() . $chargetotal .
$currency . $sharedSecret;
$ascii = bin2hex($stringToHash);
return sha1($ascii);
}
?>
In this instruction i setup 3.3 PHP Example
The form look like this:
<form method="post" action="https://test.ipgonline.com/connect/gateway/processing">
<input type="hidden" name="txntype" value="sale">
<input type="hidden" name="timezone" value="GMT"/>
<input type="hidden" name="txndatetime" value="<?php echo getDateTime() ?>"/>
<input type="hidden" name="hash" value="<?php echo createHash( "13.00","978" ) ?>"/>
<input type="hidden" name="storename" value="XXX My store id XXX"/>
<input type="hidden" name="mode" value="fullpay"/>
<input type="text" name="chargetotal" value="13.00"/>
<input type="hidden" name="currency" value="978"/>
<input type="hidden" name="responseSuccessURL" value="http://www.abbeyglen.ie/abbeyglen-castle-hotel/voucher-succes.html"/>
<input type="hidden" name="responseFailURL" value="http://www.abbeyglen.ie/abbeyglen-castle-hotel/voucher-failure.html"/>
<input type="submit" value="Submit">
</form>
My problem is that in the above form example they use a strict value of 13.00 for <input type="text" name="chargetotal" value="13.00"/>
to create the hash 'form variable'.
But in my case chargetotal
is the 'Total amount' of the jQuery function in this HTML <span id="chargetotal" class="chargetotal">Amount</strong></span>
.
See below, the jQuery script to get the 'Total amount'.
<script type="text/javascript">
$(document).ready(function(){
update_amounts();
$('.qty').change(function() {
update_amounts();
});
});
function update_amounts()
{
var chargetotal = 0;
var sum = 0.0;
$(function () {
var qty = $(this).find('.qty').val();
var price = $(this).find('.price').val();
var chargetotal = (qty*price)
sum+=chargetotal;
$(this).find('.chargetotal').text(''+chargetotal);
});
}
</script>
How do i translate the jQuery 'Total amount' to a <input type="text" name="chargetotal">
?
Thanks!