You are here

function commerce_paypal_library_info_build in Commerce PayPal 8

Implements hook_library_info_build().

File

./commerce_paypal.module, line 149
Implements PayPal payment services for use with Drupal Commerce.

Code

function commerce_paypal_library_info_build() {

  // Only build the PayPal Credit messaging JS if a PayPal Client ID was set on
  // the PayPal Credit messaging settings form.
  $client_id = \Drupal::config('commerce_paypal.credit_messaging_settings')
    ->get('client_id');
  if (!$client_id) {
    return [];
  }
  $url = sprintf('https://www.paypal.com/sdk/js?client-id=%s&components=messages', $client_id);
  $libraries['credit_messaging'] = [
    'header' => TRUE,
    'js' => [
      $url => [
        'type' => 'external',
        'attributes' => [
          'data-partner-attribution-id' => 'CommerceGuys_Cart_SPB',
        ],
      ],
    ],
  ];
  return $libraries;
}