0

I have an ASP.Net code that processes cart order information and has the billed amount there to be processed. I need to pass the billed amount to a javascript function in order to pass that to MasterCard integration. It works well with a fixed amount, but I need the dynamic amount to be passed now.

Here is the code of the billed amount section:

if(data['ErrorCode'] == '000'){

  $('#divMsg').html('Voucher Code Applied Successfully..!');
  $('#divMsg').show('slide').fadeOut(8000);

  $('#<%= divDisplayDiscount.ClientID %>').show();
  $('#<%= divDiscount.ClientID %>').text(data['Discount']);

  $('#<%= divDisplaySubAmount.ClientID %>').show();
  $('#<%= divSubAmount.ClientID %>').text(addCommas(data['SubAmount']));

  $('#<%= divBillAmount.ClientID %>').text(addCommas(data['BillAmount']));
  $('#<%= divCartAmounts.ClientID %>').text(addCommas(data['BillAmount']));

  $('#<%= txtCouponCode.ClientID %>').text(data['CouponCode']);

  $('#<%= divDiscountPerc.ClientID %>').text(addCommas(data['DiscountPercentage']));

  $('#<%= txtCouponCode.ClientID %>').attr('disabled','disabled');

  $('#<%= btnChangeCode.ClientID %>').show();
  $('#<%= btnApplyCode.ClientID %>').hide();

and here is the javascript part to pass the value, I set it to 70 to test it initially:

Checkout.configure({
  merchant: 'xxxxxx',
  order: {
    amount: function() {
      //Dynamic calculation of amount
      return 70;
    },
  • How exactly is the billed amount being processed? When processing is done, is the page reloaded completely or partially? You may want to look into [how to register a client script](https://stackoverflow.com/questions/666519/difference-between-registerstartupscript-and-registerclientscriptblock) – Lennart Stoop Jun 11 '18 at 09:28
  • The billed amount is being passed through a payment button to mastercard payment gateway. So simply it should take the value that appears on the "divBillAmount", convert it to number and then the javascript part "where it returns 70" is supposed to pass this value to the url. – Bessa14915 Jun 11 '18 at 10:01
  • When it is a fixed number everything goes smoothly, but my struggle is in retrieving the div amount and dealing with the value. it has to be a number. – Bessa14915 Jun 11 '18 at 10:01
  • I tried parseInt, and document.getElementById("divBillAmount").text, but it didnt work. – Bessa14915 Jun 11 '18 at 10:02
  • But is at any point the calculation done server-side? In the code snippet you posted the billed amount is retrieved as `data['BillAmount']` : why can't you use this value? – Lennart Stoop Jun 11 '18 at 11:25
  • So should it be like: Checkout.configure({ merchant: 'xxxxxx', order: { amount: function() { //Dynamic calculation of amount var total=data['BillAmount']; return total; }, – Bessa14915 Jun 11 '18 at 12:35
  • I tried using the data['BillAmount'] return, but it stopped the redirect process fully! – Bessa14915 Jun 11 '18 at 22:18
  • and to answer your first question: when processing the amount, or clicking on the integration button, the page loads the integration new page in order to have the credit card payment information processed. – Bessa14915 Jun 11 '18 at 22:31

0 Answers0