You are here

function commerce_payflow_page_alter in Commerce PayPal 7.2

Implements hook_page_alter().

File

modules/payflow/commerce_payflow.module, line 252
Implements PayPal Payments Advanced (U.S. only) and Payflow Link Hosted Checkout pages and Transparent Redirect.

Code

function commerce_payflow_page_alter(&$page) {

  // Add a registration link to the PayPal Payments Advanced and Payflow Link
  // payment method rules on the payment methods admin page.
  if (!empty($page['content']['system_main']['#page_callback']) && $page['content']['system_main']['#page_callback'] == 'commerce_payment_ui_admin_page') {

    // Ensure we loop over both enabled and disabled rules.
    foreach (array(
      'enabled',
      'disabled',
    ) as $key) {
      foreach ($page['content']['system_main'][$key]['rules']['#rows'] as $row_key => &$row) {
        $services = array(
          'commerce_payment_payflow_link' => 'payflow_link',
          'commerce_payment_paypal_ppa' => 'paypal_ppa',
        );
        foreach ($services as $rule_name => $method_id) {
          if (strpos($row[0]['data']['description']['settings']['machine_name']['#markup'], $rule_name) > 0) {
            $row[0]['data']['#suffix'] = '<div class="service-description">' . commerce_payflow_service_description($method_id) . '</div></div>';
          }
        }
      }
    }
  }
}