# bit-form/2.9.1/includes/Admin/Form/InitJs/Paypal.php

Bit Form – Contact Form, Payment Forms, Multi Step Forms, Calculator &amp; Custom Form Builder, version 2.9.1. 35 lines.

- Page: https://pluginprobe.com/plugins/bit-form/2.9.1/code/includes/Admin/Form/InitJs/Paypal.php
- Raw: https://pluginprobe.com/plugins/bit-form/2.9.1/raw/includes/Admin/Form/InitJs/Paypal.php
- Modified: 2023-07-16T07:55:48+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/bit-form/2.9.1/code/includes/Admin/Form/InitJs/Paypal.php#L10-L20`.

```php
<?php

namespace BitCode\BitForm\Admin\Form\InitJs;

class Paypal
{
  public static function init()
  {
    return <<<PAYPAL_INIT_JS
      const paypalUrlParams = {'client-id': fldData.clientId};
      if('locale' in fldData){
        paypalUrlParams.locale = fldData.locale;
      }
      if('disableFunding' in fldData && fldData.disableFunding.length){
        paypalUrlParams['disable-funding'] = fldData.disableFunding;
      }
      if(fldData?.payType === 'subscription'){
          paypalUrlParams.vault = 'true';
          paypalUrlParams.intent = 'subscription';
      } else if('currency' in fldData){
        paypalUrlParams.currency = fldData.currency;
      }

      const paypalUrl = 'https://www.paypal.com/sdk/js?' + Object.entries(paypalUrlParams).map(([key, val]) => key+'='+val).join('&');
      const attrs = {'data-namespace': 'bit-paypal-'+ contentId};
      const id = 'bit_paypal_script-' + contentId;
      const initFunc = function(){
        bf_globals[contentId].inits[fldKey] = getFldInstance(contentId, fldKey, fldType)
      };

      scriptLoader(paypalUrl, '', attrs, id, initFunc);
PAYPAL_INIT_JS;
  }
}

```
