/**
  * Displays the bean.
  */
 public function view($bean, $content, $view_mode = 'default', $langcode = NULL)
 {
     // There's no point in displaying the button if amazon js was not included.
     if (($js = commerce_cba_javascript_file()) && ($purchase_contract_id = commerce_cba_get_purchase_contract_id())) {
         $html_id = drupal_html_id('AmazonWalletWidget');
         $content['bean'][$bean->delta]['#attached']['library'] = array(array('commerce_cba', 'amazon_widgets'));
         // @TODO: Add height and width.
         $callbacks = array('callbacks' => array('onPaymentSelect' => 'commerce_cba_add_widget_info'));
         $display_mode = $view_mode == 'commerce_cba_read_only' ? 'Read' : 'Edit';
         $data = array('commerce_cba' => array($html_id => array('html_id' => $html_id, 'widget_type' => 'WalletWidget', 'merchantId' => variable_get('cba_merchant_id', ''), 'purchaseContractId' => commerce_cba_get_purchase_contract_id(), 'displayMode' => $display_mode) + $callbacks));
         $content['bean'][$bean->delta]['#attached']['js'][] = array('data' => $data, 'type' => 'setting');
         $content['bean'][$bean->delta]['#type'] = 'container';
         $content['bean'][$bean->delta]['#attributes'] = array('id' => $html_id);
     }
     return $content;
 }
 /**
  * Displays the bean.
  */
 public function view($bean, $content, $view_mode = 'default', $langcode = NULL, $test = NULL)
 {
     // There's no point in displaying the button if amazon js was not included.
     if (($js = commerce_cba_javascript_file()) && isset($bean->order) && ($order = $bean->order)) {
         if (!empty($order->commerce_cba_amazon_order_ids)) {
             $content['bean'][$bean->delta]['#attached']['library'] = array(array('commerce_cba', 'amazon_widgets'));
             $order_ids = field_get_items('commerce_order', $order, 'commerce_cba_amazon_order_ids');
             foreach ($order_ids as $order_id) {
                 $html_id = drupal_html_id('OrderDetailsWidget');
                 // @TODO: Add height and width.
                 $data = array('commerce_cba' => array($html_id => array('html_id' => $html_id, 'widget_type' => 'OrderDetailsWidget', 'merchantId' => variable_get('cba_merchant_id', ''), 'orderId' => $order_id['value'])));
                 $content['bean'][$bean->delta][$html_id]['#attached']['js'][] = array('data' => $data, 'type' => 'setting');
                 $content['bean'][$bean->delta][$html_id]['#type'] = 'container';
                 $content['bean'][$bean->delta][$html_id]['#attributes'] = array('id' => $html_id);
             }
         }
     }
     return $content;
 }
 /**
  * Displays the bean.
  */
 public function view($bean, $content, $view_mode = 'default', $langcode = NULL)
 {
     // There's no point in displaying the button if amazon js was not included.
     if ($js = commerce_cba_javascript_file()) {
         $html_id = drupal_html_id('AmazonInlineWidget');
         $content['bean'][$bean->delta]['#attached']['library'] = array(array('commerce_cba', 'amazon_widgets'));
         $callbacks = array();
         if ($bean->settings['button_type'] == 'checkout') {
             $callbacks = array('callbacks' => array('onAuthorize' => 'commerce_cba_redirect_checkout'));
         } elseif ($bean->settings['button_type'] == 'addressBook') {
             $callbacks = array('callbacks' => array('onAuthorize' => 'commerce_cba_address_redirect_checkout'));
         }
         $content['bean'][$bean->delta]['#attached']['js'][] = array('data' => array($html_id => $html_id, 'commerce_cba' => array($html_id => array('merchantId' => variable_get('cba_merchant_id', ''), 'purchaseContractId' => commerce_cba_get_purchase_contract_id(), 'widget_type' => 'InlineCheckoutWidget', 'checkout_pane' => isset($bean->checkout_pane) ? $bean->checkout_pane : NULL, 'settings' => array('buttonType' => isset($bean->settings['button_type']) ? $bean->settings['button_type'] : 'checkout', 'buttonSettings' => array('size' => isset($bean->settings['button_settings']['size']) ? $bean->settings['button_settings']['size'] : 'large', 'color' => isset($bean->settings['button_settings']['color']) ? $bean->settings['button_settings']['color'] : 'orange', 'background' => isset($bean->settings['button_settings']['background']) ? $bean->settings['button_settings']['background'] : 'white'))) + $callbacks)), 'type' => 'setting');
         $content['bean'][$bean->delta]['#attached']['css'] = array(drupal_get_path('module', 'commerce_cba') . '/css/commerce_cba.css');
         $content['bean'][$bean->delta]['#type'] = 'container';
         $content['bean'][$bean->delta]['#attributes'] = array('id' => $html_id);
         // Place the button aligned to the right if it's checkout.
         if ($bean->settings['button_type'] == 'checkout') {
             $content['bean'][$bean->delta]['#attributes']['class'] = 'checkout-by-amazon-pay';
         }
     }
     return $content;
 }