Commit e08af223 authored by András Czövek's avatar András Czövek Committed by András Czövek
Browse files

Issue #2885678 by czigor: Notice on payment method creation

parent d7d44997
Loading
Loading
Loading
Loading
+6 −2
Original line number Diff line number Diff line
@@ -54,6 +54,8 @@ function commerce_square_form_rules_ui_edit_element_alter(&$form, &$form_state)
    if ($form_state['element_settings']['payment_method'] === 'commerce_square' || (!empty($form_state['element_settings']['payment_method']['method_id']) && $form_state['element_settings']['payment_method']['method_id'] === 'commerce_square')) {
      $settings = empty($form_state['element_settings']['payment_method']['settings']) ? [] : $form_state['element_settings']['payment_method']['settings'];
      $payment_form = &$form['parameter']['payment_method']['settings']['payment_method']['settings'];
      // Weirdly, AJAX fails if adding the library using #attached.
      libraries_load('square');
      $rule_id = $form_state['build_info']['args'][0]->name;
      // The rules action we are editing.
      $action = $form_state['build_info']['args'][1];
@@ -179,7 +181,6 @@ function commerce_square_form_rules_ui_edit_element_alter(&$form, &$form_state)
 * Payment method form callback.
 */
function commerce_square_settings_form($settings) {
  libraries_load('square');
  $form['mode'] = [
    '#type' => 'radios',
    '#title' => t('Mode'),
@@ -317,8 +318,10 @@ function commerce_square_settings_form_submit(&$form, &$form_state) {
    if (get_class($action) == 'RulesAction' && strpos($action->getElementName(), 'commerce_payment_enable_') === 0) {
      foreach (_commerce_square_get_supported_modes() as $mode => $name) {
        $action->settings['payment_method']['settings'][$mode . '_app_id'] = $values[$mode]['app_id'];
        if (!empty($values[$mode]['location_wrapper']) && !empty($values[$mode]['location_wrapper']['location_id'])) {
          $action->settings['payment_method']['settings'][$mode . '_location_id'] = $values[$mode]['location_wrapper']['location_id'];
        }
      }
      $action->settings['payment_method']['settings']['test_access_token'] = $values['test']['access_token'];
      $action->save();
      break;
@@ -368,6 +371,7 @@ function commerce_square_obtain_token() {
      'code' => $_GET['code'],
    ],
  ];
  drupal_set_message(t('Now that you have a production access token, you can select a Production Location ID. The payment gateway is not ready for use in production until you do that.', 'warning'));
  drupal_goto($url, $options);
}