diff --git a/modules/order/src/Plugin/views/area/OrderTotal.php b/modules/order/src/Plugin/views/area/OrderTotal.php
index 2cb48506..bfebab86 100644
--- a/modules/order/src/Plugin/views/area/OrderTotal.php
+++ b/modules/order/src/Plugin/views/area/OrderTotal.php
@@ -76,7 +76,11 @@ class OrderTotal extends AreaPluginBase {
if (!$argument instanceof NumericArgument) {
continue;
}
- if (!in_array($argument->getField(), ['commerce_order.order_id', 'commerce_order_item.order_id'])) {
+ if (!in_array($argument->getField(), [
+ 'commerce_order.order_id',
+ 'commerce_order_item.order_id',
+ 'commerce_payment.order_id',
+ ])) {
continue;
}
/** @var \Drupal\commerce_order\Entity\OrderInterface $order */
diff --git a/modules/payment/commerce_payment.post_update.php b/modules/payment/commerce_payment.post_update.php
index 69a9800b..13ff10dd 100644
--- a/modules/payment/commerce_payment.post_update.php
+++ b/modules/payment/commerce_payment.post_update.php
@@ -167,3 +167,15 @@ function commerce_payment_post_update_3(&$sandbox = NULL) {
$sandbox['#finished'] = ($sandbox['total_count'] - $sandbox['current_count']) / $sandbox['total_count'];
}
}
+
+/**
+ * Import the payments view.
+ */
+function commerce_payment_post_update_4() {
+ /** @var \Drupal\commerce\Config\ConfigUpdaterInterface $config_updater */
+ $config_updater = \Drupal::service('commerce.config_updater');
+ $result = $config_updater->import([
+ 'views.view.commerce_order_payments',
+ ]);
+ return implode('
', $result->getFailed());
+}
diff --git a/modules/payment/commerce_payment.views.inc b/modules/payment/commerce_payment.views.inc
new file mode 100644
index 00000000..d25f57d9
--- /dev/null
+++ b/modules/payment/commerce_payment.views.inc
@@ -0,0 +1,19 @@
+ t('Payment total summary'),
+ 'area' => [
+ 'id' => 'commerce_payment_total_summary',
+ ],
+ ];
+ return $data;
+}
diff --git a/modules/payment/config/install/views.view.commerce_order_payments.yml b/modules/payment/config/install/views.view.commerce_order_payments.yml
new file mode 100644
index 00000000..7fc628b2
--- /dev/null
+++ b/modules/payment/config/install/views.view.commerce_order_payments.yml
@@ -0,0 +1,901 @@
+langcode: en
+status: true
+dependencies:
+ module:
+ - commerce_payment
+ - commerce_price
+ - options
+ - user
+id: commerce_order_payments
+label: Payments
+module: views
+description: ''
+tag: ''
+base_table: commerce_payment
+base_field: payment_id
+display:
+ default:
+ id: default
+ display_title: Default
+ display_plugin: default
+ position: 0
+ display_options:
+ title: Payments
+ fields:
+ amount__number:
+ id: amount__number
+ table: commerce_payment
+ field: amount__number
+ relationship: none
+ group_type: group
+ admin_label: ''
+ entity_type: commerce_payment
+ entity_field: amount
+ plugin_id: field
+ label: Payment
+ exclude: false
+ alter:
+ alter_text: false
+ text: ''
+ make_link: false
+ path: ''
+ absolute: false
+ external: false
+ replace_spaces: false
+ path_case: none
+ trim_whitespace: false
+ alt: ''
+ rel: ''
+ link_class: ''
+ prefix: ''
+ suffix: ''
+ target: ''
+ nl2br: false
+ max_length: 0
+ word_boundary: true
+ ellipsis: true
+ more_link: false
+ more_link_text: ''
+ more_link_path: ''
+ strip_tags: false
+ trim: false
+ preserve_tags: ''
+ html: false
+ element_type: ''
+ element_class: ''
+ element_label_type: ''
+ element_label_class: ''
+ element_label_colon: true
+ element_wrapper_type: ''
+ element_wrapper_class: ''
+ element_default_classes: true
+ empty: ''
+ hide_empty: false
+ empty_zero: false
+ hide_alter_empty: true
+ click_sort_column: number
+ type: commerce_price_default
+ settings:
+ strip_trailing_zeroes: false
+ currency_display: symbol
+ group_column: ''
+ group_columns: { }
+ group_rows: true
+ delta_limit: 0
+ delta_offset: 0
+ delta_reversed: false
+ delta_first_last: false
+ multi_type: separator
+ separator: ', '
+ field_api_classes: false
+ refunded_amount__number:
+ id: refunded_amount__number
+ table: commerce_payment
+ field: refunded_amount__number
+ relationship: none
+ group_type: group
+ admin_label: ''
+ entity_type: commerce_payment
+ entity_field: refunded_amount
+ plugin_id: field
+ label: 'Refunded:'
+ exclude: false
+ alter:
+ alter_text: true
+ text: 'Refunded: {{ refunded_amount__number }}'
+ make_link: false
+ path: ''
+ absolute: false
+ external: false
+ replace_spaces: false
+ path_case: none
+ trim_whitespace: false
+ alt: ''
+ rel: ''
+ link_class: ''
+ prefix: ''
+ suffix: ''
+ target: ''
+ nl2br: false
+ max_length: 0
+ word_boundary: true
+ ellipsis: true
+ more_link: false
+ more_link_text: ''
+ more_link_path: ''
+ strip_tags: false
+ trim: false
+ preserve_tags: ''
+ html: false
+ element_type: ''
+ element_class: ''
+ element_label_type: ''
+ element_label_class: ''
+ element_label_colon: true
+ element_wrapper_type: ''
+ element_wrapper_class: ''
+ element_default_classes: true
+ empty: ''
+ hide_empty: true
+ empty_zero: false
+ hide_alter_empty: true
+ click_sort_column: number
+ type: commerce_price_default
+ settings:
+ strip_trailing_zeroes: false
+ currency_display: symbol
+ group_column: ''
+ group_columns: { }
+ group_rows: true
+ delta_limit: 0
+ delta_offset: 0
+ delta_reversed: false
+ delta_first_last: false
+ multi_type: separator
+ separator: ', '
+ field_api_classes: false
+ avs_response_code_label:
+ id: avs_response_code_label
+ table: commerce_payment
+ field: avs_response_code_label
+ relationship: none
+ group_type: group
+ admin_label: ''
+ entity_type: commerce_payment
+ entity_field: avs_response_code_label
+ plugin_id: field
+ label: ''
+ exclude: true
+ alter:
+ alter_text: false
+ text: ''
+ make_link: false
+ path: ''
+ absolute: false
+ external: false
+ replace_spaces: false
+ path_case: none
+ trim_whitespace: false
+ alt: ''
+ rel: ''
+ link_class: ''
+ prefix: ''
+ suffix: ''
+ target: ''
+ nl2br: false
+ max_length: 0
+ word_boundary: true
+ ellipsis: true
+ more_link: false
+ more_link_text: ''
+ more_link_path: ''
+ strip_tags: false
+ trim: false
+ preserve_tags: ''
+ html: false
+ element_type: ''
+ element_class: ''
+ element_label_type: ''
+ element_label_class: ''
+ element_label_colon: false
+ element_wrapper_type: ''
+ element_wrapper_class: ''
+ element_default_classes: true
+ empty: ''
+ hide_empty: true
+ empty_zero: false
+ hide_alter_empty: true
+ click_sort_column: value
+ type: string
+ settings: { }
+ group_column: value
+ group_columns: { }
+ group_rows: true
+ delta_limit: 0
+ delta_offset: 0
+ delta_reversed: false
+ delta_first_last: false
+ multi_type: separator
+ separator: ', '
+ field_api_classes: false
+ avs_response_code:
+ id: avs_response_code
+ table: commerce_payment
+ field: avs_response_code
+ relationship: none
+ group_type: group
+ admin_label: ''
+ entity_type: commerce_payment
+ entity_field: avs_response_code
+ plugin_id: field
+ label: 'AVS response code'
+ exclude: false
+ alter:
+ alter_text: true
+ text: 'AVS response: [{{ avs_response_code }}] {{ avs_response_code_label }}'
+ make_link: false
+ path: ''
+ absolute: false
+ external: false
+ replace_spaces: false
+ path_case: none
+ trim_whitespace: false
+ alt: ''
+ rel: ''
+ link_class: ''
+ prefix: ''
+ suffix: ''
+ target: ''
+ nl2br: false
+ max_length: 0
+ word_boundary: true
+ ellipsis: true
+ more_link: false
+ more_link_text: ''
+ more_link_path: ''
+ strip_tags: false
+ trim: false
+ preserve_tags: ''
+ html: false
+ element_type: ''
+ element_class: ''
+ element_label_type: ''
+ element_label_class: ''
+ element_label_colon: true
+ element_wrapper_type: ''
+ element_wrapper_class: ''
+ element_default_classes: true
+ empty: ''
+ hide_empty: true
+ empty_zero: false
+ hide_alter_empty: true
+ click_sort_column: value
+ type: string
+ settings: { }
+ group_column: value
+ group_columns: { }
+ group_rows: true
+ delta_limit: 0
+ delta_offset: 0
+ delta_reversed: false
+ delta_first_last: false
+ multi_type: separator
+ separator: ', '
+ field_api_classes: false
+ state:
+ id: state
+ table: commerce_payment
+ field: state
+ relationship: none
+ group_type: group
+ admin_label: ''
+ entity_type: commerce_payment
+ entity_field: state
+ plugin_id: field
+ label: State
+ exclude: false
+ alter:
+ alter_text: false
+ text: ''
+ make_link: false
+ path: ''
+ absolute: false
+ external: false
+ replace_spaces: false
+ path_case: none
+ trim_whitespace: false
+ alt: ''
+ rel: ''
+ link_class: ''
+ prefix: ''
+ suffix: ''
+ target: ''
+ nl2br: false
+ max_length: 0
+ word_boundary: true
+ ellipsis: true
+ more_link: false
+ more_link_text: ''
+ more_link_path: ''
+ strip_tags: false
+ trim: false
+ preserve_tags: ''
+ html: false
+ element_type: ''
+ element_class: ''
+ element_label_type: ''
+ element_label_class: ''
+ element_label_colon: true
+ element_wrapper_type: ''
+ element_wrapper_class: ''
+ element_default_classes: true
+ empty: ''
+ hide_empty: false
+ empty_zero: false
+ hide_alter_empty: true
+ click_sort_column: value
+ type: list_default
+ settings: { }
+ group_column: value
+ group_columns: { }
+ group_rows: true
+ delta_limit: 0
+ delta_offset: 0
+ delta_reversed: false
+ delta_first_last: false
+ multi_type: separator
+ separator: ', '
+ field_api_classes: false
+ payment_gateway:
+ id: payment_gateway
+ table: commerce_payment
+ field: payment_gateway
+ relationship: none
+ group_type: group
+ admin_label: ''
+ entity_type: commerce_payment
+ entity_field: payment_gateway
+ plugin_id: field
+ label: 'Payment gateway'
+ exclude: false
+ alter:
+ alter_text: false
+ text: ''
+ make_link: false
+ path: ''
+ absolute: false
+ external: false
+ replace_spaces: false
+ path_case: none
+ trim_whitespace: false
+ alt: ''
+ rel: ''
+ link_class: ''
+ prefix: ''
+ suffix: ''
+ target: ''
+ nl2br: false
+ max_length: 0
+ word_boundary: true
+ ellipsis: true
+ more_link: false
+ more_link_text: ''
+ more_link_path: ''
+ strip_tags: false
+ trim: false
+ preserve_tags: ''
+ html: false
+ element_type: ''
+ element_class: ''
+ element_label_type: ''
+ element_label_class: ''
+ element_label_colon: true
+ element_wrapper_type: ''
+ element_wrapper_class: ''
+ element_default_classes: true
+ empty: ''
+ hide_empty: false
+ empty_zero: false
+ hide_alter_empty: true
+ click_sort_column: target_id
+ type: entity_reference_label
+ settings:
+ link: true
+ group_column: target_id
+ group_columns: { }
+ group_rows: true
+ delta_limit: 0
+ delta_offset: 0
+ delta_reversed: false
+ delta_first_last: false
+ multi_type: separator
+ separator: ', '
+ field_api_classes: false
+ authorized:
+ id: authorized
+ table: commerce_payment
+ field: authorized
+ relationship: none
+ group_type: group
+ admin_label: ''
+ entity_type: commerce_payment
+ entity_field: authorized
+ plugin_id: field
+ label: Authorized
+ exclude: false
+ alter:
+ alter_text: false
+ text: ''
+ make_link: false
+ path: ''
+ absolute: false
+ external: false
+ replace_spaces: false
+ path_case: none
+ trim_whitespace: false
+ alt: ''
+ rel: ''
+ link_class: ''
+ prefix: ''
+ suffix: ''
+ target: ''
+ nl2br: false
+ max_length: 0
+ word_boundary: true
+ ellipsis: true
+ more_link: false
+ more_link_text: ''
+ more_link_path: ''
+ strip_tags: false
+ trim: false
+ preserve_tags: ''
+ html: false
+ element_type: ''
+ element_class: ''
+ element_label_type: ''
+ element_label_class: ''
+ element_label_colon: true
+ element_wrapper_type: ''
+ element_wrapper_class: ''
+ element_default_classes: true
+ empty: ''
+ hide_empty: false
+ empty_zero: false
+ hide_alter_empty: true
+ click_sort_column: value
+ type: timestamp
+ settings:
+ date_format: short
+ custom_date_format: ''
+ timezone: ''
+ group_column: value
+ group_columns: { }
+ group_rows: true
+ delta_limit: 0
+ delta_offset: 0
+ delta_reversed: false
+ delta_first_last: false
+ multi_type: separator
+ separator: ', '
+ field_api_classes: false
+ completed:
+ id: completed
+ table: commerce_payment
+ field: completed
+ relationship: none
+ group_type: group
+ admin_label: ''
+ entity_type: commerce_payment
+ entity_field: completed
+ plugin_id: field
+ label: Completed
+ exclude: false
+ alter:
+ alter_text: false
+ text: ''
+ make_link: false
+ path: ''
+ absolute: false
+ external: false
+ replace_spaces: false
+ path_case: none
+ trim_whitespace: false
+ alt: ''
+ rel: ''
+ link_class: ''
+ prefix: ''
+ suffix: ''
+ target: ''
+ nl2br: false
+ max_length: 0
+ word_boundary: true
+ ellipsis: true
+ more_link: false
+ more_link_text: ''
+ more_link_path: ''
+ strip_tags: false
+ trim: false
+ preserve_tags: ''
+ html: false
+ element_type: ''
+ element_class: ''
+ element_label_type: ''
+ element_label_class: ''
+ element_label_colon: true
+ element_wrapper_type: ''
+ element_wrapper_class: ''
+ element_default_classes: true
+ empty: ''
+ hide_empty: false
+ empty_zero: false
+ hide_alter_empty: true
+ click_sort_column: value
+ type: timestamp
+ settings:
+ date_format: short
+ custom_date_format: ''
+ timezone: ''
+ group_column: value
+ group_columns: { }
+ group_rows: true
+ delta_limit: 0
+ delta_offset: 0
+ delta_reversed: false
+ delta_first_last: false
+ multi_type: separator
+ separator: ', '
+ field_api_classes: false
+ remote_id:
+ id: remote_id
+ table: commerce_payment
+ field: remote_id
+ relationship: none
+ group_type: group
+ admin_label: ''
+ entity_type: commerce_payment
+ entity_field: remote_id
+ plugin_id: field
+ label: 'Remote ID'
+ exclude: false
+ alter:
+ alter_text: false
+ text: ''
+ make_link: false
+ path: ''
+ absolute: false
+ external: false
+ replace_spaces: false
+ path_case: none
+ trim_whitespace: false
+ alt: ''
+ rel: ''
+ link_class: ''
+ prefix: ''
+ suffix: ''
+ target: ''
+ nl2br: false
+ max_length: 0
+ word_boundary: true
+ ellipsis: true
+ more_link: false
+ more_link_text: ''
+ more_link_path: ''
+ strip_tags: false
+ trim: false
+ preserve_tags: ''
+ html: false
+ element_type: ''
+ element_class: ''
+ element_label_type: ''
+ element_label_class: ''
+ element_label_colon: true
+ element_wrapper_type: ''
+ element_wrapper_class: ''
+ element_default_classes: true
+ empty: N/A
+ hide_empty: false
+ empty_zero: false
+ hide_alter_empty: true
+ click_sort_column: value
+ type: string
+ settings: { }
+ group_column: value
+ group_columns: { }
+ group_rows: true
+ delta_limit: 0
+ delta_offset: 0
+ delta_reversed: false
+ delta_first_last: false
+ multi_type: separator
+ separator: ', '
+ field_api_classes: false
+ operations:
+ id: operations
+ table: commerce_payment
+ field: operations
+ relationship: none
+ group_type: group
+ admin_label: ''
+ entity_type: null
+ entity_field: null
+ plugin_id: entity_operations
+ label: Operations
+ exclude: false
+ alter:
+ alter_text: false
+ text: ''
+ make_link: false
+ path: ''
+ absolute: false
+ external: false
+ replace_spaces: false
+ path_case: none
+ trim_whitespace: false
+ alt: ''
+ rel: ''
+ link_class: ''
+ prefix: ''
+ suffix: ''
+ target: ''
+ nl2br: false
+ max_length: 0
+ word_boundary: true
+ ellipsis: true
+ more_link: false
+ more_link_text: ''
+ more_link_path: ''
+ strip_tags: false
+ trim: false
+ preserve_tags: ''
+ html: false
+ element_type: ''
+ element_class: ''
+ element_label_type: ''
+ element_label_class: ''
+ element_label_colon: true
+ element_wrapper_type: ''
+ element_wrapper_class: ''
+ element_default_classes: true
+ empty: ''
+ hide_empty: false
+ empty_zero: false
+ hide_alter_empty: true
+ destination: false
+ pager:
+ type: none
+ options:
+ offset: 0
+ exposed_form:
+ type: basic
+ options:
+ submit_button: Apply
+ reset_button: false
+ reset_button_label: Reset
+ exposed_sorts_label: 'Sort by'
+ expose_sort_order: true
+ sort_asc_label: Asc
+ sort_desc_label: Desc
+ access:
+ type: perm
+ options:
+ perm: 'administer commerce_payment'
+ cache:
+ type: tag
+ options: { }
+ empty:
+ area_text_custom:
+ id: area_text_custom
+ table: views
+ field: area_text_custom
+ relationship: none
+ group_type: group
+ admin_label: ''
+ plugin_id: text_custom
+ empty: true
+ content: 'No payments yet.'
+ tokenize: false
+ sorts:
+ payment_id:
+ id: payment_id
+ table: commerce_payment
+ field: payment_id
+ relationship: none
+ group_type: group
+ admin_label: ''
+ entity_type: commerce_payment
+ entity_field: payment_id
+ plugin_id: standard
+ order: DESC
+ expose:
+ label: ''
+ field_identifier: ''
+ exposed: false
+ arguments:
+ order_id:
+ id: order_id
+ table: commerce_payment
+ field: order_id
+ relationship: none
+ group_type: group
+ admin_label: ''
+ entity_type: commerce_payment
+ entity_field: order_id
+ plugin_id: numeric
+ default_action: empty
+ exception:
+ value: all
+ title_enable: false
+ title: All
+ title_enable: false
+ title: ''
+ default_argument_type: fixed
+ default_argument_options:
+ argument: ''
+ default_argument_skip_url: false
+ summary_options:
+ base_path: ''
+ count: true
+ override: false
+ items_per_page: 25
+ summary:
+ sort_order: asc
+ number_of_records: 0
+ format: default_summary
+ specify_validation: false
+ validate:
+ type: none
+ fail: 'not found'
+ validate_options: { }
+ break_phrase: false
+ not: false
+ filters: { }
+ style:
+ type: table
+ options:
+ grouping: { }
+ row_class: ''
+ default_row_class: true
+ columns:
+ amount__number: amount__number
+ refunded_amount__number: amount__number
+ avs_response_code_label: amount__number
+ avs_response_code: amount__number
+ state: state
+ payment_gateway: payment_gateway
+ authorized: authorized
+ completed: completed
+ remote_id: remote_id
+ operations: operations
+ default: '-1'
+ info:
+ amount__number:
+ sortable: false
+ default_sort_order: asc
+ align: ''
+ separator: '
'
+ empty_column: false
+ responsive: ''
+ refunded_amount__number:
+ sortable: false
+ default_sort_order: asc
+ align: ''
+ separator: ''
+ empty_column: false
+ responsive: ''
+ avs_response_code_label:
+ sortable: false
+ default_sort_order: asc
+ align: ''
+ separator: ''
+ empty_column: false
+ responsive: ''
+ avs_response_code:
+ sortable: false
+ default_sort_order: asc
+ align: ''
+ separator: ''
+ empty_column: false
+ responsive: ''
+ state:
+ sortable: false
+ default_sort_order: asc
+ align: ''
+ separator: ''
+ empty_column: false
+ responsive: ''
+ payment_gateway:
+ sortable: false
+ default_sort_order: asc
+ align: ''
+ separator: ''
+ empty_column: false
+ responsive: ''
+ authorized:
+ sortable: false
+ default_sort_order: asc
+ align: ''
+ separator: ''
+ empty_column: false
+ responsive: ''
+ completed:
+ sortable: false
+ default_sort_order: asc
+ align: ''
+ separator: ''
+ empty_column: false
+ responsive: ''
+ remote_id:
+ sortable: false
+ default_sort_order: asc
+ align: ''
+ separator: ''
+ empty_column: false
+ responsive: ''
+ operations:
+ align: ''
+ separator: ''
+ empty_column: false
+ responsive: ''
+ override: true
+ sticky: false
+ summary: ''
+ empty_table: true
+ caption: ''
+ description: ''
+ row:
+ type: fields
+ query:
+ type: views_query
+ options:
+ query_comment: ''
+ disable_sql_rewrite: false
+ distinct: false
+ replica: false
+ query_tags: { }
+ relationships: { }
+ header: { }
+ footer:
+ commerce_payment_total_summary:
+ id: commerce_payment_total_summary
+ table: views
+ field: commerce_payment_total_summary
+ relationship: none
+ group_type: group
+ admin_label: ''
+ plugin_id: commerce_payment_total_summary
+ empty: false
+ display_extenders: { }
+ cache_metadata:
+ max-age: -1
+ contexts:
+ - 'languages:language_content'
+ - 'languages:language_interface'
+ - url
+ - user.permissions
+ tags: { }
+ page_1:
+ id: page_1
+ display_title: Page
+ display_plugin: page
+ position: 1
+ display_options:
+ enabled: true
+ display_extenders: { }
+ path: admin/commerce/orders/%/payments
+ menu:
+ type: tab
+ title: Payments
+ description: ''
+ weight: 15
+ expanded: false
+ menu_name: main
+ parent: ''
+ context: '0'
+ cache_metadata:
+ max-age: -1
+ contexts:
+ - 'languages:language_content'
+ - 'languages:language_interface'
+ - url
+ - user.permissions
+ tags: { }
diff --git a/modules/payment/src/Plugin/views/area/PaymentTotalSummary.php b/modules/payment/src/Plugin/views/area/PaymentTotalSummary.php
new file mode 100644
index 00000000..f08e10f7
--- /dev/null
+++ b/modules/payment/src/Plugin/views/area/PaymentTotalSummary.php
@@ -0,0 +1,78 @@
+entityTypeManager = $container->get('entity_type.manager');
+
+ return $instance;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function buildOptionsForm(&$form, FormStateInterface $form_state) {
+ parent::buildOptionsForm($form, $form_state);
+
+ $form['empty']['#description'] = $this->t("Even if selected, this area handler will never render if a valid order cannot be found in the View's arguments.");
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function render($empty = FALSE) {
+ if (!$empty || !empty($this->options['empty'])) {
+ $order_storage = $this->entityTypeManager->getStorage('commerce_order');
+ foreach ($this->view->argument as $name => $argument) {
+ // First look for an order_id argument.
+ if (!$argument instanceof NumericArgument) {
+ continue;
+ }
+ if (!in_array($argument->getField(), [
+ 'commerce_order.order_id',
+ 'commerce_order_item.order_id',
+ 'commerce_payment.order_id',
+ ], TRUE)) {
+ continue;
+ }
+ /** @var \Drupal\commerce_order\Entity\OrderInterface $order */
+ if ($order = $order_storage->load($argument->getValue())) {
+ return [
+ 'payment_total_summary' => [
+ '#theme' => 'commerce_payment_total_summary',
+ '#order_entity' => $order,
+ ],
+ ];
+ }
+ }
+ }
+
+ return [];
+ }
+
+}