-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcommerce_multisafepay_payments.module
More file actions
45 lines (42 loc) · 1.39 KB
/
commerce_multisafepay_payments.module
File metadata and controls
45 lines (42 loc) · 1.39 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
<?php declare(strict_types=1);
/**
* @file
* Implement hooks.
*/
use Drupal\Core\Form\FormStateInterface;
/**
* Alter a form.
*
* Implements hook_form_alter().
*
* @param mixed $form
* The form.
* @param \Drupal\Core\Form\FormStateInterface $formState
* The form state.
* @param int $formId
* The form id.
*/
function commerce_multisafepay_payments_form_alter(
&$form,
FormStateInterface $formState,
$formId
) {
if (!isset($form['#step_id'])) {
return;
}
if ($form['#step_id'] == 'order_information') {
if (isset($form['payment_information']['#payment_options'])) {
/** @var \Drupal\commerce_payment\PaymentOption $payment_option */
foreach ($form['payment_information']['#payment_options'] as $payment_option) {
/** @var \Drupal\Core\Config\ImmutableConfig $config */
$config = \Drupal::config('commerce_payment.commerce_payment_gateway.' . $payment_option->getId());
if ('msp_applepay' == $config->get('plugin')) {
$form['#attached']['library'][] = 'commerce_multisafepay_payments/applepay';
$computed_settings['name'] = $payment_option->getId();
$form['#attached']['drupalSettings']['commerce_multisafepay_payments']['applepay'] = $computed_settings;
break;
}
}
}
}
}