You are here

function _commerce_square_ensure_assets_attached in Commerce Square Connect 7

Ensures the JavaScript assets are attached to the Square payment form.

Parameters

array $element: The element.

string $mode: The API mode.

2 calls to _commerce_square_ensure_assets_attached()
commerce_square_form_alter in ./commerce_square.module
Implements hook_form_alter().
commerce_square_payment_method_submit_form in ./commerce_square.module
Square payment checkout pane form callback.

File

./commerce_square.module, line 738
Module file for Commerce Square.

Code

function _commerce_square_ensure_assets_attached(&$element, $mode) {
  if ($mode === 'test') {
    $element['#attached']['js']['https://js.squareupsandbox.com/v2/paymentform'] = array(
      'type' => 'external',
    );
  }
  else {
    $element['#attached']['js']['https://js.squareup.com/v2/paymentform'] = array(
      'type' => 'external',
    );
  }
  $element['#attached']['js'][] = drupal_get_path('module', 'commerce_square') . '/js/commerce_square.form.js';
}