title: 'paypal' is not defined in PHP
body: <p>I have codes in ajax which calls php file to show the paypal sdk button in that page :</p>
  <pre class="lang-js prettyprint-override"><code>function redirectPaypal() {
      $('#tabs2').html('&lt;img src=&quot;' + webroot + 'facebox/loading.gif&quot;&gt;');
      callAjax(webroot + 'TESTS.php', 'mode=paypall', function (t) {
          //  $.facebox(t);
          $('#walletBg').removeClass('addBgColor');
          $('#paypalBg').addClass('addBgColor');
          $('#neverBg').removeClass('addBgColor');
          $('#authBg').removeClass('addBgColor');
          // $('#paymentInfo').show();     
          $('#tabs2').html(t);
      });
  }
  </code></pre>
  <p>As you see it calls TESTS.php file with the mode value <code>paypal</code>. The TESTS.php file is looks like below :</p>
  <pre class="lang-php-template prettyprint-override"><code>&lt;? 
  require_once 'application-top.php';
  require_once 'includes/navigation-functions.php';
  require_once 'includes/site-functions-extended.php';
  require_once 'includes/buy-deal-functions.php';
  // ini_set('display_errors', 1);
  // ini_set('display_startup_errors', 1);
  // error_reporting(E_ALL);
  $post = getPostedData();
  print_r($post);
  if ($_POST['mode'] == 'paypall')
  { 
      ?&gt;
  &lt;!DOCTYPE html&gt;
  &lt;html lang=&quot;en&quot;&gt;
  &lt;head&gt;
      &lt;!-- Add meta tags for mobile and IE --&gt;
      &lt;meta name=&quot;viewport&quot; content=&quot;width=device-width, initial-scale=1&quot;&gt;
      &lt;meta http-equiv=&quot;X-UA-Compatible&quot; content=&quot;IE=edge&quot; /&gt;
      &lt;title&gt; PayPal Checkout Integration | Client Demo &lt;/title&gt;
  &lt;/head&gt;
  &lt;body&gt;
      &lt;!-- Set up a container element for the button --&gt;
      &lt;div id=&quot;paypal-button-container&quot;&gt;&lt;/div&gt;
      &lt;!-- Include the PayPal JavaScript SDK --&gt;
      &lt;script src=&quot;https://www.paypal.com/sdk/js?client-id=test&amp;currency=USD&quot; data-namespace=&quot;paypal_sdk&quot;&gt;&lt;/script&gt;
      &lt;script&gt;
          // Render the PayPal button into #paypal-button-container
          paypal_sdk.Buttons({
              // Set up the transaction
              createOrder: function(data, actions) {
                  return actions.order.create({
                      purchase_units: [{
                          amount: {
                              value: '88.44'
                          }
                      }]
                  });
              },
              // Finalize the transaction
              onApprove: function(data, actions) {
                  return actions.order.capture().then(function(orderData) {
                      // Successful capture! For demo purposes:
                      console.log('Capture result', orderData, JSON.stringify(orderData, null, 2));
                      var transaction = orderData.purchase_units[0].payments.captures[0];
                      alert('Transaction '+ transaction.status + ': ' + transaction.id + '\n\nSee console for all available details');
  
                      // Replace the above to show a success message within this page, e.g.
                      // const element = document.getElementById('paypal-button-container');
                      // element.innerHTML = '';
                      // element.innerHTML = '&lt;h3&gt;Thank you for your payment!&lt;/h3&gt;';
                      // Or go to another URL:  actions.redirect('thank_you.html');
                  });
              }
          }).render('#paypal-button-container');
      &lt;/script&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  &lt;?
  } 
  ?&gt;
  </code></pre>
  <p>File is called successfully but as you see the code below I am getting the reference error when the page is called :</p>
  <pre><code>VM1597:3 
          
         Uncaught ReferenceError: paypal_sdk is not defined
      at eval (eval at &lt;anonymous&gt; (js.php?f=js%2Fjquery-1.7.2.min.js%2Cjs%2Fmodernizr.custom.02358.js%2Cfunctions.js.php%2Cjs%2Fsite-functions.js%2Cform-validation.js.php%2Cform-validation-lang.php%2Cjs%2Fjquery-ui.min.js%2Cfacebox%2Ffacebox.js%2Cjs%2Fmbsmessage.js&amp;min=1&amp;sid=1631542832:2:11369), &lt;anonymous&gt;:3:9)
      at eval (&lt;anonymous&gt;)
      at js.php?f=js%2Fjquery-1.7.2.min.js%2Cjs%2Fmodernizr.custom.02358.js%2Cfunctions.js.php%2Cjs%2Fsite-functions.js%2Cform-validation.js.php%2Cform-validation-lang.php%2Cjs%2Fjquery-ui.min.js%2Cfacebox%2Ffacebox.js%2Cjs%2Fmbsmessage.js&amp;min=1&amp;sid=1631542832:2:11369
      at Function.globalEval (js.php?f=js%2Fjquery-1.7.2.min.js%2Cjs%2Fmodernizr.custom.02358.js%2Cfunctions.js.php%2Cjs%2Fsite-functions.js%2Cform-validation.js.php%2Cform-validation-lang.php%2Cjs%2Fjquery-ui.min.js%2Cfacebox%2Ffacebox.js%2Cjs%2Fmbsmessage.js&amp;min=1&amp;sid=1631542832:2:11380)
      at HTMLScriptElement.&lt;anonymous&gt; (js.php?f=js%2Fjquery-1.7.2.min.js%2Cjs%2Fmodernizr.custom.02358.js%2Cfunctions.js.php%2Cjs%2Fsite-functions.js%2Cform-validation.js.php%2Cform-validation-lang.php%2Cjs%2Fjquery-ui.min.js%2Cfacebox%2Ffacebox.js%2Cjs%2Fmbsmessage.js&amp;min=1&amp;sid=1631542832:4:2538)
      at Function.each (js.php?f=js%2Fjquery-1.7.2.min.js%2Cjs%2Fmodernizr.custom.02358.js%2Cfunctions.js.php%2Cjs%2Fsite-functions.js%2Cform-validation.js.php%2Cform-validation-lang.php%2Cjs%2Fjquery-ui.min.js%2Cfacebox%2Ffacebox.js%2Cjs%2Fmbsmessage.js&amp;min=1&amp;sid=1631542832:2:11776)
      at init.domManip (js.php?f=js%2Fjquery-1.7.2.min.js%2Cjs%2Fmodernizr.custom.02358.js%2Cfunctions.js.php%2Cjs%2Fsite-functions.js%2Cform-validation.js.php%2Cform-validation-lang.php%2Cjs%2Fjquery-ui.min.js%2Cfacebox%2Ffacebox.js%2Cjs%2Fmbsmessage.js&amp;min=1&amp;sid=1631542832:4:2441)
      at init.append (js.php?f=js%2Fjquery-1.7.2.min.js%2Cjs%2Fmodernizr.custom.02358.js%2Cfunctions.js.php%2Cjs%2Fsite-functions.js%2Cform-validation.js.php%2Cform-validation-lang.php%2Cjs%2Fjquery-ui.min.js%2Cfacebox%2Ffacebox.js%2Cjs%2Fmbsmessage.js&amp;min=1&amp;sid=1631542832:3:32408)
      at init.&lt;anonymous&gt; (js.php?f=js%2Fjquery-1.7.2.min.js%2Cjs%2Fmodernizr.custom.02358.js%2Cfunctions.js.php%2Cjs%2Fsite-functions.js%2Cform-validation.js.php%2Cform-validation-lang.php%2Cjs%2Fjquery-ui.min.js%2Cfacebox%2Ffacebox.js%2Cjs%2Fmbsmessage.js&amp;min=1&amp;sid=1631542832:4:1283)
      at Function.access (js.php?f=js%2Fjquery-1.7.2.min.js%2Cjs%2Fmodernizr.custom.02358.js%2Cfunctions.js.php%2Cjs%2Fsite-functions.js%2Cform-validation.js.php%2Cform-validation-lang.php%2Cjs%2Fjquery-ui.min.js%2Cfacebox%2Ffacebox.js%2Cjs%2Fmbsmessage.js&amp;min=1&amp;sid=1631542832:2:13266)
  </code></pre>
  <p>The error is related to the script which is called in TESTS.php :</p>
  <pre><code> &lt;script src=&quot;https://www.paypal.com/sdk/js?client-id=test&amp;currency=USD&quot; data-namespace=&quot;paypal_sdk&quot;&gt;&lt;/script&gt;
  </code></pre>
  <p>It seems the file is not imported or there is some errors in php file which I am not able to find it out. Can anyone help me with this please as I have spent my whole day on it. Thanks.</p>
  <p><strong>EDIT :</strong>
  I have seperated the codes like below in order to prevent the preloading the papyal.button codes first. And now it looks like below :</p>
  <pre><code>&lt;? 
  require_once 'application-top.php';
  require_once 'includes/navigation-functions.php';
  require_once 'includes/site-functions-extended.php';
  require_once 'includes/buy-deal-functions.php';
  ?&gt;
  &lt;script type=&quot;text/javascript&quot; src=&quot;https://www.paypal.com/sdk/js?client-id=AQgUM6x3URK1A-rcNIq56covuc0CYGv3pb5sYeL6-cqsO1HYV2CV6h4ur6BCly_1YYd3-UOMTNGtwQXd&amp;currency=USD&quot;&gt;&lt;/script&gt;
  
  &lt;?
  // ini_set('display_errors', 1);
  // ini_set('display_startup_errors', 1);
  // error_reporting(E_ALL);
  $post = getPostedData();
  print_r($post);
  if ($_POST['mode'] == 'paypall')
  { 
      ?&gt;   
      &lt;script src=&quot;https://example.com/TESTS.js&quot;&gt;&lt;/script&gt;
  &lt;?
  } 
  ?&gt;
  </code></pre>
  <p>Now I am getting the error like below :</p>
  <pre><code>GET https://www.paypal.com/sdk/js?client-id=AQgUM6x3URK1A-rcNIq56covuc0CYGv3pb5sYeL6-cqsO1HYV2CV6h4ur6BCly_1YYd3-UOMTNGtwQXd&amp;currency=USD&amp;_=1647908135353 net::ERR_ABORTED 400
  </code></pre>
  <p>When I checked the error code the requested src url is looking like different as it adds the timestamp at the end of the link therefore I am getting the error :</p>
  <pre><code>https://www.paypal.com/sdk/js?client-id=AQgUM6x3URK1A-rcNIq56covuc0CYGv3pb5sYeL6-cqsO1HYV2CV6h4ur6BCly_1YYd3-UOMTNGtwQXd&amp;currency=USD&amp;_=1647908731335
  </code></pre>
  <p><strong>EDIT 2:</strong></p>
  <p>The payment page looks like below :</p>
  <p><a href="https://i.stack.imgur.com/98ymR.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/98ymR.png" alt="enter image description here" /></a></p>