Paypal in firefox using PHP

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • munnaj
    New Member
    • Jul 2007
    • 6

    #1

    Paypal in firefox using PHP

    I have used the following code for submitting the values to paypal. but it is not working for firefox. Please give me a suggestion.
    [code=php]
    // implied -- pbmods
    echo '
    <script language="javas cript">

    document.write( "<form name=\"main_for m1\" method=\"post\" action=\"'.PAYP AL_URL.'\">");

    document.write( "<input type=\"hidden\" name=\"cmd\" value=\"_cart\" >");

    document.write( "<input type=\"hidden\" name=\"upload\" value=\"1\">");

    document.write( "<input type=\"hidden\" name=\"business \" value=\"'.$payp al_id.'\">");
    document.write( "<input type=\"hidden\" name=\"no_shipp ing\" value=\"1\">");
    document.write( "<input type=\"hidden\" name=\"currency _code\" value=\"USD\">" );


    document.write( "<input type=\"hidden\" name=\"return\" value=\"'.NOTIF Y_URL_SHOPPING. '\">");

    document.write( "<input type=\"hidden\" name=\"rm\" value=\"2\">");

    document.write( "<input type=\"hidden\" name=\"payer_id \" value=\"'.$paye r_session.'\">" );

    document.write( "<input type=\"hidden\" name=\"first_na me\" value=\"'.$sfir stName.'\">");
    document.write( "<input type=\"hidden\" name=\"last_nam e\" value=\"'.$slas tName.'\">");
    document.write( "<input type=\"hidden\" name=\"address1 \" value=\"'.$sstr eet.'\">");
    document.write( "<input type=\"hidden\" name=\"city\" value=\"'.$scit y.'\">");';

    if($scountry == "1")
    { $state_for_payp al = trim($state_for _paypal);
    $paypal_content .='document.wri te("<input type=\"hidden\" name=\"state\" value=\"'.$stat e_for_paypal.'\ ">");
    document.write( "<input type=\"hidden\" name=\"country\ " value=\"US\">") ;';
    }
    else
    {
    $sprovince = trim($sprovince );
    $paypal_content .='document.wri te("<input type=\"hidden\" name=\"state\" value=\"'.$spro vince.'\">");
    document.write( "<input type=\"hidden\" name=\"country\ " value=\"CA\">") ;';
    }
    $paypal_content .='
    document.write( "<input type=\"hidden\" name=\"zip\" value=\"'.$zipc ode.'\">");
    document.write( "<input type=\"hidden\" name=\"mobile\" value=\"'.$mobi le.'\">");
    document.write( "<input type=\"hidden\" name=\"email\" value=\"'.$emai l.'\">");';


    $sno=1;
    $shipping_cost= 0;
    $totamt=0;

    $select_sales_d etails = "Select S.Product_id, S.Price, S.Quantity, S.Shipping_cost , P.Product_name, P.Item_No from ".TEMP_SALE S." as S, ".PRODUCTS. " as P Where S.Order_no='$or der_no' and S.Product_id=P. Product_id";
    $result_sales_d etails = mysql_query($se lect_sales_deta ils,$dbconnecti on1);
    while(list($Pro duct_id,$Price, $Quantity,$Ship ping_cost,$Prod uct_name,$Item_ No)=mysql_fetch _array($result_ sales_details))
    {
    $paypal_content .='
    document.write( "<input type=\"hidden\" name=\"item_nam e_'.$sno.'\" value=\"'.$Prod uct_name.'\">") ;
    document.write( "<input type=\"hidden\" name=\"item_num ber_'.$sno.'\" value=\"'.$Item _No.'\">");
    document.write( "<input type=\"hidden\" name=\"amount_' .$sno.'\" value=\"'.$Pric e.'\">");
    document.write( "<input type=\"hidden\" name=\"quantity _'.$sno.'\" value=\"'.$Quan tity.'\">");
    document.write( "<input type=\"hidden\" name=\"shipping _'.$sno.'\" value=\"'.$Ship ping_cost.'\">" );';

    $sno++;
    $totamt +=($Price*$Quan tity);
    $shipping_cost += $Shipping_cost;
    }

    $ord_tot = $totamt;
    $tax = ($ord_tot*$sale s_tax)/100;
    $ord_tot = $ord_tot+$tax+$ shipping_cost;
    $tax=number_for mat($tax,2,'.', '');
    $shipping_cost= number_format($ shipping_cost,2 ,'.','');
    $ord_tot=number _format($ord_to t,2,'.','');

    $paypal_content .=
    '
    document.write( "<input type=\"hidden\" name=\"shipping \" value=\"'.$ship ping_cost.'\">" );
    document.write( "<input type=\"hidden\" name=\"tax_cart \" value=\"'.$tax. '\">");
    document.write( "<input type=\"hidden\" name=\"tot_amt\ " value=\"'.$ord_ tot.'\">");
    document.write( "<input type=\"hidden\" name=\"custom\" value=\"'.$paye r_session.'~~~' .$memberid.'~~~ '.$first_name.' ~~~'.$last_name .'~~~'.$email.' ~~~'.$username. '~~~'.$time.'~~ ~'.$order_no.'~ ~~'.$store_id.' ~~~'.$tax.'\">" );
    document.write( "<input type=\"hidden\" name=\"night_ph one_a\" value=\"'.$phon e1.'\">");
    document.write( "<input type=\"hidden\" name=\"night_ph one_b\" value=\"'.$phon e2.'\">");
    document.write( "<input type=\"hidden\" name=\"night_ph one_c\" value=\"'.$phon e3.'\">");
    document.write( "</form>");


    document.main_f orm1.action="'. PAYPAL_URL.'";
    document.main_f orm1.submit();

    </script>';
    echo $paypal_content ;[/code]

    [Please use CODE tags when posting source code. Thanks! --pbmods]
  • pbmods
    Recognized Expert Expert
    • Apr 2007
    • 5821

    #2
    Heya, munnaj. Welcome to TSDN!

    If it's working in one browser but not another, then the problem is in the Javascript.

    What JavaScript errors is your code generating?

    Comment

    • drhowarddrfine
      Recognized Expert Expert
      • Sep 2006
      • 7434

      #3
      Let's start with the only thing I can probably help with. This is invalid:
      <script language="javas cript">

      Replace it with this:
      <script type="text/javascript">

      Comment

      • Motoma
        Recognized Expert Specialist
        • Jan 2007
        • 3236

        #4
        First suggestion: stop using javascript to dynamically build your page. That is what PHP is there for.

        Comment

        • munnaj
          New Member
          • Jul 2007
          • 6

          #5
          Originally posted by pbmods
          Heya, munnaj. Welcome to TSDN!

          If it's working in one browser but not another, then the problem is in the Javascript.

          What JavaScript errors is your code generating?
          hai,

          Thanks for your reply. This is the error am getting from the Error console on firefox
          Error: document.main_f orm1 has no properties
          Source File: http://ang.gwg.com/scripts/topaypal_shoppi ng_cart.php?mod e=guest&id=36&s essionid=130fc8 97de7f37ccc1abf 9172894f2c7&sto re_id=0&order_n o=a9233&sales_t ax=10.00
          Line: 45

          Comment

          • pbmods
            Recognized Expert Expert
            • Apr 2007
            • 5821

            #6
            Heya, munnaj.

            Yeah. You're going to want to completely rewrite your PHP so that you're outputting HTML instead of JavaScript, as Motoma suggested.

            Comment

            • munnaj
              New Member
              • Jul 2007
              • 6

              #7
              Originally posted by pbmods
              Heya, munnaj.

              Yeah. You're going to want to completely rewrite your PHP so that you're outputting HTML instead of JavaScript, as Motoma suggested.

              Thank You all....

              I juz included a form with submit option using PHP and it is working fine.
              Thanks for your suggestions

              Comment

              • pbmods
                Recognized Expert Expert
                • Apr 2007
                • 5821

                #8
                Heya, munnaj.

                Glad to hear you got it working! Good luck with your project, and if you ever need anything, post back anytime :)

                Comment

                Working...