public function __construct() { $this->purchaseContractId = commerce_cba_get_purchase_contract_id(); $this->country = variable_get('cba_country', 'gb'); $this->mode = variable_get('cba_mode', 'sandbox'); $this->method = variable_get('cba_method', 'POST'); $this->publicKey = variable_get('cba_public_key', ''); $this->secretKey = variable_get('cba_secret_key', ''); $this->merchant_id = variable_get('cba_merchant_id', ''); $this->endPoint = $this->getEndPoint(); $this->integratorId = $this->getIntegratorId(); $this->integratorName = $this->getIntegratorName(); }
/** * Displays the bean. */ public function view($bean, $content, $view_mode = 'default', $langcode = NULL) { if ($purchase_contract_id = commerce_cba_get_purchase_contract_id()) { $html_id = drupal_html_id('AmazonAddressWidget'); $content['bean'][$bean->delta]['#attached']['library'][] = array('commerce_cba', 'amazon_widgets'); // @TODO: Add height and width. $callbacks = array('callbacks' => array('onAddressSelect' => '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, 'purchaseContractId' => commerce_cba_get_purchase_contract_id(), 'widget_type' => 'AddressWidget', 'merchantId' => variable_get('cba_merchant_id', ''), 'displayMode' => $display_mode, 'destinationName' => isset($bean->settings['destination']) ? $bean->settings['destination'] : 'billing') + $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) { // 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) { // 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; }