0

I am working on a Authorize.net form submit.

$api_login_id = $bookingSettingObj->getAuthorizeAPI();  // works
$transaction_key =  $bookingSettingObj->getAuthorizeTXN(); // works
$amount = /* What should i put here so i can echo the final price that is calculated by Javascript Function : addToAuthorizeForm(); ????? */ 

and the price calculation is done by javascript function addToAuthorizeForm. Please let me know what code should i add so the javascript funcrtion "addToAuthorizeForm" can echo succesfully..

UPDATE :

I am already using Ajax. Here is the javascript function i am using. I just need to know what code i put to execute this javascript function and echo final price..

    function addToAuthorizeForm() {
        $wbc('#slots_purchased').html('');
        var new_html = '';
        var i = 1;
        $wbc('#booking_slots').find('input').each(function() {


            if($wbc(this).attr('checked')) {
                var slot_id = $wbc(this).val();
                //ajax request to get data
                $wbc.ajax({
                  url: '<?php echo plugins_url('my_plugin/public');?>/ajax/getSlotInfo.php?slot_id='+$wbc(this).val(),
                  success: function(data) {

                      arrData=data.split("$");
                      if(arrData[1]>0) {
                          q = 1;
                          if($wbc('#seats_'+slot_id).val()!=undefined) {
                              q = $wbc('#seats_'+slot_id).val();
                          }
                          new_html += '<input type="hidden" name="item_name_'+i+'" value="'+arrData[0]+'" /><input type="hidden" name="amount_'+i+'" value="'+arrData[1]+'" /><input type="hidden" name="quantity_'+i+'" value="'+q+'" />';
                          $wbc('#slots_purchased').html(new_html);
                         i++;
                      }
                  }
                });

            }

        });

    }
Arpit
  • 51
  • 1
  • 6

1 Answers1

0

You can't call JS function in side the server side PHP code.

Try to implement the same logic in PHP side and call that function

<?php 
function addToAuthorizeForm () {
.
.
Add the Same logic that you have put in the JS function
.
.
}

$amount = addToAuthorizeForm();
?>

Pass required parameters in to the function and get the out put encapsulating the logic.

Harsha
  • 818
  • 11
  • 10