Beispiel #1
0
 /**
  * {@inheritdoc}
  */
 public function orderSubmit(OrderInterface $order)
 {
     if ($order->getTotal() >= 0.01) {
         return array(array('pass' => FALSE, 'message' => t('We cannot process your order without payment.')));
     }
     uc_payment_enter($order->id(), 'free_order', 0, 0, NULL, t('Checkout completed for a free order.'));
 }
 /**
  * {@inheritdoc}
  */
 public function view(OrderInterface $order, $view_mode)
 {
     if ($view_mode == 'customer' && $order->access('invoice')) {
         $build = array('#type' => 'link', '#title' => $this->t('Click to open a window with a printable invoice.'), '#url' => Url::fromRoute('uc_order.user_invoice_print', ['user' => $order->getOwnerId(), 'uc_order' => $order->id()], array('attributes' => array('onclick' => "window.open(this.href, '" . $this->t('Invoice') . "', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=1,width=600,height=480,left=50,top=50'); return false;"))));
         return $build;
     }
 }
Beispiel #3
0
 /**
  * {@inheritdoc}
  */
 public function view(OrderInterface $order, $view_mode)
 {
     if ($view_mode == 'customer' || $view_mode == 'view') {
         $tracking = array();
         $result = db_query('SELECT sid FROM {uc_shipments} WHERE order_id = :id', [':id' => $order->id()]);
         foreach ($result as $shipment) {
             $shipment = Shipment::load($shipment->sid);
             if ($shipment->tracking_number) {
                 $tracking[$shipment->carrier]['data'] = $shipment->carrier;
                 $tracking[$shipment->carrier]['children'][] = $shipment->tracking_number;
             } else {
                 foreach ($shipment->packages as $package) {
                     if ($package->tracking_number) {
                         $tracking[$shipment->carrier]['data'] = $shipment->carrier;
                         $tracking[$shipment->carrier]['children'][] = $package->tracking_number;
                     }
                 }
             }
         }
         // Do not show an empty pane to customers.
         if ($view_mode == 'view' || !empty($tracking)) {
             $build['tracking'] = array('#theme' => 'item_list', '#items' => $tracking);
             return $build;
         }
     }
 }
 /**
  * {@inheritdoc}
  */
 public function view(OrderInterface $order, $view_mode)
 {
     // @todo Simplify this or replace with Views
     if ($view_mode == 'customer') {
         $comments = uc_order_comments_load($order->id());
         $statuses = OrderStatus::loadMultiple();
         $header = array($this->t('Date'), $this->t('Status'), $this->t('Message'));
         $rows[] = array(array('data' => \Drupal::service('date.formatter')->format($order->created->value, 'uc_store'), 'class' => array('date')), array('data' => '-', 'class' => array('status')), array('data' => $this->t('Order created.'), 'class' => array('message')));
         if (count($comments) > 0) {
             foreach ($comments as $comment) {
                 $rows[] = array(array('data' => \Drupal::service('date.formatter')->format($comment->created, 'uc_store'), 'class' => array('date')), array('data' => array('#plain_text' => $statuses[$comment->order_status]->getName()), 'class' => array('status')), array('data' => array('#markup' => $comment->message), 'class' => array('message')));
             }
         }
         $build = array('#theme' => 'table', '#header' => $header, '#rows' => $rows, '#attributes' => array('class' => array('uc-order-comments')));
     } else {
         $build = array('#theme' => 'table', '#header' => array(array('data' => $this->t('Date'), 'class' => array('date')), array('data' => $this->t('User'), 'class' => array('user', RESPONSIVE_PRIORITY_LOW)), array('data' => $this->t('Notified'), 'class' => array('notified')), array('data' => $this->t('Status'), 'class' => array('status', RESPONSIVE_PRIORITY_LOW)), array('data' => $this->t('Comment'), 'class' => array('message'))), '#rows' => array(), '#attributes' => array('class' => array('order-pane-table uc-order-comments')), '#empty' => $this->t('This order has no comments associated with it.'));
         $comments = uc_order_comments_load($order->id());
         $statuses = OrderStatus::loadMultiple();
         foreach ($comments as $comment) {
             $icon = $comment->notified ? 'true-icon.gif' : 'false-icon.gif';
             $build['#rows'][] = array(array('data' => \Drupal::service('date.formatter')->format($comment->created, 'short'), 'class' => array('date')), array('data' => array('#theme' => 'uc_uid', '#uid' => $comment->uid), 'class' => array('user')), array('data' => array('#theme' => 'image', '#uri' => drupal_get_path('module', 'uc_order') . '/images/' . $icon), 'class' => array('notified')), array('data' => array('#plain_text' => $statuses[$comment->order_status]->getName()), 'class' => array('status')), array('data' => array('#markup' => $comment->message), 'class' => array('message')));
         }
     }
     return $build;
 }
 /**
  * {@inheritdoc}
  */
 public function buildForm(array $form, FormStateInterface $form_state, OrderInterface $uc_order = NULL)
 {
     $this->order = $uc_order;
     $form['email'] = array('#type' => 'email', '#title' => t('Recipient e-mail address'), '#default_value' => $uc_order->getEmail(), '#required' => TRUE);
     $form['actions'] = array('#type' => 'actions');
     $form['actions']['submit'] = array('#type' => 'submit', '#value' => t('Mail invoice'));
     return $form;
 }
Beispiel #6
0
 /**
  * {@inheritdoc}
  */
 public function orderSave(OrderInterface $order)
 {
     if (empty($order->payment_details['description'])) {
         db_delete('uc_payment_other')->condition('order_id', $order->id())->execute();
     } else {
         db_merge('uc_payment_other')->key(array('order_id' => $order->id()))->fields(array('description' => $order->payment_details['description']))->execute();
     }
 }
 /**
  * {@inheritdoc}
  */
 public function review(OrderInterface $order)
 {
     $review = NULL;
     $result = db_query('SELECT message FROM {uc_order_comments} WHERE order_id = :id', [':id' => $order->id()]);
     if ($comment = $result->fetchObject()) {
         $review[] = array('title' => $this->t('Comment'), 'data' => array('#markup' => $comment->message));
     }
     return $review;
 }
 /**
  * {@inheritdoc}
  */
 public function orderView(OrderInterface $order)
 {
     $txn_id = db_query("SELECT txn_id FROM {uc_payment_paypal_ipn} WHERE order_id = :id ORDER BY received ASC", [':id' => $order->id()])->fetchField();
     if (empty($txn_id)) {
         $txn_id = $this->t('Unknown');
     }
     $build['#markup'] = $this->t('Transaction ID:<br />@txn_id', ['@txn_id' => $txn_id]);
     return $build;
 }
 /**
  * {@inheritdoc}
  */
 public function buildForm(array $form, FormStateInterface $form_state, OrderInterface $uc_order = NULL, $payment = NULL)
 {
     $this->payment = uc_payment_load($payment);
     // Make sure the payment is for the specified order.
     if ($this->payment->order_id != $uc_order->id()) {
         throw new NotFoundHttpException();
     }
     return parent::buildForm($form, $form_state);
 }
 /**
  * {@inheritdoc}
  */
 public function review(OrderInterface $order)
 {
     $review = NULL;
     $result = db_query("SELECT message FROM {uc_order_comments} WHERE order_id = :id", array(':id' => $order->id()));
     if ($comment = $result->fetchObject()) {
         $review[] = array('title' => t('Comment'), 'data' => SafeMarkup::checkPlain($comment->message));
     }
     return $review;
 }
Beispiel #11
0
 /**
  * {@inheritdoc}
  */
 public function fulfillOrder(OrderInterface $order, array $package_ids)
 {
     $shipment = new \stdClass();
     $shipment->order_id = $order->id();
     $shipment->packages = array();
     foreach ($package_ids as $id) {
         $package = Package::load($id);
         $shipment->packages[$id] = $package;
     }
     return \Drupal::formBuilder()->getForm('\\Drupal\\uc_fulfillment\\Form\\ShipmentEditForm', $order, $shipment);
 }
 /**
  * {@inheritdoc}
  */
 public function submitForm(OrderInterface $order, array &$form, FormStateInterface $form_state)
 {
     $pane = $this->pluginDefinition['id'];
     $address = $order->getAddress($pane);
     foreach ($form_state->getValue($pane) as $key => $value) {
         if (uc_address_field_enabled($key)) {
             $address->{$key} = $value;
         }
     }
     $order->setAddress($pane, $address);
 }
 /**
  * Displays a list of an order's packaged products.
  *
  * @param \Drupal\uc_order\OrderInterface $uc_order
  *   The order.
  *
  * @return array|\Symfony\Component\HttpFoundation\RedirectResponse
  *   A render array, or a redirect response if there are no packaged products.
  */
 public function listOrderPackages(OrderInterface $uc_order)
 {
     $shipping_type_options = uc_quote_shipping_type_options();
     $header = array($this->t('Package ID'), $this->t('Products'), $this->t('Shipping type'), $this->t('Package type'), $this->t('Shipment ID'), $this->t('Tracking number'), $this->t('Labels'), $this->t('Actions'));
     $rows = array();
     $result = db_query('SELECT package_id FROM {uc_packages} WHERE order_id = :id', [':id' => $uc_order->id()]);
     while ($package_id = $result->fetchField()) {
         $package = Package::load($package_id);
         $row = array();
         // Package ID.
         $row[] = array('data' => array('#plain_text' => $package->package_id));
         $product_list = array();
         $result2 = db_query('SELECT op.order_product_id, pp.qty, op.title, op.model FROM {uc_packaged_products} pp LEFT JOIN {uc_order_products} op ON op.order_product_id = pp.order_product_id WHERE pp.package_id = :id', [':id' => $package->package_id]);
         foreach ($result2 as $product) {
             $product_list[] = $product->qty . ' x ' . $product->model;
         }
         // Products.
         $row[] = array('data' => array('#theme' => 'item_list', '#items' => $product_list));
         // Shipping type.
         $row[] = isset($shipping_type_options[$package->shipping_type]) ? $shipping_type_options[$package->shipping_type] : strtr($package->shipping_type, '_', ' ');
         // Package type.
         $row[] = array('data' => array('#plain_text' => $package->pkg_type));
         // Shipment ID.
         $row[] = isset($package->sid) ? Link::createFromRoute($package->sid, 'uc_fulfillment.view_shipment', ['uc_order' => $uc_order->id(), 'shipment_id' => $package->sid])->toString() : '';
         // Tracking number.
         $row[] = isset($package->tracking_number) ? array('data' => array('#plain_text' => $package->tracking_number)) : '';
         if ($package->label_image && ($image = file_load($package->label_image))) {
             $package->label_image = $image;
         } else {
             unset($package->label_image);
         }
         // Shipping label.
         if (isset($package->sid) && isset($package->label_image)) {
             $method = db_query('SELECT shipping_method FROM {uc_shipments} WHERE sid = :sid', [':sid' => $package->sid])->fetchField();
             $row[] = Link::fromTextAndUrl("image goes here", Url::fromUri('base:admin/store/orders/' . $uc_order->id() . '/shipments/labels/' . $method . '/' . $package->label_image->uri, ['uc_order' => $uc_order->id(), 'method' => $method, 'image_uri' => $package->label_image->uri]))->toString();
         } else {
             $row[] = '';
         }
         // Operations.
         $ops = array('#type' => 'operations', '#links' => array('edit' => array('title' => $this->t('Edit'), 'url' => Url::fromRoute('uc_fulfillment.edit_package', ['uc_order' => $uc_order->id(), 'package_id' => $package->package_id])), 'ship' => array('title' => $this->t('Ship'), 'url' => Url::fromRoute('uc_fulfillment.new_shipment', ['uc_order' => $uc_order->id()], ['query' => ['pkgs' => $package->package_id]])), 'delete' => array('title' => $this->t('Delete'), 'url' => Url::fromRoute('uc_fulfillment.delete_package', ['uc_order' => $uc_order->id(), 'package_id' => $package->package_id]))));
         if ($package->sid) {
             $ops['#links']['cancel'] = array('title' => $this->t('Cancel'), 'url' => Url::fromRoute('uc_fulfillment.cancel_package', ['uc_order' => $uc_order->id(), 'package_id' => $package->package_id]));
         }
         $row[] = array('data' => $ops);
         $rows[] = $row;
     }
     if (empty($rows)) {
         drupal_set_message($this->t("This order's products have not been organized into packages."), 'warning');
         return $this->redirect('uc_fulfillment.new_package', ['uc_order' => $uc_order->id()]);
     }
     $build['packages'] = array('#theme' => 'table', '#header' => $header, '#rows' => $rows);
     return $build;
 }
 /**
  * {@inheritdoc}
  */
 public function buildForm(OrderInterface $order, array $form, FormStateInterface $form_state)
 {
     $items = array();
     $comments = uc_order_comments_load($order->id(), TRUE);
     foreach ($comments as $comment) {
         $items[] = ['username' => ['#theme' => 'uc_uid', '#uid' => $comment->uid, '#prefix' => '[', '#suffix' => '] '], 'message' => ['#markup' => $comment->message]];
     }
     $form['comments'] = array('#theme' => 'item_list', '#items' => $items, '#empty' => $this->t('No admin comments have been entered for this order.'));
     $form['admin_comment_field'] = array('#type' => 'details', '#title' => $this->t('Add an admin comment'));
     $form['admin_comment_field']['admin_comment'] = array('#type' => 'textarea', '#description' => $this->t('Admin comments are only seen by store administrators.'));
     return $form;
 }
 /**
  * {@inheritdoc}
  */
 public function buildForm(array $form, FormStateInterface $form_state, OrderInterface $order = NULL, $line_item_id = '')
 {
     $func = _uc_line_item_data($line_item_id, 'callback');
     if (!function_exists($func) || ($form = $func('form', $order->id())) == NULL) {
         $form['title'] = array('#type' => 'textfield', '#title' => $this->t('Line item title'), '#description' => $this->t('Display title of the line item.'), '#size' => 32, '#maxlength' => 128, '#default_value' => _uc_line_item_data($line_item_id, 'title'));
         $form['amount'] = array('#type' => 'uc_price', '#title' => $this->t('Line item amount'), '#allow_negative' => TRUE);
     }
     $form['order_id'] = array('#type' => 'hidden', '#value' => $order->id());
     $form['line_item_id'] = array('#type' => 'hidden', '#value' => $line_item_id);
     $form['actions'] = array('#type' => 'actions');
     $form['actions']['submit'] = array('#type' => 'submit', '#value' => $this->t('Add line item'), '#suffix' => Link::createFromRoute($this->t('Cancel'), 'entity.uc_order.edit_form', ['uc_order' => $order->id()])->toString());
     return $form;
 }
 /**
  * {@inheritdoc}
  */
 public function buildForm(array $form, FormStateInterface $form_state, OrderInterface $order = NULL)
 {
     $form['order_comment_field'] = array('#type' => 'details', '#title' => $this->t('Add an order comment'));
     $form['order_comment_field']['order_comment'] = array('#type' => 'textarea', '#description' => $this->t('Order comments are used primarily to communicate with the customer.'));
     $form['admin_comment_field'] = array('#type' => 'details', '#title' => $this->t('Add an admin comment'));
     $form['admin_comment_field']['admin_comment'] = array('#type' => 'textarea', '#description' => $this->t('Admin comments are only seen by store administrators.'));
     $form['current_status'] = array('#type' => 'value', '#value' => $order->getStatusId());
     $form['order_id'] = array('#type' => 'value', '#value' => $order->id());
     $form['controls'] = array('#type' => 'container', '#attributes' => array('class' => array('uc-inline-form')), '#weight' => 10);
     $form['controls']['status'] = array('#type' => 'select', '#title' => $this->t('Order status'), '#default_value' => $order->getStatusId(), '#options' => OrderStatus::getOptionsList());
     $form['controls']['notify'] = array('#type' => 'checkbox', '#title' => $this->t('Send e-mail notification on update.'));
     $form['controls']['actions'] = array('#type' => 'actions');
     $form['controls']['actions']['submit'] = array('#type' => 'submit', '#value' => $this->t('Update'), '#button_type' => 'primary');
     return $form;
 }
 /**
  * {@inheritdoc}
  */
 public function buildForm(array $form, FormStateInterface $form_state, OrderInterface $uc_order = NULL)
 {
     $form['#tree'] = TRUE;
     $form['#attached']['library'][] = 'uc_fulfillment/uc_fulfillment.scripts';
     $shipping_types_products = array();
     foreach ($uc_order->products as $product) {
         if (uc_order_product_is_shippable($product)) {
             $product->shipping_type = uc_product_get_shipping_type($product);
             $shipping_types_products[$product->shipping_type][] = $product;
         }
     }
     $quote_config = \Drupal::config('uc_quote.settings');
     $shipping_type_weights = $quote_config->get('type_weight');
     $result = db_query('SELECT op.order_product_id, SUM(pp.qty) AS quantity FROM {uc_packaged_products} pp LEFT JOIN {uc_packages} p ON pp.package_id = p.package_id LEFT JOIN {uc_order_products} op ON op.order_product_id = pp.order_product_id WHERE p.order_id = :id GROUP BY op.order_product_id', [':id' => $uc_order->id()]);
     $packaged_products = $result->fetchAllKeyed();
     $form['shipping_types'] = array();
     $header = array(array('data' => '', 'class' => array('select-all')), 'model' => $this->t('SKU'), 'name' => $this->t('Title'), 'qty' => $this->t('Quantity'), 'package' => $this->t('Package'));
     $shipping_type_options = uc_quote_shipping_type_options();
     foreach ($shipping_types_products as $shipping_type => $products) {
         $form['shipping_types'][$shipping_type] = array('#type' => 'fieldset', '#title' => isset($shipping_type_options[$shipping_type]) ? $shipping_type_options[$shipping_type] : Unicode::ucwords(str_replace('_', ' ', $shipping_type)), '#weight' => isset($shipping_type_weights[$shipping_type]) ? $shipping_type_weights[$shipping_type] : 0);
         $form['shipping_types'][$shipping_type]['table'] = array('#type' => 'table', '#header' => $header, '#empty' => $this->t('There are no products available for this type of package.'));
         foreach ($products as $product) {
             $unboxed_qty = $product->qty->value;
             if (isset($packaged_products[$product->order_product_id->value])) {
                 $unboxed_qty -= $packaged_products[$product->order_product_id->value];
             }
             if ($unboxed_qty > 0) {
                 $row = array();
                 $row['checked'] = array('#type' => 'checkbox', '#default_value' => 0);
                 $row['model'] = array('#plain_text' => $product->model->value);
                 $row['name'] = array('#markup' => $product->title->value);
                 $range = range(1, $unboxed_qty);
                 $row['qty'] = array('#type' => 'select', '#title' => $this->t('Quantity'), '#title_display' => 'invisible', '#options' => array_combine($range, $range), '#default_value' => $unboxed_qty);
                 $range = range(0, count($uc_order->products));
                 $options = array_combine($range, $range);
                 $options[0] = $this->t('Sep.');
                 $row['package'] = array('#type' => 'select', '#title' => $this->t('Package'), '#title_display' => 'invisible', '#options' => $options, '#default_value' => 0);
                 $form['shipping_types'][$shipping_type]['table'][$product->order_product_id->value] = $row;
             }
         }
     }
     $form['order_id'] = array('#type' => 'hidden', '#value' => $uc_order->id());
     $form['actions'] = array('#type' => 'actions');
     $form['actions']['create'] = array('#type' => 'submit', '#value' => $this->t('Make packages'));
     $form['actions']['combine'] = array('#type' => 'submit', '#value' => $this->t('Create one package'));
     $form['actions']['cancel'] = array('#type' => 'submit', '#value' => $this->t('Cancel'));
     return $form;
 }
 /**
  * {@inheritdoc}
  */
 public function buildForm(array $form, FormStateInterface $form_state, OrderInterface $uc_order = NULL, $package_id = NULL)
 {
     $this->package = Package::load($package_id);
     $form['#tree'] = TRUE;
     $form['#attached']['library'][] = 'uc_fulfillment/uc_fulfillment.scripts';
     $products = array();
     $shipping_types_products = array();
     foreach ($uc_order->products as $product) {
         if (uc_order_product_is_shippable($product)) {
             $product->shipping_type = uc_product_get_shipping_type($product);
             $shipping_types_products[$product->shipping_type][$product->order_product_id->value] = $product;
             $products[$product->order_product_id->value] = $product;
         }
     }
     $header = array(array('data' => '', 'class' => array('select-all')), 'model' => $this->t('SKU'), 'name' => $this->t('Title'), 'qty' => $this->t('Quantity'));
     $result = db_query('SELECT order_product_id, SUM(qty) AS quantity FROM {uc_packaged_products} pp LEFT JOIN {uc_packages} p ON pp.package_id = p.package_id WHERE p.order_id = :id GROUP BY order_product_id', [':id' => $uc_order->id()]);
     foreach ($result as $packaged_product) {
         // Make already packaged products unavailable, except those in this package.
         $products[$packaged_product->order_product_id]->qty->value -= $packaged_product->quantity;
         if (isset($this->package->products[$packaged_product->order_product_id])) {
             $products[$packaged_product->order_product_id]->qty->value += $this->package->products[$packaged_product->order_product_id]->qty;
         }
     }
     $form['products'] = array('#type' => 'table', '#header' => $header, '#empty' => $this->t('There are no products available for this type of package.'));
     foreach ($products as $product) {
         if ($product->qty->value > 0) {
             $row = array();
             $row['checked'] = array('#type' => 'checkbox', '#default_value' => isset($this->package->products[$product->order_product_id->value]));
             $row['model'] = array('#markup' => $product->model->value);
             $row['name'] = array('#markup' => $product->title->value);
             $range = range(1, $product->qty->value);
             $row['qty'] = array('#type' => 'select', '#options' => array_combine($range, $range), '#default_value' => isset($this->package->products[$product->order_product_id->value]) ? $this->package->products[$product->order_product_id->value]->qty : 1);
             $form['products'][$product->order_product_id->value] = $row;
         }
     }
     $options = array();
     $shipping_type_options = uc_quote_shipping_type_options();
     foreach (array_keys($shipping_types_products) as $type) {
         $options[$type] = isset($shipping_type_options[$type]) ? $shipping_type_options[$type] : Unicode::ucwords(str_replace('_', ' ', $type));
     }
     $form['shipping_type'] = array('#type' => 'select', '#title' => $this->t('Shipping type'), '#options' => $options, '#default_value' => isset($this->package->shipping_type) ? $this->package->shipping_type : 'small_package');
     $form['actions'] = array('#type' => 'actions');
     $form['actions']['submit'] = array('#type' => 'submit', '#value' => $this->t('Save'));
     return $form;
 }
 /**
  * {@inheritdoc}
  */
 public function buildForm(array $form, FormStateInterface $form_state, array $addresses = [], OrderInterface $uc_order = NULL)
 {
     $form['#attached']['library'][] = 'uc_fulfillment/uc_fulfillment.scripts';
     $form['origin'] = array('#type' => 'fieldset', '#title' => t('Origin address'), '#weight' => -2);
     $form['origin']['pickup_address_select'] = $this->selectAddress($addresses);
     $form['origin']['pickup_address_select']['#weight'] = -2;
     $form['origin']['pickup_email'] = array('#type' => 'email', '#title' => t('E-mail'), '#default_value' => uc_store_email(), '#weight' => -1);
     $form['origin']['pickup_email']['#weight'] = -1;
     $form['origin']['pickup_address']['#tree'] = TRUE;
     $form['origin']['pickup_address']['pickup_address'] = array('#type' => 'uc_address', '#default_value' => reset($addresses), '#required' => FALSE);
     $form['destination'] = array('#type' => 'fieldset', '#title' => t('Destination address'), '#weight' => -1);
     if ($form_state->hasValue('delivery_country')) {
         $uc_order->delivery_country = $form_state->getValue('delivery_country');
     }
     $form['destination']['delivery_email'] = array('#type' => 'email', '#title' => t('E-mail'), '#default_value' => $uc_order->getEmail(), '#weight' => -1);
     $form['destination']['delivery_email']['#weight'] = -1;
     $form['destination']['delivery_address'] = array('#type' => 'uc_address', '#default_value' => $uc_order->getAddress('delivery'), '#required' => FALSE, '#key_prefix' => 'delivery');
     return $form;
 }
 /**
  * {@inheritdoc}
  */
 public function submitForm(array &$form, FormStateInterface $form_state)
 {
     $payment = $form_state->getValue(['payments', 'new']);
     $received = strtotime($payment['received']['year'] . '-' . $payment['received']['month'] . '-' . $payment['received']['day'] . ' 00:00:00');
     // If the value entered is today, use the exact timestamp instead
     $startofday = mktime(0, 0, 0);
     if ($received == $startofday) {
         $received = REQUEST_TIME;
     }
     uc_payment_enter($this->order->id(), $payment['method'], $payment['amount'], \Drupal::currentUser()->id(), '', $payment['comment'], $received);
     drupal_set_message($this->t('Payment entered.'));
 }
 /**
  * Handles a complete Website Payments Standard sale.
  *
  * @return \Symfony\Component\HttpFoundation\RedirectResponse
  *   A redirect to the cart or checkout complete page.
  */
 public function wpsComplete(OrderInterface $uc_order)
 {
     // If the order ID specified in the return URL is not the same as the one in
     // the user's session, we need to assume this is either a spoof or that the
     // user tried to adjust the order on this side while at PayPal. If it was a
     // legitimate checkout, the IPN will still come in from PayPal so the order
     // gets processed correctly. We'll leave an ambiguous message just in case.
     $session = \Drupal::service('session');
     if (!$session->has('cart_order') || intval($session->get('cart_order')) != $uc_order->id()) {
         drupal_set_message($this->t('Thank you for your order! PayPal will notify us once your payment has been processed.'));
         return $this->redirect('uc_cart.cart');
     }
     // Ensure the payment method is PayPal WPS.
     $method = \Drupal::service('plugin.manager.uc_payment.method')->createFromOrder($uc_order);
     if (!$method instanceof PayPalWebsitePaymentsStandard) {
         return $this->redirect('uc_cart.cart');
     }
     // This lets us know it's a legitimate access of the complete page.
     $session = \Drupal::service('session');
     $session->set('uc_checkout_complete_' . $uc_order->id(), TRUE);
     return $this->redirect('uc_cart.checkout_complete');
 }
Beispiel #22
0
 /**
  * {@inheritdoc}
  */
 public function orderView(OrderInterface $order)
 {
     $build = array();
     // Add the hidden span for the CC details if possible.
     $account = \Drupal::currentUser();
     if ($account->hasPermission('view cc details')) {
         $rows = array();
         if (!empty($order->payment_details['cc_type'])) {
             $rows[] = t('Card type') . ': ' . SafeMarkup::checkPlain($order->payment_details['cc_type']);
         }
         if (!empty($order->payment_details['cc_owner'])) {
             $rows[] = t('Card owner') . ': ' . SafeMarkup::checkPlain($order->payment_details['cc_owner']);
         }
         if (!empty($order->payment_details['cc_number'])) {
             $rows[] = t('Card number') . ': ' . uc_credit_display_number($order->payment_details['cc_number']);
         }
         if (!empty($order->payment_details['cc_start_month']) && !empty($order->payment_details['cc_start_year'])) {
             $rows[] = t('Start date') . ': ' . $order->payment_details['cc_start_month'] . '/' . $order->payment_details['cc_start_year'];
         }
         if (!empty($order->payment_details['cc_exp_month']) && !empty($order->payment_details['cc_exp_year'])) {
             $rows[] = t('Expiration') . ': ' . $order->payment_details['cc_exp_month'] . '/' . $order->payment_details['cc_exp_year'];
         }
         if (!empty($order->payment_details['cc_issue'])) {
             $rows[] = t('Issue number') . ': ' . SafeMarkup::checkPlain($order->payment_details['cc_issue']);
         }
         if (!empty($order->payment_details['cc_bank'])) {
             $rows[] = t('Issuing bank') . ': ' . SafeMarkup::checkPlain($order->payment_details['cc_bank']);
         }
         $build['cc_info'] = array('#prefix' => '<a href="#" onclick="jQuery(this).hide().next().show();">' . t('Show card details') . '</a><div style="display: none;">', '#markup' => implode('<br />', $rows), '#suffix' => '</div>');
         // Add the form to process the card if applicable.
         if ($account->hasPermission('process credit cards')) {
             $build['terminal'] = \Drupal::formBuilder()->getForm('uc_credit_order_view_form', $order->id());
         }
     }
     return $build;
 }
Beispiel #23
0
 /**
  * {@inheritdoc}
  */
 public function review(OrderInterface $order)
 {
     $review = array();
     $result = db_query("SELECT * FROM {uc_order_line_items} WHERE order_id = :id AND type = :type", [':id' => $order->id(), ':type' => 'shipping']);
     if ($line_item = $result->fetchAssoc()) {
         $review[] = array('title' => $line_item['title'], 'data' => array('#theme' => 'uc_price', '#price' => $line_item['amount']));
     }
     return $review;
 }
 /**
  * Checks access to fulfill this order.
  *
  * @param \Drupal\uc_order\OrderInterface $order
  *   The Order to check access for.
  *
  * @return \Drupal\Core\Access\AccessResultInterface
  *   The access result.
  */
 public function accessOrder(OrderInterface $uc_order)
 {
     $account = \Drupal::currentUser();
     return AccessResult::allowedIf($account->hasPermission('fulfill orders') && $uc_order->isShippable());
 }
 /**
  * {@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;
 }
 /**
  * {@inheritdoc}
  */
 public function review(OrderInterface $order)
 {
     $review[] = array('title' => $this->t('E-mail'), 'data' => array('#plain_text' => $order->getEmail()));
     return $review;
 }
 /**
  * Returns an instance of the payment method plugin for a specific order.
  *
  * @param \Drupal\uc_order\OrderInterface $order
  *   The order from which the plugin should be instantiated.
  *
  * @return \Drupal\uc_payment\PaymentMethodPluginInterface
  *   A fully configured plugin instance.
  */
 public function createFromOrder(OrderInterface $order)
 {
     return PaymentMethod::load($order->getPaymentMethodId())->getPlugin();
 }
Beispiel #28
0
 /**
  * {@inheritdoc}
  */
 public function orderDelete(OrderInterface $order)
 {
     // delete payment transaction recorded in table {uc_payment_icepay}
     Database::getConnection()->delete('uc_payment_icepay')->condition('order_id', $order->id())->execute();
 }
 /**
  * The title callback for order view routes.
  *
  * @param \Drupal\uc_order\OrderInterface $uc_order
  *   The order that is being viewed.
  *
  * @return string
  *   The page title.
  */
 public function pageTitle(OrderInterface $uc_order)
 {
     return $uc_order->label();
 }
 /**
  * Returns the payment method entity for a specific order.
  *
  * @param \Drupal\uc_order\OrderInterface $order
  *   The order from which the payment method should be loaded.
  *
  * @return static|null
  *   The entity object or NULL if there is no valid payment method.
  */
 public static function loadFromOrder(OrderInterface $order)
 {
     if ($method = $order->getPaymentMethodId()) {
         return static::load($method);
     }
     return NULL;
 }