-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstripe_payment.theme.inc
41 lines (38 loc) · 1.35 KB
/
stripe_payment.theme.inc
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
<?php
/**
* @file
* Theme processing functions for stripe_payment.
*/
/**
* Prepares variables for stripe iframe field templates.
*
* @param array $variables
* An associative array containing:
* - element: The rendered form API element.
*/
function template_process_stripe_payment_field(&$vars) {
$vars['attributes'] = $vars['element']['#attributes'] ?? [];
$parents = $vars['element']['#parents'];
$name = array_shift($parents);
$name .= $parents ? '[' . implode('][', $parents) . ']' : '';
$vars['attributes'] += [
'id' => $vars['element']['#id'] ?? drupal_html_id('stripe-payment-field'),
'data-stripe-element' => $vars['element']['#field_name'],
'name' => $name,
];
$vars['attributes']['class'][] = 'stripe-payment-field-iframe-wrapper';
$vars['attributes']['class'][] = 'text-input';
}
/**
* Prepares variables for the SEPA mandate info template.
*
* @param array $variables
* An associative array containing:
* - payment: The payment object for which the info is produced.
*/
function template_preprocess_stripe_payment_sepa_mandate_info(array &$variables) {
$payment = $variables['payment'];
$variables['creditor_id'] = $payment->method->controller_data['creditor_id'];
$variables['mandate_reference'] = $payment->stripe_sepa['mandate_reference'];
$variables['iban_last4'] = $payment->stripe_sepa['last4'];
}