/**
  * {@inheritdoc}
  */
 public function submitForm(array &$form, FormStateInterface $form_state)
 {
     $items = \Drupal::service('uc_cart.manager')->get()->getContents();
     $paypal_config = $this->config('uc_paypal.settings');
     if (empty($items)) {
         drupal_set_message($this->t('You do not have any items in your shopping cart.'));
         return;
     }
     list($desc, $subtotal) = _uc_paypal_product_details($items);
     $order = Order::create(['uid' => $this->currentUser()->id()]);
     $order->save();
     $nvp_request = array('METHOD' => 'SetExpressCheckout', 'RETURNURL' => Url::fromRoute('uc_paypal.ec_review', [], ['absolute' => TRUE])->toString(), 'CANCELURL' => Url::fromRoute('uc_cart.cart', [], ['absolute' => TRUE])->toString(), 'AMT' => uc_currency_format($subtotal, FALSE, FALSE, '.'), 'CURRENCYCODE' => $order->getCurrency(), 'PAYMENTACTION' => $paypal_config->get('wpp_cc_txn_type') == 'authorize' ? 'Authorization' : 'Sale', 'DESC' => substr($desc, 0, 127), 'INVNUM' => $order->id() . '-' . REQUEST_TIME, 'REQCONFIRMSHIPPING' => $paypal_config->get('ec_rqconfirmed_addr'), 'BUTTONSOURCE' => 'Ubercart_ShoppingCart_EC_US', 'NOTIFYURL' => Url::fromRoute('uc_paypal.ipn', [], ['absolute' => TRUE])->toString(), 'LANDINGPAGE' => $paypal_config->get('ec_landingpage_style'));
     $order->products = $items;
     $order->save();
     $nvp_response = uc_paypal_api_request($nvp_request, $paypal_config->get('wpp_server'));
     if ($nvp_response['ACK'] != 'Success') {
         drupal_set_message($this->t('PayPal reported an error: @code: @message', ['@code' => $nvp_response['L_ERRORCODE0'], '@message' => $nvp_response['L_LONGMESSAGE0']]), 'error');
         return;
     }
     $session = \Drupal::service('session');
     $session->set('cart_order', $order->id());
     $session->set('TOKEN', $nvp_response['TOKEN']);
     $sandbox = '';
     if (strpos($paypal_config->get('wpp_server'), 'sandbox') > 0) {
         $sandbox = 'sandbox.';
     }
     header('Location: https://www.' . $sandbox . 'paypal.com/cgi-bin/webscr?cmd=_express-checkout&token=' . $session->get('TOKEN'));
     exit;
 }
示例#2
0
 /**
  * {@inheritdoc}
  */
 protected function chargeCard($order, $amount, $txn_type, $reference = NULL)
 {
     $user = \Drupal::currentUser();
     // cc_exp_month and cc_exp_year are also validated by
     // _uc_credit_valid_card_expiration() on the checkout form.
     $month = $order->payment_details['cc_exp_month'];
     $year = $order->payment_details['cc_exp_year'];
     if ($year < 100) {
         $year = $year + 2000;
     }
     // Card is expired at 0:00 on the first day of the next month.
     $expiration_date = mktime(0, 0, 0, $month + 1, 1, $year);
     // Conditions for failure are described in file documentation block above.
     // All other transactions will succeed.
     if ($order->payment_details['cc_number'] == '0000000000000000' || isset($order->payment_details['cc_cvv']) && $order->payment_details['cc_cvv'] == '000' || $expiration_date - REQUEST_TIME <= 0 || $amount == 12.34 || $order->billing_first_name == 'Fictitious' || $order->billing_phone == '8675309') {
         $success = FALSE;
     } else {
         $success = TRUE;
     }
     // The information for the payment is in the $order->payment_details array.
     if ($this->configuration['debug']) {
         \Drupal::logger('uc_credit')->notice('Test gateway payment details @details.', ['@details' => print_r($order->payment_details, TRUE)]);
     }
     if ($success) {
         $message = $this->t('Credit card charged: @amount', ['@amount' => uc_currency_format($amount)]);
         uc_order_comment_save($order->id(), $user->id(), $message, 'admin');
     } else {
         $message = $this->t('Credit card charge failed.');
         uc_order_comment_save($order->id(), $user->id(), $message, 'admin');
     }
     $result = array('success' => $success, 'comment' => $this->t('Card charged, resolution code: 0022548315'), 'message' => $success ? $this->t('Credit card payment processed successfully.') : $this->t('Credit card charge failed.'), 'uid' => $user->id());
     return $result;
 }
 /**
  * {@inheritdoc}
  */
 public function viewElements(FieldItemListInterface $items, $langcode)
 {
     $elements = [];
     foreach ($items as $delta => $item) {
         $elements[$delta] = array('#markup' => uc_currency_format($item->value));
     }
     return $elements;
 }
 /**
  * {@inheritdoc}
  */
 public function cartDetails(OrderInterface $order, array $form, FormStateInterface $form_state)
 {
     $build['#attached']['library'][] = 'uc_payment_pack/cod.styles';
     $build['policy'] = array('#prefix' => '<p>', '#markup' => Html::escape($this->configuration['policy']), '#suffix' => '</p>');
     if (($max = $this->configuration['max_order']) > 0 && is_numeric($max)) {
         $build['eligibility'] = array('#prefix' => '<p>', '#markup' => $this->t('Orders totalling more than @amount are <b>not eligible</b> for COD.', ['@amount' => uc_currency_format($max)]), '#suffix' => '</p>');
     }
     if ($this->configuration['delivery_date']) {
         $build += $this->deliveryDateForm($order);
     }
     return $build;
 }
示例#5
0
 /**
  * {@inheritdoc}
  */
 public function render(ResultRow $values)
 {
     if ($this->options['format'] == 'uc_price') {
         $value = $this->getValue($values);
         if (is_null($value) || $value == 0 && $this->options['empty_zero']) {
             return '';
         }
         return uc_currency_format($value);
     } else {
         return parent::render($values);
     }
 }
示例#6
0
 /**
  * {@inheritdoc}
  */
 public function cartDetails(OrderInterface $order, array $form, FormStateInterface $form_state)
 {
     $cod_config = \Drupal::config('uc_payment_pack.cod.settings');
     $build['policy'] = array('#markup' => '<p>' . $cod_config->get('policy') . '</p>');
     if (($max = $cod_config->get('max_order')) > 0 && is_numeric($max)) {
         $build['eligibility'] = array('#markup' => '<p>' . t('Orders totalling more than @amount are <b>not eligible</b> for COD.', ['@amount' => uc_currency_format($max)]) . '</p>');
     }
     if ($cod_config->get('delivery_date')) {
         $build += $this->deliveryDateForm($order);
     }
     return $build;
 }
 /**
  * {@inheritdoc}
  */
 public function buildForm(array $form, FormStateInterface $form_state, OrderInterface $uc_order = NULL)
 {
     $balance = uc_payment_balance($uc_order);
     $form['balance'] = array('#prefix' => '<strong>' . $this->t('Order balance:') . '</strong> ', '#markup' => uc_currency_format($balance));
     $form['order_id'] = array('#type' => 'hidden', '#value' => $uc_order->id());
     $form['amount'] = array('#type' => 'uc_price', '#title' => $this->t('Check amount'), '#default_value' => $balance);
     $form['comment'] = array('#type' => 'textfield', '#title' => $this->t('Comment'), '#description' => $this->t('Any notes about the check, like type or check number.'), '#size' => 64, '#maxlength' => 256);
     $form['clear_date'] = array('#type' => 'datetime', '#title' => $this->t('Expected clear date'), '#date_date_element' => 'date', '#date_time_element' => 'none', '#default_value' => DrupalDateTime::createFromTimestamp(REQUEST_TIME));
     $form['actions'] = array('#type' => 'actions');
     $form['actions']['submit'] = array('#type' => 'submit', '#value' => $this->t('Receive check'));
     return $form;
 }
 /**
  * {@inheritdoc}
  */
 public function buildForm(array $form, FormStateInterface $form_state, OrderInterface $uc_order = NULL)
 {
     $balance = uc_payment_balance($uc_order);
     $form['balance'] = array('#prefix' => '<strong>' . $this->t('Order balance:') . '</strong> ', '#markup' => uc_currency_format($balance));
     $form['order_id'] = array('#type' => 'hidden', '#value' => $uc_order->id());
     $form['amount'] = array('#type' => 'uc_price', '#title' => $this->t('Amount'), '#default_value' => $balance);
     $form['comment'] = array('#type' => 'textfield', '#title' => $this->t('Comment'), '#description' => $this->t('Any notes about the check, like type or check number.'), '#size' => 64, '#maxlength' => 256);
     $form['clear'] = array('#type' => 'fieldset', '#title' => $this->t('Expected clear date'), '#attributes' => array('class' => array('uc-inline-form', 'clearfix')));
     $form['clear']['clear_month'] = uc_select_month(NULL, \Drupal::service('date.formatter')->format(REQUEST_TIME, 'custom', 'n'));
     $form['clear']['clear_day'] = uc_select_day(NULL, \Drupal::service('date.formatter')->format(REQUEST_TIME, 'custom', 'j'));
     $form['clear']['clear_year'] = uc_select_year(NULL, \Drupal::service('date.formatter')->format(REQUEST_TIME, 'custom', 'Y'), \Drupal::service('date.formatter')->format(REQUEST_TIME, 'custom', 'Y'), \Drupal::service('date.formatter')->format(REQUEST_TIME, 'custom', 'Y') + 1);
     $form['actions'] = array('#type' => 'actions');
     $form['actions']['submit'] = array('#type' => 'submit', '#value' => $this->t('Receive check'));
     return $form;
 }
示例#9
0
 /**
  * Displays the taxes for an order.
  */
 function calculate($uc_order)
 {
     // Fetch the taxes for the order.
     $data = uc_cybersource_uc_calculate_tax($uc_order);
     // Build an item list for the taxes.
     $items = array();
     foreach ($data as $tax) {
         $items[] = t('@tax: @amount', array('@tax' => $tax['name'], '@amount' => uc_currency_format($tax['amount'])));
     }
     // Display a message if there are no taxes.
     if (empty($items)) {
         $items[] = t('No taxes returned for this order.');
     }
     return array('#theme' => 'item_list', '#items' => $items);
 }
示例#10
0
 /**
  * Tests the catalog display and "buy it now" button.
  */
 public function testCatalog()
 {
     $this->drupalLogin($this->adminUser);
     $term = $this->createTerm();
     $product = $this->createProduct(array('taxonomy_catalog' => array($term->id())));
     $this->drupalGet('catalog');
     $this->assertTitle('Catalog | Drupal');
     $this->assertLink($term->label(), 0, 'The term is listed in the catalog.');
     $this->clickLink($term->label());
     $this->assertTitle($term->label() . ' | Drupal');
     $this->assertLink($product->label(), 0, 'The product is listed in the catalog.');
     $this->assertText($product->model->value, 'The product SKU is shown in the catalog.');
     $this->assertText(uc_currency_format($product->price->value), 'The product price is shown in the catalog.');
     $this->drupalPostForm(NULL, array(), 'Add to cart');
     $this->assertText($product->label() . ' added to your shopping cart.');
 }
 /**
  * {@inheritdoc}
  */
 public function buildForm(array $form, FormStateInterface $form_state, $attributes = NULL)
 {
     $form['attributes'] = array('#type' => 'table', '#header' => array($this->t('Remove'), $this->t('Name'), $this->t('Label'), $this->t('Default'), $this->t('Required'), $this->t('List position'), $this->t('Display')), '#empty' => $this->t('No attributes available.'), '#tabledrag' => array(array('action' => 'order', 'relationship' => 'sibling', 'group' => 'uc-attribute-table-ordering')));
     foreach ($attributes as $aid => $attribute) {
         $option = isset($attribute->options[$attribute->default_option]) ? $attribute->options[$attribute->default_option] : NULL;
         $form['attributes'][$aid]['#attributes']['class'][] = 'draggable';
         $form['attributes'][$aid]['remove'] = array('#type' => 'checkbox', '#title' => $this->t('Remove'), '#title_display' => 'invisible');
         $form['attributes'][$aid]['name'] = array('#markup' => $attribute->name);
         $form['attributes'][$aid]['label'] = array('#type' => 'textfield', '#title' => $this->t('Label'), '#title_display' => 'invisible', '#default_value' => empty($attribute->label) ? $attribute->name : $attribute->label, '#size' => 20);
         $form['attributes'][$aid]['option'] = array('#markup' => $option ? $option->name . ' (' . uc_currency_format($option->price) . ')' : $this->t('n/a'));
         $form['attributes'][$aid]['required'] = array('#type' => 'checkbox', '#title' => $this->t('Required'), '#title_display' => 'invisible', '#default_value' => $attribute->required);
         $form['attributes'][$aid]['ordering'] = array('#type' => 'weight', '#title' => $this->t('List position'), '#title_display' => 'invisible', '#default_value' => $attribute->ordering, '#attributes' => array('class' => array('uc-attribute-table-ordering')));
         $form['attributes'][$aid]['display'] = array('#type' => 'select', '#title' => $this->t('Display'), '#title_display' => 'invisible', '#default_value' => $attribute->display, '#options' => _uc_attribute_display_types());
     }
     $form['actions'] = array('#type' => 'actions');
     $form['actions']['save'] = array('#type' => 'submit', '#value' => $this->t('Save changes'));
     return $form;
 }
示例#12
0
 public function testProductNodeForm()
 {
     $this->drupalGet('node/add/product');
     $fields = array('model[0][value]', 'price[0][value]', 'shippable[value]', 'weight[0][value]', 'weight[0][units]', 'dimensions[0][length]', 'dimensions[0][width]', 'dimensions[0][height]', 'dimensions[0][units]', 'files[uc_product_image_0][]');
     foreach ($fields as $field) {
         $this->assertFieldByName($field, NULL);
     }
     $title_key = 'title[0][value]';
     $body_key = 'body[0][value]';
     // Make a node with those fields.
     $edit = array($title_key => $this->randomMachineName(32), $body_key => $this->randomMachineName(64), 'model[0][value]' => $this->randomMachineName(8), 'price[0][value]' => mt_rand(1, 150), 'shippable[value]' => mt_rand(0, 1), 'weight[0][value]' => mt_rand(1, 50), 'weight[0][units]' => array_rand(array('lb' => t('Pounds'), 'kg' => t('Kilograms'), 'oz' => t('Ounces'), 'g' => t('Grams'))), 'dimensions[0][length]' => mt_rand(1, 50), 'dimensions[0][width]' => mt_rand(1, 50), 'dimensions[0][height]' => mt_rand(1, 50), 'dimensions[0][units]' => array_rand(array('in' => t('Inches'), 'ft' => t('Feet'), 'cm' => t('Centimeters'), 'mm' => t('Millimeters'))));
     $this->drupalPostForm('node/add/product', $edit, 'Save');
     $this->assertText(t('Product @title has been created.', ['@title' => $edit[$title_key]]), 'Product created.');
     $this->assertText($edit[$body_key], 'Product body found.');
     $this->assertText($edit['model[0][value]'], 'Product model found.');
     $this->assertNoUniqueText(uc_currency_format($edit['price[0][value]']), 'Product price found.');
     $this->assertText(uc_weight_format($edit['weight[0][value]'], $edit['weight[0][units]']), 'Product weight found.');
     $this->assertText(uc_length_format($edit['dimensions[0][length]'], $edit['dimensions[0][units]']), 'Product length found.');
     $this->assertText(uc_length_format($edit['dimensions[0][width]'], $edit['dimensions[0][units]']), 'Product width found.');
     $this->assertText(uc_length_format($edit['dimensions[0][height]'], $edit['dimensions[0][units]']), 'Product height found.');
     $elements = $this->xpath('//body[contains(@class, "uc-product-node")]');
     $this->assertEqual(count($elements), 1, 'Product page contains body CSS class.');
     // Update the node fields.
     $edit = array($title_key => $this->randomMachineName(32), $body_key => $this->randomMachineName(64), 'model[0][value]' => $this->randomMachineName(8), 'price[0][value]' => mt_rand(1, 150), 'shippable[value]' => mt_rand(0, 1), 'weight[0][value]' => mt_rand(1, 50), 'weight[0][units]' => array_rand(array('lb' => t('Pounds'), 'kg' => t('Kilograms'), 'oz' => t('Ounces'), 'g' => t('Grams'))), 'dimensions[0][length]' => mt_rand(1, 50), 'dimensions[0][width]' => mt_rand(1, 50), 'dimensions[0][height]' => mt_rand(1, 50), 'dimensions[0][units]' => array_rand(array('in' => t('Inches'), 'ft' => t('Feet'), 'cm' => t('Centimeters'), 'mm' => t('Millimeters'))));
     $this->clickLink('Edit');
     $this->drupalPostForm(NULL, $edit, 'Save');
     $this->assertText(t('Product @title has been updated.', ['@title' => $edit[$title_key]]), 'Product updated.');
     $this->assertText($edit[$body_key], 'Updated product body found.');
     $this->assertText($edit['model[0][value]'], 'Updated product model found.');
     $this->assertNoUniqueText(uc_currency_format($edit['price[0][value]']), 'Updated product price found.');
     $this->assertText(uc_weight_format($edit['weight[0][value]'], $edit['weight[0][units]']), 'Product weight found.');
     $this->assertText(uc_length_format($edit['dimensions[0][length]'], $edit['dimensions[0][units]']), 'Product length found.');
     $this->assertText(uc_length_format($edit['dimensions[0][width]'], $edit['dimensions[0][units]']), 'Product width found.');
     $this->assertText(uc_length_format($edit['dimensions[0][height]'], $edit['dimensions[0][units]']), 'Product height found.');
     $this->clickLink('Delete');
     $this->drupalPostForm(NULL, [], 'Delete');
     $this->assertText(t('Product @title has been deleted.', ['@title' => $edit[$title_key]]), 'Product deleted.');
 }
示例#13
0
 /**
  * Test cart block functionality.
  */
 public function testCartBlock()
 {
     // Test the empty cart block.
     $this->drupalGet('');
     $this->assertRaw('empty');
     $this->assertText('There are no products in your shopping cart.');
     $this->assertText('0 Items');
     $this->assertText('Total: $0.00');
     $this->assertNoLink('View cart');
     $this->assertNoLink('Checkout');
     // Test the cart block with an item.
     $this->addToCart($this->product);
     $this->drupalGet('');
     $this->assertNoRaw('empty');
     $this->assertNoText('There are no products in your shopping cart.');
     $this->assertText('1 ×');
     $this->assertText($this->product->label());
     $this->assertNoUniqueText(uc_currency_format($this->product->price->value));
     $this->assertText('1 Item');
     $this->assertText('Total: ' . uc_currency_format($this->product->price->value));
     $this->assertLink('View cart');
     $this->assertLink('Checkout');
 }
示例#14
0
 /**
  * {@inheritdoc}
  */
 public function view(OrderInterface $order, $view_mode)
 {
     if ($view_mode != 'customer') {
         $build['balance'] = array('#markup' => $this->t('Balance: @balance', ['@balance' => uc_currency_format(uc_payment_balance($order))]));
         $account = \Drupal::currentUser();
         if ($account->hasPermission('view payments')) {
             $build['view_payments'] = array('#type' => 'link', '#prefix' => ' (', '#title' => $this->t('View'), '#url' => Url::fromRoute('uc_payments.order_payments', ['uc_order' => $order->id()]), '#suffix' => ')');
         }
         $method = \Drupal::service('plugin.manager.uc_payment.method')->createFromOrder($order);
         $build['method'] = array('#markup' => $this->t('Method: @payment_method', ['@payment_method' => $method->cartReviewTitle()]), '#prefix' => '<br />');
         $method_output = $method->orderView($order);
         if (!empty($method_output)) {
             $build['output'] = $method_output + array('#prefix' => '<br />');
         }
     } else {
         $method = \Drupal::service('plugin.manager.uc_payment.method')->createFromOrder($order);
         $build['method'] = array('#markup' => $this->t('Method: @payment_method', ['@payment_method' => $method->cartReviewTitle()]));
         $method_output = $method->customerView($order);
         if (!empty($method_output)) {
             $build['output'] = $method_output + array('#prefix' => '<br />');
         }
     }
     return $build;
 }
示例#15
0
 /**
  * {@inheritdoc}
  */
 public function buildForm(array $form, FormStateInterface $form_state)
 {
     $config = $this->config('uc_store.settings');
     $form['store'] = array('#type' => 'vertical_tabs');
     $form['basic'] = array('#type' => 'details', '#title' => $this->t('Basic information'), '#group' => 'store');
     $form['basic']['uc_store_name'] = array('#type' => 'textfield', '#title' => $this->t('Store name'), '#default_value' => uc_store_name());
     $form['basic']['uc_store_email'] = array('#type' => 'email', '#title' => $this->t('E-mail address'), '#size' => 32, '#required' => TRUE, '#default_value' => uc_store_email());
     $form['basic']['uc_store_email_include_name'] = array('#type' => 'checkbox', '#title' => $this->t('Include the store name in the "From" line of store e-mails.'), '#description' => $this->t('May not be available on all server configurations. Turn off if this causes problems.'), '#default_value' => $config->get('mail_include_name'));
     $form['basic']['uc_store_phone'] = array('#type' => 'tel', '#title' => $this->t('Phone number'), '#default_value' => $config->get('phone'));
     $form['basic']['uc_store_fax'] = array('#type' => 'tel', '#title' => $this->t('Fax number'), '#default_value' => $config->get('fax'));
     $form['basic']['uc_store_help_page'] = array('#type' => 'textfield', '#title' => $this->t('Store help page'), '#description' => $this->t('The Drupal page for the store help link.'), '#default_value' => $config->get('help_page'), '#size' => 32, '#field_prefix' => $this->url('<front>', [], ['absolute' => TRUE]));
     $form['address'] = array('#type' => 'details', '#title' => $this->t('Store address'), '#group' => 'store');
     $form['address']['address'] = array('#type' => 'uc_address', '#default_value' => array('uc_store_street1' => $config->get('address.street1'), 'uc_store_street2' => $config->get('address.street2'), 'uc_store_city' => $config->get('address.city'), 'uc_store_zone' => $config->get('address.zone'), 'uc_store_country' => $form_state->hasValue('uc_store_country') ? $form_state->getValue('uc_store_country') : $config->get('address.country'), 'uc_store_postal_code' => $config->get('address.postal_code')), '#required' => FALSE, '#key_prefix' => 'uc_store');
     $form['currency'] = array('#type' => 'details', '#title' => $this->t('Currency format'), '#group' => 'store');
     $form['currency']['uc_currency_code'] = array('#type' => 'textfield', '#title' => $this->t('Currency code'), '#description' => $this->t('While not used directly in formatting, the currency code is used by other modules as the primary currency for your site.  Enter here your three character <a href=":url">ISO 4217</a> currency code.', [':url' => Url::fromUri('http://en.wikipedia.org/wiki/ISO_4217#Active_codes')->toString()]), '#default_value' => $config->get('currency.code'), '#maxlength' => 3, '#size' => 5);
     $form['currency']['example'] = array('#type' => 'textfield', '#title' => $this->t('Current format'), '#value' => uc_currency_format(1000.1234), '#disabled' => TRUE, '#size' => 10);
     $form['currency']['uc_currency_sign'] = array('#type' => 'textfield', '#title' => $this->t('Currency sign'), '#default_value' => $config->get('currency.symbol'), '#size' => 10, '#maxlength' => 10);
     $form['currency']['uc_sign_after_amount'] = array('#type' => 'checkbox', '#title' => $this->t('Display currency sign after amount.'), '#default_value' => $config->get('currency.symbol_after'));
     $form['currency']['uc_currency_thou'] = array('#type' => 'textfield', '#title' => $this->t('Thousands marker'), '#default_value' => $config->get('currency.thousands_marker'), '#size' => 10, '#maxlength' => 10);
     $form['currency']['uc_currency_dec'] = array('#type' => 'textfield', '#title' => $this->t('Decimal marker'), '#default_value' => $config->get('currency.decimal_marker'), '#size' => 10, '#maxlength' => 10);
     $form['currency']['uc_currency_prec'] = array('#type' => 'select', '#title' => $this->t('Number of decimal places'), '#options' => array(0 => 0, 1 => 1, 2 => 2), '#default_value' => $config->get('currency.precision'));
     $form['weight'] = array('#type' => 'details', '#title' => $this->t('Weight format'), '#group' => 'store');
     $form['weight']['uc_weight_unit'] = array('#type' => 'select', '#title' => $this->t('Default weight units'), '#default_value' => $config->get('weight.units'), '#options' => array('lb' => $this->t('Pounds'), 'oz' => $this->t('Ounces'), 'kg' => $this->t('Kilograms'), 'g' => $this->t('Grams')));
     $form['weight']['uc_weight_thou'] = array('#type' => 'textfield', '#title' => $this->t('Thousands marker'), '#default_value' => $config->get('weight.thousands_marker'), '#size' => 10, '#maxlength' => 10);
     $form['weight']['uc_weight_dec'] = array('#type' => 'textfield', '#title' => $this->t('Decimal marker'), '#default_value' => $config->get('weight.decimal_marker'), '#size' => 10, '#maxlength' => 10);
     $form['weight']['uc_weight_prec'] = array('#type' => 'select', '#title' => $this->t('Number of decimal places'), '#options' => array(0 => 0, 1 => 1, 2 => 2), '#default_value' => $config->get('weight.precision'));
     $form['length'] = array('#type' => 'details', '#title' => $this->t('Length format'), '#group' => 'store');
     $form['length']['uc_length_unit'] = array('#type' => 'select', '#title' => $this->t('Default length units'), '#default_value' => $config->get('length.units'), '#options' => array('in' => $this->t('Inches'), 'ft' => $this->t('Feet'), 'cm' => $this->t('Centimeters'), 'mm' => $this->t('Millimeters')));
     $form['length']['uc_length_thou'] = array('#type' => 'textfield', '#title' => $this->t('Thousands marker'), '#default_value' => $config->get('length.thousands_marker'), '#size' => 10, '#maxlength' => 10);
     $form['length']['uc_length_dec'] = array('#type' => 'textfield', '#title' => $this->t('Decimal marker'), '#default_value' => $config->get('length.decimal_marker'), '#size' => 10, '#maxlength' => 10);
     $form['length']['uc_length_prec'] = array('#type' => 'select', '#title' => $this->t('Number of decimal places'), '#options' => array(0 => 0, 1 => 1, 2 => 2), '#default_value' => $config->get('length.precision'));
     $form['display'] = array('#type' => 'details', '#title' => $this->t('Display settings'), '#group' => 'store');
     $form['display']['uc_customer_list_address'] = array('#type' => 'radios', '#title' => $this->t('Primary customer address'), '#description' => $this->t('Select the address to be used on customer lists and summaries.'), '#options' => array('billing' => $this->t('Billing address'), 'shipping' => $this->t('Shipping address')), '#default_value' => $config->get('customer_address'));
     $form['display']['uc_order_capitalize_addresses'] = array('#type' => 'checkbox', '#title' => $this->t('Capitalize address on order screens'), '#default_value' => $config->get('capitalize_address'));
     return parent::buildForm($form, $form_state);
 }
示例#16
0
 [order-shipping-method]
</p>

<p>
<?php 
echo t('Products:');
?>
<br />
<?php 
foreach ($products as $product) {
    ?>
- <?php 
    echo $product->qty;
    ?>
 x <?php 
    echo $product->title . ' - ' . uc_currency_format($product->price * $product->qty);
    ?>
<br />
&nbsp;&nbsp;<?php 
    echo t('Model: ') . $product->model;
    ?>
<br />
    <?php 
    if (is_array($product->data['attributes']) && count($product->data['attributes']) > 0) {
        ?>
    <?php 
        foreach ($product->data['attributes'] as $key => $value) {
            echo '&nbsp;&nbsp;' . $key . ': ' . $value . '<br />';
        }
        ?>
    <?php 
示例#17
0
 /**
  * Tests that product in cart has the selected attribute option.
  */
 public function testAttributeAddToCart()
 {
     for ($display = 0; $display <= 3; ++$display) {
         // Set up an attribute.
         $data = array('display' => $display);
         $attribute = $this->createAttribute($data);
         if ($display) {
             // Give the attribute an option.
             $option = $this->createAttributeOption(array('aid' => $attribute->aid));
         }
         $attribute = uc_attribute_load($attribute->aid);
         // Put the attribute on a product.
         $product = $this->createProduct();
         uc_attribute_subject_save($attribute, 'product', $product->id(), TRUE);
         // Add the product to the cart.
         if ($display == 3) {
             $edit = array("attributes[{$attribute->aid}][{$option->oid}]" => $option->oid);
         } elseif (isset($option)) {
             $edit = array("attributes[{$attribute->aid}]" => $option->oid);
         } else {
             $option = new \stdClass();
             $option->name = self::randomMachineName();
             $option->price = 0;
             $edit = array("attributes[{$attribute->aid}]" => $option->name);
         }
         $this->addToCart($product, $edit);
         $this->assertText("{$attribute->label}: {$option->name}", 'Option selected on cart item.');
         $this->assertText(uc_currency_format($product->price->value + $option->price), 'Product has adjusted price.');
     }
 }
示例#18
0
					</div>
					<?php 
}
?>
				</div>
				<div id="product_header">
					<font color="#FF7400">
					<?php 
print $field_heading[0]['view'];
?>
				</div>
				<div id="buy">
					<div id="price">
						<font color="#777777">
						<?php 
print uc_currency_format($node->sell_price);
?>
					</div>

					<div id="cartButtons">
						<font color="#777777">
						<?php 
// add to cart buttons
?>
						<?php 
print $node->content['add_to_cart']["#value"];
?>
					</div>
				</div>
				<div id="product_text">
					<?php 
<?php

/**
 * @file
 * definition of ubercart-funds-account-withdrawals.tpl.php.
 */
$user = user_load($variables['uid']);
$transactions = db_query("SELECT * FROM {ubercart_funds_withdraw_requests} WHERE uid='{$user->uid}' AND status='Pending Approval'");
$methods = ubercart_funds_get_enabled_withdrawal_methods();
/*commerce_funds_get_enabled_withdrawal_methods();*/
$header = array(t('Time'), t('Amount'), t('Method'), t('Status'));
$rows = array();
foreach ($transactions as $transaction) {
    $rows[] = array(date('d/m/Y   g:i:s A', $transaction->created), uc_currency_format($transaction->amount / 100), $methods[$transaction->method], $transaction->status);
}
print t('<h2>Pending Withdrawals</h2>');
print theme('table', array('header' => $header, 'rows' => $rows));
$transactions = db_query("SELECT * FROM {ubercart_funds_withdraw_requests} WHERE uid='{$user->uid}' AND status!='Pending Approval'");
$header = array(t('Time'), t('Amount'), t('Method'), t('Status'));
$rows = array();
foreach ($transactions as $transaction) {
    $rows[] = array(date('d/m/Y   g:i:s A', $transaction->created), uc_currency_format($transaction->amount / 100), $methods[$transaction->method], $transaction->status == 'Declined' ? $transaction->status . '<br><br>Reason: ' . $transaction->notes : $transaction->status);
}
print t('<h2>Previous Requests</h2>');
print theme('table', array('header' => $header, 'rows' => $rows));
?>

示例#20
0
 public function testTaxDisplay()
 {
     $this->drupalLogin($this->adminUser);
     // Enable a payment method for the payment preview checkout pane.
     $edit = array('methods[check][status]' => 1);
     $this->drupalPostForm('admin/store/config/payment', $edit, t('Save configuration'));
     // Create a 20% inclusive tax rate.
     $rate = (object) array('name' => $this->randomMachineName(8), 'rate' => 0.2, 'taxed_product_types' => array('product'), 'taxed_line_items' => array(), 'weight' => 0, 'shippable' => 0, 'display_include' => 1, 'inclusion_text' => '');
     uc_tax_rate_save($rate);
     $this->drupalGet('admin/store/config/taxes');
     $this->assertText($rate->name, 'Tax was saved successfully.');
     // $this->drupalGet("admin/store/config/taxes/manage/uc_tax_$rate->id");
     // $this->assertText(t('Conditions'), 'Rules configuration linked to tax.');
     $this->addToCart($this->product);
     // Manually step through checkout. $this->checkout() doesn't know about taxes.
     $this->drupalPostForm('cart', array(), 'Checkout');
     $this->assertText(t('Enter your billing address and information here.'), 'Viewed cart page: Billing pane has been displayed.');
     $this->assertRaw($rate->name, 'Tax line item displayed.');
     $this->assertRaw(uc_currency_format($rate->rate * $this->product->price->value), 'Correct tax amount displayed.');
     // Submit the checkout page.
     $edit = $this->populateCheckoutForm();
     $this->drupalPostForm('cart/checkout', $edit, t('Review order'));
     $this->assertRaw(t('Your order is almost complete.'));
     $this->assertRaw($rate->name, 'Tax line item displayed.');
     $this->assertRaw(uc_currency_format($rate->rate * $this->product->price->value), 'Correct tax amount displayed.');
     // Complete the review page.
     $this->drupalPostForm(NULL, array(), t('Submit order'));
     $order_ids = \Drupal::entityQuery('uc_order')->condition('delivery_first_name', $edit['panes[delivery][first_name]'])->execute();
     $order_id = reset($order_ids);
     if ($order_id) {
         $this->pass(SafeMarkup::format('Order %order_id has been created', ['%order_id' => $order_id]));
         $this->drupalGet('admin/store/orders/' . $order_id . '/edit');
         $this->assertTaxLineCorrect($this->loadTaxLine($order_id), $rate->rate, 'on initial order load');
         $this->drupalPostForm('admin/store/orders/' . $order_id . '/edit', array(), t('Save changes'));
         $this->assertText(t('Order changes saved.'));
         $this->assertTaxLineCorrect($this->loadTaxLine($order_id), $rate->rate, 'after saving order');
         // Change tax rate and ensure order doesn't change.
         $oldrate = $rate->rate;
         $rate->rate = 0.1;
         $rate = uc_tax_rate_save($rate);
         // Save order because tax changes are only updated on save.
         $this->drupalPostForm('admin/store/orders/' . $order_id . '/edit', array(), t('Save changes'));
         $this->assertText(t('Order changes saved.'));
         $this->assertTaxLineCorrect($this->loadTaxLine($order_id), $oldrate, 'after rate change');
         // Change taxable products and ensure order doesn't change.
         $class = $this->createProductClass();
         $rate->taxed_product_types = array($class->getEntityTypeId());
         uc_tax_rate_save($rate);
         // entity_flush_caches();
         $this->drupalPostForm('admin/store/orders/' . $order_id . '/edit', array(), t('Save changes'));
         $this->assertText(t('Order changes saved.'));
         $this->assertTaxLineCorrect($this->loadTaxLine($order_id), $oldrate, 'after applicable product change');
         // Change order Status back to in_checkout and ensure tax-rate changes now update the order.
         \Drupal\uc_order\Entity\Order::load($order_id)->setStatusId('in_checkout')->save();
         $this->drupalPostForm('admin/store/orders/' . $order_id . '/edit', array(), t('Save changes'));
         $this->assertText(t('Order changes saved.'));
         $this->assertFalse($this->loadTaxLine($order_id), 'The tax line was removed from the order when order status changed back to in_checkout.');
         // Restore taxable product and ensure new tax is added.
         $rate->taxed_product_types = array('product');
         uc_tax_rate_save($rate);
         $this->drupalPostForm('admin/store/orders/' . $order_id . '/edit', array(), t('Save changes'));
         $this->assertText(t('Order changes saved.'));
         $this->assertTaxLineCorrect($this->loadTaxLine($order_id), $rate->rate, 'when order status changed back to in_checkout');
     } else {
         $this->fail('No order was created.');
     }
 }
 /**
  * {@inheritdoc}
  */
 public function review(OrderInterface $order)
 {
     $line_items = $order->getDisplayLineItems();
     foreach ($line_items as $line_item) {
         $review[] = array('title' => $line_item['title'], 'data' => uc_currency_format($line_item['amount']));
     }
     $method = $this->paymentMethodManager->createFromOrder($order);
     $review[] = array('border' => 'top', 'title' => $this->t('Paying by'), 'data' => $method->cartReviewTitle());
     $result = $method->cartReview($order);
     if (is_array($result)) {
         $review = array_merge($review, $result);
     }
     return $review;
 }
示例#22
0
        ?>
                          <tr>
                            <td valign="top" nowrap="nowrap">
                              <b><?php 
        echo $product->qty;
        ?>
 x </b>
                            </td>
                            <td width="98%">
                              <b><?php 
        echo $product->title . ' - ' . uc_price($price_info, $context, array(), 'formatted');
        ?>
</b>
                              <?php 
        if ($product->qty > 1) {
            echo t('(!price each)', array('!price' => uc_currency_format($product->price)));
        }
        ?>
                              <br />
                              <?php 
        echo t('SKU: ') . $product->model;
        ?>
<br />
                              <?php 
        if (is_array($product->data['attributes']) && count($product->data['attributes']) > 0) {
            ?>
                              <?php 
            foreach ($product->data['attributes'] as $key => $value) {
                echo '<li>' . $key . ': ' . $value . '</li>';
            }
            ?>
 /**
  * {@inheritdoc}
  */
 public function buildRedirectForm(array $form, FormStateInterface $form_state, OrderInterface $order = NULL)
 {
     $shipping = 0;
     foreach ($order->line_items as $item) {
         if ($item['type'] == 'shipping') {
             $shipping += $item['amount'];
         }
     }
     $tax = 0;
     if (\Drupal::moduleHandler()->moduleExists('uc_tax')) {
         foreach (uc_tax_calculate($order) as $tax_item) {
             $tax += $tax_item->amount;
         }
     }
     $address = $order->getAddress($this->configuration['wps_address_selection']);
     $country = $address->country;
     $phone = '';
     for ($i = 0; $i < strlen($address->phone); $i++) {
         if (is_numeric($address->phone[$i])) {
             $phone .= $address->phone[$i];
         }
     }
     /**
      * night_phone_a: The area code for U.S. phone numbers, or the country code
      *                for phone numbers outside the U.S.
      * night_phone_b: The three-digit prefix for U.S. phone numbers, or the
      *                entire phone number for phone numbers outside the U.S.,
      *                excluding country code.
      * night_phone_c: The four-digit phone number for U.S. phone numbers.
      *                (Not Used for UK numbers)
      */
     if ($country == 'US' || $country == 'CA') {
         $phone = substr($phone, -10);
         $phone_a = substr($phone, 0, 3);
         $phone_b = substr($phone, 3, 3);
         $phone_c = substr($phone, 6, 4);
     } else {
         $phone_a = $phone_b = $phone_c = '';
     }
     $data = array('cmd' => '_cart', 'charset' => 'utf-8', 'notify_url' => Url::fromRoute('uc_paypal.ipn', [], ['absolute' => TRUE])->toString(), 'cancel_return' => Url::fromRoute('uc_cart.checkout_review', [], ['absolute' => TRUE])->toString(), 'no_note' => 1, 'no_shipping' => $this->configuration['wps_no_shipping'], 'return' => Url::fromRoute('uc_paypal.wps_complete', ['uc_order' => $order->id()], ['absolute' => TRUE])->toString(), 'rm' => 1, 'currency_code' => $order->getCurrency(), 'handling_cart' => uc_currency_format($shipping, FALSE, FALSE, '.'), 'invoice' => $order->id() . '-' . \Drupal::service('uc_cart.manager')->get()->getId(), 'tax_cart' => uc_currency_format($tax, FALSE, FALSE, '.'), 'business' => $this->configuration['wps_email'], 'upload' => 1, 'lc' => $this->configuration['wps_language'], 'address1' => substr($address->street1, 0, 100), 'address2' => substr($address->street2, 0, 100), 'city' => substr($address->city, 0, 40), 'country' => $country, 'email' => $order->getEmail(), 'first_name' => substr($address->first_name, 0, 32), 'last_name' => substr($address->last_name, 0, 64), 'state' => $address->zone, 'zip' => $address->postal_code, 'night_phone_a' => $phone_a, 'night_phone_b' => $phone_b, 'night_phone_c' => $phone_c);
     if ($this->configuration['wps_address_override']) {
         $data['address_override'] = 1;
     }
     // Account for stores that just want to authorize funds instead of capture.
     if ($this->configuration['wps_payment_action'] == 'Authorization') {
         $data['paymentaction'] = 'authorization';
     }
     if ($this->configuration['wps_submit_method'] == 'itemized') {
         // List individual items.
         $i = 0;
         foreach ($order->products as $item) {
             $i++;
             $data['amount_' . $i] = uc_currency_format($item->price, FALSE, FALSE, '.');
             $data['item_name_' . $i] = $item->title;
             $data['item_number_' . $i] = $item->model;
             $data['quantity_' . $i] = $item->qty;
             // PayPal will only display the first two...
             if (!empty($item->data['attributes']) && count($item->data['attributes']) > 0) {
                 $o = 0;
                 foreach ($item->data['attributes'] as $name => $setting) {
                     $data['on' . $o . '_' . $i] = $name;
                     $data['os' . $o . '_' . $i] = implode(', ', (array) $setting);
                     $o++;
                 }
             }
         }
         // Apply discounts (negative amount line items). For example, this handles
         // line items created by uc_coupon.
         $discount = 0;
         foreach ($order->line_items as $item) {
             if ($item['amount'] < 0) {
                 // The minus sign is not an error! The discount amount must be positive.
                 $discount -= $item['amount'];
             }
         }
         if ($discount != 0) {
             $data['discount_amount_cart'] = $discount;
         }
     } else {
         // List the whole cart as a single item to account for fees/discounts.
         $data['amount_1'] = uc_currency_format($order->getTotal() - $shipping - $tax, FALSE, FALSE, '.');
         $data['item_name_1'] = $this->t('Order @order_id at @store', ['@order_id' => $order->id(), '@store' => uc_store_name()]);
     }
     $form['#action'] = $this->configuration['wps_server'];
     foreach ($data as $name => $value) {
         if (!empty($value)) {
             $form[$name] = array('#type' => 'hidden', '#value' => $value);
         }
     }
     $form['actions'] = array('#type' => 'actions');
     $form['actions']['submit'] = array('#type' => 'submit', '#value' => $this->t('Submit order'));
     return $form;
 }
		  <?php 
    }
    ?>
        </div>
	  <?php 
}
?>
      <div class="prices">
	    <?php 
if ($node->field_sale_price[0]['value']) {
    print '<div class="pp-msrp">' . t('MSRP') . ': <span class="msrprice">' . uc_currency_format($node->list_price) . '</span></div>';
    print '<div class="pp-pr">' . t('Price') . ': <span class="ppprice">' . uc_currency_format($node->sell_price) . '</span></div>';
    print '<div class="pp-se">' . t('Sale price') . ': <span class="theprice">' . uc_currency_format(cpo_isr_special_get_price_display($node)) . '</span></div>';
} else {
    print '<div class="pp-msrp">' . t('MSRP') . ': <span class="msrprice">' . uc_currency_format($node->list_price) . '</span></div>';
    print '<div class="pp-se">' . t('Sale price') . ': <span class="theprice">' . uc_currency_format(cpo_isr_special_get_price_display($node)) . '</span></div>';
}
?>

	  </div>
	  <?php 
if (arg(0) != 'print' && $node->field_prod_offline[0]['value'] != 'TRUE') {
    ?>
	  <div class="problem"><?php 
    print variable_get('cpo_isr_special_product_text', t('<a href="http://www.israel-catalog.com/help">Have a problem? Click here</a>'));
    ?>
</div>
	  <?php 
}
?>
	  
示例#25
0
 /**
  * {@inheritdoc}
  */
 public function getDescription()
 {
     return $this->t('@base_rate + @product_rate per @unit', ['@base_rate' => uc_currency_format($this->configuration['base_rate']), '@product_rate' => uc_currency_format($this->configuration['product_rate']), '@unit' => \Drupal::config('uc_store.settings')->get('weight.units')]);
 }
示例#26
0
 public function testProductKitMutability()
 {
     $this->drupalLogin($this->adminUser);
     // Create some test products and prepare a kit.
     $products = array();
     for ($i = 0; $i < 3; $i++) {
         $products[$i] = $this->createProduct();
     }
     $kit_data = array('type' => 'product_kit', 'title[0][value]' => $this->randomMachineName(32), 'products' => array($products[0]->id(), $products[1]->id(), $products[2]->id()));
     // Test kits with no listing.
     $kit_data['mutable'] = UC_PRODUCT_KIT_UNMUTABLE_NO_LIST;
     $kit = $this->drupalCreateNode($kit_data);
     $this->drupalGet('node/' . $kit->id());
     $this->assertText($kit->label(), 'Product kit title found.');
     $this->assertNoText($products[0]->label(), 'Product 1 title not shown.');
     $this->assertNoText($products[1]->label(), 'Product 2 title not shown.');
     $this->assertNoText($products[2]->label(), 'Product 3 title not shown.');
     $this->addToCart($kit);
     $this->drupalGet('cart');
     $this->assertText($kit->label(), 'Product kit title found.');
     $this->assertNoText($products[0]->label(), 'Product 1 title not shown.');
     $this->assertNoText($products[1]->label(), 'Product 2 title not shown.');
     $this->assertNoText($products[2]->label(), 'Product 3 title not shown.');
     $total = $products[0]->price->value + $products[1]->price->value + $products[2]->price->value;
     $this->assertText('Subtotal: ' . uc_currency_format($total), 'Product kit total found.');
     $qty = mt_rand(2, 10);
     $this->drupalPostForm(NULL, array('items[2][qty]' => $qty), 'Update cart');
     $this->assertText('Subtotal: ' . uc_currency_format($total * $qty), 'Updated product kit total found.');
     $this->drupalPostForm(NULL, array(), 'Remove');
     $this->assertText('There are no products in your shopping cart.');
     // Test kits with listing.
     $kit_data['mutable'] = UC_PRODUCT_KIT_UNMUTABLE_WITH_LIST;
     $kit = $this->drupalCreateNode($kit_data);
     $this->drupalGet('node/' . $kit->id());
     $this->assertText($kit->label(), 'Product kit title found.');
     $this->assertText($products[0]->label(), 'Product 1 title shown.');
     $this->assertText($products[1]->label(), 'Product 2 title shown.');
     $this->assertText($products[2]->label(), 'Product 3 title shown.');
     $this->addToCart($kit);
     $this->drupalGet('cart');
     $this->assertText($kit->label(), 'Product kit title found.');
     $this->assertText($products[0]->label(), 'Product 1 title shown.');
     $this->assertText($products[1]->label(), 'Product 2 title shown.');
     $this->assertText($products[2]->label(), 'Product 3 title shown.');
     $total = $products[0]->price->value + $products[1]->price->value + $products[2]->price->value;
     $this->assertText('Subtotal: ' . uc_currency_format($total), 'Product kit total found.');
     $qty = mt_rand(2, 10);
     $this->drupalPostForm(NULL, array('items[2][qty]' => $qty), 'Update cart');
     $this->assertText('Subtotal: ' . uc_currency_format($total * $qty), 'Updated product kit total found.');
     $this->drupalPostForm(NULL, array(), 'Remove');
     $this->assertText('There are no products in your shopping cart.');
     // Test mutable kits.
     $kit_data['mutable'] = UC_PRODUCT_KIT_MUTABLE;
     $kit = $this->drupalCreateNode($kit_data);
     $this->drupalGet('node/' . $kit->id());
     $this->assertText($kit->label(), 'Product kit title found.');
     $this->assertText($products[0]->label(), 'Product 1 title shown.');
     $this->assertText($products[1]->label(), 'Product 2 title shown.');
     $this->assertText($products[2]->label(), 'Product 3 title shown.');
     $this->addToCart($kit);
     $this->drupalGet('cart');
     $this->assertNoText($kit->label(), 'Product kit title not shown.');
     $this->assertText($products[0]->label(), 'Product 1 title shown.');
     $this->assertText($products[1]->label(), 'Product 2 title shown.');
     $this->assertText($products[2]->label(), 'Product 3 title shown.');
     $total = $products[0]->price->value + $products[1]->price->value + $products[2]->price->value;
     $this->assertText('Subtotal: ' . uc_currency_format($total), 'Product kit total found.');
     $qty = array(mt_rand(2, 10), mt_rand(2, 10), mt_rand(2, 10));
     $edit = array('items[0][qty]' => $qty[0], 'items[1][qty]' => $qty[1], 'items[2][qty]' => $qty[2]);
     $this->drupalPostForm(NULL, $edit, 'Update cart');
     $total = $products[0]->price->value * $qty[0];
     $total += $products[1]->price->value * $qty[1];
     $total += $products[2]->price->value * $qty[2];
     $this->assertText('Subtotal: ' . uc_currency_format($total), 'Updated product kit total found.');
     $this->drupalPostForm(NULL, array(), 'Remove');
     $this->drupalPostForm(NULL, array(), 'Remove');
     $this->drupalPostForm(NULL, array(), 'Remove');
     $this->assertText('There are no products in your shopping cart.');
 }
示例#27
0
/**
 * Takes action when a payment is entered for an order.
 *
 * @param $order
 *   The order object.
 * @param $method
 *   The name of the payment method used.
 * @param $amount
 *   The value of the payment.
 * @param $account
 *   The user account that entered the order. When the payment is entered
 *   during checkout, this is probably the order's user. Otherwise, it is
 *   likely a store administrator.
 * @param $data
 *   Extra data associated with the transaction.
 * @param $comment
 *   Any comments from the user about the transaction.
 */
function hook_uc_payment_entered($order, $method, $amount, $account, $data, $comment)
{
    drupal_set_message(t('User @uid entered a @method payment of @amount for order @order_id.', array('@uid' => $account->uid, '@method' => $method, '@amount' => uc_currency_format($amount), '@order_id' => $order->order_id)));
}
 /**
  * Processes Instant Payment Notifications from PayPal.
  *
  * @param array $ipn
  *   The IPN data.
  */
 protected function processIpn($ipn)
 {
     $amount = $ipn['mc_gross'];
     $email = !empty($ipn['business']) ? $ipn['business'] : $ipn['receiver_email'];
     $txn_id = $ipn['txn_id'];
     if (!isset($ipn['invoice'])) {
         \Drupal::logger('uc_paypal')->error('IPN attempted with invalid order ID.');
         return;
     }
     // Extract order and cart IDs.
     $order_id = $ipn['invoice'];
     if (strpos($order_id, '-') > 0) {
         list($order_id, $cart_id) = explode('-', $order_id);
         \Drupal::service('session')->set('uc_cart_id', $cart_id);
     }
     $order = Order::load($order_id);
     if (!$order) {
         \Drupal::logger('uc_paypal')->error('IPN attempted for non-existent order @order_id.', ['@order_id' => $order_id]);
         return;
     }
     // @todo Send method name and order ID in the IPN URL?
     $config = \Drupal::service('plugin.manager.uc_payment.method')->createFromOrder($order)->getConfiguration();
     // Optionally log IPN details.
     if (!empty($config['wps_debug_ipn'])) {
         \Drupal::logger('uc_paypal')->notice('Receiving IPN at URL for order @order_id. <pre>@debug</pre>', ['@order_id' => $order_id, '@debug' => print_r($ipn, TRUE)]);
     }
     // Express Checkout IPNs may not have the WPS email stored. But if it is,
     // make sure that the right account is being paid.
     if (!empty($config['wps_email']) && Unicode::strtolower($email) != Unicode::strtolower($config['wps_email'])) {
         \Drupal::logger('uc_paypal')->error('IPN for a different PayPal account attempted.');
         return;
     }
     // Determine server.
     if (empty($data['test_ipn'])) {
         $host = 'https://www.paypal.com/cgi-bin/webscr';
     } else {
         $host = 'https://www.sandbox.paypal.com/cgi-bin/webscr';
     }
     // POST IPN data back to PayPal to validate.
     try {
         $response = \Drupal::httpClient()->request('POST', $host, ['form_params' => ['cmd' => '_notify-validate'] + $ipn]);
     } catch (TransferException $e) {
         \Drupal::logger('uc_paypal')->error('IPN validation failed with HTTP error %error.', ['%error' => $e->getMessage()]);
         return;
     }
     // Check IPN validation response to determine if the IPN was valid..
     if ($response->getBody() != 'VERIFIED') {
         \Drupal::logger('uc_paypal')->error('IPN transaction failed verification.');
         uc_order_comment_save($order_id, 0, $this->t('An IPN transaction failed verification for this order.'), 'admin');
         return;
     }
     // Check for a duplicate transaction ID.
     $duplicate = (bool) db_query_range('SELECT 1 FROM {uc_payment_paypal_ipn} WHERE txn_id = :id AND status <> :status', 0, 1, [':id' => $txn_id, ':status' => 'Pending'])->fetchField();
     if ($duplicate) {
         if ($order->getPaymentMethodId() != 'credit') {
             \Drupal::logger('uc_paypal')->notice('IPN transaction ID has been processed before.');
         }
         return;
     }
     db_insert('uc_payment_paypal_ipn')->fields(array('order_id' => $order_id, 'txn_id' => $txn_id, 'txn_type' => $ipn['txn_type'], 'mc_gross' => $amount, 'status' => $ipn['payment_status'], 'receiver_email' => $email, 'payer_email' => $ipn['payer_email'], 'received' => REQUEST_TIME))->execute();
     switch ($ipn['payment_status']) {
         case 'Canceled_Reversal':
             uc_order_comment_save($order_id, 0, $this->t('PayPal has canceled the reversal and returned @amount @currency to your account.', ['@amount' => uc_currency_format($amount, FALSE), '@currency' => $ipn['mc_currency']]), 'admin');
             break;
         case 'Completed':
             if (abs($amount - $order->getTotal()) > 0.01) {
                 \Drupal::logger('uc_paypal')->warning('Payment @txn_id for order @order_id did not equal the order total.', ['@txn_id' => $txn_id, '@order_id' => $order->id(), 'link' => Link::createFromRoute($this->t('view'), 'entity.uc_order.canonical', ['uc_order' => $order->id()])->toString()]);
             }
             $comment = $this->t('PayPal transaction ID: @txn_id', ['@txn_id' => $txn_id]);
             uc_payment_enter($order_id, 'paypal_wps', $amount, $order->getOwnerId(), NULL, $comment);
             uc_order_comment_save($order_id, 0, $this->t('PayPal IPN reported a payment of @amount @currency.', ['@amount' => uc_currency_format($amount, FALSE), '@currency' => $ipn['mc_currency']]));
             break;
         case 'Denied':
             uc_order_comment_save($order_id, 0, $this->t("You have denied the customer's payment."), 'admin');
             break;
         case 'Expired':
             uc_order_comment_save($order_id, 0, $this->t('The authorization has failed and cannot be captured.'), 'admin');
             break;
         case 'Failed':
             uc_order_comment_save($order_id, 0, $this->t("The customer's attempted payment from a bank account failed."), 'admin');
             break;
         case 'Pending':
             $order->setStatusId('paypal_pending')->save();
             uc_order_comment_save($order_id, 0, $this->t('Payment is pending at PayPal: @reason', ['@reason' => $this->pendingMessage($ipn['pending_reason'])]), 'admin');
             break;
             // You, the merchant, refunded the payment.
         // You, the merchant, refunded the payment.
         case 'Refunded':
             $comment = $this->t('PayPal transaction ID: @txn_id', ['@txn_id' => $txn_id]);
             uc_payment_enter($order_id, 'paypal_wps', $amount, $order->getOwnerId(), NULL, $comment);
             break;
         case 'Reversed':
             \Drupal::logger('uc_paypal')->error('PayPal has reversed a payment!');
             uc_order_comment_save($order_id, 0, $this->t('Payment has been reversed by PayPal: @reason', ['@reason' => $this->reversalMessage($ipn['reason_code'])]), 'admin');
             break;
         case 'Processed':
             uc_order_comment_save($order_id, 0, $this->t('A payment has been accepted.'), 'admin');
             break;
         case 'Voided':
             uc_order_comment_save($order_id, 0, $this->t('The authorization has been voided.'), 'admin');
             break;
     }
 }
 /**
  * {@inheritdoc}
  */
 public function getDescription()
 {
     return $this->t('@base_rate + @product_rate% per item', ['@base_rate' => uc_currency_format($this->configuration['base_rate']), '@product_rate' => $this->configuration['product_rate']]);
 }
<?php

/**
 * @file
 * definition of ubercart-funds-account-transactions.tpl.php.
 */
$user = user_load($variables['uid']);
$transactions = db_query("SELECT * FROM {ubercart_funds_transactions} WHERE uid='{$user->uid}'");
$header = array(t('Time'), t('Amount'), t('Transaction Type'), t('Details'));
$rows = array();
foreach ($transactions as $transaction) {
    if ($transaction->type == 'Transfer') {
        $to_user = user_load($transaction->reference);
        $rows[] = array(date('d/m/Y   g:i:s A', $transaction->created), uc_currency_format($transaction->amount / 100), $transaction->type, t('Transfer to: ') . $to_user->mail . '<br ><br>' . $transaction->notes);
    } elseif ($transaction->type == 'Escrow Payment') {
        $to_user = user_load($transaction->reference);
        $rows[] = array(date('d/m/Y   g:i:s A', $transaction->created), uc_currency_format($transaction->amount / 100), $transaction->type, t('Escrow allocated to: ') . $to_user->mail . '<br ><br>' . $transaction->notes);
    } else {
        $rows[] = array(date('d/m/Y   g:i:s A', $transaction->created), uc_currency_format($transaction->amount / 100), $transaction->type, $transaction->notes);
    }
}
print t('<h2>Your Transactions</h2>');
print theme('table', array('header' => $header, 'rows' => $rows));
?>