/**
  * @return TotalInterface
  */
 private function getTotal()
 {
     /** @var TotalInterface $total */
     $total = $this->totalFactory->create();
     $total->setBaseShippingAmount($this->order->getBaseShippingAmount());
     $total->setBaseShippingCanceled($this->order->getBaseShippingCanceled());
     $total->setBaseShippingDiscountAmount($this->order->getBaseShippingDiscountAmount());
     $total->setBaseShippingDiscountTaxCompensationAmnt($this->order->getBaseShippingDiscountTaxCompensationAmnt());
     $total->setBaseShippingInclTax($this->order->getBaseShippingInclTax());
     $total->setBaseShippingInvoiced($this->order->getBaseShippingInvoiced());
     $total->setBaseShippingRefunded($this->order->getBaseShippingRefunded());
     $total->setBaseShippingTaxAmount($this->order->getBaseShippingTaxAmount());
     $total->setBaseShippingTaxRefunded($this->order->getBaseShippingTaxRefunded());
     $total->setShippingAmount($this->order->getShippingAmount());
     $total->setShippingCanceled($this->order->getShippingCanceled());
     $total->setShippingDiscountAmount($this->order->getShippingDiscountAmount());
     $total->setShippingDiscountTaxCompensationAmount($this->order->getShippingDiscountTaxCompensationAmount());
     $total->setShippingInclTax($this->order->getShippingInclTax());
     $total->setShippingInvoiced($this->order->getShippingInvoiced());
     $total->setShippingRefunded($this->order->getShippingRefunded());
     $total->setShippingTaxAmount($this->order->getShippingTaxAmount());
     $total->setShippingTaxRefunded($this->order->getShippingTaxRefunded());
     return $total;
 }
Example #2
0
 /**
  * @param $order Order
  * @return Purchase
  */
 protected function makePurchase(Order $order)
 {
     // Get all of the purchased products
     $items = $order->getAllItems();
     $purchase = SignifydModel::Make("\\Signifyd\\Models\\Purchase");
     $purchase->orderChannel = "WEB";
     $purchase->products = array();
     foreach ($items as $item) {
         $purchase->products[] = $this->makeProduct($item);
     }
     $purchase->totalPrice = $order->getGrandTotal();
     $purchase->currency = $order->getOrderCurrencyCode();
     $purchase->orderId = $order->getIncrementId();
     $purchase->paymentGateway = $order->getPayment()->getMethod();
     $purchase->shippingPrice = floatval($order->getShippingAmount());
     $purchase->avsResponseCode = $order->getPayment()->getCcAvsStatus();
     $purchase->cvvResponseCode = $order->getPayment()->getCcSecureVerify();
     $purchase->createdAt = date('c', strtotime($order->getCreatedAt()));
     $purchase->browserIpAddress = $this->getIPAddress($order);
     return $purchase;
 }
Example #3
0
 /**
  * @param \Magento\Sales\Model\Order $order
  * @return string
  */
 protected function _getReceiptOrderLines(\Magento\Sales\Model\Order $order)
 {
     $myReceiptOrderLines = "";
     $currency = $order->getOrderCurrencyCode();
     $formattedAmountValue = $this->_currencyFactory->create()->format($order->getGrandTotal(), ['display' => \Magento\Framework\Currency::NO_SYMBOL], false);
     $taxAmount = $order->getTaxAmount();
     $formattedTaxAmount = $this->_currencyFactory->create()->format($taxAmount, ['display' => \Magento\Framework\Currency::NO_SYMBOL], false);
     $myReceiptOrderLines .= "---||C\n" . "====== YOUR ORDER DETAILS ======||CB\n" . "---||C\n" . " No. Description |Piece  Subtotal|\n";
     foreach ($order->getItemsCollection() as $item) {
         //skip dummies
         if ($item->isDummy()) {
             continue;
         }
         $singlePriceFormat = $this->_currencyFactory->create()->format($item->getPriceInclTax(), ['display' => \Magento\Framework\Currency::NO_SYMBOL], false);
         $itemAmount = $item->getPriceInclTax() * (int) $item->getQtyOrdered();
         $itemAmountFormat = $this->_currencyFactory->create()->format($itemAmount, ['display' => \Magento\Framework\Currency::NO_SYMBOL], false);
         $myReceiptOrderLines .= "  " . (int) $item->getQtyOrdered() . "  " . trim(substr($item->getName(), 0, 25)) . "| " . $currency . " " . $singlePriceFormat . "  " . $currency . " " . $itemAmountFormat . "|\n";
     }
     //discount cost
     if ($order->getDiscountAmount() > 0 || $order->getDiscountAmount() < 0) {
         $discountAmountFormat = $this->_currencyFactory->create()->format($order->getDiscountAmount(), ['display' => \Magento\Framework\Currency::NO_SYMBOL], false);
         $myReceiptOrderLines .= "  " . 1 . " " . $this->__('Total Discount') . "| " . $currency . " " . $discountAmountFormat . "|\n";
     }
     //shipping cost
     if ($order->getShippingAmount() > 0 || $order->getShippingTaxAmount() > 0) {
         $shippingAmountFormat = $this->_currencyFactory->create()->format($order->getShippingAmount(), ['display' => \Magento\Framework\Currency::NO_SYMBOL], false);
         $myReceiptOrderLines .= "  " . 1 . " " . $order->getShippingDescription() . "| " . $currency . " " . $shippingAmountFormat . "|\n";
     }
     if ($order->getPaymentFeeAmount() > 0) {
         $paymentFeeAmount = $this->_currencyFactory->create()->format($order->getPaymentFeeAmount(), ['display' => \Magento\Framework\Currency::NO_SYMBOL], false);
         $myReceiptOrderLines .= "  " . 1 . " " . $this->__('Payment Fee') . "| " . $currency . " " . $paymentFeeAmount . "|\n";
     }
     $myReceiptOrderLines .= "|--------|\n" . "|Order Total:  " . $currency . " " . $formattedAmountValue . "|B\n" . "|Tax:  " . $currency . " " . $formattedTaxAmount . "|B\n" . "||C\n";
     /*
      * New header for card details section!
      * Default location is After Header so simply add to Order Details as separator
      */
     $myReceiptOrderLines .= "---||C\n" . "====== YOUR PAYMENT DETAILS ======||CB\n" . "---||C\n";
     return $myReceiptOrderLines;
 }